voog-kit 0.1.10 → 0.1.11

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: 48013ec6fe272a3a6133f9a610d20c81206167ea
4
- data.tar.gz: d2429fdabe6243f3c6bffa58da1e78919513797e
3
+ metadata.gz: a43f2ab887fd0a79a362c3f2615f3be925f5874e
4
+ data.tar.gz: 40f3e9c9cbee44a066c5007da876dedcb94884ea
5
5
  SHA512:
6
- metadata.gz: f9564892648ff8d743fedb767ffd7d4a99e6b0310c27f692d74fd9e06ff6bc49d2770ed9d78bb4cebf2f849c43f3bd816b48dac89e3433fcbe172caf1afb2c45
7
- data.tar.gz: 7d9e297d744d4ec40db00ca0461e3bc20f349b0c6b3900f1ba975893ed4e2b922dad3d9d4c523b3df2900dc1b06894ded203ca6dab3269c69822a79da247dde5
6
+ metadata.gz: 0349c5f771587b3eb973a2e6886fa31bc3b91d0d3f09f4fa8fb639224d55113421034cd5d40c58d90754143be25d7c087b659f8b0e2455a9a4b173cf7a39d356
7
+ data.tar.gz: 1170fb9a1172a16a6486588160b8d5a75bdfafdc6c3636724fb6a528bb16d9ba2d100f721bacee7bb903690c4a0e076650ffe80b7b730c716b530530b88e9dbd
data/README.markdown CHANGED
@@ -101,7 +101,9 @@ This command starts a watcher that monitors the current folder and its subfolder
101
101
  a file changes. This is most useful for styling your site as all style changes are instantly uploaded and visible in
102
102
  the browser.
103
103
 
104
- `watch` also looks for newly created files and file removals, updates the manifest accordingly and triggers `kit push`.
104
+ `watch` also looks for newly created files and file removals, updates the manifest accordingly and triggers `kit push`.
105
+
106
+ You can stop the watch command by pressing Ctrl+D or typing "exit" or "q".
105
107
 
106
108
  ### help
107
109
 
data/bin/kit CHANGED
@@ -154,6 +154,10 @@ command :manifest do |c|
154
154
  end
155
155
 
156
156
  desc 'Watches for file changes and pushes them automatically'
157
+ long_desc "This starts watching the current folder and its subfolders for file
158
+ changes and tries to push them to the remote site. When new files are
159
+ added or old ones removed, it also adds or removes them from the manifest
160
+ file, respectively. You can exit by pressing Ctrl+D or typing 'q' or 'exit'."
157
161
  command :watch do |c|
158
162
  c.switch *debug_args
159
163
  c.switch *verbose_args
@@ -200,7 +204,7 @@ pre do |global, command, options, args|
200
204
  api_token ||= @config[:api_token]
201
205
 
202
206
  client = Voog::Client.new(host, api_token)
203
- @filemanager = Voog::Dtk::FileManager.new(client, verbose, silent)
207
+ @filemanager = Voog::Dtk::FileManager.new(client, @config, verbose, silent)
204
208
  end
205
209
 
206
210
  on_error do |exception|
data/lib/voog/dtk.rb CHANGED
@@ -19,7 +19,8 @@ module Voog
19
19
  def read_config(block = nil, file = CONFIG_FILENAME)
20
20
  config = {
21
21
  :host => nil,
22
- :api_token => nil
22
+ :api_token => nil,
23
+ :overwrite => false
23
24
  }
24
25
  local_config = config_exists?(file) ? ParseConfig.new(File.expand_path(file)).params : {}
25
26
  global_config = global_config_exists?(file) ? ParseConfig.new(File.expand_path([ENV['HOME'], file].join('/'))).params : {}
@@ -39,6 +40,7 @@ module Voog
39
40
 
40
41
  config[:host] = options[@block].fetch("host")
41
42
  config[:api_token] = options[@block].fetch("api_token")
43
+ config[:overwrite] = options[@block].fetch("overwrite", false) == 'true' ? true : false
42
44
  end
43
45
  config
44
46
  end
@@ -8,18 +8,20 @@ require 'mime/types'
8
8
  module Voog::Dtk
9
9
  class FileManager
10
10
  attr_accessor :notifier
11
- def initialize(client, verbose=false, silent=false)
11
+ def initialize(client, config, verbose=false, silent=false)
12
12
  @notifier = Voog::Dtk::Notifier.new($stderr, silent)
13
13
  @client = client
14
14
  @verbose = verbose
15
+ @config = config
16
+ puts "CONFIG: #{@config}"
15
17
  end
16
18
 
17
19
  def read_manifest
18
- JSON.parse(File.read('manifest.json')).to_h
20
+ JSON.parse(File.read('manifest.json', :encoding => 'UTF-8')).to_h
19
21
  end
20
22
 
21
23
  def write_manifest(manifest)
22
- File.open('manifest.json', 'w+') do |file|
24
+ File.open('manifest.json', 'w+', :encoding => 'UTF-8') do |file|
23
25
  file << JSON.pretty_generate(manifest)
24
26
  end
25
27
  end
@@ -97,16 +99,6 @@ module Voog::Dtk
97
99
  write_manifest @manifest
98
100
  end
99
101
 
100
- def delete_remote_files(files)
101
- return if files.nil?
102
- files = (files.is_a? String) ? [files] : files
103
- layouts = layout_id_map
104
- assets = asset_id_map
105
- files.uniq.each do |file|
106
-
107
- end
108
- end
109
-
110
102
  def get_layouts
111
103
  @client.layouts(per_page: 10000)
112
104
  end
@@ -131,6 +123,10 @@ module Voog::Dtk
131
123
  @client.update_layout_asset(id, data: data)
132
124
  end
133
125
 
126
+ def delete_layout_asset(id)
127
+ @client.delete_layout_asset(id)
128
+ end
129
+
134
130
  def valid?(item)
135
131
  if item.is_a? String
136
132
  begin
@@ -615,7 +611,16 @@ module Voog::Dtk
615
611
  @notifier.error "Unable to update file #{file}!"
616
612
  end
617
613
  else
618
- @notifier.warning "Not allowed to update file #{file}! Skipping."
614
+ if @config.fetch(:overwrite)
615
+ @notifier.info "Re-uploading file #{file}..."
616
+ if delete_layout_asset(layout_assets[file]) && create_remote_file(file)
617
+ @notifier.success 'OK!'
618
+ else
619
+ @notifier.error "Unable to update file #{file}!"
620
+ end
621
+ else
622
+ @notifier.warning "Not allowed to update file #{file}!"
623
+ end
619
624
  end
620
625
  else
621
626
  @notifier.warning "Remote file #{file} not found!"
@@ -1,5 +1,5 @@
1
1
  module Voog
2
2
  module Dtk
3
- VERSION = '0.1.10'
3
+ VERSION = '0.1.11'
4
4
  end
5
5
  end
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.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikk Pristavka
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-07 00:00:00.000000000 Z
12
+ date: 2014-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler