ymdp 0.2.6 → 0.3.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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.6
1
+ 0.3.0
@@ -36,10 +36,14 @@ module YMDP
36
36
  @domain_config = CONFIG
37
37
  end
38
38
 
39
+ @domain_config["validate"]["embedded_js"]["build"] = false if @domain_config["external_assets"]["javascripts"]
40
+ @domain_config["validate"]["embedded_js"]["deploy"] = false if @domain_config["external_assets"]["javascripts"]
41
+
39
42
  YMDP::Base.configure do |config|
40
43
  config.verbose = @domain_config["verbose"]
41
44
  config.compress = @domain_config["compress"]
42
45
  config.validate = @domain_config["validate"]
46
+ config.external_assets = @domain_config["external_assets"]
43
47
  end
44
48
  end
45
49
 
@@ -135,6 +139,7 @@ module YMDP
135
139
  FileUtils.rm_rf(Dir.glob("#{dir}/assets/yrb/*"))
136
140
  FileUtils.rm_rf(Dir.glob("#{TMP_PATH}/*"))
137
141
  FileUtils.mkdir_p(TMP_PATH)
142
+ FileUtils.mkdir_p("#{dir}/assets/stylesheets/")
138
143
  end
139
144
 
140
145
  # Format text in a standard way for output to the screen.
@@ -65,6 +65,8 @@ module YMDP
65
65
  #
66
66
  attr_accessor :jslint_settings
67
67
 
68
+ attr_accessor :external_assets
69
+
68
70
  def initialize #:nodoc:
69
71
  @paths = {}
70
72
  @content_variables = {}
@@ -3,7 +3,7 @@ require 'epic'
3
3
 
4
4
  begin
5
5
  CATEGORIES = YAML.load_file("./config/categories.yml")["categories"] unless defined?(CATEGORIES)
6
- rescue
6
+ rescue StandardError => e
7
7
  CATEGORIES = {} unless defined?(CATEGORIES)
8
8
  end
9
9
 
@@ -14,7 +14,8 @@ def set_application_variables(application)
14
14
  @application_id = SERVERS[@application]["application_id"]
15
15
  @assets_id = SERVERS[@application]["assets_id"]
16
16
  @dir = @application
17
- rescue
17
+ rescue StandardError => e
18
+ $stdout.puts "Rescued error: #{e.message}"
18
19
  end
19
20
 
20
21
  def create_from_servers
@@ -336,6 +337,9 @@ namespace :sync do
336
337
  desc "Syncs javascript assets to the #{key} server"
337
338
  task :javascripts => [set_task, :set_javascripts, :set_sync, :deploy]
338
339
 
340
+ desc "Syncs stylesheet assets to the #{key} server"
341
+ task :stylesheets => [set_task, :set_stylesheets, :set_sync, :deploy]
342
+
339
343
  desc "Syncs image assets to the #{key} server"
340
344
  task :images => [set_task, :set_images, :set_sync, :deploy]
341
345
 
@@ -180,8 +180,8 @@ module YMDP
180
180
  end
181
181
 
182
182
  output << render_html_partial(params)
183
- output << render_javascript_partial(params)
184
- output << render_stylesheet_partial(params)
183
+ output << render_javascript_partial(params) if params[:javascript]
184
+ output << render_stylesheet_partial(params) if params[:stylesheet]
185
185
 
186
186
  output.flatten.join("\n")
187
187
  end
@@ -247,18 +247,48 @@ module YMDP
247
247
  end
248
248
 
249
249
  def render_javascript_partial(params)
250
+ filename = params[:filename] || params[:javascript].to_a.join("_")
251
+
252
+ if configuration.external_assets["javascripts"]
253
+ tags = false
254
+ else
255
+ tags = params[:tags]
256
+ end
257
+
250
258
  output = []
251
259
  # Render a JavaScript partial.
252
260
  #
253
261
  if params[:javascript]
254
262
  content = render_javascripts(params[:javascript].to_a, params[:filename])
255
263
  unless content.blank?
256
- output << "<script type='text/javascript'>" if params[:tags]
264
+ output << "<script type='text/javascript'>" if tags
257
265
  output << content
258
- output << "</script>" if params[:tags]
266
+ output << "</script>" if tags
259
267
  end
260
268
  end
261
269
  output
270
+
271
+ if configuration.external_assets["javascripts"] && params[:tags]
272
+ write_javascript_asset(output, filename)
273
+
274
+ "<script type='text/javascript' src='#{assets_directory}/javascripts/#{filename}.js'></script>"
275
+ else
276
+ output
277
+ end
278
+ end
279
+
280
+ def write_javascript_asset(output, filename)
281
+ path = "#{server_path}/assets/javascripts/#{filename}.js"
282
+ File.open(path, "w") do |f|
283
+ f.write(output)
284
+ end
285
+ end
286
+
287
+ def write_stylesheet_asset(output, filename)
288
+ path = "#{server_path}/assets/stylesheets/#{filename}.css"
289
+ File.open(path, "w") do |f|
290
+ f.write(output)
291
+ end
262
292
  end
263
293
 
264
294
  # Renders a JavaScript partial.
@@ -292,16 +322,25 @@ module YMDP
292
322
  # Render a CSS partial.
293
323
  #
294
324
  def render_stylesheet_partial(params)
325
+ filename = params[:filename] || params[:stylesheet].to_a.join("_")
326
+ external_asset = params[:tags] && configuration.external_assets["javascripts"]
295
327
  output = []
296
328
  if params[:stylesheet]
297
329
  content = render_stylesheets(params[:stylesheet].to_a, params[:filename])
298
330
  unless content.blank?
299
- output << "<style type='text/css'>" if params[:tags]
331
+ output << "<style type='text/css'>" unless external_asset
300
332
  output << content
301
- output << "</style>" if params[:tags]
333
+ output << "</style>" unless external_asset
302
334
  end
303
335
  end
304
- output
336
+
337
+ if external_asset
338
+ write_stylesheet_asset(output, filename)
339
+
340
+ "<link rel='stylesheet' type='text/css' href='#{assets_directory}/stylesheets/#{filename}.css'></link>"
341
+ else
342
+ output
343
+ end
305
344
  end
306
345
 
307
346
  # Renders a JavaScript partial.
data/ymdp.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ymdp}
8
- s.version = "0.2.6"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Coleman"]
12
- s.date = %q{2011-02-23}
12
+ s.date = %q{2011-03-11}
13
13
  s.description = %q{Framework for developing applications in the Yahoo! Mail Development Platform.}
14
14
  s.email = %q{progressions@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ymdp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 6
10
- version: 0.2.6
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeff Coleman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-23 00:00:00 -06:00
18
+ date: 2011-03-11 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency