heywatch 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/heywatch +34 -29
- data/lib/heywatch.rb +1 -1
- metadata +3 -3
data/bin/heywatch
CHANGED
|
@@ -17,10 +17,10 @@ else
|
|
|
17
17
|
print "#{f}: ".capitalize
|
|
18
18
|
data[f] = $stdin.gets.chomp
|
|
19
19
|
end
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
[:password, :password_confirmation].each do |f|
|
|
22
22
|
print "#{f}: ".capitalize.gsub("_", " ")
|
|
23
|
-
system "stty -echo"
|
|
23
|
+
system "stty -echo"
|
|
24
24
|
data[f] = $stdin.gets.chomp
|
|
25
25
|
system "stty echo"
|
|
26
26
|
puts
|
|
@@ -28,7 +28,7 @@ else
|
|
|
28
28
|
|
|
29
29
|
print "Is the information correct? (Y/n) "
|
|
30
30
|
exit if $stdin.gets.chomp.downcase != "y"
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
begin
|
|
33
33
|
HeyWatch.register(data)
|
|
34
34
|
user, passwd = data[:login], data[:password]
|
|
@@ -45,10 +45,10 @@ else
|
|
|
45
45
|
system "stty echo"
|
|
46
46
|
puts
|
|
47
47
|
end
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
# testing credentials
|
|
50
50
|
begin
|
|
51
|
-
HeyWatch.new(user, passwd)
|
|
51
|
+
HeyWatch.new(user, passwd)
|
|
52
52
|
File.open(config_file, "w") {|f| f.write("#{user}\n#{passwd}") }
|
|
53
53
|
File.chmod(0600, config_file)
|
|
54
54
|
puts "Your credentials have been saved in this file #{config_file} (0600)\n-----\n"
|
|
@@ -67,15 +67,15 @@ begin
|
|
|
67
67
|
Resources:
|
|
68
68
|
|
|
69
69
|
account # manage account | create, update
|
|
70
|
-
video # manage video | all, info, delete, count, bin
|
|
71
|
-
encoded_video # manage encoded video | all, info, delete, count, bin, jpg
|
|
72
|
-
download # manage download | all, info, delete, count, create
|
|
73
|
-
job # manage job | all, info, delete, count, create
|
|
74
|
-
format # manage format | all, info, delete, count, create, update
|
|
75
|
-
upload # upload a video
|
|
76
|
-
|
|
70
|
+
video # manage video | all, info, delete, count, bin
|
|
71
|
+
encoded_video # manage encoded video | all, info, delete, count, bin, jpg
|
|
72
|
+
download # manage download | all, info, delete, count, create
|
|
73
|
+
job # manage job | all, info, delete, count, create
|
|
74
|
+
format # manage format | all, info, delete, count, create, update
|
|
75
|
+
upload # upload a video
|
|
76
|
+
|
|
77
77
|
Usage:
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
heywatch account
|
|
80
80
|
heywatch account:update env=sandbox
|
|
81
81
|
heywatch video:info 123456
|
|
@@ -90,12 +90,12 @@ begin
|
|
|
90
90
|
)
|
|
91
91
|
exit
|
|
92
92
|
end
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
if ARGV.size == 1 and ARGV[0] == "account"
|
|
95
95
|
puts JSON.pretty_generate(hw.account)
|
|
96
96
|
exit
|
|
97
97
|
end
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
resource, method = ARGV[0].split(":")
|
|
100
100
|
params = ARGV[1..-1]
|
|
101
101
|
if method.nil?
|
|
@@ -107,7 +107,7 @@ begin
|
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
$stderr.puts [resource, method, params].inspect if ENV["DEBUG"]
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
if resource == "upload"
|
|
112
112
|
path = ARGV[1]
|
|
113
113
|
params = Hash[*ARGV[2..-1].map{|p| k,v = p.split("=") }.flatten]
|
|
@@ -117,23 +117,28 @@ begin
|
|
|
117
117
|
|
|
118
118
|
if method == "create"
|
|
119
119
|
params = Hash[*ARGV[1..-1].map{|p| k,v = p.split("=") }.flatten]
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
if resource == "account"
|
|
122
122
|
puts JSON.pretty_generate(HeyWatch.register(params))
|
|
123
123
|
else
|
|
124
|
-
|
|
124
|
+
res = hw.send(method, *[resource, params])
|
|
125
|
+
if res.empty?
|
|
126
|
+
puts "ok"
|
|
127
|
+
else
|
|
128
|
+
puts JSON.pretty_generate(hw.send(method, *[resource, params]))
|
|
129
|
+
end
|
|
125
130
|
end
|
|
126
131
|
exit
|
|
127
132
|
end
|
|
128
|
-
|
|
133
|
+
|
|
129
134
|
if method == "update"
|
|
130
135
|
params = Hash[*ARGV[2..-1].map{|p| k,v = p.split("=") }.flatten]
|
|
131
|
-
|
|
136
|
+
|
|
132
137
|
hw.send(method, *[resource, ARGV[1], params])
|
|
133
138
|
puts "ok"
|
|
134
139
|
exit
|
|
135
140
|
end
|
|
136
|
-
|
|
141
|
+
|
|
137
142
|
if method == "jpg"
|
|
138
143
|
params = Hash[*ARGV[2..-1].map{|p| k,v = p.split("=") }.flatten]
|
|
139
144
|
puts hw.send(method, *[ARGV[1], params])
|
|
@@ -144,18 +149,18 @@ begin
|
|
|
144
149
|
puts hw.send(method, *[resource, ARGV[1]])
|
|
145
150
|
exit
|
|
146
151
|
end
|
|
147
|
-
|
|
152
|
+
|
|
148
153
|
if params.empty?
|
|
149
154
|
res = hw.send(method, resource)
|
|
150
155
|
if method == "count"
|
|
151
156
|
puts res
|
|
152
157
|
exit
|
|
153
158
|
end
|
|
154
|
-
|
|
159
|
+
|
|
155
160
|
puts JSON.pretty_generate(res)
|
|
156
161
|
exit
|
|
157
162
|
end
|
|
158
|
-
|
|
163
|
+
|
|
159
164
|
if params.last =~ /\[([0-9\.-]+)\]/
|
|
160
165
|
offset = eval($1)
|
|
161
166
|
params = params[0..-2]
|
|
@@ -166,21 +171,21 @@ begin
|
|
|
166
171
|
puts "ok"
|
|
167
172
|
exit
|
|
168
173
|
end
|
|
169
|
-
|
|
174
|
+
|
|
170
175
|
if res.is_a?(Fixnum)
|
|
171
176
|
puts res
|
|
172
177
|
exit
|
|
173
178
|
end
|
|
174
|
-
|
|
179
|
+
|
|
175
180
|
if res.empty?
|
|
176
181
|
exit
|
|
177
182
|
end
|
|
178
|
-
|
|
183
|
+
|
|
179
184
|
res = res[offset] if offset
|
|
180
|
-
|
|
185
|
+
|
|
181
186
|
puts JSON.pretty_generate(res)
|
|
182
187
|
exit
|
|
183
|
-
|
|
188
|
+
|
|
184
189
|
rescue => e
|
|
185
190
|
puts e
|
|
186
191
|
puts e.backtrace.join("\n") if ENV["DEBUG"]
|
data/lib/heywatch.rb
CHANGED
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 1
|
|
7
7
|
- 2
|
|
8
|
-
-
|
|
9
|
-
version: 1.2.
|
|
8
|
+
- 3
|
|
9
|
+
version: 1.2.3
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Bruno Celeste
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2013-
|
|
17
|
+
date: 2013-05-21 00:00:00 +02:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|