opencode_theme 0.0.7 → 0.1.0
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.
- checksums.yaml +4 -4
- data/lib/opencode_theme/base_service.rb +15 -11
- data/lib/opencode_theme/cli.rb +96 -32
- data/lib/opencode_theme/version.rb +1 -1
- data/opencode_theme.gemspec +1 -1
- data/spec/functional/functional_spec.rb +46 -39
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 50a078e9de7768e1b3ad4439d66279058b46c7d7
|
|
4
|
+
data.tar.gz: 8d8813b24adc34d37a84b929308ea9aabd1c6345
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ec7cc150e37db2b7a7f28713da5727d1d4d0a2eb2c29acebcbcc6be578989a6cf98a71a0e25f61cee1e54ca76714b3ef3d8e9271c4daf8a6cad34eb506350b9f
|
|
7
|
+
data.tar.gz: e4ea09cc4b0b1f84c2a13a0ad5e4307913f71631dfd3b4c80dff53ae227860b06848bf0681ba27dfb9ffaa3ade037fd673117c271d6e6794b75786d4107e37a4
|
|
@@ -11,53 +11,57 @@ module OpencodeTheme
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def self.check_config
|
|
14
|
-
response = opencode_theme.post('/api/check', query: { theme_id: config[:theme_id]
|
|
14
|
+
response = opencode_theme.post('/api/check', query: { theme_id: config[:theme_id],
|
|
15
|
+
gem_version: OpencodeTheme::VERSION })
|
|
15
16
|
{ success: response.success?, response: JSON.parse(response.body) }
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def self.list
|
|
19
|
-
response = opencode_theme.get('/api/list')
|
|
20
|
+
response = opencode_theme.get('/api/list', query: { gem_version: OpencodeTheme::VERSION })
|
|
20
21
|
{ success: response.success?, response: JSON.parse(response.body) }
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
def self.clean
|
|
24
|
-
response = opencode_theme.post('/api/clean_cache', query: { theme_id: config[:theme_id]
|
|
25
|
+
response = opencode_theme.post('/api/clean_cache', query: { theme_id: config[:theme_id],
|
|
26
|
+
gem_version: OpencodeTheme::VERSION })
|
|
25
27
|
{ success: response.success?, response: JSON.parse(response.body) }
|
|
26
28
|
end
|
|
27
29
|
|
|
28
30
|
def self.theme_delete(theme_id)
|
|
29
|
-
response = opencode_theme.delete("/api/themes/#{theme_id}", parser: NOOPParser)
|
|
31
|
+
response = opencode_theme.delete("/api/themes/#{theme_id}", parser: NOOPParser, query: { gem_version: OpencodeTheme::VERSION })
|
|
30
32
|
{ success: response.success?, response: JSON.parse(response.body) }
|
|
31
33
|
end
|
|
32
34
|
|
|
33
35
|
def self.theme_new(theme_base, theme_name)
|
|
34
36
|
response = opencode_theme.post('/api/themes',
|
|
35
|
-
|
|
37
|
+
query: { gem_version: OpencodeTheme::VERSION },
|
|
38
|
+
body: { theme: { theme_base: theme_name, name: theme_name, gem_version: OpencodeTheme::VERSION } }.to_json,
|
|
36
39
|
headers: { 'Content-Type' => 'application/json'},
|
|
37
|
-
parser: NOOPParser)
|
|
40
|
+
parser: NOOPParser )
|
|
38
41
|
assets = response.code == 200 ? JSON.parse(response.body)["assets"] : {}
|
|
39
42
|
{ success: response.success?, assets: assets, response: JSON.parse(response.body) }
|
|
40
43
|
end
|
|
41
44
|
|
|
42
45
|
def self.asset_list
|
|
43
|
-
response = opencode_theme.get(path, parser: NOOPParser)
|
|
44
|
-
assets = response.code == 200 ? JSON.parse(response.body)['assets'].collect {|a| a['key'][1..a['key'].length] } :
|
|
46
|
+
response = opencode_theme.get(path, parser: NOOPParser, query: { gem_version: OpencodeTheme::VERSION })
|
|
47
|
+
assets = response.code == 200 ? JSON.parse(response.body)['assets'].collect {|a| a['key'][1..a['key'].length] } : response.body
|
|
45
48
|
assets
|
|
46
49
|
end
|
|
47
50
|
|
|
48
51
|
def self.get_asset(asset)
|
|
49
|
-
response = opencode_theme.get(path, query: { key: "/#{asset}" }, parser: NOOPParser)
|
|
50
|
-
asset = response.code == 200 ? JSON.parse(response.body) :
|
|
52
|
+
response = opencode_theme.get(path, query: { key: "/#{asset}", gem_version: OpencodeTheme::VERSION }, parser: NOOPParser)
|
|
53
|
+
asset = response.code == 200 ? JSON.parse(response.body) : JSON.parse(response.body)
|
|
51
54
|
asset
|
|
52
55
|
end
|
|
53
56
|
|
|
54
57
|
def self.send_asset(data)
|
|
58
|
+
data[:gem_version] = OpencodeTheme::VERSION
|
|
55
59
|
response = opencode_theme.put(path, body: data)
|
|
56
60
|
response
|
|
57
61
|
end
|
|
58
62
|
|
|
59
63
|
def self.delete_asset(asset)
|
|
60
|
-
response = opencode_theme.delete(path, body: { key: "/#{asset}" })
|
|
64
|
+
response = opencode_theme.delete(path, body: { key: "/#{asset}" }, query: { key: "/#{asset}", gem_version: OpencodeTheme::VERSION })
|
|
61
65
|
response
|
|
62
66
|
end
|
|
63
67
|
|
data/lib/opencode_theme/cli.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
require 'pry'
|
|
2
3
|
require 'thor'
|
|
3
4
|
require 'yaml'
|
|
4
5
|
YAML::ENGINE.yamler = 'syck' if defined? Syck
|
|
@@ -32,14 +33,21 @@ module OpencodeTheme
|
|
|
32
33
|
desc 'configure API_KEY PASSWORD THEME_ID', 'Configura o tema que sera modificado'
|
|
33
34
|
def configure(api_key = nil, password = nil, theme_id = nil)
|
|
34
35
|
config = { api_key: api_key, password: password, theme_id: theme_id }
|
|
36
|
+
|
|
37
|
+
if api_key.nil? || password.nil? || theme_id.nil?
|
|
38
|
+
response = {}
|
|
39
|
+
response["message"] = 'necessário informar api_key e password e theme_id.'
|
|
40
|
+
return report_error(Time.now, 'Configuration [FAIL]', response)
|
|
41
|
+
end
|
|
35
42
|
OpencodeTheme.config = config
|
|
43
|
+
|
|
36
44
|
response = OpencodeTheme.check_config
|
|
37
45
|
if response[:success]
|
|
38
46
|
config.merge!(preview_url: response[:response]['preview'])
|
|
39
47
|
create_file('config.yml', config.to_yaml, force: true)
|
|
40
48
|
say('Configuration [OK]', :green)
|
|
41
49
|
else
|
|
42
|
-
|
|
50
|
+
report_error(Time.now, 'Configuration [FAIL]', response[:response])
|
|
43
51
|
end
|
|
44
52
|
end
|
|
45
53
|
|
|
@@ -47,6 +55,12 @@ module OpencodeTheme
|
|
|
47
55
|
def list
|
|
48
56
|
config = OpencodeTheme.config
|
|
49
57
|
response = OpencodeTheme.list
|
|
58
|
+
if response[:response]["authentication"] == false
|
|
59
|
+
response = {}
|
|
60
|
+
response["message"] = 'necessário autenticação'
|
|
61
|
+
return report_error(Time.now, 'Configuration [FAIL]', response)
|
|
62
|
+
end
|
|
63
|
+
|
|
50
64
|
if response[:success]
|
|
51
65
|
say("\n")
|
|
52
66
|
response[:response]['themes'].each do |theme|
|
|
@@ -68,18 +82,17 @@ module OpencodeTheme
|
|
|
68
82
|
def clean
|
|
69
83
|
config = OpencodeTheme.config
|
|
70
84
|
response = OpencodeTheme.clean
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
end
|
|
85
|
+
if response[:success]
|
|
86
|
+
say('Clean cache [OK]\n', :green)
|
|
87
|
+
else
|
|
88
|
+
report_error(Time.now, 'Clean cache [FAIL]', response[:response])
|
|
76
89
|
end
|
|
90
|
+
end
|
|
77
91
|
|
|
78
92
|
desc 'bootstrap API_KEY PASSWORD THEME_NAME THEME_BASE', 'Cria um novo tema com o nome informado'
|
|
79
93
|
method_option :master, type: :boolean, default: false
|
|
80
94
|
def bootstrap(api_key = nil, password = nil, theme_name = 'default', theme_base = 'default')
|
|
81
95
|
OpencodeTheme.config = { api_key: api_key, password: password }
|
|
82
|
-
|
|
83
96
|
check_config = OpencodeTheme.check_config
|
|
84
97
|
|
|
85
98
|
if check_config[:success]
|
|
@@ -122,16 +135,21 @@ module OpencodeTheme
|
|
|
122
135
|
method_option :exclude
|
|
123
136
|
def download(*keys)
|
|
124
137
|
assets = keys.empty? ? OpencodeTheme.asset_list : keys
|
|
138
|
+
if assets.is_a? String
|
|
139
|
+
return report_error(Time.now, "List Could not download", JSON.parse(assets))
|
|
140
|
+
end
|
|
125
141
|
if options['exclude']
|
|
126
142
|
assets = assets.delete_if { |asset| asset =~ Regexp.new(options['exclude']) }
|
|
127
143
|
end
|
|
128
|
-
|
|
129
144
|
assets.each do |asset|
|
|
130
145
|
asset = URI.decode(asset)
|
|
131
|
-
download_asset(asset)
|
|
132
|
-
|
|
146
|
+
download = download_asset(asset)
|
|
147
|
+
if download
|
|
148
|
+
|
|
149
|
+
say("#{OpencodeTheme.api_usage} Downloaded: #{asset}", :green) unless options['quiet'] || !download
|
|
150
|
+
say('Done.', :green) unless options['quiet']
|
|
151
|
+
end
|
|
133
152
|
end
|
|
134
|
-
say('Done.', :green) unless options['quiet']
|
|
135
153
|
end
|
|
136
154
|
|
|
137
155
|
desc 'upload FILE', 'Sobe o arquivo informado ou todos se FILE for omitido'
|
|
@@ -156,21 +174,44 @@ module OpencodeTheme
|
|
|
156
174
|
desc 'watch', 'Baixa e sobe um arquivo sempre que ele for salvo'
|
|
157
175
|
method_option :quiet, type: :boolean, default: false
|
|
158
176
|
method_option :keep_files, type: :boolean, default: false
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
# def watch
|
|
180
|
+
# watcher do |filename, event|
|
|
181
|
+
# filename = filename.gsub("#{Dir.pwd}/", '')
|
|
182
|
+
# unless local_assets_list.include?(filename)
|
|
183
|
+
# say("Unknown file [#{filename}]", :red)
|
|
184
|
+
# next
|
|
185
|
+
# end
|
|
186
|
+
# action = if [:changed, :new].include?(event)
|
|
187
|
+
# :send_asset
|
|
188
|
+
# elsif event == :delete
|
|
189
|
+
# :delete_asset
|
|
190
|
+
# else
|
|
191
|
+
# raise NotImplementedError, "Unknown event -- #{event} -- #{filename}"
|
|
192
|
+
# end
|
|
193
|
+
# send(action, filename, options['quiet'])
|
|
194
|
+
# end
|
|
195
|
+
# end
|
|
159
196
|
def watch
|
|
160
197
|
watcher do |filename, event|
|
|
161
198
|
filename = filename.gsub("#{Dir.pwd}/", '')
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
next
|
|
165
|
-
end
|
|
199
|
+
if is_file?(filename)
|
|
200
|
+
|
|
166
201
|
action = if [:changed, :new].include?(event)
|
|
167
|
-
|
|
202
|
+
:send_asset
|
|
168
203
|
elsif event == :delete
|
|
169
204
|
:delete_asset
|
|
170
205
|
else
|
|
206
|
+
say("This is not file [#{filename}]", :blue)
|
|
171
207
|
raise NotImplementedError, "Unknown event -- #{event} -- #{filename}"
|
|
172
208
|
end
|
|
173
209
|
send(action, filename, options['quiet'])
|
|
210
|
+
else
|
|
211
|
+
next
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
|
|
174
215
|
end
|
|
175
216
|
end
|
|
176
217
|
|
|
@@ -179,6 +220,8 @@ module OpencodeTheme
|
|
|
179
220
|
ruby_version = "#{RUBY_VERSION}"
|
|
180
221
|
ruby_version += "-p#{RUBY_PATCHLEVEL}" if RUBY_PATCHLEVEL
|
|
181
222
|
puts "Ruby: v#{ruby_version}"
|
|
223
|
+
puts "OpencodeTheme: v:" + OpencodeTheme::VERSION
|
|
224
|
+
|
|
182
225
|
puts "Operating System: #{RUBY_PLATFORM}"
|
|
183
226
|
%w(HTTParty Launchy).each do |lib|
|
|
184
227
|
require "#{lib.downcase}/version"
|
|
@@ -188,6 +231,10 @@ module OpencodeTheme
|
|
|
188
231
|
|
|
189
232
|
protected
|
|
190
233
|
|
|
234
|
+
def is_file?(filename)
|
|
235
|
+
!FileTest.directory?(filename)
|
|
236
|
+
end
|
|
237
|
+
|
|
191
238
|
def config
|
|
192
239
|
@config ||= YAML.load_file 'config.yml'
|
|
193
240
|
end
|
|
@@ -209,7 +256,8 @@ module OpencodeTheme
|
|
|
209
256
|
|
|
210
257
|
def send_asset(asset, quiet = false)
|
|
211
258
|
if valid_name?(asset)
|
|
212
|
-
return unless
|
|
259
|
+
return unless is_file?(asset)
|
|
260
|
+
return unless valid_name?(asset)
|
|
213
261
|
data = { key: "/#{asset}" }
|
|
214
262
|
content = File.read("#{asset}")
|
|
215
263
|
if binary_file?(asset) || OpencodeTheme.is_binary_data?(content)
|
|
@@ -222,20 +270,28 @@ module OpencodeTheme
|
|
|
222
270
|
OpencodeTheme.send_asset(data)
|
|
223
271
|
end
|
|
224
272
|
if response.success?
|
|
225
|
-
say("[#{timestamp}]
|
|
273
|
+
say("[#{timestamp}] File uploaded: #{asset}", :green) unless quiet
|
|
226
274
|
else
|
|
227
275
|
report_error(Time.now, "Could not upload #{asset}", response)
|
|
228
276
|
end
|
|
229
277
|
end
|
|
230
278
|
end
|
|
231
279
|
|
|
280
|
+
def temporary_file?(asset)
|
|
281
|
+
false unless asset.include?('~')
|
|
282
|
+
end
|
|
283
|
+
|
|
232
284
|
def delete_asset(key, quiet = false)
|
|
233
|
-
return unless
|
|
285
|
+
return say("[#{timestamp}] Folder removed/rename: #{key}", :green) unless key.include?('.')
|
|
286
|
+
return exec_delete_file(key) if valid_name?(key)
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def exec_delete_file(key, quiet = false)
|
|
234
290
|
response = show_during("[#{timestamp}] Removing: #{key}", quiet) do
|
|
235
291
|
OpencodeTheme.delete_asset(key)
|
|
236
292
|
end
|
|
237
293
|
if response.success?
|
|
238
|
-
say("[#{timestamp}]
|
|
294
|
+
say("[#{timestamp}] File removed: #{key} ", :green) unless quiet
|
|
239
295
|
else
|
|
240
296
|
report_error(Time.now, "Could not remove #{key}", response)
|
|
241
297
|
end
|
|
@@ -249,7 +305,7 @@ module OpencodeTheme
|
|
|
249
305
|
|
|
250
306
|
def local_assets_list
|
|
251
307
|
local_files.reject do |p|
|
|
252
|
-
@permitted_files ||= (DEFAULT_WHITELIST | OpencodeTheme.whitelist_files).map{|pattern| Regexp.new(pattern)}
|
|
308
|
+
@permitted_files ||= (DEFAULT_WHITELIST | OpencodeTheme.whitelist_files).map{ |pattern| Regexp.new(pattern)}
|
|
253
309
|
@permitted_files.none? { |regex| regex =~ p } || OpencodeTheme.ignore_files.any? { |regex| regex =~ p }
|
|
254
310
|
end
|
|
255
311
|
end
|
|
@@ -273,11 +329,15 @@ module OpencodeTheme
|
|
|
273
329
|
end
|
|
274
330
|
|
|
275
331
|
def valid_name?(key)
|
|
332
|
+
return if temporary_file?(key)
|
|
276
333
|
name = key.split('/').last
|
|
277
334
|
if name =~ /^[0-9a-zA-Z\-_.]+\.(ttf|eot|svg|woff|css|scss|html|js|jpg|gif|png|json|TTF|EOT|SVG|WOFF|CSS|SCSS|HTML|JS|PNG|GIF|JPG|JSON)$/
|
|
278
335
|
valid = true
|
|
279
336
|
else
|
|
280
|
-
|
|
337
|
+
response = {}
|
|
338
|
+
response["message"] = 'verifique as regras de nome de arquivos:'
|
|
339
|
+
response["more_info"] = 'https://sites.google.com/a/tray.net.br/tecnologia/open-code/api?pli=1#00313'
|
|
340
|
+
report_error(Time.now, "Invalid name: #{name}", response)
|
|
281
341
|
end
|
|
282
342
|
valid
|
|
283
343
|
end
|
|
@@ -286,17 +346,17 @@ module OpencodeTheme
|
|
|
286
346
|
if valid_name?(key)
|
|
287
347
|
return unless valid?(key)
|
|
288
348
|
notify_and_sleep('Approaching limit of API permits. Naptime until more permits become available!') if OpencodeTheme.needs_sleep?
|
|
289
|
-
|
|
290
|
-
unless
|
|
291
|
-
report_error(Time.now, "Could not download #{key}",
|
|
292
|
-
return
|
|
349
|
+
response = OpencodeTheme.get_asset(URI.encode(key))
|
|
350
|
+
unless response['key']
|
|
351
|
+
report_error(Time.now, "Could not download #{key}", response)
|
|
352
|
+
return false
|
|
293
353
|
end
|
|
294
|
-
if
|
|
295
|
-
content = Base64.decode64(
|
|
354
|
+
if response['content']
|
|
355
|
+
content = Base64.decode64(response['content'])
|
|
296
356
|
content = content.force_encoding('UTF-8')
|
|
297
357
|
format = 'w+b:ISO-8859-1'
|
|
298
|
-
elsif
|
|
299
|
-
content = Base64.decode64(
|
|
358
|
+
elsif response['attachment']
|
|
359
|
+
content = Base64.decode64(response['attachment'])
|
|
300
360
|
format = 'w+b'
|
|
301
361
|
end
|
|
302
362
|
FileUtils.mkdir_p(File.dirname(URI.decode(key)))
|
|
@@ -312,8 +372,12 @@ module OpencodeTheme
|
|
|
312
372
|
end
|
|
313
373
|
|
|
314
374
|
def report_error(time, message, response)
|
|
315
|
-
say("[#{timestamp(time)}] Error: #{message}", :red)
|
|
316
|
-
|
|
375
|
+
say("[#{timestamp(time)}] Error: #{message}", :red) if message
|
|
376
|
+
if response
|
|
377
|
+
message_details = response["message"]
|
|
378
|
+
message_details = "#{message_details} \n #{response["more_info"]}" if !response["more_info"].nil?
|
|
379
|
+
say("Error Details: #{message_details}", :yellow)
|
|
380
|
+
end
|
|
317
381
|
end
|
|
318
382
|
end
|
|
319
383
|
end
|
data/opencode_theme.gemspec
CHANGED
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
|
13
13
|
spec.homepage = "http://tray-tecnologia.github.io/theme-template/"
|
|
14
14
|
spec.license = "MIT"
|
|
15
15
|
|
|
16
|
-
spec.add_dependency('thor', '>= 0.
|
|
16
|
+
spec.add_dependency('thor', '>= 0.14.4')
|
|
17
17
|
spec.add_dependency('httparty', '~> 0.13.0')
|
|
18
18
|
spec.add_dependency('json', '~> 1.8.0')
|
|
19
19
|
spec.add_dependency('mimemagic')
|
|
@@ -1,66 +1,71 @@
|
|
|
1
1
|
require_relative '../spec_helper'
|
|
2
2
|
|
|
3
3
|
describe OpencodeTheme::Cli, :functional do
|
|
4
|
-
|
|
5
4
|
STORE_ID = '430692'
|
|
6
5
|
FILE_NAME = 'layouts/default.html'
|
|
7
6
|
API_KEY = '11451c354c1f95fe60f80d7672bf184a'
|
|
8
7
|
PASSWORD = '14ae838d9e971465af45b35803b8f0a4'
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
before(:all) do
|
|
10
|
+
# clearing generated and downloaded files
|
|
11
|
+
FileUtils.rm_rf 'config.yml' if File.exist?('config.yml')
|
|
12
|
+
FileUtils.rm_rf 'default' if File.exist?('default')
|
|
13
|
+
end
|
|
14
|
+
|
|
10
15
|
after(:all) do
|
|
11
16
|
# clearing generated and downloaded files
|
|
12
|
-
FileUtils.
|
|
17
|
+
FileUtils.rm_rf 'config.yml'
|
|
13
18
|
FileUtils.rm_rf 'default'
|
|
14
19
|
end
|
|
15
|
-
|
|
20
|
+
|
|
16
21
|
context 'Invalid or Inexistent Configuration' do
|
|
17
22
|
it 'does not list when the config is invalid' do
|
|
18
23
|
output = capture(:stdout) { subject.list }
|
|
19
|
-
expect(File.
|
|
24
|
+
expect(File.exist? 'config.yml').to eq false
|
|
20
25
|
expect(output).to include 'config.yml does not exist!'
|
|
21
|
-
expect(output).to include 'Error:
|
|
22
|
-
expect(output).to include 'Error Details:
|
|
26
|
+
expect(output).to include 'Error: Configuration [FAIL]'
|
|
27
|
+
expect(output).to include 'Error Details: necessário autenticação'
|
|
23
28
|
end
|
|
24
|
-
|
|
29
|
+
|
|
25
30
|
it 'does not clean cache when the config is invalid' do
|
|
26
31
|
output = capture(:stdout) { subject.clean }
|
|
27
|
-
expect(File.
|
|
32
|
+
expect(File.exist? 'config.yml').to eq false
|
|
28
33
|
expect(output).to include 'Clean cache [FAIL]'
|
|
29
34
|
end
|
|
30
|
-
|
|
35
|
+
|
|
31
36
|
it 'does not upload any file when the config is invalid' do
|
|
32
37
|
output = capture(:stdout) { subject.upload }
|
|
33
38
|
expect(output).not_to include 'Uploaded'
|
|
34
39
|
expect(output).to include 'Done.'
|
|
35
40
|
end
|
|
36
41
|
end
|
|
37
|
-
|
|
42
|
+
|
|
38
43
|
context 'Configure' do
|
|
39
44
|
it 'fails to create config.yml file when called with no arguments' do
|
|
40
45
|
output = capture(:stdout) { subject.configure }
|
|
41
46
|
expect(output).to include 'Configuration [FAIL]'
|
|
42
|
-
expect(File.
|
|
47
|
+
expect(File.exist? 'config.yml').to eq false
|
|
43
48
|
end
|
|
44
|
-
|
|
49
|
+
|
|
45
50
|
it 'fails to create config.yml file when called with inexistent theme_id' do
|
|
46
|
-
output = capture(:stdout) { subject.configure API_KEY, PASSWORD,
|
|
51
|
+
output = capture(:stdout) { subject.configure API_KEY, PASSWORD, 214_748_364_7 }
|
|
47
52
|
expect(output).to include 'Configuration [FAIL]'
|
|
48
|
-
expect(File.
|
|
53
|
+
expect(File.exist? 'config.yml').to eq false
|
|
49
54
|
end
|
|
50
|
-
|
|
55
|
+
|
|
51
56
|
it 'fails to create config.yml file when called with invalid theme_id' do
|
|
52
57
|
output = capture(:stdout) { subject.configure API_KEY, PASSWORD, 'aaa' }
|
|
53
58
|
expect(output).to include 'Configuration [FAIL]'
|
|
54
|
-
expect(File.
|
|
59
|
+
expect(File.exist? 'config.yml').to eq false
|
|
55
60
|
end
|
|
56
|
-
|
|
61
|
+
|
|
57
62
|
it 'creates config.yml when called with valid theme_id' do
|
|
58
63
|
output = capture(:stdout) { subject.configure API_KEY, PASSWORD, 1 }
|
|
59
64
|
expect(output).to include 'Configuration [OK]'
|
|
60
|
-
expect(File.
|
|
65
|
+
expect(File.exist? 'config.yml').to eq true
|
|
61
66
|
end
|
|
62
67
|
end
|
|
63
|
-
|
|
68
|
+
|
|
64
69
|
context 'Bootstrap' do
|
|
65
70
|
it 'create new theme' do
|
|
66
71
|
output = capture(:stdout) { subject.bootstrap API_KEY, PASSWORD }
|
|
@@ -69,11 +74,11 @@ describe OpencodeTheme::Cli, :functional do
|
|
|
69
74
|
expect(output).to include 'Create default theme on store'
|
|
70
75
|
expect(output).to include 'Saving configuration to default'
|
|
71
76
|
expect(output).to include 'Downloading default assets from Opencode'
|
|
72
|
-
expect(output).to include "Downloaded: #{
|
|
77
|
+
expect(output).to include "Downloaded: #{FILE_NAME}"
|
|
73
78
|
expect(output).to include 'Done.'
|
|
74
79
|
end
|
|
75
80
|
end
|
|
76
|
-
|
|
81
|
+
|
|
77
82
|
context 'List' do
|
|
78
83
|
it 'lists all the themes from the store' do
|
|
79
84
|
output = capture(:stdout) { subject.list }
|
|
@@ -82,71 +87,74 @@ describe OpencodeTheme::Cli, :functional do
|
|
|
82
87
|
expect(output).to include 'Theme status:'
|
|
83
88
|
end
|
|
84
89
|
end
|
|
85
|
-
|
|
90
|
+
|
|
86
91
|
context 'Cleaning cache' do
|
|
87
92
|
it 'cleans the cache' do
|
|
93
|
+
expect(File.exist? 'default').to eq true
|
|
88
94
|
FileUtils.cd 'default'
|
|
89
95
|
output = capture(:stdout) { subject.clean }
|
|
90
96
|
FileUtils.cd '..'
|
|
91
97
|
expect(output).to include 'Clean cache [OK]'
|
|
92
98
|
end
|
|
93
99
|
end
|
|
94
|
-
|
|
100
|
+
|
|
95
101
|
context 'Download' do
|
|
96
102
|
it 'downloads all files' do
|
|
103
|
+
expect(File.exist? 'default').to eq true
|
|
97
104
|
FileUtils.cd 'default'
|
|
98
105
|
output = capture(:stdout) { subject.download }
|
|
99
106
|
FileUtils.cd '..'
|
|
100
107
|
expect(output).to include 'Downloaded'
|
|
101
|
-
expect(output).to include "Downloaded: #{
|
|
108
|
+
expect(output).to include "Downloaded: #{FILE_NAME}"
|
|
102
109
|
expect(output).not_to include 'Error'
|
|
103
110
|
expect(output).not_to include 'Net::ReadTimeout'
|
|
104
111
|
expect(output).to include 'Done.'
|
|
105
112
|
end
|
|
106
|
-
|
|
113
|
+
|
|
107
114
|
it 'downloads a single file' do
|
|
115
|
+
expect(File.exist? 'default').to eq true
|
|
108
116
|
FileUtils.cd 'default'
|
|
109
117
|
output = capture(:stdout) { subject.download FILE_NAME }
|
|
110
118
|
FileUtils.cd '..'
|
|
111
|
-
expect(output).to include "Downloaded: #{
|
|
119
|
+
expect(output).to include "Downloaded: #{FILE_NAME}"
|
|
112
120
|
expect(output).to include 'Done.'
|
|
113
121
|
expect(output).not_to include 'Error'
|
|
114
122
|
end
|
|
115
123
|
end
|
|
116
|
-
|
|
124
|
+
|
|
117
125
|
context 'Upload' do
|
|
118
126
|
it 'uploads all files' do
|
|
127
|
+
expect(File.exist? 'default').to eq true
|
|
119
128
|
FileUtils.cd 'default'
|
|
129
|
+
|
|
120
130
|
output = capture(:stdout) { subject.upload }
|
|
121
131
|
FileUtils.cd '..'
|
|
122
|
-
expect(output).to include
|
|
123
|
-
expect(output).to include "Uploaded: #{ FILE_NAME }"
|
|
124
|
-
expect(output).not_to include 'Error'
|
|
132
|
+
expect(output).to include "File uploaded: #{FILE_NAME}"
|
|
125
133
|
expect(output).to include 'Done.'
|
|
134
|
+
expect(output).not_to include 'Error'
|
|
126
135
|
end
|
|
127
|
-
|
|
136
|
+
|
|
128
137
|
it 'uploads a single file' do
|
|
138
|
+
expect(File.exist? 'default').to eq true
|
|
129
139
|
FileUtils.cd 'default'
|
|
130
140
|
output = capture(:stdout) { subject.upload FILE_NAME }
|
|
131
141
|
FileUtils.cd '..'
|
|
132
|
-
expect(output).to include "
|
|
142
|
+
expect(output).to include "File uploaded: #{FILE_NAME}"
|
|
133
143
|
expect(output).to include 'Done.'
|
|
134
144
|
expect(output).not_to include 'Error'
|
|
135
145
|
end
|
|
136
146
|
end
|
|
137
|
-
|
|
147
|
+
|
|
138
148
|
context 'System Information' do
|
|
139
149
|
let(:output) { capture(:stdout) { subject.systeminfo } }
|
|
140
|
-
|
|
150
|
+
|
|
141
151
|
it 'displays system information' do
|
|
142
|
-
pending 'redmine issue 37576'
|
|
143
152
|
expect(output).not_to be_nil
|
|
144
153
|
end
|
|
145
154
|
end
|
|
146
|
-
|
|
155
|
+
|
|
147
156
|
context 'Help' do
|
|
148
157
|
let(:output) { capture(:stdout) { subject.help } }
|
|
149
|
-
|
|
150
158
|
it 'displays help about each command' do
|
|
151
159
|
expect(output).to include 'Commands:'
|
|
152
160
|
expect(output).to include 'bootstrap API_KEY PASSWORD THEME_NAME THEME_BASE'
|
|
@@ -162,5 +170,4 @@ describe OpencodeTheme::Cli, :functional do
|
|
|
162
170
|
expect(output).to include 'watch'
|
|
163
171
|
end
|
|
164
172
|
end
|
|
165
|
-
|
|
166
173
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: opencode_theme
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rafael Takashi Tanaka
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-02-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.
|
|
19
|
+
version: 0.14.4
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.
|
|
26
|
+
version: 0.14.4
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: httparty
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
208
208
|
version: '0'
|
|
209
209
|
requirements: []
|
|
210
210
|
rubyforge_project:
|
|
211
|
-
rubygems_version: 2.
|
|
211
|
+
rubygems_version: 2.4.5.1
|
|
212
212
|
signing_key:
|
|
213
213
|
specification_version: 4
|
|
214
214
|
summary: Provides simple commands to upload and donwload files from a themes
|