rapper 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +1 -0
- data/README.markdown +35 -52
- data/Rakefile +2 -11
- data/VERSION +1 -1
- data/lib/rapper.rb +2 -1
- data/lib/rapper/definition.rb +8 -46
- data/lib/tasks.rb +35 -0
- data/rapper.gemspec +7 -21
- data/spec/fixtures/config/asset_definitions/base/javascripts.yml +11 -11
- data/spec/fixtures/config/asset_definitions/base/stylesheets.yml +11 -11
- data/spec/fixtures/test_cases/compression/definitions/css.yml +12 -12
- data/spec/fixtures/test_cases/compression/definitions/js.yml +12 -12
- data/spec/fixtures/test_cases/concatenation/definitions/css.yml +12 -12
- data/spec/fixtures/test_cases/concatenation/definitions/js.yml +12 -12
- data/spec/rapper_spec.rb +21 -21
- data/spec/spec_helper.rb +1 -2
- metadata +12 -91
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.markdown
CHANGED
@@ -45,61 +45,32 @@ Rapper is configured using a YAML file that defines the settings to be used in v
|
|
45
45
|
|
46
46
|
The only required setting is `definition_root`. (Of course, you'll still need definition files to define the asset packages that you want build. More on that below.)
|
47
47
|
|
48
|
-
The minimum settings needed for a configuration file is:
|
49
|
-
|
50
|
-
base:
|
51
|
-
definition_root: config/assets
|
52
|
-
|
53
|
-
The following defaults are applied if not defined in your configuration:
|
54
|
-
|
55
|
-
bundle: true
|
56
|
-
compress: true
|
57
|
-
tag_style: html5
|
58
|
-
version: true
|
59
|
-
closure_compiler:
|
60
|
-
compilation_level: SIMPLE_OPTIMIZATIONS
|
61
|
-
|
62
48
|
## Rapper definitions
|
63
49
|
|
64
|
-
The `definition_root` setting in the rapper config is a path to a folder containing more YAML files that define the various types of bundles you want to build (eg. `stylesheets.yml`, `javascripts.yml`)
|
50
|
+
The `definition_root` setting in the rapper config is a path to a folder containing more YAML files that define the various types of bundles you want to build (eg. `stylesheets.yml`, `javascripts.yml`). For example, JavaScripts:
|
65
51
|
|
66
|
-
---
|
52
|
+
--- !omap
|
67
53
|
- root: public/javascripts
|
68
54
|
- tag_root: /javascripts
|
69
55
|
- suffix: js
|
70
|
-
- assets:
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
-
|
76
|
-
|
77
|
-
|
56
|
+
- assets: !omap
|
57
|
+
- base: !omap
|
58
|
+
- files:
|
59
|
+
- mootools
|
60
|
+
- version: 7b06
|
61
|
+
- stats: !omap
|
62
|
+
- files:
|
63
|
+
- protovis
|
64
|
+
- ext_js_full
|
65
|
+
- version: db62
|
78
66
|
|
79
|
-
The above definition will create two asset files: `public/assets/
|
67
|
+
The above definition will create two asset files: `public/javascripts/assets/base.js` and `public/javascripts/assets/stats.js` from the component files in `public/javascripts` (in this case: `public/javascripts/protovis.js` and `public/javascripts/ext_js_full.js`).
|
80
68
|
|
81
|
-
**Note:** Definition files are YAML ordered mapping documents. This is so that version updates (which involves rapper updating the version numbers and writing out the updated definition as YAML) don't change the order of the file. This is especially useful when using git and
|
69
|
+
**Note:** Definition files are YAML ordered mapping documents. This is so that version updates (which involves rapper updating the version numbers and writing out the updated definition as YAML) don't change the order of the file. This is especially useful when using git and merging branches because it prevents nasty merge conflicts.
|
82
70
|
|
83
71
|
## Versioning
|
84
72
|
|
85
|
-
|
86
|
-
|
87
|
-
---
|
88
|
-
- root: public/javascripts
|
89
|
-
- tag_root: /javascripts
|
90
|
-
- suffix: js
|
91
|
-
- assets:
|
92
|
-
- base:
|
93
|
-
- files:
|
94
|
-
- mootools
|
95
|
-
- version: 7b06
|
96
|
-
- stats:
|
97
|
-
- files:
|
98
|
-
- protovis
|
99
|
-
- ext_js_full
|
100
|
-
- version: db62
|
101
|
-
|
102
|
-
Version strings are short hashes of the pre-compression asset file. This means that they will only change when the contents of the component files for an asset change and time-consuming compression will only happen when a bundle needs to be re-packaged.
|
73
|
+
Version strings are short hashes of the before-compression asset file. This means that they will only change when the contents of the component files for an asset change and time-consuming compression will only happen when a bundle needs to be re-packaged.
|
103
74
|
|
104
75
|
Version strings are also used to enforce good browser caching habits, especially when you have a far-future expires header configured on your web server. For example, suppose you had the following asset:
|
105
76
|
|
@@ -111,6 +82,21 @@ When the contents of the asset change, the version will change in the query stri
|
|
111
82
|
|
112
83
|
Browsers will automatically re-download and cache the new asset.
|
113
84
|
|
85
|
+
# Rake tasks
|
86
|
+
|
87
|
+
Rapper includes Rake tasks for packaging assets. Set this up in your `Rakefile`:
|
88
|
+
|
89
|
+
Rapper::Tasks.new do |config|
|
90
|
+
config[:path] = "config/assets.yml"
|
91
|
+
config[:env] = "production"
|
92
|
+
end
|
93
|
+
|
94
|
+
Default namespace is `rapper`. The namespace can be changed as the first param:
|
95
|
+
|
96
|
+
Rapper::Tasks.new :assets do ...
|
97
|
+
|
98
|
+
Both config options are required.
|
99
|
+
|
114
100
|
# Development
|
115
101
|
|
116
102
|
Rapper's got a Gemfile. You know what to do.
|
@@ -118,20 +104,17 @@ Rapper's got a Gemfile. You know what to do.
|
|
118
104
|
bundle install --path vendor
|
119
105
|
bundle exec rake spec
|
120
106
|
|
121
|
-
##
|
122
|
-
|
123
|
-
* Merb view helpers
|
124
|
-
* Sinatra helpers
|
125
|
-
|
126
|
-
## To do later
|
107
|
+
## Wishlist
|
127
108
|
|
128
|
-
* Per-asset configuration overrides
|
129
|
-
* Rails helpers
|
130
109
|
* Watch for CoffeeScript changes and automatically compile
|
131
110
|
* Watch for Sass changes and automatically compile
|
111
|
+
* Per-asset configuration overrides
|
112
|
+
* Sinatra helpers
|
113
|
+
* Rails helpers
|
132
114
|
|
133
115
|
## Version history
|
134
116
|
|
117
|
+
* **0.1.0** - View helpers.
|
135
118
|
* **0.0.3** - New `Definition` object to make working with definitions significantly easier, don't re-package assets that don't need re-packaging.
|
136
119
|
* **0.0.2** - Compression now works and is specced.
|
137
120
|
* **0.0.1** - Initial release. Functioning bundler, minus the view helpers.
|
data/Rakefile
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler'
|
3
|
+
|
3
4
|
begin
|
4
5
|
Bundler.setup(:default, :development)
|
5
6
|
rescue Bundler::BundlerError => e
|
@@ -15,19 +16,9 @@ Jeweler::Tasks.new do |gem|
|
|
15
16
|
gem.homepage = "http://tysontate.github.com/rapper/"
|
16
17
|
gem.license = "MIT"
|
17
18
|
gem.summary = %Q{Static asset packager and compressor with versioning and built-in view helpers.}
|
18
|
-
gem.description = %Q{Static asset packager and compressor with versioning and built-in view helpers.
|
19
|
+
gem.description = %Q{Static asset packager and compressor with versioning and built-in view helpers. Compresses files only when they need compressing.}
|
19
20
|
gem.email = "tyson@tysontate.com"
|
20
21
|
gem.authors = ["Tyson Tate"]
|
21
|
-
|
22
|
-
# Runtime dependencies
|
23
|
-
gem.add_runtime_dependency "closure-compiler", "~> 1.0.0"
|
24
|
-
|
25
|
-
# Development dependencies
|
26
|
-
gem.add_development_dependency "rspec", "~> 1.3.1"
|
27
|
-
gem.add_development_dependency "yard", "~> 0.6.4"
|
28
|
-
gem.add_development_dependency "bluecloth", "~> 2.0.10"
|
29
|
-
gem.add_development_dependency "bundler", "~> 1.0.0"
|
30
|
-
gem.add_development_dependency "jeweler", "~> 1.5.2"
|
31
22
|
end
|
32
23
|
Jeweler::RubygemsDotOrgTasks.new
|
33
24
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/rapper.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
|
3
|
-
Dir[File.expand_path( File.dirname( __FILE__ )
|
3
|
+
Dir[File.expand_path( "#{File.dirname( __FILE__ )}/rapper/*.rb" )].each do |file|
|
4
4
|
require file
|
5
5
|
end
|
6
|
+
require File.dirname( __FILE__ ) + "/tasks.rb"
|
6
7
|
|
7
8
|
# No batteries included, and no strings attached /
|
8
9
|
# No holds barred, no time for move fakin' /
|
data/lib/rapper/definition.rb
CHANGED
@@ -17,44 +17,35 @@ module Rapper
|
|
17
17
|
|
18
18
|
# @return [String] The root for asset component files.
|
19
19
|
def root
|
20
|
-
|
20
|
+
@definition["root"]
|
21
21
|
end
|
22
22
|
|
23
23
|
def destination_root
|
24
|
-
|
24
|
+
@definition["root"].gsub( /\/$/, '' ) + "/assets"
|
25
25
|
end
|
26
26
|
|
27
27
|
# @return [String] The public url root for the asset component files (used
|
28
28
|
# when bundling is off).
|
29
29
|
def component_tag_root
|
30
|
-
|
30
|
+
@definition["tag_root"]
|
31
31
|
end
|
32
32
|
|
33
33
|
# @return [String] The public url root for packaged asset files.
|
34
34
|
def asset_tag_root
|
35
|
-
|
35
|
+
@definition["tag_root"].gsub( /\/$/, '' ) + "/assets"
|
36
36
|
end
|
37
37
|
|
38
38
|
# @return [String] The suffix of files used in this definition.
|
39
39
|
def suffix
|
40
|
-
|
40
|
+
@definition["suffix"]
|
41
41
|
end
|
42
42
|
|
43
43
|
# ==========
|
44
44
|
# = Assets =
|
45
45
|
# ==========
|
46
46
|
|
47
|
-
# @return [Hash] Simplified structure representing all asset definitions.
|
48
47
|
def assets
|
49
|
-
assets
|
50
|
-
|
51
|
-
definition_value( "assets" ).each do |spec|
|
52
|
-
assets[spec.keys.first] = spec.values.first.inject({}) do |memo, item|
|
53
|
-
memo.merge( item )
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
assets
|
48
|
+
@definition["assets"]
|
58
49
|
end
|
59
50
|
|
60
51
|
# Update the version string for a specific asset.
|
@@ -63,27 +54,11 @@ module Rapper
|
|
63
54
|
#
|
64
55
|
# @param [String] version New version string for the asset.
|
65
56
|
def set_version( name, version )
|
66
|
-
name =
|
67
|
-
definition_value( "assets" ).each do |spec|
|
68
|
-
next unless spec[name]
|
69
|
-
spec[name].each do |setting|
|
70
|
-
next unless setting["version"]
|
71
|
-
setting["version"] = version
|
72
|
-
end
|
73
|
-
end
|
57
|
+
@definition["assets"][name.to_s]["version"] = version
|
74
58
|
end
|
75
59
|
|
76
60
|
def get_version( name )
|
77
|
-
name
|
78
|
-
definition_value( "assets" ).each do |spec|
|
79
|
-
next unless spec[name]
|
80
|
-
spec[name].each do |setting|
|
81
|
-
next unless setting["version"]
|
82
|
-
return setting["version"]
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
false
|
61
|
+
@definition["assets"][name.to_s]["version"]
|
87
62
|
end
|
88
63
|
|
89
64
|
# ==========
|
@@ -128,18 +103,5 @@ module Rapper
|
|
128
103
|
File.join( root, file_name )
|
129
104
|
end
|
130
105
|
end
|
131
|
-
|
132
|
-
private
|
133
|
-
|
134
|
-
# @param [Object] key Key to search for.
|
135
|
-
#
|
136
|
-
# @param [Array<Hash>] array Array of Hash object to search in.
|
137
|
-
#
|
138
|
-
# @return [Object,nil] The first value found for the key or nil of nothing
|
139
|
-
# was found.
|
140
|
-
def definition_value( key )
|
141
|
-
hash = @definition.find { |h| h.keys.include? key }
|
142
|
-
hash ? hash[key] : ""
|
143
|
-
end
|
144
106
|
end
|
145
107
|
end
|
data/lib/tasks.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Rapper
|
2
|
+
|
3
|
+
# Rake tasks for building / refreshing packages
|
4
|
+
class Tasks
|
5
|
+
|
6
|
+
def initialize( namespace = :rapper, &block )
|
7
|
+
@namespace = namespace
|
8
|
+
@config = {}
|
9
|
+
yield @config
|
10
|
+
@config[:env] ||= :production
|
11
|
+
@rapper = Rapper::Engine.new( @config[:path], @config[:env] )
|
12
|
+
define
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def define
|
18
|
+
namespace @namespace do
|
19
|
+
desc "Package all assets that need re-packaging"
|
20
|
+
task :package do
|
21
|
+
@rapper.package
|
22
|
+
end
|
23
|
+
|
24
|
+
namespace :package do
|
25
|
+
@rapper.definitions.each do |type, definition|
|
26
|
+
desc "Package all #{type} assets that need re-packaging"
|
27
|
+
task key do
|
28
|
+
@rapper.package( type )
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/rapper.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rapper}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Tyson Tate"]
|
12
|
-
s.date = %q{2011-03-
|
13
|
-
s.description = %q{Static asset packager and compressor with versioning and built-in view helpers.
|
12
|
+
s.date = %q{2011-03-23}
|
13
|
+
s.description = %q{Static asset packager and compressor with versioning and built-in view helpers. Compresses files only when they need compressing.}
|
14
14
|
s.email = %q{tyson@tysontate.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
"lib/rapper/logging.rb",
|
36
36
|
"lib/rapper/utils.rb",
|
37
37
|
"lib/rapper/versioning.rb",
|
38
|
+
"lib/tasks.rb",
|
38
39
|
"lib/yui/css_compressor.rb",
|
39
40
|
"rapper.gemspec",
|
40
41
|
"spec/fixtures/config/asset_definitions/base/javascripts.yml",
|
@@ -137,12 +138,7 @@ Gem::Specification.new do |s|
|
|
137
138
|
s.add_development_dependency(%q<bluecloth>, ["~> 2.0.10"])
|
138
139
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
139
140
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
140
|
-
s.
|
141
|
-
s.add_development_dependency(%q<rspec>, ["~> 1.3.1"])
|
142
|
-
s.add_development_dependency(%q<yard>, ["~> 0.6.4"])
|
143
|
-
s.add_development_dependency(%q<bluecloth>, ["~> 2.0.10"])
|
144
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
145
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
141
|
+
s.add_development_dependency(%q<rake>, ["~> 0.8.7"])
|
146
142
|
else
|
147
143
|
s.add_dependency(%q<closure-compiler>, ["~> 1.0.0"])
|
148
144
|
s.add_dependency(%q<rspec>, ["~> 1.3.1"])
|
@@ -150,12 +146,7 @@ Gem::Specification.new do |s|
|
|
150
146
|
s.add_dependency(%q<bluecloth>, ["~> 2.0.10"])
|
151
147
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
152
148
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
153
|
-
s.add_dependency(%q<
|
154
|
-
s.add_dependency(%q<rspec>, ["~> 1.3.1"])
|
155
|
-
s.add_dependency(%q<yard>, ["~> 0.6.4"])
|
156
|
-
s.add_dependency(%q<bluecloth>, ["~> 2.0.10"])
|
157
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
158
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
149
|
+
s.add_dependency(%q<rake>, ["~> 0.8.7"])
|
159
150
|
end
|
160
151
|
else
|
161
152
|
s.add_dependency(%q<closure-compiler>, ["~> 1.0.0"])
|
@@ -164,12 +155,7 @@ Gem::Specification.new do |s|
|
|
164
155
|
s.add_dependency(%q<bluecloth>, ["~> 2.0.10"])
|
165
156
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
166
157
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
167
|
-
s.add_dependency(%q<
|
168
|
-
s.add_dependency(%q<rspec>, ["~> 1.3.1"])
|
169
|
-
s.add_dependency(%q<yard>, ["~> 0.6.4"])
|
170
|
-
s.add_dependency(%q<bluecloth>, ["~> 2.0.10"])
|
171
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
172
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
158
|
+
s.add_dependency(%q<rake>, ["~> 0.8.7"])
|
173
159
|
end
|
174
160
|
end
|
175
161
|
|
@@ -1,14 +1,14 @@
|
|
1
|
-
---
|
1
|
+
--- !omap
|
2
2
|
- root: spec/fixtures/javascripts
|
3
3
|
- tag_root: /javascripts
|
4
4
|
- suffix: js
|
5
|
-
- assets:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
- assets: !omap
|
6
|
+
- single_file: !omap
|
7
|
+
- files:
|
8
|
+
- simple_1
|
9
|
+
- version: 98bc
|
10
|
+
- multiple_files: !omap
|
11
|
+
- files:
|
12
|
+
- simple_1
|
13
|
+
- simple_2
|
14
|
+
- version: f3d9
|
@@ -1,14 +1,14 @@
|
|
1
|
-
---
|
1
|
+
--- !omap
|
2
2
|
- root: spec/fixtures/stylesheets
|
3
3
|
- tag_root: /stylesheets
|
4
4
|
- suffix: css
|
5
|
-
- assets:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
- assets: !omap
|
6
|
+
- single_file: !omap
|
7
|
+
- files:
|
8
|
+
- simple_1
|
9
|
+
- version: 1e17
|
10
|
+
- multiple_files: !omap
|
11
|
+
- files:
|
12
|
+
- simple_1
|
13
|
+
- simple_2
|
14
|
+
- version: 683e
|
@@ -1,15 +1,15 @@
|
|
1
|
-
---
|
1
|
+
--- !omap
|
2
2
|
- root: spec/fixtures/stylesheets
|
3
3
|
- tag_root: /stylesheets
|
4
4
|
- suffix: css
|
5
|
-
- assets:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
- assets: !omap
|
6
|
+
- base: !omap
|
7
|
+
- files:
|
8
|
+
- simple_1
|
9
|
+
- simple_2
|
10
|
+
- version: 683e
|
11
|
+
- base_reversed: !omap
|
12
|
+
- files:
|
13
|
+
- simple_2
|
14
|
+
- simple_1
|
15
|
+
- version: 4a04
|
@@ -1,15 +1,15 @@
|
|
1
|
-
---
|
1
|
+
--- !omap
|
2
2
|
- root: spec/fixtures/javascripts
|
3
3
|
- tag_root: /javascripts
|
4
4
|
- suffix: js
|
5
|
-
- assets:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
- assets: !omap
|
6
|
+
- base: !omap
|
7
|
+
- files:
|
8
|
+
- simple_1
|
9
|
+
- simple_2
|
10
|
+
- version: 683e
|
11
|
+
- base_reversed: !omap
|
12
|
+
- files:
|
13
|
+
- simple_2
|
14
|
+
- simple_1
|
15
|
+
- version: 4a04
|
@@ -1,15 +1,15 @@
|
|
1
|
-
---
|
1
|
+
--- !omap
|
2
2
|
- root: spec/fixtures/stylesheets
|
3
3
|
- tag_root: /stylesheets
|
4
4
|
- suffix: css
|
5
|
-
- assets:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
- assets: !omap
|
6
|
+
- base: !omap
|
7
|
+
- files:
|
8
|
+
- simple_1
|
9
|
+
- simple_2
|
10
|
+
- version: 683e
|
11
|
+
- base_reversed: !omap
|
12
|
+
- files:
|
13
|
+
- simple_2
|
14
|
+
- simple_1
|
15
|
+
- version: 4a04
|
@@ -1,15 +1,15 @@
|
|
1
|
-
---
|
1
|
+
--- !omap
|
2
2
|
- root: spec/fixtures/javascripts
|
3
3
|
- tag_root: /javascripts
|
4
4
|
- suffix: js
|
5
|
-
- assets:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
- assets: !omap
|
6
|
+
- base: !omap
|
7
|
+
- files:
|
8
|
+
- simple_1
|
9
|
+
- simple_2
|
10
|
+
- version: f3d9
|
11
|
+
- base_reversed: !omap
|
12
|
+
- files:
|
13
|
+
- simple_2
|
14
|
+
- simple_1
|
15
|
+
- version: fcfe
|
data/spec/rapper_spec.rb
CHANGED
@@ -55,16 +55,17 @@ describe Rapper do
|
|
55
55
|
rapper.definitions["javascripts"].component_tag_root.should == "/javascripts"
|
56
56
|
rapper.definitions["javascripts"].asset_tag_root.should == "/javascripts/assets"
|
57
57
|
rapper.definitions["javascripts"].suffix.should == "js"
|
58
|
-
rapper.definitions["javascripts"].assets.should
|
59
|
-
|
60
|
-
|
61
|
-
"
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
"
|
66
|
-
|
67
|
-
|
58
|
+
rapper.definitions["javascripts"].assets.should be_a( YAML::Omap )
|
59
|
+
rapper.definitions["javascripts"].assets.should == [
|
60
|
+
["single_file", [
|
61
|
+
["files", ["simple_1"]],
|
62
|
+
["version", "98bc"]]
|
63
|
+
],
|
64
|
+
["multiple_files", [
|
65
|
+
["files", ["simple_1", "simple_2"]],
|
66
|
+
["version", "f3d9"]]
|
67
|
+
]
|
68
|
+
]
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
@@ -107,19 +108,18 @@ describe Rapper do
|
|
107
108
|
it "uses the concatenated file to calculate versions" do
|
108
109
|
rapper = Rapper::Engine.new( "spec/fixtures/config/assets.yml", "test" )
|
109
110
|
rapper.send( :refresh_versions )
|
110
|
-
rapper.definitions["javascripts"].assets["single_file"].should ==
|
111
|
-
"files"
|
112
|
-
"version"
|
113
|
-
|
114
|
-
rapper.definitions["javascripts"].assets["multiple_files"].should ==
|
115
|
-
"files"
|
116
|
-
"version"
|
117
|
-
|
111
|
+
rapper.definitions["javascripts"].assets["single_file"].should == [
|
112
|
+
["files", ["simple_1"]],
|
113
|
+
["version", "98bc"]
|
114
|
+
]
|
115
|
+
rapper.definitions["javascripts"].assets["multiple_files"].should == [
|
116
|
+
["files", ["simple_1", "simple_2"]],
|
117
|
+
["version", "f3d9"]
|
118
|
+
]
|
118
119
|
end
|
119
120
|
|
120
121
|
it "doesn't re-package assets that don't need re-packaging" do
|
121
122
|
rapper = Rapper::Engine.new( "spec/fixtures/config/assets.yml", "test" )
|
122
|
-
rapper.stub!( :update_definitions ).and_return( nil ) # Block definition updating
|
123
123
|
rapper.package
|
124
124
|
|
125
125
|
rapper.should_not_receive( :compress )
|
@@ -211,8 +211,8 @@ describe Rapper do
|
|
211
211
|
|
212
212
|
it "adds a version number if versioning is on" do
|
213
213
|
Rapper::Engine.new( "spec/fixtures/config/assets.yml", "versions" )
|
214
|
-
@controller.rapper_stylesheets_tag( :single_file ).should == "<link rel=\"stylesheet\" href=\"/stylesheets/assets/single_file.css?v=
|
215
|
-
@controller.rapper_javascripts_tag( :single_file ).should == "<script src=\"/javascripts/assets/single_file.js?v=
|
214
|
+
@controller.rapper_stylesheets_tag( :single_file ).should == "<link rel=\"stylesheet\" href=\"/stylesheets/assets/single_file.css?v=1e17\">"
|
215
|
+
@controller.rapper_javascripts_tag( :single_file ).should == "<script src=\"/javascripts/assets/single_file.js?v=98bc\"></script>"
|
216
216
|
end
|
217
217
|
end
|
218
218
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,7 +5,6 @@ require 'rapper'
|
|
5
5
|
require 'fileutils'
|
6
6
|
|
7
7
|
Spec::Runner.configure do |config|
|
8
|
-
|
9
8
|
# Tear down test case assets folders
|
10
9
|
config.after :each do
|
11
10
|
FileUtils.rm_r( Dir[ "tmp/*" ] )
|
@@ -50,4 +49,4 @@ module Kernel
|
|
50
49
|
yield
|
51
50
|
$stdout = STDOUT
|
52
51
|
end
|
53
|
-
end
|
52
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tyson Tate
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-23 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -116,101 +116,21 @@ dependencies:
|
|
116
116
|
requirement: *id006
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
prerelease: false
|
119
|
-
name:
|
120
|
-
type: :
|
119
|
+
name: rake
|
120
|
+
type: :development
|
121
121
|
version_requirements: &id007 !ruby/object:Gem::Requirement
|
122
122
|
none: false
|
123
123
|
requirements:
|
124
124
|
- - ~>
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
hash:
|
126
|
+
hash: 49
|
127
127
|
segments:
|
128
|
-
- 1
|
129
|
-
- 0
|
130
128
|
- 0
|
131
|
-
|
129
|
+
- 8
|
130
|
+
- 7
|
131
|
+
version: 0.8.7
|
132
132
|
requirement: *id007
|
133
|
-
-
|
134
|
-
prerelease: false
|
135
|
-
name: rspec
|
136
|
-
type: :development
|
137
|
-
version_requirements: &id008 !ruby/object:Gem::Requirement
|
138
|
-
none: false
|
139
|
-
requirements:
|
140
|
-
- - ~>
|
141
|
-
- !ruby/object:Gem::Version
|
142
|
-
hash: 25
|
143
|
-
segments:
|
144
|
-
- 1
|
145
|
-
- 3
|
146
|
-
- 1
|
147
|
-
version: 1.3.1
|
148
|
-
requirement: *id008
|
149
|
-
- !ruby/object:Gem::Dependency
|
150
|
-
prerelease: false
|
151
|
-
name: yard
|
152
|
-
type: :development
|
153
|
-
version_requirements: &id009 !ruby/object:Gem::Requirement
|
154
|
-
none: false
|
155
|
-
requirements:
|
156
|
-
- - ~>
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
hash: 15
|
159
|
-
segments:
|
160
|
-
- 0
|
161
|
-
- 6
|
162
|
-
- 4
|
163
|
-
version: 0.6.4
|
164
|
-
requirement: *id009
|
165
|
-
- !ruby/object:Gem::Dependency
|
166
|
-
prerelease: false
|
167
|
-
name: bluecloth
|
168
|
-
type: :development
|
169
|
-
version_requirements: &id010 !ruby/object:Gem::Requirement
|
170
|
-
none: false
|
171
|
-
requirements:
|
172
|
-
- - ~>
|
173
|
-
- !ruby/object:Gem::Version
|
174
|
-
hash: 27
|
175
|
-
segments:
|
176
|
-
- 2
|
177
|
-
- 0
|
178
|
-
- 10
|
179
|
-
version: 2.0.10
|
180
|
-
requirement: *id010
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
prerelease: false
|
183
|
-
name: bundler
|
184
|
-
type: :development
|
185
|
-
version_requirements: &id011 !ruby/object:Gem::Requirement
|
186
|
-
none: false
|
187
|
-
requirements:
|
188
|
-
- - ~>
|
189
|
-
- !ruby/object:Gem::Version
|
190
|
-
hash: 23
|
191
|
-
segments:
|
192
|
-
- 1
|
193
|
-
- 0
|
194
|
-
- 0
|
195
|
-
version: 1.0.0
|
196
|
-
requirement: *id011
|
197
|
-
- !ruby/object:Gem::Dependency
|
198
|
-
prerelease: false
|
199
|
-
name: jeweler
|
200
|
-
type: :development
|
201
|
-
version_requirements: &id012 !ruby/object:Gem::Requirement
|
202
|
-
none: false
|
203
|
-
requirements:
|
204
|
-
- - ~>
|
205
|
-
- !ruby/object:Gem::Version
|
206
|
-
hash: 7
|
207
|
-
segments:
|
208
|
-
- 1
|
209
|
-
- 5
|
210
|
-
- 2
|
211
|
-
version: 1.5.2
|
212
|
-
requirement: *id012
|
213
|
-
description: Static asset packager and compressor with versioning and built-in view helpers. Easy to configure, easy to use, and easy to ignore when you want to. No crazy JavaScript comment DSLs, either.
|
133
|
+
description: Static asset packager and compressor with versioning and built-in view helpers. Compresses files only when they need compressing.
|
214
134
|
email: tyson@tysontate.com
|
215
135
|
executables: []
|
216
136
|
|
@@ -238,6 +158,7 @@ files:
|
|
238
158
|
- lib/rapper/logging.rb
|
239
159
|
- lib/rapper/utils.rb
|
240
160
|
- lib/rapper/versioning.rb
|
161
|
+
- lib/tasks.rb
|
241
162
|
- lib/yui/css_compressor.rb
|
242
163
|
- rapper.gemspec
|
243
164
|
- spec/fixtures/config/asset_definitions/base/javascripts.yml
|