-
Notifications
You must be signed in to change notification settings - Fork 0
/
camera.rb
55 lines (47 loc) · 1.43 KB
/
camera.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class Camera < SourceAdapter
PATH = File.join(RAILS_ROOT,'public','images')
BASEURL = 'http://gentle-mountain-31.heroku.com'
def initialize(source,credential)
super(source,credential)
end
def login
end
def query
@result={}
puts "====================================== Rails Root::::::#{RAILS_ROOT}"
puts "====================================== PATH::::::#{PATH}"
Dir.entries(PATH).each do |entry|
puts "QUERY---------------------$$$$$$$$$$$$$$$$$$$$$$$$$$$ #{entry}"
new_item = {'lin' => BASEURL+'/images/'+entry, 'attrib_type' => 'blob.url'}
unless entry == '..' || entry == '.' || entry == '.keep'
p "Found: #{entry}"
@result[entry.hash.to_s] = new_item
end
end
@result
end
def sync
super
end
def create(name_value_list,blob=nil)
if blob
obj = ObjectValue.find(:first, :conditions => "object = '#{blob.instance.object}' AND value = '#{name_value_list[0]["value"]}'")
path = blob.path.gsub(/\/\//,"\/#{obj.id}\/")
name = name_value_list[0]["value"]
`cp #{path} #{File.join(PATH,name)}`
end
end
def update(name_value_list)
end
def delete(name_value_list)
Dir.entries(PATH).each do |entry|
obj_id = name_value_list[0]['value']
if entry.hash.to_s == obj_id
p "Removing: #{entry}"
`rm #{File.join(PATH,entry)}`
end
end
end
def logoff
end
end