voog-kit 0.3.1 → 0.3.3

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: 9c9f1079f0ef59107da7b523f88cf7a443201e78
4
- data.tar.gz: 315a4457e8b6801c2496a0f816dbfd7153be7b33
3
+ metadata.gz: 4d8f302218c12c39a550e03d9b6b4607ac45b7b1
4
+ data.tar.gz: fc4e9d0851bf63d22fd44b2a809df0ea4fad6f0f
5
5
  SHA512:
6
- metadata.gz: aa86407a6dd8e34f0226bfe37503e3b405490533e0ea517c6661f83166db2de1a7f2fd6fde1e68bb72664bc2197af5b5bda622211292672cacaefe35a30c8b9e
7
- data.tar.gz: a2d01697c7aaa0c530e9f538af1521618da54ca8c6fd03bf9e67eceea244d8989a1c2d6c568d4fc5aba796b2347fed9578116656fb777ba7a0b8c9661375c8ed
6
+ metadata.gz: ced86da8f72e62c1642798ba6ec39b86b01c805a1d943cf9ea6c04ac377f7d84e2c635a2c7b39eaf99e05b4d5d9fb3d548571413f21b7e69151d5f68b5e902c1
7
+ data.tar.gz: e3ae174c9d9e03bcd362751e5717462d693e495059af9fd349c4706fbf440340a73d28df076027b37417b885860d55de6dab01ad53c9ad055c591b9508ba97ed
data/bin/kit CHANGED
@@ -25,7 +25,6 @@ hostname_args = [:h, :host, :hostname, { desc: 'Provide a hostname', arg_name: :
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
27
  overwrite_args = [:overwrite, { negatable: true, default_value: false, desc: 'Enable overwriting asset files that cannot be normally updated.' }]
28
- cleanup_args = [:cleanup, { negatable: false, default_value: false, desc: 'Delete remote layout files that are not in local manifest.' }]
29
28
 
30
29
  flag *hostname_args
31
30
  flag *api_token_args
@@ -51,7 +50,6 @@ command :init do |c|
51
50
  c.switch *debug_args
52
51
  c.switch *verbose_args
53
52
  c.switch *silent_args
54
- c.switch *overwrite_args
55
53
  c.flag *hostname_args
56
54
  c.flag *api_token_args
57
55
  c.flag *site_args
@@ -88,7 +86,6 @@ command :check do |c|
88
86
  c.switch *debug_args
89
87
  c.switch *verbose_args
90
88
  c.switch *silent_args
91
- c.switch *overwrite_args
92
89
  c.flag *hostname_args
93
90
  c.flag *api_token_args
94
91
  c.flag *site_args
@@ -98,16 +95,20 @@ command :check do |c|
98
95
  end
99
96
 
100
97
  desc 'Fetches the layout and layout asset files for the given site'
101
- long_desc 'If no arguments are provided, the \'pull\' command fetches all
98
+ long_desc "If no arguments are provided, the 'pull' command fetches all
102
99
  layout files and layout assets and (re-)generates a manifest file.
103
- If filenames are provided, it fetches only those and updates the
104
- manifest with only those files. The provided names can be either
105
- filenames or layout/component titles.'
100
+ If file or folder names are provided, it fetches any files matching the
101
+ given names and updates the manifest with those files. The provided
102
+ names can be either folder names or full filenames. For layouts and
103
+ components, the .tpl extension is optional.\n
104
+ Examples:\n
105
+ kit pull images stylesheets javascripts\n
106
+ kit pull images/image.png images/image.jpg\n
107
+ kit pull layouts/front_page components/news.tpl"
106
108
  command :pull do |c|
107
109
  c.switch *debug_args
108
110
  c.switch *verbose_args
109
111
  c.switch *silent_args
110
- c.switch *overwrite_args
111
112
  c.flag *hostname_args
112
113
  c.flag *api_token_args
113
114
  c.flag *site_args
@@ -132,7 +133,6 @@ command :push do |c|
132
133
  c.switch *verbose_args
133
134
  c.switch *silent_args
134
135
  c.switch *overwrite_args
135
- c.switch *cleanup_args
136
136
  c.flag *hostname_args
137
137
  c.flag *api_token_args
138
138
  c.flag *site_args
@@ -246,7 +246,6 @@ pre do |global, command, options, args|
246
246
  silent = global.fetch(:silent, false) || options.fetch(:silent, false)
247
247
  verbose = global.fetch(:verbose, false) || options.fetch(:verbose, false)
248
248
  overwrite = global.fetch(:overwrite, false) || options.fetch(:overwrite, false)
249
- cleanup = global.fetch(:cleanup, false) || options.fetch(:cleanup, false)
250
249
 
251
250
  @notifier = Voog::Dtk::Notifier.new($stderr, silent)
252
251
 
@@ -283,8 +282,7 @@ pre do |global, command, options, args|
283
282
  @filemanager = Voog::Dtk::FileManager.new(client, {
284
283
  silent: silent,
285
284
  verbose: verbose,
286
- overwrite: overwrite,
287
- cleanup: cleanup
285
+ overwrite: overwrite
288
286
  })
289
287
  end
290
288
 
@@ -235,7 +235,7 @@ module Voog::Dtk
235
235
  @notifier.info 'Reading local files...'
236
236
  layouts_dir = Dir.new('layouts')
237
237
  layouts = layouts_dir.entries.select do |file|
238
- (file =~ /(.*)\.tpl/ && !File.directory?(File.join(layouts_dir, file)))
238
+ (!File.directory?(File.join(layouts_dir, file)) && valid_for_folder?(file, 'layouts'))
239
239
  end
240
240
  layouts = layouts.map do |l|
241
241
  attrs = {
@@ -253,7 +253,7 @@ module Voog::Dtk
253
253
  end
254
254
  components_dir = Dir.new('components')
255
255
  components = components_dir.entries.select do |file|
256
- (file =~ /(.*)\.tpl/ && !File.directory?(File.join(components_dir, file)))
256
+ (!File.directory?(File.join(components_dir, file)) && valid_for_folder?(file, 'components'))
257
257
  end
258
258
  components = components.map do |c|
259
259
  name = c.split('.').first.gsub('_', ' ')
@@ -276,7 +276,7 @@ module Voog::Dtk
276
276
  next unless Dir.exist? dir
277
277
  current_dir = Dir.new(dir)
278
278
  current_dir.entries.each do |file|
279
- next if File.directory?(File.join(current_dir, file))
279
+ next unless !File.directory?(File.join(current_dir, file)) && valid_for_folder?(file, dir)
280
280
  attrs = {
281
281
  'content_type' => begin
282
282
  MIME::Types.type_for(file).first.content_type
@@ -893,55 +893,56 @@ module Voog::Dtk
893
893
 
894
894
  def find_layouts(names)
895
895
  layouts = get_layouts
896
- @manifest = read_manifest if File.exist? 'manifest.json'
897
896
  results = []
898
897
 
899
898
  names.each do |name|
900
- name = name.split('/').last.split('.').first
901
- if @manifest
902
- layout = @manifest.fetch('layouts', []).reject(&:nil?).find{ |l| l['file'].split('/').last.split('.').first == name }
903
- if layout # layout file is in manifest
904
- layout = layouts.find { |l| l.title == layout['title'] }
905
- else # not found in manifest
906
- layout = layouts.find { |l| l.title == name }
907
- end
908
- id = layout.id if layout
899
+ case name
900
+ when /\Alayouts\/?\Z/
901
+ results << layouts.select { |l| !l.component }.map(&:id)
902
+ when /\Acomponents\/?\Z/
903
+ results << layouts.select { |l| l.component }.map(&:id)
909
904
  else
910
- layout = layouts.find{ |l| l.title.gsub(/[^\w\.]/, '_').downcase == name}
911
- id = layout['id'] if layout
905
+ type, name = name.gsub('.tpl', '').split('/')
906
+ results << layouts.select do |l|
907
+ (type == 'layouts' ? !l.component : l.component) && l.title.gsub(/[^\w\.]/, '_').downcase == name
908
+ end.map(&:id)
912
909
  end
913
- results << id if id
914
910
  end
915
-
916
- results
911
+ results.flatten
917
912
  end
918
913
 
919
914
  def find_assets(names)
920
915
  assets = get_layout_assets
921
916
  results = []
922
917
  names.each do |name|
923
- name = name.split('/').last
924
- layout = assets.find{ |l| l.filename == name }
925
- results << layout.id if layout
918
+ case name
919
+ when /\Aassets\/?\Z/
920
+ results << assets.select { |a| a.asset_type == 'asset' }.map(&:id)
921
+ when /\Aimages\/?\Z/
922
+ results << assets.select { |a| a.asset_type == 'image' }.map(&:id)
923
+ when /\Ajavascripts\/?\Z/
924
+ results << assets.select { |a| a.asset_type == 'javascript' }.map(&:id)
925
+ when /\Astylesheets\/?\Z/
926
+ results << assets.select { |a| a.asset_type == 'stylesheet' }.map(&:id)
927
+ else
928
+ results << assets.select { |a| a.filename == name.split('/').last }.map(&:id)
929
+ end
926
930
  end
927
- results
931
+ results.flatten
928
932
  end
929
933
 
930
934
  def pull_files(names)
931
- # TODO: pull whole folders, e.g "pull images"
932
935
  layout_ids = find_layouts(names)
933
936
  asset_ids = find_assets(names)
934
937
 
935
938
  found = layout_ids.length + asset_ids.length
936
- if found > 0 && found < names.length
937
- @notifier.warning 'Unable to find some specified files!'
939
+
940
+ unless found
941
+ @notifier.error "Unable to find any files matching the given pattern#{'s' if names.length > 1}!"
938
942
  @notifier.newline
939
- ret = true
940
- elsif found == names.length
941
- ret = true
942
- elsif found == 0
943
- @notifier.error 'Unable to find any specified files!'
944
943
  ret = false
944
+ else
945
+ ret = true
945
946
  end
946
947
 
947
948
  create_layouts(layout_ids) unless layout_ids.empty?
@@ -949,6 +950,7 @@ module Voog::Dtk
949
950
 
950
951
  ret
951
952
  end
953
+
952
954
  def display_sites(sites)
953
955
  sites.each_with_index do |site, index|
954
956
  @notifier.info "#{site.fetch(:name)} #{'(default)' if index == 0}"
@@ -1,5 +1,5 @@
1
1
  module Voog
2
2
  module Dtk
3
- VERSION = '0.3.1'
3
+ VERSION = '0.3.3'
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.3.1
4
+ version: 0.3.3
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: 2015-01-12 00:00:00.000000000 Z
12
+ date: 2015-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler