zfben_libjs 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
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', 'railtie.rb'].each { |f| require File.join(File.dirname(__FILE__), 'zfben_libjs', f) }
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) }
21
21
 
22
22
  def err msg
23
23
  STDERR.print "#{msg}\n".color(:red)
@@ -0,0 +1,39 @@
1
+ module Zfben_libjs::Helpers
2
+ Lib_version = Time.now.strftime('?%s')
3
+ def lib *opts
4
+ html = ''
5
+ unless opts.blank?
6
+ preload = []
7
+ lib_preload = []
8
+ opts.each do |name|
9
+ name = name.to_s
10
+ if name.end_with?('.css') || name.end_with?('.js')
11
+ preload.push name
12
+ else
13
+ lib_preload.push name
14
+ end
15
+ end
16
+ if preload.length > 0
17
+ preload.each do |url|
18
+ if url.end_with?('.css')
19
+ html << lib_css(url)
20
+ else
21
+ html << lib_js(url)
22
+ end
23
+ end
24
+ end
25
+ if lib_preload.length > 0
26
+ html << lib_js('lib.js') << "<script>lib('#{lib_preload.join(' ')}')</script>"
27
+ end
28
+ end
29
+ return html
30
+ end
31
+
32
+ def lib_js url
33
+ return "<script src='/javascripts/#{url}#{Lib_version}'></script>"
34
+ end
35
+
36
+ def lib_css url
37
+ return "<link rel='stylesheet' href='/stylesheets/#{url}#{Lib_version}' />"
38
+ end
39
+ end
@@ -1,42 +1,8 @@
1
1
  if defined?(Rails)
2
- Lib_version = Time.now.strftime('?%s')
3
- module Rails
4
- module ActionView::Helpers::AssetTagHelper
5
- def lib *opts
6
- html = ''
7
- unless opts.blank?
8
- preload = []
9
- lib_preload = []
10
- opts.each do |name|
11
- name = name.to_s
12
- if name.end_with?('.css') || name.end_with?('.js')
13
- preload.push name
14
- else
15
- lib_preload.push name
16
- end
17
- end
18
- if preload.length > 0
19
- preload.each do |url|
20
- if url.end_with?('.css')
21
- html << lib_css(url)
22
- else
23
- html << lib_js(url)
24
- end
25
- end
26
- end
27
- if lib_preload.length > 0
28
- html << lib_js('lib.js') << "<script>lib('#{lib_preload.join(' ')}')</script>"
29
- end
30
- end
31
- return html
32
- end
33
-
34
- def lib_js url
35
- return "<script src='/javascripts/#{url}#{Lib_version}'></script>"
36
- end
37
-
38
- def lib_css url
39
- return "<link rel='stylesheet' href='/stylesheets/#{url}#{Lib_version}' />"
2
+ module Zfben_libjs
3
+ class Railtie < Rails::Railtie
4
+ initializer 'zfben_libjs.helper' do
5
+ ActionView::Base.send :include, Helpers
40
6
  end
41
7
  end
42
8
  end
@@ -0,0 +1,3 @@
1
+ if defined?(Sinatra)
2
+ helpers Zfben_libjs::Helpers
3
+ end
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.15'
6
+ s.version = '0.0.16'
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.15
4
+ version: 0.0.16
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-03 00:00:00.000000000Z
12
+ date: 2011-09-04 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rainbow
16
- requirement: &24261320 !ruby/object:Gem::Requirement
16
+ requirement: &14422280 !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: *24261320
24
+ version_requirements: *14422280
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &24260860 !ruby/object:Gem::Requirement
27
+ requirement: &14421820 !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: *24260860
35
+ version_requirements: *14421820
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: compass
38
- requirement: &24260440 !ruby/object:Gem::Requirement
38
+ requirement: &14421400 !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: *24260440
46
+ version_requirements: *14421400
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: coffee-script
49
- requirement: &24260020 !ruby/object:Gem::Requirement
49
+ requirement: &14420980 !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: *24260020
57
+ version_requirements: *14420980
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: uglifier
60
- requirement: &24259600 !ruby/object:Gem::Requirement
60
+ requirement: &14420560 !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: *24259600
68
+ version_requirements: *14420560
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: activesupport
71
- requirement: &24259180 !ruby/object:Gem::Requirement
71
+ requirement: &14420140 !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: *24259180
79
+ version_requirements: *14420140
80
80
  description: ''
81
81
  email:
82
82
  - ben@zfben.com
@@ -91,11 +91,13 @@ 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
95
  - lib/zfben_libjs/initialize.rb
95
96
  - lib/zfben_libjs/lib.coffee
96
97
  - lib/zfben_libjs/lib.rb
97
98
  - lib/zfben_libjs/libjs.yml
98
99
  - lib/zfben_libjs/railtie.rb
100
+ - lib/zfben_libjs/sinatra.rb
99
101
  - lib/zfben_libjs/source.rb
100
102
  - lib/zfben_libjs/support_source/coffee.rb
101
103
  - lib/zfben_libjs/support_source/css.rb