rails2_asset_pipeline 0.1.20 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -4,3 +4,4 @@ gemspec
4
4
  gem 'rake'
5
5
  gem 'json'
6
6
  gem 'rspec', '~>2'
7
+ gem 'bump'
@@ -1,17 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails2_asset_pipeline (0.1.20)
4
+ rails2_asset_pipeline (0.2.0)
5
5
  sprockets
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
+ bump (0.3.9)
10
11
  diff-lcs (1.1.3)
11
12
  hike (1.2.1)
12
13
  json (1.7.3)
13
- multi_json (1.3.6)
14
- rack (1.4.1)
14
+ multi_json (1.5.0)
15
+ rack (1.4.3)
15
16
  rake (0.9.2)
16
17
  rspec (2.6.0)
17
18
  rspec-core (~> 2.6.0)
@@ -32,6 +33,7 @@ PLATFORMS
32
33
  ruby
33
34
 
34
35
  DEPENDENCIES
36
+ bump
35
37
  json
36
38
  rails2_asset_pipeline!
37
39
  rake
data/Rakefile CHANGED
@@ -1,22 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
+ require 'bump/tasks'
2
3
 
3
4
  task :default do
4
5
  sh "rspec spec/"
5
6
  end
6
-
7
- # extracted from https://github.com/grosser/project_template
8
- rule /^version:bump:.*/ do |t|
9
- sh "git status | grep 'nothing to commit'" # ensure we are not dirty
10
- index = ['major', 'minor','patch'].index(t.name.split(':').last)
11
- file = 'lib/rails2_asset_pipeline/version.rb'
12
-
13
- version_file = File.read(file)
14
- old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
15
- version_parts[index] = version_parts[index].to_i + 1
16
- version_parts[2] = 0 if index < 2 # remove patch for minor
17
- version_parts[1] = 0 if index < 1 # remove minor for major
18
- new_version = version_parts * '.'
19
- File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }
20
-
21
- sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
22
- end
data/Readme.md CHANGED
@@ -37,6 +37,16 @@ Just a path: <%= asset_path "application.js" %>
37
37
  # config/environment.rb
38
38
  config.gem "rails2_asset_pipeline"
39
39
 
40
+ # Gemfile (if you have one)
41
+ gem "rails2_asset_pipeline"
42
+
43
+ group :development do
44
+ gem "coffee-script", :require => false # need coffee ?
45
+ gem "sass", :require => false # need sass ?
46
+ gem "sprockets-sass", :require => false
47
+ end
48
+
49
+
40
50
  ### Initializer
41
51
  Here you can do configuration of sprockets.
42
52
  - loaded in `rake assets:precompile` **without** the rails environment (to enable compiling/deploying without development environment)
@@ -46,8 +56,9 @@ Here you can do configuration of sprockets.
46
56
  ```Ruby
47
57
  # config/initializers/rails2_asset_pipeline.rb
48
58
  if Rails.env.development? # dynamic asset compilation needs these
59
+ require 'coffee-script' # need coffee ?
49
60
  require 'sprockets/sass' # need sass ?
50
- autoload :Sass, 'sass' # require if used inside rake tasks <-> require 'sass' takes 0.8s
61
+ autoload :Sass, 'sass' # autoload when used via rake assets:precompile
51
62
  require 'sprockets/source_url' # sprockets-source_url for debugable assets in chrome
52
63
  end
53
64
 
@@ -60,6 +71,18 @@ require 'rails2_asset_pipeline/view_helpers'
60
71
  Rails2AssetPipeline::ViewHelpers.ignored_folders = ["images"]
61
72
  ```
62
73
 
74
+ Optional: remove unnecessary Sass middleware + monkey-patches
75
+
76
+ ```Ruby
77
+ # config/environment.rb
78
+ ...
79
+
80
+ module Sass; RAILS_LOADED = true; end # prevent sass middleware + monkeypatches -> all handled by rails2_asset_pipeline (verify via: rake middleware | grep Sass)
81
+
82
+ Rails::Initializer.run do
83
+ ...
84
+ ```
85
+
63
86
  ### Tasks
64
87
 
65
88
  # Rakefile
@@ -77,7 +100,7 @@ Setup a config.ru so development has dynamic assets
77
100
  # we need to protect against multiple includes of the Rails environment (trust me)
78
101
  require './config/environment' if !defined?(Rails) || !Rails.initialized?
79
102
 
80
- instance_exec(&Rails2AssetPipeline.config_ru)
103
+ Rails2AssetPipeline.config_ru(self)
81
104
 
82
105
  map '/' do
83
106
  use Rails::Rack::LogTailer unless Rails.env.test?
@@ -102,6 +125,7 @@ You can also use `Rails2AssetPipeline::ViewHelpers.asset_path("application.js")`
102
125
 
103
126
  ### Fast tests
104
127
  To not compile assets during testing you can overwrite the manifest.
128
+
105
129
  ```Ruby
106
130
  # spec/fixtures/empty_manifest.json
107
131
  {"assets": {}, "files": {}}
@@ -110,6 +134,18 @@ To not compile assets during testing you can overwrite the manifest.
110
134
  Rails2AssetPipeline.manifest = Rails.root.join("spec/fixtures/empty_manifest.json")
111
135
  ```
112
136
 
137
+ ### Images vs CSS
138
+
139
+ /* application.css */
140
+ .image_via_sass_url{
141
+ background: url('ok.gif');
142
+ }
143
+
144
+ /* application.css.erb ... not recommended but possible ... */
145
+ .image_with_erb{
146
+ background-image:url(<%= asset_data_uri 'ok.gif' %>);
147
+ }
148
+
113
149
  ### Sass
114
150
  - add `sass` to your gems for sass parsing
115
151
  - add `sprockets-sass` to your gems for sass @import support
@@ -117,11 +153,17 @@ Rails2AssetPipeline.manifest = Rails.root.join("spec/fixtures/empty_manifest.jso
117
153
 
118
154
  # Todo
119
155
  - read config from Rails 3 style config.assets
120
- - asset image helpers for inside css/scss
121
156
  - make output location configurable in .setup and use it for manifest location and rake tasks
122
157
 
158
+
159
+
160
+
123
161
  Author
124
162
  ======
163
+
164
+ ### [Contributors](https://github.com/grosser/rails2_asset_pipeline/contributors)
165
+ - [Michael Peteuil](https://github.com/mpeteuil)
166
+
125
167
  [Michael Grosser](http://grosser.it)<br/>
126
168
  michael@grosser.it<br/>
127
169
  License: MIT<br/>
@@ -22,11 +22,12 @@ module Rails2AssetPipeline
22
22
  @env
23
23
  end
24
24
 
25
- def self.config_ru
26
- lambda do
27
- unless STATIC_ENVIRONMENTS.include?(Rails.env)
28
- Rails2AssetPipeline.dynamic_assets_available = true
29
- map '/assets' do
25
+ def self.config_ru(rack)
26
+ unless STATIC_ENVIRONMENTS.include?(Rails.env)
27
+ Rails2AssetPipeline.dynamic_assets_available = true
28
+
29
+ rack.instance_eval do
30
+ map "/assets" do
30
31
  run Rails2AssetPipeline.env
31
32
  end
32
33
  end
@@ -1,3 +1,3 @@
1
1
  module Rails2AssetPipeline
2
- VERSION = '0.1.20'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -41,14 +41,16 @@ describe Rails2AssetPipeline do
41
41
 
42
42
  it "sets up a route for development" do
43
43
  Rails.env = "development"
44
- instance_exec(&Rails2AssetPipeline.config_ru)
44
+ result = Rails2AssetPipeline.config_ru(self)
45
45
  @mapped.should == ["/assets"]
46
+ (!!result).should == true
46
47
  end
47
48
 
48
49
  it "does not set up a route for production" do
49
50
  Rails.env = "production"
50
- instance_exec(&Rails2AssetPipeline.config_ru)
51
+ result = Rails2AssetPipeline.config_ru(self)
51
52
  @mapped.should == nil
53
+ (!!result).should == false
52
54
  end
53
55
  end
54
56
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails2_asset_pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-05 00:00:00.000000000 Z
12
+ date: 2013-01-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets
@@ -67,7 +67,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
67
67
  version: '0'
68
68
  segments:
69
69
  - 0
70
- hash: -3628641569286209555
70
+ hash: 3234184968952417120
71
71
  required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  version: '0'
77
77
  segments:
78
78
  - 0
79
- hash: -3628641569286209555
79
+ hash: 3234184968952417120
80
80
  requirements: []
81
81
  rubyforge_project:
82
82
  rubygems_version: 1.8.24