voog-kit 0.1.11 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a43f2ab887fd0a79a362c3f2615f3be925f5874e
4
- data.tar.gz: 40f3e9c9cbee44a066c5007da876dedcb94884ea
3
+ metadata.gz: e1c88db6b03fc5e1e036dd8ed3df13bb2f5cb1b2
4
+ data.tar.gz: eb9caf57e75c716860c4c2b719d5f283a8cd090a
5
5
  SHA512:
6
- metadata.gz: 0349c5f771587b3eb973a2e6886fa31bc3b91d0d3f09f4fa8fb639224d55113421034cd5d40c58d90754143be25d7c087b659f8b0e2455a9a4b173cf7a39d356
7
- data.tar.gz: 1170fb9a1172a16a6486588160b8d5a75bdfafdc6c3636724fb6a528bb16d9ba2d100f721bacee7bb903690c4a0e076650ffe80b7b730c716b530530b88e9dbd
6
+ metadata.gz: 621fd03b7e3dfdbd2801bff9df93337cdbaf93b329de9b71fcc99579b4cb329bca156746ac41c39be6fc3a56a0a5b73adec06b78852084cb3daf18b2fabd75a4
7
+ data.tar.gz: 2771bf3cad4702850652021296b9e3fa1253bf090b125206885e6954b29fdbb4de6459d3a42cd2bf3ba94fe57b2d0fbda98111681d15e9c24b3373c719af1ecd
data/README.markdown CHANGED
@@ -62,6 +62,17 @@ If the configuration file isn't present and you provide the token, hostname and
62
62
  command, the file is then generated and the options are stored within so you don't have to provide them
63
63
  later.
64
64
 
65
+ Another useful option is `--overwrite` to allow updating asset files you normally couldn't update. This deletes the
66
+ old file and uploads the newer one as a replacement. This cannot be undone, so take caution!
67
+ To enable overwriting for all commands, you can add it to the site's configuration block in the `.voog` file like so:
68
+
69
+ ```
70
+ [site1]
71
+ host=mysite.voog.com
72
+ api_token=afcf30182aecfc8155d390d7d4552d14
73
+ overwrite=true
74
+ ```
75
+
65
76
  ### init
66
77
 
67
78
  This command either initializes an empty folder structure via `kit init empty`, clones the file and folder
data/bin/kit CHANGED
@@ -24,6 +24,7 @@ silent_args = [:silent, { default_value: false, negatable: false, desc: 'Hide al
24
24
  hostname_args = [:h, :host, :hostname, { desc: 'Provide a hostname', arg_name: :HOST }]
25
25
  api_token_args = [:t, :token, :api_token, { desc: 'Provide an API token', arg_name: :API_TOKEN }]
26
26
  site_args = [:s, :site, { arg_name: :SITE, default_value: nil, desc: 'Specify which site block to use when parsing the .voog file' }]
27
+ overwrite_args = [:overwrite, { negatable: true, default_value: false, desc: 'Enable overwriting asset files that cannot be normally updated. '}]
27
28
 
28
29
  flag *hostname_args
29
30
  flag *api_token_args
@@ -32,6 +33,8 @@ flag *site_args
32
33
  switch *debug_args
33
34
  switch *verbose_args
34
35
  switch *silent_args
36
+ switch *overwrite_args
37
+
35
38
  version Voog::Dtk::VERSION
36
39
 
37
40
  desc 'Initializes the local folder structure and files for a site'
@@ -47,6 +50,7 @@ command :init do |c|
47
50
  c.switch *debug_args
48
51
  c.switch *verbose_args
49
52
  c.switch *silent_args
53
+ c.switch *overwrite_args
50
54
  c.flag *hostname_args
51
55
  c.flag *api_token_args
52
56
  c.flag *site_args
@@ -74,6 +78,7 @@ command :check do |c|
74
78
  c.switch *debug_args
75
79
  c.switch *verbose_args
76
80
  c.switch *silent_args
81
+ c.switch *overwrite_args
77
82
  c.flag *hostname_args
78
83
  c.flag *api_token_args
79
84
  c.flag *site_args
@@ -92,6 +97,7 @@ command :pull do |c|
92
97
  c.switch *debug_args
93
98
  c.switch *verbose_args
94
99
  c.switch *silent_args
100
+ c.switch *overwrite_args
95
101
  c.flag *hostname_args
96
102
  c.flag *api_token_args
97
103
  c.flag *site_args
@@ -115,6 +121,7 @@ command :push do |c|
115
121
  c.switch *debug_args
116
122
  c.switch *verbose_args
117
123
  c.switch *silent_args
124
+ c.switch *overwrite_args
118
125
  c.flag *hostname_args
119
126
  c.flag *api_token_args
120
127
  c.flag *site_args
@@ -135,6 +142,7 @@ command :manifest do |c|
135
142
  c.switch *debug_args
136
143
  c.switch *verbose_args
137
144
  c.switch *silent_args
145
+ c.switch *overwrite_args
138
146
  c.flag *hostname_args
139
147
  c.flag *api_token_args
140
148
  c.flag *site_args
@@ -162,6 +170,7 @@ command :watch do |c|
162
170
  c.switch *debug_args
163
171
  c.switch *verbose_args
164
172
  c.switch *silent_args
173
+ c.switch *overwrite_args
165
174
  c.flag *hostname_args
166
175
  c.flag *api_token_args
167
176
  c.flag *site_args
@@ -177,6 +186,7 @@ pre do |global, command, options, args|
177
186
 
178
187
  silent = global.fetch(:silent, false) || options.fetch(:silent, false)
179
188
  verbose = global.fetch(:verbose, false) || options.fetch(:verbose, false)
189
+ overwrite = global.fetch(:overwrite, false) || options.fetch(:overwrite, false)
180
190
 
181
191
  @notifier = Voog::Dtk::Notifier.new($stderr, silent)
182
192
 
@@ -184,7 +194,12 @@ pre do |global, command, options, args|
184
194
  api_token = global.fetch(:token, nil) || options.fetch(:token, nil)
185
195
 
186
196
  if host && api_token && @config_block
187
- Voog::Dtk.write_config(host, api_token, @config_block)
197
+ Voog::Dtk.write_config({
198
+ host: host,
199
+ api_token: api_token,
200
+ block: @config_block,
201
+ overwrite: overwrite
202
+ })
188
203
  end
189
204
 
190
205
  @config = Voog::Dtk.read_config @config_block
@@ -204,7 +219,11 @@ pre do |global, command, options, args|
204
219
  api_token ||= @config[:api_token]
205
220
 
206
221
  client = Voog::Client.new(host, api_token)
207
- @filemanager = Voog::Dtk::FileManager.new(client, @config, verbose, silent)
222
+ @filemanager = Voog::Dtk::FileManager.new(client, {
223
+ silent: silent,
224
+ verbose: verbose,
225
+ overwrite: overwrite
226
+ })
208
227
  end
209
228
 
210
229
  on_error do |exception|
@@ -8,12 +8,12 @@ require 'mime/types'
8
8
  module Voog::Dtk
9
9
  class FileManager
10
10
  attr_accessor :notifier
11
- def initialize(client, config, verbose=false, silent=false)
12
- @notifier = Voog::Dtk::Notifier.new($stderr, silent)
11
+ def initialize(client, opts = {})
13
12
  @client = client
14
- @verbose = verbose
15
- @config = config
16
- puts "CONFIG: #{@config}"
13
+ @silent = opts.fetch(:silent, false)
14
+ @verbose = opts.fetch(:verbose, false)
15
+ @overwrite = opts.fetch(:overwrite, false)
16
+ @notifier = Voog::Dtk::Notifier.new($stderr, @silent)
17
17
  end
18
18
 
19
19
  def read_manifest
@@ -430,7 +430,6 @@ module Voog::Dtk
430
430
  not_ok_char = "!"
431
431
  @notifier.info "Checking manifest.json..."
432
432
 
433
- # Check for manifest
434
433
  if File.exists? 'manifest.json'
435
434
  @manifest = read_manifest
436
435
  @notifier.success 'OK!'
@@ -611,7 +610,7 @@ module Voog::Dtk
611
610
  @notifier.error "Unable to update file #{file}!"
612
611
  end
613
612
  else
614
- if @config.fetch(:overwrite)
613
+ if @overwrite
615
614
  @notifier.info "Re-uploading file #{file}..."
616
615
  if delete_layout_asset(layout_assets[file]) && create_remote_file(file)
617
616
  @notifier.success 'OK!'
@@ -1,5 +1,5 @@
1
1
  module Voog
2
2
  module Dtk
3
- VERSION = '0.1.11'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
data/lib/voog/dtk.rb CHANGED
@@ -45,7 +45,12 @@ module Voog
45
45
  config
46
46
  end
47
47
 
48
- def write_config(host, api_token, block, silent=false)
48
+ def write_config(opts)
49
+ block = opts.fetch(:block, '')
50
+ host = opts.fetch(:host, '')
51
+ api_token = opts.fetch(:api_token, '')
52
+ silent = opts.fetch(:silent, false)
53
+
49
54
  @file = if config_exists?
50
55
  CONFIG_FILENAME
51
56
  elsif global_config_exists?
@@ -61,11 +66,13 @@ module Voog
61
66
  puts "Writing new configuration options to existing config block.".white unless silent
62
67
  options.params[block]['host'] = host unless host.empty?
63
68
  options.params[block]['api_token'] = api_token unless api_token.empty?
69
+ options.params[block]['overwrite'] = overwrite unless overwrite.empty?
64
70
  else
65
71
  puts "Writing configuration options to new config block.".white unless silent
66
72
  options.params[block] = {
67
73
  'host' => host,
68
- 'api_token' => api_token
74
+ 'api_token' => api_token,
75
+ 'overwrite' => overwrite
69
76
  }
70
77
  end
71
78
 
@@ -3,7 +3,7 @@
3
3
  {
4
4
  "component": true,
5
5
  "content_type": "component",
6
- "file": "test_component.tpl",
6
+ "file": "components/test_component.tpl",
7
7
  "layout_name": "test_component",
8
8
  "title": "test_component"
9
9
  }
@@ -7,7 +7,7 @@ describe Voog::Dtk::FileManager do
7
7
  before :all do
8
8
  Dir.mkdir 'TEST'
9
9
  Dir.chdir 'TEST'
10
- @filemanager = Voog::Dtk::FileManager.new(nil, false, true)
10
+ @filemanager = Voog::Dtk::FileManager.new(nil, {silent: false, verbose: true, overwrite: false})
11
11
  @dir = Dir.new('.')
12
12
  end
13
13
 
@@ -284,7 +284,7 @@ describe Voog::Dtk::FileManager do
284
284
  end
285
285
  end
286
286
 
287
- describe '#remove_from_manifest', focus: true do
287
+ describe '#remove_from_manifest' do
288
288
  before :all do
289
289
  @filemanager.generate_manifest(get_layouts, get_layout_assets)
290
290
  @filemanager.add_to_manifest ['components/testfile2.tpl', 'assets/test.svg']
@@ -319,12 +319,21 @@ describe Voog::Dtk::FileManager do
319
319
 
320
320
  describe '#check' do
321
321
  context 'with an empty folder' do
322
+ before :all do
323
+ Dir.mkdir('temp')
324
+ Dir.chdir('temp')
325
+ end
326
+
327
+ after :all do
328
+ Dir.chdir('..')
329
+ Dir.delete('temp')
330
+ end
322
331
  it 'returns false' do
323
332
  expect(@filemanager.check).to be_false
324
333
  end
325
334
  end
326
335
 
327
- context 'with empty manifest.json but no files' do
336
+ context 'with empty manifest.json and no files' do
328
337
  it 'returns false' do
329
338
  File.open('manifest.json', 'w+') do |file|
330
339
  file << {
@@ -338,7 +347,7 @@ describe Voog::Dtk::FileManager do
338
347
 
339
348
  context 'with filled manifest.json but no files' do
340
349
  it 'returns false' do
341
- File.open('manifest.json', 'w+') do |file|
350
+ @manifest = File.open('manifest.json', 'w+') do |file|
342
351
  file << {
343
352
  'layouts' => [{
344
353
  "component" => false,
data/spec/spec_helper.rb CHANGED
@@ -4,7 +4,6 @@ require_relative '../lib/voog/dtk/notifier.rb'
4
4
 
5
5
  RSpec.configure do |c|
6
6
  # filter_run is short-form alias for filter_run_including
7
- c.filter_run focus: true
8
7
  end
9
8
 
10
9
  FIXTURE_PATH = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures'))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voog-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikk Pristavka