Class: MrMurano::UserBase
Overview
User Management common things
Instance Method Summary
collapse
#endPoint, #initialize
Methods included from SyncUpDown
#docmp, #dodiff, #ignoring, #locallist, #searchFor, #status, #syncdown, #synckey, #syncup, #toRemoteItem, #tolocalname
Methods included from Verbose
#debug, #error, #outf, #tabularize, #verbose, #warning
Methods included from Http
#curldebug, #delete, #get, #http, #http_reset, #isJSON, #json_opts, #post, #postf, #put, #set_def_headers, #showHttpError, #token, #workit
Instance Method Details
#download(local, item) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/MrMurano/Solution-Users.rb', line 40
def download(local, item)
here = []
if local.exist? then
local.open('rb') {|io| here = YAML.load(io)}
here = [] if here == false
end
here.delete_if do |i|
Hash.transform_keys_to_symbols(i)[@itemkey] == item[@itemkey]
end
here << item.reject{|k,v| k==:synckey}
local.open('wb') do |io|
io.write here.map{|i| Hash.transform_keys_to_strings(i)}.to_yaml
end
end
|
#fetch(id) ⇒ Object
16
17
18
|
# File 'lib/MrMurano/Solution-Users.rb', line 16
def fetch(id)
get('/' + id.to_s)
end
|
#list ⇒ Object
12
13
14
|
# File 'lib/MrMurano/Solution-Users.rb', line 12
def list()
get()
end
|
#localitems(from) ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/MrMurano/Solution-Users.rb', line 78
def localitems(from)
from = Pathname.new(from) unless from.kind_of? Pathname
if not from.exist? then
warning "Skipping missing #{from.to_s}"
return []
end
unless from.file? then
warning "Cannot read from #{from.to_s}"
return []
end
here = []
from.open {|io| here = YAML.load(io) }
here = [] if here == false
here.map{|i| Hash.transform_keys_to_symbols(i)}
end
|
#remove(id) ⇒ Object
20
21
22
|
# File 'lib/MrMurano/Solution-Users.rb', line 20
def remove(id)
delete('/' + id.to_s)
end
|
#removelocal(local, item) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/MrMurano/Solution-Users.rb', line 57
def removelocal(local, item)
here = []
if local.exist? then
local.open('rb') {|io| here = YAML.load(io)}
here = [] if here == false
end
key = @itemkey.to_sym
here.delete_if do |it|
Hash.transform_keys_to_symbols(it)[key] == item[key]
end
local.open('wb') do|io|
io.write here.map{|i| Hash.transform_keys_to_strings(i)}.to_yaml
end
end
|
#tolocalpath(into, item) ⇒ Object
74
75
76
|
# File 'lib/MrMurano/Solution-Users.rb', line 74
def tolocalpath(into, item)
into
end
|
#upload(local, remote, modify) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/MrMurano/Solution-Users.rb', line 25
def upload(local, remote, modify)
delete('/' + remote[@itemkey]) do |request, http|
response = http.request(request)
case response
when Net::HTTPSuccess
when Net::HTTPNotFound
else
showHttpError(request, response)
end
end
remote.reject!{|k,v| k==:synckey or k==:bundled}
post('/', remote)
end
|