diff options
| author | Luke Kanies <luke@madstop.com> | 2005-04-14 17:20:11 +0000 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2005-04-14 17:20:11 +0000 |
| commit | e86cf4c5cc016a1d71e4f3fc40db754b1e2c9ce9 (patch) | |
| tree | 395e84fdf89c076a49f96264f2e5100447663a06 | |
| parent | d8e8b7bac463353728f703a73ae98deedc3fc146 (diff) | |
| download | puppet-e86cf4c5cc016a1d71e4f3fc40db754b1e2c9ce9.tar.gz puppet-e86cf4c5cc016a1d71e4f3fc40db754b1e2c9ce9.tar.xz puppet-e86cf4c5cc016a1d71e4f3fc40db754b1e2c9ce9.zip | |
renaming "value" to "is"
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@158 980ebf18-57e1-0310-9a29-db15c13687c0
| -rw-r--r-- | lib/blink/interface.rb | 4 | ||||
| -rw-r--r-- | lib/blink/state.rb | 26 | ||||
| -rw-r--r-- | lib/blink/types.rb | 17 | ||||
| -rw-r--r-- | lib/blink/types/file.rb | 22 | ||||
| -rw-r--r-- | lib/blink/types/package.rb | 58 | ||||
| -rw-r--r-- | lib/blink/types/service.rb | 4 | ||||
| -rw-r--r-- | lib/blink/types/symlink.rb | 6 |
7 files changed, 75 insertions, 62 deletions
diff --git a/lib/blink/interface.rb b/lib/blink/interface.rb index f778dc802..7e19c9798 100644 --- a/lib/blink/interface.rb +++ b/lib/blink/interface.rb @@ -105,8 +105,8 @@ module Blink raise "'#{newobj.name}' already exists in " + "class '#{newobj.class}': #{@objects[newobj.name]}" else - Blink.debug("adding %s of type %s to class list" % - [object.name,object.class]) + #Blink.debug("adding %s of type %s to class list" % + # [object.name,object.class]) @objects[newobj.name] = newobj end end diff --git a/lib/blink/state.rb b/lib/blink/state.rb index d952b7a8a..983913b13 100644 --- a/lib/blink/state.rb +++ b/lib/blink/state.rb @@ -13,9 +13,7 @@ module Blink class State include Comparable - attr_accessor :value - attr_accessor :should - attr_accessor :object + attr_accessor :is, :should, :object #----------------------------------- # every state class must tell us what it's name will be (as a symbol) @@ -29,10 +27,10 @@ module Blink #----------------------------------- # we aren't actually comparing the states themselves, we're only - # comparing the "should" value with the "real" value + # comparing the "should" value with the "is" value def insync? - Blink.debug "%s value is %s, should be %s" % [self,self.value,self.should] - self.value == self.should + Blink.debug "%s value is %s, should be %s" % [self,self.is,self.should] + self.is == self.should end #----------------------------------- @@ -49,10 +47,10 @@ module Blink # or a comparison between an object and the live system -- we'll # let the object decide that, rather than us #def <=>(other) - # if (self.value.respond_to?(:<=>)) - # return self.value <=> other + # if (self.is.respond_to?(:<=>)) + # return self.is <=> other # else - # fail TypeError.new("class #{self.value.class} does not respond to <=>") + # fail TypeError.new("class #{self.is.class} does not respond to <=>") # end #end #----------------------------------- @@ -87,7 +85,7 @@ module Blink # # see objects.rb for how this is used class Symbol - attr_reader :value + attr_reader :is attr_reader :should def initialize(symbol) @@ -107,7 +105,7 @@ module Blink end def should=(value) - @value = value + @is = value @should = value end @@ -115,8 +113,8 @@ module Blink true end - def value=(value) - @value = value + def is=(value) + @is = value @should = value end end @@ -128,7 +126,7 @@ module Blink class MetaState include Comparable attr_accessor :parent - attr_accessor :value + attr_accessor :is def <=>(other) raise "'<=>' method was not overridden by %s" % self.class diff --git a/lib/blink/types.rb b/lib/blink/types.rb index 8b050ca04..4d3325ef7 100644 --- a/lib/blink/types.rb +++ b/lib/blink/types.rb @@ -2,7 +2,10 @@ # $Id$ +# included so we can test object types require 'blink/state' + +# this is our base class require 'blink/interface' #--------------------------------------------------------------- @@ -30,8 +33,8 @@ module Blink # all objects total def Types.push(object) @@allobjects.push object - Blink.debug("adding %s of type %s to master list" % - [object.name,object.class]) + #Blink.debug("adding %s of type %s to master list" % + # [object.name,object.class]) end #----------------------------------- @@ -98,7 +101,7 @@ module Blink @paramsbyname = Hash.new { |hash,key| fail TypeError.new( "Parameter %s is invalid for class %s" % - [key.to_s,self.class.to_s] + [key.to_s,self] ) } @params.each { |param| @@ -149,7 +152,7 @@ module Blink attrclass = self.class.classparambyname[param] - Blink.debug("creating state of type '%s'" % attrclass) + #Blink.debug("creating state of type '%s'" % attrclass) # any given object can normally only have one of any given state # type, but it might have many Symbol states # @@ -356,8 +359,8 @@ module Blink hash.each { |param,value| @monitor.push(param) - Blink.debug("adding param '%s' with value '%s'" % - [param,value]) + #Blink.debug("adding param '%s' with value '%s'" % + # [param,value]) self[param] = value } @@ -392,7 +395,7 @@ module Blink #name = nameattr.value #Blink.debug "returning %s from attr %s and namevar %s" % [name,nameattr,namevar] #return name - return @states[self.class.namevar].value + return @states[self.class.namevar].is end #----------------------------------- diff --git a/lib/blink/types/file.rb b/lib/blink/types/file.rb index 233f77962..e8b9c797c 100644 --- a/lib/blink/types/file.rb +++ b/lib/blink/types/file.rb @@ -26,7 +26,7 @@ module Blink raise "File '%s' does not exist: #{$!}" % self.object[:path] end - self.value = stat.uid + self.is = stat.uid unless self.should.is_a?(Integer) begin user = Etc.getpwnam(self.should) @@ -40,7 +40,7 @@ module Blink raise "Could not get any info on user %s" % self.should end end - Blink.debug "chown state is %d" % self.value + Blink.debug "chown state is %d" % self.is end #def <=>(other) @@ -52,12 +52,12 @@ module Blink # end # end # -# self.value <=> other +# self.is <=> other # end def sync begin - File.chown(value,-1,self.object[:path]) + File.chown(self.should,-1,self.object[:path]) rescue raise "failed to sync #{@params[:file]}: #{$!}" end @@ -83,8 +83,8 @@ module Blink raise "File %s could not be stat'ed: %s" % [self.object[:path],error] end - self.value = stat.mode & 007777 - Blink.debug "chmod state is %o" % self.value + self.is = stat.mode & 007777 + Blink.debug "chmod state is %o" % self.is end def sync @@ -107,13 +107,13 @@ module Blink @name = :setuid def <=>(other) - self.value <=> @parent.value[11] + self.is <=> @parent.value[11] end # this just doesn't seem right... def sync tmp = 0 - if self.value == true + if self.is == true tmp = 1 end @parent.value[11] = tmp @@ -135,7 +135,7 @@ module Blink raise "File #{self.object[:path]} does not exist: #{$!}" end - self.value = stat.gid + self.is = stat.gid # we probably shouldn't actually modify the 'should' value # but i don't see a good way around it right now @@ -156,7 +156,7 @@ module Blink raise "Could not get any info on group %s" % self.should end end - Blink.debug "chgrp state is %d" % self.value + Blink.debug "chgrp state is %d" % self.is end # def <=>(other) @@ -177,7 +177,7 @@ module Blink # end # # #puts self.should -# self.value <=> other +# self.is <=> other # end def sync diff --git a/lib/blink/types/package.rb b/lib/blink/types/package.rb index c431a4693..8dd596c14 100644 --- a/lib/blink/types/package.rb +++ b/lib/blink/types/package.rb @@ -3,41 +3,48 @@ # $Id$ module Blink + class State + class PackageInstalled < Blink::State + @name = :install + + def retrieve + self.is = Blink::PackageType[object.format][object.name] + Blink.debug "package install state is %d" % self.is + end + + def sync + begin + raise "cannot sync package states yet" + rescue + raise "failed to sync #{@params[:file]}: #{$!}" + end + + #self.object.newevent(:event => :inode_changed) + end + end + end + class Types # packages are complicated because each package format has completely # different commands. We need some way to convert specific packages # into the general package object... class Package < Types attr_reader :version, :format - # class instance variable @params = [ - :install, + Blink::State::PackageInstalled, :format, - :version + :name, + :status, + :version, + :category, + :platform, + :root, + :vendor, + :description ] @name = :package @namevar = :name - - # this is already being done in objects.rb - #def Package.inhereted(sub) - # sub.module_eval %q{ - # @objects = Hash.new - # @actions = Hash.new - # } - #end - - def initialize(hash) - end - - def retrieve - end - - def insync? - end - - def sync - end end # Blink::Types::Package class PackagingType @@ -53,6 +60,11 @@ module Blink end end + # whether a package is installed or not + def [](name) + return @packages[name] + end + [:list, :install, :remove, :check].each { |method| self.send(:define_method, method) { # retrieve the variable diff --git a/lib/blink/types/service.rb b/lib/blink/types/service.rb index 8508a6dbd..be2f4eb4d 100644 --- a/lib/blink/types/service.rb +++ b/lib/blink/types/service.rb @@ -14,9 +14,9 @@ module Blink @name = :running def retrieve - self.value = self.running() + self.is = self.running() Blink.debug "Running value for '%s' is '%s'" % - [self.object.name,self.value] + [self.object.name,self.is] end # should i cache this info? diff --git a/lib/blink/types/symlink.rb b/lib/blink/types/symlink.rb index 195454328..8b862cdc3 100644 --- a/lib/blink/types/symlink.rb +++ b/lib/blink/types/symlink.rb @@ -52,11 +52,11 @@ module Blink stat = nil if FileTest.symlink?(self.object[:path]) - self.value = File.readlink(self.object[:path]) - Blink.debug("link value is '%s'" % self.value) + self.is = File.readlink(self.object[:path]) + Blink.debug("link value is '%s'" % self.is) return else - self.value = nil + self.is = nil return end end |
