zfben_libjs 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -81,3 +81,7 @@ support before and after events
81
81
 
82
82
  <%= lib 'home.js' %>
83
83
  # => <script src="/javascripts/home.js?12345678"></script><script src="/javascripts/lib.js?12345678"></script>
84
+
85
+ == Sinatra
86
+
87
+ helpers Zfben_libjs::Helpers
data/lib/zfben_libjs.rb CHANGED
@@ -17,7 +17,7 @@ module Zfben_libjs
17
17
  end
18
18
  end
19
19
 
20
- ['lib.rb', 'source.rb', 'initialize.rb', 'collection.rb', 'helper.rb', 'railtie.rb', 'sinatra.rb'].each { |f| require File.join(File.dirname(__FILE__), 'zfben_libjs', f) }
20
+ ['lib.rb', 'source.rb', 'initialize.rb', 'collection.rb', 'helpers.rb', 'railtie.rb', 'sinatra.rb'].each { |f| require File.join(File.dirname(__FILE__), 'zfben_libjs', f) }
21
21
 
22
22
  def err msg
23
23
  STDERR.print "#{msg}\n".color(:red)
@@ -65,13 +65,13 @@ class Zfben_libjs::Libjs
65
65
 
66
66
  tip '== [2/2] Generate lib.js =='
67
67
 
68
- libjs = File.read(@libs['lazyload'][0]) << ';'
68
+ libjs = File.read(@libs['lazyload'][0]) << ";\n"
69
69
 
70
70
  libjs_core = File.read(File.join(@path_gem, 'lib.coffee'))
71
71
 
72
72
  libjs_core = CoffeeScript.compile(libjs_core)
73
73
 
74
- libjs << libjs_core << ';'
74
+ libjs << libjs_core << ";\n"
75
75
 
76
76
  @urls = {}
77
77
 
@@ -91,8 +91,8 @@ class Zfben_libjs::Libjs
91
91
  @urls[lib] = path
92
92
  end
93
93
 
94
- libjs << "\n/* libs */\nlib.libs(#{@urls.to_json});lib.loaded('add', 'lazyload');"
95
- libjs << Time.now.strftime('lib.defaults.version = "?%s";')
94
+ libjs << "\n/* libs */\nlib.libs(#{@urls.to_json});lib.loaded('add', 'lazyload');\n"
95
+ libjs << Time.now.strftime("lib.defaults.version = '?%s';\n")
96
96
 
97
97
  if @opts.has_key?(:bundle)
98
98
  bundle = {}
@@ -109,7 +109,7 @@ class Zfben_libjs::Libjs
109
109
  when '.css'
110
110
  css << File.read(file)
111
111
  when '.js'
112
- js << File.read(file) << ';'
112
+ js << File.read(file) << ";\n"
113
113
  end
114
114
  end
115
115
  end
@@ -136,7 +136,7 @@ class Zfben_libjs::Libjs
136
136
  end
137
137
  end
138
138
 
139
- libjs << "\n/* bundle */\nlib.libs(#{bundle.to_json});"
139
+ libjs << "\n/* bundle */\nlib.libs(#{bundle.to_json});\n"
140
140
  end
141
141
 
142
142
  if @opts.has_key?(:routes)
@@ -145,12 +145,12 @@ class Zfben_libjs::Libjs
145
145
  lib_name = lib_name.join ' ' if lib_name.class == Array
146
146
  routes[path] = lib_name
147
147
  end
148
- libjs << "\n/* routes */\nlib.routes('add', #{routes.to_json});"
148
+ libjs << "\n/* routes */\nlib.routes('add', #{routes.to_json});\n"
149
149
  end
150
150
 
151
151
  if @opts.has_key?(:preload)
152
152
  preload = @opts[:preload].class == Array ? @opts[:preload] : [ @opts[:preload] ]
153
- libjs << "\n/* preload */\nlib('#{preload.join(' ')}');"
153
+ libjs << "\n/* preload */\nlib('#{preload.join(' ')}');\n"
154
154
  end
155
155
 
156
156
  libjs = minify(libjs, :js) if @opts[:config]['minify']
@@ -48,7 +48,7 @@ class Zfben_libjs::Collection
48
48
 
49
49
  merge_js = ''
50
50
  @js.each do |js|
51
- merge_js << js.to_js + ';'
51
+ merge_js << js.to_js + ";\n"
52
52
  end
53
53
  if merge_js != ''
54
54
  @js_path = File.join(@options['src/javascripts'], @name + '.js')
@@ -24,6 +24,8 @@ module Zfben_libjs::Helpers
24
24
  end
25
25
  if lib_preload.length > 0
26
26
  html << lib_js('lib.js') << "<script>lib('#{lib_preload.join(' ')}')</script>"
27
+ else
28
+ html << '<script>lib()</script>'
27
29
  end
28
30
  end
29
31
  return html
data/zfben_libjs.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'zfben_libjs'
6
- s.version = '0.0.16'
6
+ s.version = '0.0.17'
7
7
  s.authors = ["Ben"]
8
8
  s.email = ["ben@zfben.com"]
9
9
  s.homepage = "https://github.com/benz303/zfben_libjs"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zfben_libjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-04 00:00:00.000000000Z
12
+ date: 2011-09-13 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rainbow
16
- requirement: &14422280 !ruby/object:Gem::Requirement
16
+ requirement: &8862080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *14422280
24
+ version_requirements: *8862080
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &14421820 !ruby/object:Gem::Requirement
27
+ requirement: &8861480 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *14421820
35
+ version_requirements: *8861480
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: compass
38
- requirement: &14421400 !ruby/object:Gem::Requirement
38
+ requirement: &8860900 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *14421400
46
+ version_requirements: *8860900
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: coffee-script
49
- requirement: &14420980 !ruby/object:Gem::Requirement
49
+ requirement: &8860320 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *14420980
57
+ version_requirements: *8860320
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: uglifier
60
- requirement: &14420560 !ruby/object:Gem::Requirement
60
+ requirement: &8859640 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *14420560
68
+ version_requirements: *8859640
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: activesupport
71
- requirement: &14420140 !ruby/object:Gem::Requirement
71
+ requirement: &8858700 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *14420140
79
+ version_requirements: *8858700
80
80
  description: ''
81
81
  email:
82
82
  - ben@zfben.com
@@ -91,13 +91,12 @@ files:
91
91
  - bin/libjs
92
92
  - lib/zfben_libjs.rb
93
93
  - lib/zfben_libjs/collection.rb
94
- - lib/zfben_libjs/helper.rb
94
+ - lib/zfben_libjs/helpers.rb
95
95
  - lib/zfben_libjs/initialize.rb
96
96
  - lib/zfben_libjs/lib.coffee
97
97
  - lib/zfben_libjs/lib.rb
98
98
  - lib/zfben_libjs/libjs.yml
99
99
  - lib/zfben_libjs/railtie.rb
100
- - lib/zfben_libjs/sinatra.rb
101
100
  - lib/zfben_libjs/source.rb
102
101
  - lib/zfben_libjs/support_source/coffee.rb
103
102
  - lib/zfben_libjs/support_source/css.rb
@@ -150,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
149
  version: '0'
151
150
  requirements: []
152
151
  rubyforge_project:
153
- rubygems_version: 1.8.6
152
+ rubygems_version: 1.8.10
154
153
  signing_key:
155
154
  specification_version: 3
156
155
  summary: ''
@@ -1,3 +0,0 @@
1
- if defined?(Sinatra)
2
- helpers Zfben_libjs::Helpers
3
- end