nimbu 0.7.9 → 0.8.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: 9d7d01bb99d406ca5718d7144a86ac847e1dd406
4
- data.tar.gz: b20d6a92f23e1d3e35d2be2497f0ac4afaf05484
3
+ metadata.gz: 21566ccc6a6c4e11b1313dc2f795b21b933f3953
4
+ data.tar.gz: c3f6dd296d5251a9f7ab40d86a9c0822dca34717
5
5
  SHA512:
6
- metadata.gz: ba5804f0fbf643a933a7c108f8957e0c5c9de0cd5254f31ac552adadcd6fe2790ef114df0421f82de6f72b88e91234805436cfe9c49bc64b5b9575c394075031
7
- data.tar.gz: 0d4299b4d55489ce381b8dcc3ba0f997716e38a1b8af08580a186e79edb2ee72193df512dbb3890c76a37b3565090029cacea4e88108dfb4b3eed43eb8e0bc3b
6
+ metadata.gz: 947e1335f4f309ce12f40f3bd33d779e541d7ae29f835e92ed43a18f9bc60c93c7975d001a48d5ce05c2c527f689a92848fdc27e74e5db831d45c0283cb9cd12
7
+ data.tar.gz: 9774466aad7d5c7bf26f83fc2dc0139e82abd5897da32da17915151bcfc95628f7496b5ad16e7cf0de37f51ef2fefddd3e3f8e382e49333bc485f820b0cde7d9
@@ -90,12 +90,16 @@ class Nimbu::Command::Themes < Nimbu::Command::Base
90
90
  # --css, --css-only # only push template code
91
91
  # --js, --js-only # only push template code
92
92
  # --images-only # only push new images
93
+ # --fonts-only # only push fonts
94
+ # --only # only push the files given on the command line
93
95
  #
94
96
  def push
95
97
  liquid_only = options[:liquid]
96
98
  css_only = options[:css]
97
99
  js_only = options[:js]
98
100
  images_only = options[:images_only]
101
+ fonts_only = options[:fonts_only]
102
+ files_only = options[:only]
99
103
 
100
104
  # if !input.to_s.strip.empty?
101
105
  # theme = input.to_s.strip
@@ -104,14 +108,105 @@ class Nimbu::Command::Themes < Nimbu::Command::Base
104
108
  theme = Nimbu::Auth.theme
105
109
  display "Pushing layouts, templates and assets for '#{theme}' to the server:"
106
110
 
107
- layouts_glob = Dir.glob("#{Dir.pwd}/layouts/**/*.liquid")
108
- layouts_files = layouts_glob.map {|dir| dir.gsub("#{Dir.pwd}/layouts/","")}
109
- templates_glob = Dir.glob("#{Dir.pwd}/templates/**/*.liquid")
110
- templates_files = templates_glob.map {|dir| dir.gsub("#{Dir.pwd}/templates/","")}
111
- snippets_glob = Dir.glob("#{Dir.pwd}/snippets/**/*.liquid")
112
- snippets_files = snippets_glob.map {|dir| dir.gsub("#{Dir.pwd}/snippets/","")}
111
+ # What should we push?
112
+ push_liquid = !(css_only || js_only || images_only || fonts_only)
113
+ push_css = !(liquid_only || js_only || images_only || fonts_only)
114
+ push_js = !(liquid_only || css_only || images_only || fonts_only)
115
+ push_images = !(liquid_only || css_only || js_only || fonts_only)
116
+ push_fonts = !(liquid_only || css_only || js_only || images_only)
117
+
118
+ if push_fonts
119
+ if files_only
120
+ font_files = args.select{|file| file.start_with?("fonts", "")}.map{|file| file.gsub("fonts/", "")}
121
+ else
122
+ font_files = Dir.glob("#{Dir.pwd}/fonts/**/*").map {|dir| dir.gsub("#{Dir.pwd}/fonts/","")} rescue []
123
+ end
124
+
125
+ print "\nFonts:\n"
126
+ font_files.each do |font|
127
+ file = "#{Dir.pwd}/fonts/#{font}"
128
+ next if File.directory?(file) || (!anyFileWithWord?(css_glob,font) && !anyFileWithWord?(js_glob,font) && !anyFileWithWord?(layouts_glob,font) && !anyFileWithWord?(templates_glob,font) && !anyFileWithWord?(snippets_glob,font))
129
+ io = Faraday::UploadIO.new(File.open(file), 'application/octet-stream', File.basename(file))
130
+ nimbu.themes(:subdomain => Nimbu::Auth.site).assets(:theme_id => theme).create({:name => "fonts/#{font}", :file => io})
131
+ print " - fonts/#{font}"
132
+ print " (ok)\n"
133
+ end
134
+ end
135
+
136
+ if push_images
137
+ if files_only
138
+ image_files = args.select{|file| file.start_with?("images", "")}.map{|file| file.gsub("images/", "")}
139
+ else
140
+ image_files = Dir.glob("#{Dir.pwd}/images/**/*").map {|dir| dir.gsub("#{Dir.pwd}/images/","")}
141
+ end
142
+
143
+ print "\nImages:\n"
144
+ image_files.each do |image|
145
+ file = "#{Dir.pwd}/images/#{image}"
146
+ next if File.directory?(file) || (!anyFileWithWord?(css_glob,image) && !anyFileWithWord?(js_glob,image) && !anyFileWithWord?(layouts_glob,image) && !anyFileWithWord?(templates_glob,image) && !anyFileWithWord?(snippets_glob,image))
147
+ io = Faraday::UploadIO.new(File.open(file), 'application/octet-stream', File.basename(file))
148
+ nimbu.themes(:subdomain => Nimbu::Auth.site).assets(:theme_id => theme).create({:name => "images/#{image}", :file => io})
149
+ print " - images/#{image}"
150
+ print " (ok)\n"
151
+ end
152
+ end
153
+
154
+ if push_css
155
+ if files_only
156
+ css_files = args.select{|file| file.start_with?("stylesheets")}.map{|file| file.gsub("stylesheets/", "")}
157
+ else
158
+ css_files = css_glob.map {|dir| dir.gsub("#{Dir.pwd}/stylesheets/","")}
159
+ end
160
+
161
+ print "\nStylesheets:\n"
162
+ css_files.each do |css|
163
+ file = "#{Dir.pwd}/stylesheets/#{css}"
164
+ next if File.directory?(file) || (!anyFileWithWord?(layouts_glob,css) && !anyFileWithWord?(templates_glob,css) && !anyFileWithWord?(snippets_glob,css))
165
+ io = Faraday::UploadIO.new(File.open(file), 'application/octet-stream', File.basename(file))
166
+ nimbu.themes(:subdomain => Nimbu::Auth.site).assets(:theme_id => theme).create({:name => "stylesheets/#{css}", :file => io})
167
+ print " - stylesheets/#{css}"
168
+ print " (ok)\n"
169
+ end
170
+ end
171
+
172
+ if push_js
173
+ if files_only
174
+ js_files = args.select{|file| file.start_with?("javascripts", "")}.map{|file| file.gsub("javascripts/", "")}
175
+ else
176
+ js_files = js_glob.map {|dir| dir.gsub("#{Dir.pwd}/javascripts/","")}
177
+ end
178
+
179
+ print "\nJavascripts:\n"
180
+ js_files.each do |js|
181
+ file = "#{Dir.pwd}/javascripts/#{js}"
182
+ next if File.directory?(file) || (!anyFileWithWord?(layouts_glob,js) && !anyFileWithWord?(templates_glob,js) && !anyFileWithWord?(snippets_glob,js))
183
+ io = Faraday::UploadIO.new(File.open(file), 'application/octet-stream', File.basename(file))
184
+ nimbu.themes(:subdomain => Nimbu::Auth.site).assets(:theme_id => theme).create({:name => "javascripts/#{js}", :file => io})
185
+ print " - javascripts/#{js}"
186
+ print " (ok)\n"
187
+ end
188
+ end
189
+
190
+ if push_liquid
191
+ if files_only
192
+ layouts_files = args.select{|file| file.start_with?("layouts")}.map{|file| file.gsub("layouts/", "")}
193
+ templates_files = args.select{|file| file.start_with?("templates")}.map{|file| file.gsub("templates/", "")}
194
+ snippets_files = args.select{|file| file.start_with?("snippets")}.map{|file| file.gsub("snippets/", "")}
195
+ else
196
+ layouts_files = layouts_glob.map {|dir| dir.gsub("#{Dir.pwd}/layouts/","")}
197
+ templates_files = templates_glob.map {|dir| dir.gsub("#{Dir.pwd}/templates/","")}
198
+ snippets_files = snippets_glob.map {|dir| dir.gsub("#{Dir.pwd}/snippets/","")}
199
+ end
200
+
201
+ print "\nSnippets:\n"
202
+ snippets_files.each do |snippet|
203
+ file = "#{Dir.pwd}/snippets/#{snippet}"
204
+ next if File.directory?(file)
205
+ print " - snippets/#{snippet}"
206
+ nimbu.themes(:subdomain => Nimbu::Auth.site).snippets(:theme_id => theme).create({:name => snippet, :content => IO.read(file).force_encoding('UTF-8')})
207
+ print " (ok)\n"
208
+ end
113
209
 
114
- if !(css_only || js_only || images_only)
115
210
  print "\nLayouts:\n"
116
211
  layouts_files.each do |layout|
117
212
  file = "#{Dir.pwd}/layouts/#{layout}"
@@ -129,72 +224,8 @@ class Nimbu::Command::Themes < Nimbu::Command::Base
129
224
  nimbu.themes(:subdomain => Nimbu::Auth.site).templates(:theme_id => theme).create({:name => template, :content => IO.read(file).force_encoding('UTF-8')})
130
225
  print " (ok)\n"
131
226
  end
132
-
133
- print "\nSnippets:\n"
134
- snippets_files.each do |snippet|
135
- file = "#{Dir.pwd}/snippets/#{snippet}"
136
- next if File.directory?(file)
137
- print " - snippets/#{snippet}"
138
- nimbu.themes(:subdomain => Nimbu::Auth.site).snippets(:theme_id => theme).create({:name => snippet, :content => IO.read(file).force_encoding('UTF-8')})
139
- print " (ok)\n"
140
- end
141
227
  end
142
228
 
143
- if !liquid_only
144
- css_glob = Dir.glob("#{Dir.pwd}/stylesheets/**/*.css")
145
- css_files = css_glob.map {|dir| dir.gsub("#{Dir.pwd}/stylesheets/","")}
146
- if !(js_only || images_only)
147
- print "\nStylesheet:\n"
148
- css_files.each do |css|
149
- file = "#{Dir.pwd}/stylesheets/#{css}"
150
- next if File.directory?(file) || (!anyFileWithWord?(layouts_glob,css) && !anyFileWithWord?(templates_glob,css) && !anyFileWithWord?(snippets_glob,css))
151
- io = Faraday::UploadIO.new(File.open(file), 'application/octet-stream', File.basename(file))
152
- nimbu.themes(:subdomain => Nimbu::Auth.site).assets(:theme_id => theme).create({:name => "stylesheets/#{css}", :file => io})
153
- print " - stylesheets/#{css}"
154
- print " (ok)\n"
155
- end
156
- end
157
-
158
- js_glob = Dir.glob("#{Dir.pwd}/javascripts/**/*.js")
159
- js_files = js_glob.map {|dir| dir.gsub("#{Dir.pwd}/javascripts/","")}
160
- if !(css_only || images_only)
161
- print "\nJavascripts:\n"
162
- js_files.each do |js|
163
- file = "#{Dir.pwd}/javascripts/#{js}"
164
- next if File.directory?(file) || (!anyFileWithWord?(layouts_glob,js) && !anyFileWithWord?(templates_glob,js) && !anyFileWithWord?(snippets_glob,js))
165
- io = Faraday::UploadIO.new(File.open(file), 'application/octet-stream', File.basename(file))
166
- nimbu.themes(:subdomain => Nimbu::Auth.site).assets(:theme_id => theme).create({:name => "javascripts/#{js}", :file => io})
167
- print " - javascripts/#{js}"
168
- print " (ok)\n"
169
- end
170
- end
171
-
172
- image_files = Dir.glob("#{Dir.pwd}/images/**/*").map {|dir| dir.gsub("#{Dir.pwd}/images/","")}
173
- if !(css_only || js_only)
174
- print "\nImages:\n"
175
- image_files.each do |image|
176
- file = "#{Dir.pwd}/images/#{image}"
177
- next if File.directory?(file) || (!anyFileWithWord?(css_glob,image) && !anyFileWithWord?(js_glob,image) && !anyFileWithWord?(layouts_glob,image) && !anyFileWithWord?(templates_glob,image) && !anyFileWithWord?(snippets_glob,image))
178
- io = Faraday::UploadIO.new(File.open(file), 'application/octet-stream', File.basename(file))
179
- nimbu.themes(:subdomain => Nimbu::Auth.site).assets(:theme_id => theme).create({:name => "images/#{image}", :file => io})
180
- print " - images/#{image}"
181
- print " (ok)\n"
182
- end
183
- end
184
-
185
- font_files = Dir.glob("#{Dir.pwd}/fonts/**/*").map {|dir| dir.gsub("#{Dir.pwd}/fonts/","")} rescue []
186
- if !(css_only || js_only)
187
- print "\nFonts:\n"
188
- font_files.each do |font|
189
- file = "#{Dir.pwd}/fonts/#{font}"
190
- next if File.directory?(file) || (!anyFileWithWord?(css_glob,font) && !anyFileWithWord?(js_glob,font) && !anyFileWithWord?(layouts_glob,font) && !anyFileWithWord?(templates_glob,font) && !anyFileWithWord?(snippets_glob,font))
191
- io = Faraday::UploadIO.new(File.open(file), 'application/octet-stream', File.basename(file))
192
- nimbu.themes(:subdomain => Nimbu::Auth.site).assets(:theme_id => theme).create({:name => "fonts/#{font}", :file => io})
193
- print " - fonts/#{font}"
194
- print " (ok)\n"
195
- end
196
- end
197
- end
198
229
  end
199
230
 
200
231
  private
@@ -242,4 +273,25 @@ class Nimbu::Command::Themes < Nimbu::Command::Base
242
273
  end
243
274
  end
244
275
  end
276
+
277
+ def layouts_glob
278
+ @layouts_glob ||= Dir.glob("#{Dir.pwd}/layouts/**/*.liquid")
279
+ end
280
+
281
+ def templates_glob
282
+ @templates_glob ||= Dir.glob("#{Dir.pwd}/templates/**/*.liquid")
283
+ end
284
+
285
+ def snippets_glob
286
+ @snippets_glob ||= Dir.glob("#{Dir.pwd}/snippets/**/*.liquid")
287
+ end
288
+
289
+ def css_glob
290
+ @css_glob ||= Dir.glob("#{Dir.pwd}/stylesheets/**/*.css")
291
+ end
292
+
293
+ def js_glob
294
+ @js_glob ||= Dir.glob("#{Dir.pwd}/javascripts/**/*.js")
295
+ end
296
+
245
297
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Nimbu
3
- VERSION = "0.7.9"
3
+ VERSION = "0.8.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nimbu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.9
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zenjoy BVBA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-12 00:00:00.000000000 Z
11
+ date: 2016-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor