pubba 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -14,6 +14,6 @@ coverage
14
14
  pkg
15
15
 
16
16
  test/sinatra/app/assets/out
17
- test/sinatra/app/assets/javascripts/*.js
18
- test/sinatra/app/assets/stylesheets/*.css
17
+ test/sinatra/app/assets/js/*.js
18
+ test/sinatra/app/assets/css/*.css
19
19
  test/sinatra/public
data/CHANGES CHANGED
@@ -1,5 +1,17 @@
1
1
  master
2
2
 
3
+
4
+ 0.6.0
5
+
6
+ * 0.5.0 broken process; not pointing to new out directory
7
+ * Consistency with directory names javascripts -> js, stylesheets -> css
8
+ * Update to Statica 0.2.0
9
+ * Don't restrict asset sources to *.js and *.css to allow for pipelining
10
+
11
+ 0.5.0
12
+
13
+ * Move output files to {asset_dir}/out/{type}
14
+
3
15
  0.4.2
4
16
  * Use Rack::StaticaServer
5
17
 
data/README.md CHANGED
@@ -10,9 +10,6 @@ __I do not consider this project production ready at this time. It will be soon
10
10
 
11
11
  TODO:
12
12
 
13
- * Add cache bursting functionality
14
- * Remove requirement for placing of scripts/styles in subdirectories. For instance, the convention now is scripts would be in subdirs like javascripts/custom and javscripts/third-party. The only scripts/styles in the root dir are those generated by this extension.
15
- * Compress the combined assets
16
13
  * More tests!
17
14
  * Improve documentation!
18
15
 
@@ -27,7 +24,7 @@ Any process that involves changing code between environments, even in an automat
27
24
  As mentioned, code organization is another focus of pubba. The config file __pubba.yml__ uses the global section to clearly state which assets should be on all pages. This functionality is not restricted to your local assets. The pubba config file also allows you to declare external assets. In short, you should not have a single script tag in your views other than those generated by the `page_head_tags` and `page_body_tags` helpers provided by pubba.
28
25
 
29
26
 
30
- In addition, when using R18n, pubba gives you access through a single page object.
27
+ In addition, when using R18n, pubba gives you access through a single page object. This allows you to have all your static text in a central location.
31
28
 
32
29
 
33
30
  # Settings
@@ -122,7 +119,20 @@ Next up is creating the all important __pubba.yml__ config file:
122
119
  - "custom/lightbox"
123
120
 
124
121
 
125
- The config file is referencing the javascripts and stylesheets located in the `asset_folder`.
122
+ The config file is referencing the javascripts and stylesheets located in the `asset_folder`. The default folder structure for assets:
123
+
124
+ # Javascript assets
125
+ {asset_folder}/js/
126
+
127
+ # Stylesheet assets
128
+ {asset_folder}/css/
129
+
130
+ # After processing javascripts will be placed in:
131
+ {public_folder}/js/
132
+
133
+ # After processing stylesheets will be placed in:
134
+ {public_folder}/css/
135
+
126
136
 
127
137
  Now you obviouslly need some helpers to make use of the definitions in __pubba.yml__, and here they are:
128
138
 
@@ -147,16 +157,16 @@ What you'll see when working with pubba is that the files in your `asset_folder`
147
157
  Using the above __pubba.yml__ configuration, if you are using the 'home' page definition, the output of `page_head_tags` will be (formatted for the README):
148
158
 
149
159
  <link href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css" rel="stylesheet" type="text/css"></link>
150
- <link href="/stylesheets/home-all.css" rel="stylesheet" type="text/css"></link>
151
- <link href="/stylesheets/home-phone.css" media="only screen and (max-width: 480px)" rel="stylesheet" type="text/css"></link>
152
- <link href="/stylesheets/home-desktop.css" media="only screen and (min-width: 480px)" rel="stylesheet" type="text/css"></link>
160
+ <link href="/css/home-all.css" rel="stylesheet" type="text/css"></link>
161
+ <link href="/css/home-phone.css" media="only screen and (max-width: 480px)" rel="stylesheet" type="text/css"></link>
162
+ <link href="/css/home-desktop.css" media="only screen and (min-width: 480px)" rel="stylesheet" type="text/css"></link>
153
163
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
154
- <script src="/javascripts/home-head.js" type="text/javascript"></script>|
164
+ <script src="/js/home-head.js" type="text/javascript"></script>|
155
165
 
156
166
  Again, using the above __pubba.yml__ configuration, if you are using the 'home' page definition, the output of `page_body_tags` will be (formatted for the README):
157
167
 
158
168
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>
159
- <script src="/javascripts/home-body.js" type="text/javascript"></script>
169
+ <script src="/js/home-body.js" type="text/javascript"></script>
160
170
 
161
171
  # R18n
162
172
 
@@ -20,8 +20,10 @@ module Sinatra
20
20
  @sprockets ||= Sprockets::Environment.new()
21
21
  end
22
22
 
23
- def self.process(source, pattern, destination)
24
- Dir.glob("#{source}/#{pattern}") do |file|
23
+ def self.process(source, destination)
24
+ FileUtils.mkdir_p destination
25
+
26
+ Dir.glob("#{source}/*") do |file|
25
27
  asset = find(file)
26
28
  asset.save_as "#{destination}/#{File.basename(file)}"
27
29
  end
@@ -112,14 +112,14 @@ module Sinatra
112
112
  def add_style_tag(group, hash, url)
113
113
  h = { tag: 'link', type: 'text/css', rel: 'stylesheet' }
114
114
  h[:media] = hash['media'] if hash['media']
115
- h[:href] = url.start_with?("http") ? url : "/stylesheets/#{name}-#{group}.css"
115
+ h[:href] = url.start_with?("http") ? url : "/#{Site.style_folder}/#{name}-#{group}.css"
116
116
 
117
117
  maybe_add_tag(@head_tags, h, :href)
118
118
  end
119
119
 
120
120
  def add_script_tag(group, url)
121
121
  h = { tag: 'script', type: "text/javascript" }
122
- h[:src] = url.start_with?("http") ? url : "/javascripts/#{name}-#{group}.js"
122
+ h[:src] = url.start_with?("http") ? url : "/#{Site.script_folder}/#{name}-#{group}.js"
123
123
 
124
124
  tag_set = (group == "head") ? @head_tags : @body_tags
125
125
  maybe_add_tag(tag_set, h, :src)
@@ -53,11 +53,14 @@ module Sinatra
53
53
  def process
54
54
  pages.each{|name, p| p.assetize }
55
55
 
56
+ asset_script_folder = File.join(asset_folder, 'out', script_folder)
57
+ asset_style_folder = File.join(asset_folder, 'out', style_folder)
58
+
56
59
  public_script_folder = File.join(public_folder, script_folder)
57
60
  public_style_folder = File.join(public_folder, style_folder)
58
61
 
59
- asset_handler.process(asset_folder, "*.js", public_script_folder)
60
- asset_handler.process(asset_folder, "*.css", public_style_folder)
62
+ asset_handler.process(asset_script_folder, public_script_folder)
63
+ asset_handler.process(asset_style_folder, public_style_folder)
61
64
 
62
65
  asset_minifier.minify(public_script_folder, :js)
63
66
  asset_minifier.minify(public_style_folder, :css)
@@ -82,8 +85,8 @@ module Sinatra
82
85
  def set_folder_defaults(settings)
83
86
  @public_folder = settings.public_folder
84
87
  @asset_folder = settings.asset_folder
85
- @script_folder = 'javascripts'
86
- @style_folder = 'stylesheets'
88
+ @script_folder = 'js'
89
+ @style_folder = 'css'
87
90
 
88
91
  Statica.root_dir = settings.public_folder
89
92
  end
@@ -1,5 +1,5 @@
1
1
  module Pubba
2
2
  # Pubba version string
3
3
  # @api public
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_runtime_dependency('r18n-desktop', ['~> 0.4.13'])
24
24
  s.add_runtime_dependency('yui-compressor', ['>= 0.9.4'])
25
25
  s.add_runtime_dependency('fssm', ['>= 0.2.7'])
26
- s.add_runtime_dependency('statica', ['>= 0.1.0'])
26
+ s.add_runtime_dependency('statica', ['>= 0.2.0'])
27
27
 
28
28
  s.add_development_dependency('rake', ['>= 0.9.2'])
29
29
  s.add_development_dependency('sinatra', ['>= 1.3.1'])
@@ -6,7 +6,7 @@ class TestPubbaHTMLHelper < TestPubba
6
6
 
7
7
  def test_home_page_head_tags
8
8
  res = get('/home-page-head-tags').body
9
- reg = Regexp.new '<link href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css" rel="stylesheet" type="text/css"></link><link href="/stylesheets/home-all.css/\w+" rel="stylesheet" type="text/css"></link><link href="/stylesheets/home-phone.css/\w+" media="only screen and \(max-width: 480px\)" rel="stylesheet" type="text/css"></link><link href="/stylesheets/home-desktop.css/\w+" media="only screen and \(min-width: 480px\)" rel="stylesheet" type="text/css"></link><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script><script src="/javascripts/home-head.js/\w+" type="text/javascript"></script>'
9
+ reg = Regexp.new '<link href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css" rel="stylesheet" type="text/css"></link><link href="/css/home-all.css/\w+" rel="stylesheet" type="text/css"></link><link href="/css/home-phone.css/\w+" media="only screen and \(max-width: 480px\)" rel="stylesheet" type="text/css"></link><link href="/css/home-desktop.css/\w+" media="only screen and \(min-width: 480px\)" rel="stylesheet" type="text/css"></link><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script><script src="/js/home-head.js/\w+" type="text/javascript"></script>'
10
10
 
11
11
 
12
12
  assert_match reg, res
@@ -14,7 +14,7 @@ class TestPubbaHTMLHelper < TestPubba
14
14
 
15
15
  def test_home_page_body_tags
16
16
  res = get('/home-page-body-tags').body
17
- reg = Regexp.new '<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script><script src="/javascripts/home-body.js/\w+" type="text/javascript"></script>'
17
+ reg = Regexp.new '<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script><script src="/js/home-body.js/\w+" type="text/javascript"></script>'
18
18
 
19
19
  assert_match reg, res
20
20
  end
@@ -16,7 +16,7 @@ class TestPubbaPage < TestPubba
16
16
  end
17
17
 
18
18
  def test_home_all_css_asset
19
- css = File.open( File.join(R.asset_folder, 'stylesheets', 'home-all.css')){|f| f.read }
19
+ css = File.open( File.join(R.asset_folder, 'out', 'css', 'home-all.css')){|f| f.read }
20
20
  contents = <<TEXT
21
21
  // This file is automatically generated from the contents
22
22
  // in #{Sinatra::Pubba::Site.asset_configuration.name}
@@ -29,7 +29,7 @@ TEXT
29
29
  end
30
30
 
31
31
  def test_home_phone_css_asset
32
- css = File.open( File.join(R.asset_folder, 'stylesheets', 'home-phone.css')){|f| f.read }
32
+ css = File.open( File.join(R.asset_folder, 'out', 'css', 'home-phone.css')){|f| f.read }
33
33
  contents = <<TEXT
34
34
  // This file is automatically generated from the contents
35
35
  // in #{Sinatra::Pubba::Site.asset_configuration.name}
@@ -41,7 +41,7 @@ TEXT
41
41
  end
42
42
 
43
43
  def test_home_desktop_css_asset
44
- css = File.open( File.join(R.asset_folder, 'stylesheets', 'home-desktop.css')){|f| f.read }
44
+ css = File.open( File.join(R.asset_folder, 'out', 'css', 'home-desktop.css')){|f| f.read }
45
45
  contents = <<TEXT
46
46
  // This file is automatically generated from the contents
47
47
  // in #{Sinatra::Pubba::Site.asset_configuration.name}
@@ -53,7 +53,7 @@ TEXT
53
53
  end
54
54
 
55
55
  def test_search_all_css_asset
56
- css = File.open( File.join(R.asset_folder, 'stylesheets', 'search-all.css')){|f| f.read }
56
+ css = File.open( File.join(R.asset_folder, 'out', 'css', 'search-all.css')){|f| f.read }
57
57
  contents = <<TEXT
58
58
  // This file is automatically generated from the contents
59
59
  // in #{Sinatra::Pubba::Site.asset_configuration.name}
@@ -67,7 +67,7 @@ TEXT
67
67
  end
68
68
 
69
69
  def test_search_phone_css_asset
70
- css = File.open( File.join(R.asset_folder, 'stylesheets', 'search-phone.css')){|f| f.read }
70
+ css = File.open( File.join(R.asset_folder, 'out', 'css', 'search-phone.css')){|f| f.read }
71
71
  contents = <<TEXT
72
72
  // This file is automatically generated from the contents
73
73
  // in #{Sinatra::Pubba::Site.asset_configuration.name}
@@ -79,7 +79,7 @@ TEXT
79
79
  end
80
80
 
81
81
  def test_search_desktop_css_asset
82
- css = File.open( File.join(R.asset_folder, 'stylesheets', 'search-desktop.css')){|f| f.read }
82
+ css = File.open( File.join(R.asset_folder, 'out', 'css', 'search-desktop.css')){|f| f.read }
83
83
  contents = <<TEXT
84
84
  // This file is automatically generated from the contents
85
85
  // in #{Sinatra::Pubba::Site.asset_configuration.name}
@@ -91,7 +91,7 @@ TEXT
91
91
  end
92
92
 
93
93
  def test_home_head_js_asset
94
- js = File.open( File.join(R.asset_folder, 'javascripts', 'home-head.js')){|f| f.read }
94
+ js = File.open( File.join(R.asset_folder, 'out', 'js', 'home-head.js')){|f| f.read }
95
95
  contents = <<TEXT
96
96
  // This file is automatically generated from the contents
97
97
  // in #{Sinatra::Pubba::Site.asset_configuration.name}
@@ -103,7 +103,7 @@ TEXT
103
103
  end
104
104
 
105
105
  def test_home_body_js_asset
106
- js = File.open( File.join(R.asset_folder, 'javascripts', 'home-body.js')){|f| f.read }
106
+ js = File.open( File.join(R.asset_folder, 'out', 'js', 'home-body.js')){|f| f.read }
107
107
  contents = <<TEXT
108
108
  // This file is automatically generated from the contents
109
109
  // in #{Sinatra::Pubba::Site.asset_configuration.name}
@@ -117,7 +117,7 @@ TEXT
117
117
  end
118
118
 
119
119
  def test_search_head_js_asset
120
- js = File.open( File.join(R.asset_folder, 'javascripts', 'search-head.js')){|f| f.read }
120
+ js = File.open( File.join(R.asset_folder, 'out', 'js', 'search-head.js')){|f| f.read }
121
121
  contents = <<TEXT
122
122
  // This file is automatically generated from the contents
123
123
  // in #{Sinatra::Pubba::Site.asset_configuration.name}
@@ -129,7 +129,7 @@ TEXT
129
129
  end
130
130
 
131
131
  def test_search_body_js_asset
132
- js = File.open( File.join(R.asset_folder, 'javascripts', 'search-body.js')){|f| f.read }
132
+ js = File.open( File.join(R.asset_folder, 'out', 'js', 'search-body.js')){|f| f.read }
133
133
  contents = <<TEXT
134
134
  // This file is automatically generated from the contents
135
135
  // in #{Sinatra::Pubba::Site.asset_configuration.name}
@@ -18,10 +18,10 @@ class TestPubbaSite < TestPubba
18
18
  end
19
19
 
20
20
  def test_script_folder_initialization
21
- assert_equal "javascripts", Sinatra::Pubba::Site.script_folder
21
+ assert_equal "js", Sinatra::Pubba::Site.script_folder
22
22
  end
23
23
 
24
24
  def test_style_folder_initialization
25
- assert_equal "stylesheets", Sinatra::Pubba::Site.style_folder
25
+ assert_equal "css", Sinatra::Pubba::Site.style_folder
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
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-12-21 00:00:00.000000000 Z
12
+ date: 2011-12-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets
16
- requirement: &2151797060 !ruby/object:Gem::Requirement
16
+ requirement: &2151888640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.1.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2151797060
24
+ version_requirements: *2151888640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: r18n-desktop
27
- requirement: &2151812720 !ruby/object:Gem::Requirement
27
+ requirement: &2151887220 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.4.13
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2151812720
35
+ version_requirements: *2151887220
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: yui-compressor
38
- requirement: &2151812000 !ruby/object:Gem::Requirement
38
+ requirement: &2151902720 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.9.4
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2151812000
46
+ version_requirements: *2151902720
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: fssm
49
- requirement: &2151811180 !ruby/object:Gem::Requirement
49
+ requirement: &2151901700 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,21 +54,21 @@ dependencies:
54
54
  version: 0.2.7
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2151811180
57
+ version_requirements: *2151901700
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: statica
60
- requirement: &2151810620 !ruby/object:Gem::Requirement
60
+ requirement: &2151900860 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
64
64
  - !ruby/object:Gem::Version
65
- version: 0.1.0
65
+ version: 0.2.0
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2151810620
68
+ version_requirements: *2151900860
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
- requirement: &2151810000 !ruby/object:Gem::Requirement
71
+ requirement: &2151900020 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.9.2
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2151810000
79
+ version_requirements: *2151900020
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: sinatra
82
- requirement: &2151809500 !ruby/object:Gem::Requirement
82
+ requirement: &2151899180 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 1.3.1
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2151809500
90
+ version_requirements: *2151899180
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: sinatra-contrib
93
- requirement: &2151808940 !ruby/object:Gem::Requirement
93
+ requirement: &2151898320 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 1.3.1
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2151808940
101
+ version_requirements: *2151898320
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: yard
104
- requirement: &2151808040 !ruby/object:Gem::Requirement
104
+ requirement: &2151897500 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *2151808040
112
+ version_requirements: *2151897500
113
113
  description:
114
114
  email:
115
115
  - andy@stonean.com
@@ -145,21 +145,19 @@ files:
145
145
  - test/pubba/html/test_helpers.rb
146
146
  - test/pubba/test_page.rb
147
147
  - test/pubba/test_site.rb
148
- - test/sinatra/app/assets/javascripts/custom/app.js
149
- - test/sinatra/app/assets/javascripts/custom/lightbox.js
150
- - test/sinatra/app/assets/javascripts/custom/tracker.js
151
- - test/sinatra/app/assets/javascripts/third-party/backbone.js
152
- - test/sinatra/app/assets/javascripts/third-party/modernizr.js
153
- - test/sinatra/app/assets/stylesheets/custom/global.css
154
- - test/sinatra/app/assets/stylesheets/custom/home.css
155
- - test/sinatra/app/assets/stylesheets/custom/large.css
156
- - test/sinatra/app/assets/stylesheets/custom/search.css
157
- - test/sinatra/app/assets/stylesheets/custom/small.css
158
- - test/sinatra/app/assets/stylesheets/third-party/widget.css
148
+ - test/sinatra/app/assets/css/custom/global.css
149
+ - test/sinatra/app/assets/css/custom/home.css
150
+ - test/sinatra/app/assets/css/custom/large.css
151
+ - test/sinatra/app/assets/css/custom/search.css
152
+ - test/sinatra/app/assets/css/custom/small.css
153
+ - test/sinatra/app/assets/css/third-party/widget.css
154
+ - test/sinatra/app/assets/js/custom/app.js
155
+ - test/sinatra/app/assets/js/custom/lightbox.js
156
+ - test/sinatra/app/assets/js/custom/tracker.js
157
+ - test/sinatra/app/assets/js/third-party/backbone.js
158
+ - test/sinatra/app/assets/js/third-party/modernizr.js
159
159
  - test/sinatra/app/i18n/en.yml
160
160
  - test/sinatra/config/pubba.yml
161
- - test/sinatra/public/javascripts/_
162
- - test/sinatra/public/stylesheets/_
163
161
  homepage: http://github.com/stonean/pubba
164
162
  licenses: []
165
163
  post_install_message: