summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/blink/types.rb2
-rw-r--r--lib/blink/types/file.rb24
-rw-r--r--lib/blink/types/package.rb8
-rw-r--r--lib/blink/types/state.rb7
-rw-r--r--lib/blink/types/symlink.rb34
5 files changed, 39 insertions, 36 deletions
diff --git a/lib/blink/types.rb b/lib/blink/types.rb
index 3f590338d..01b4f2d57 100644
--- a/lib/blink/types.rb
+++ b/lib/blink/types.rb
@@ -164,7 +164,7 @@ module Blink
# parameter access and stuff
def [](param)
if @states.has_key?(param)
- return @states[param].should
+ return @states[param]
else
raise "Undefined parameter '#{param}' in #{self}"
end
diff --git a/lib/blink/types/file.rb b/lib/blink/types/file.rb
index 492f11c60..71ef3315c 100644
--- a/lib/blink/types/file.rb
+++ b/lib/blink/types/file.rb
@@ -20,10 +20,10 @@ module Blink
stat = nil
begin
- stat = File.stat(self.object[:path])
+ stat = File.stat(self.object[:path].is)
rescue
# this isn't correct, but what the hell
- raise "File '%s' does not exist: #{$!}" % self.object[:path]
+ raise "File '%s' does not exist: #{$!}" % self.object[:path].is
end
self.is = stat.uid
@@ -57,9 +57,9 @@ module Blink
def sync
begin
- File.chown(self.should,-1,self.object[:path])
+ File.chown(self.should,-1,self.object[:path].is)
rescue
- raise "failed to sync #{@params[:file]}: #{$!}"
+ raise "failed to sync #{self.object[:path].is}: #{$!}"
end
self.object.newevent(:event => :inode_changed)
@@ -78,9 +78,9 @@ module Blink
stat = nil
begin
- stat = File.stat(self.object[:path])
+ stat = File.stat(self.object[:path].is)
rescue => error
- raise "File %s could not be stat'ed: %s" % [self.object[:path],error]
+ raise "File %s could not be stat'ed: %s" % [self.object[:path].is,error]
end
self.is = stat.mode & 007777
@@ -89,9 +89,9 @@ module Blink
def sync
begin
- File.chmod(self.should,self.object[:path])
+ File.chmod(self.should,self.object[:path].is)
rescue
- raise "failed to chmod #{self.object[:path]}: #{$!}"
+ raise "failed to chmod #{self.object[:path].is}: #{$!}"
end
self.object.newevent(:event => :inode_changed)
end
@@ -129,10 +129,10 @@ module Blink
stat = nil
begin
- stat = File.stat(self.object[:path])
+ stat = File.stat(self.object[:path].is)
rescue
# this isn't correct, but what the hell
- raise "File #{self.object[:path]} does not exist: #{$!}"
+ raise "File #{self.object[:path].is} does not exist: #{$!}"
end
self.is = stat.gid
@@ -184,10 +184,10 @@ module Blink
Blink.debug "setting chgrp state to %d" % self.should
begin
# set owner to nil so it's ignored
- File.chown(nil,self.should,self.object[:path])
+ File.chown(nil,self.should,self.object[:path].is)
rescue
raise "failed to chgrp %s to %s: %s" %
- [self.object[:path], self.should, $!]
+ [self.object[:path].is, self.should, $!]
end
self.object.newevent(:event => :inode_changed)
end
diff --git a/lib/blink/types/package.rb b/lib/blink/types/package.rb
index 8dd596c14..a012816a0 100644
--- a/lib/blink/types/package.rb
+++ b/lib/blink/types/package.rb
@@ -13,11 +13,11 @@ module Blink
end
def sync
- begin
+ #begin
raise "cannot sync package states yet"
- rescue
- raise "failed to sync #{@params[:file]}: #{$!}"
- end
+ #rescue
+ # raise "failed to sync #{@params[:file]}: #{$!}"
+ #end
#self.object.newevent(:event => :inode_changed)
end
diff --git a/lib/blink/types/state.rb b/lib/blink/types/state.rb
index 983913b13..fbaec04ef 100644
--- a/lib/blink/types/state.rb
+++ b/lib/blink/types/state.rb
@@ -85,8 +85,7 @@ module Blink
#
# see objects.rb for how this is used
class Symbol
- attr_reader :is
- attr_reader :should
+ attr_reader :is, :should
def initialize(symbol)
@symbol = symbol
@@ -117,6 +116,10 @@ module Blink
@is = value
@should = value
end
+
+ def to_s
+ return @is
+ end
end
end
diff --git a/lib/blink/types/symlink.rb b/lib/blink/types/symlink.rb
index e030eddef..98ecd7f3c 100644
--- a/lib/blink/types/symlink.rb
+++ b/lib/blink/types/symlink.rb
@@ -19,40 +19,40 @@ module Blink
def create
begin
Blink.debug("Creating symlink '%s' to '%s'" %
- [self.object[:path],self.should])
- unless File.symlink(self.should,self.object[:path])
+ [self.object[:path].is,self.should])
+ unless File.symlink(self.should,self.object[:path].is)
raise TypeError.new("Could not create symlink '%s'" %
- self.object[:path])
+ self.object[:path].is)
end
rescue => detail
raise TypeError.new("Cannot create symlink '%s': %s" %
- [self.object[:path],detail])
+ [self.object[:path].is,detail])
end
end
def remove
- if FileTest.symlink?(self.object[:path])
- Blink.debug("Removing symlink '%s'" % self.object[:path])
+ if FileTest.symlink?(self.object[:path].is)
+ Blink.debug("Removing symlink '%s'" % self.object[:path].is)
begin
- File.unlink(self.object[:path])
+ File.unlink(self.object[:path].is)
rescue
raise TypeError.new("Failed to remove symlink '%s'" %
- self.object[:path])
+ self.object[:path].is)
end
- elsif FileTest.exists?(self.object[:path])
+ elsif FileTest.exists?(self.object[:path].is)
raise TypeError.new("Cannot remove normal file '%s'" %
- self.object[:path])
+ self.object[:path].is)
else
Blink.debug("Symlink '%s' does not exist" %
- self.object[:path])
+ self.object[:path].is)
end
end
def retrieve
stat = nil
- if FileTest.symlink?(self.object[:path])
- self.is = File.readlink(self.object[:path])
+ if FileTest.symlink?(self.object[:path].is)
+ self.is = File.readlink(self.object[:path].is)
Blink.debug("link value is '%s'" % self.is)
return
else
@@ -67,15 +67,15 @@ module Blink
if self.should.nil?
self.remove()
else # it should exist and be a symlink
- if FileTest.symlink?(self.object[:path])
- path = File.readlink(self.object[:path])
+ if FileTest.symlink?(self.object[:path].is)
+ path = File.readlink(self.object[:path].is)
if path != self.should
self.remove()
self.create()
end
- elsif FileTest.exists?(self.object[:path])
+ elsif FileTest.exists?(self.object[:path].is)
raise TypeError.new("Cannot replace normal file '%s'" %
- self.object[:path])
+ self.object[:path].is)
else
self.create()
end