sinatra_asset_packager 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,12 +1,14 @@
1
- # Sinatra::AssetPackager
1
+ # SinatraAssetPackager
2
2
 
3
3
  Opinionated asset packaging for Sinatra done well.
4
4
 
5
+ Uses Sprockets, Uglifier, and YUI Compressor under the hood.
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
8
10
 
9
- gem 'sinatra-assetpackager'
11
+ gem 'sinatra_asset_packager'
10
12
 
11
13
  And then execute:
12
14
 
@@ -14,11 +16,24 @@ And then execute:
14
16
 
15
17
  Or install it yourself as:
16
18
 
17
- $ gem install sinatra-assetpackager
19
+ $ gem install sinatra_asset_packager
20
+
21
+ Then in your Sinatra app's config.ru place the following:
22
+
23
+ use SinatraAssetPackager::Routes
24
+
25
+ Recommendation: Go a step further and only run the live asset packager on development. To do so, do the following:
26
+
27
+ use SinatraAssetPackager::Routes if ENV['RACK_ENV'] == "development"
28
+ use Rack::Static, :urls => ['/favicon.ico', '/assets'], :root => 'public'
29
+
30
+ Now Rack::Static will pick the static files up at /assets in production mode.
31
+
32
+ You also get the following task with it.
18
33
 
19
- ## Usage
34
+ $ rake assets:precompile
20
35
 
21
- TODO: Write usage instructions here
36
+ If you are using heroku this will precompile your assets on deploy.
22
37
 
23
38
  ## Contributing
24
39
 
@@ -0,0 +1,28 @@
1
+ namespace :assets do
2
+ desc "Precompile assets"
3
+ task :precompile do
4
+ assets = SinatraAssetPackager.environment(true)
5
+ dir = 'public/assets'
6
+ FileUtils.rm_rf(dir, secure: true)
7
+
8
+ CSS_EXTENSIONS = [".less", ".scss", ".sass", ".css"]
9
+ JS_EXTENSIONS = [".js", ".coffee"]
10
+
11
+ (CSS_EXTENSIONS + JS_EXTENSIONS).each do |extension|
12
+ files = Dir.glob("app/assets/**/**#{extension}")
13
+ files.each do |full_filepath|
14
+ regex_path = /app\/assets\/javascripts\/|app\/assets\/stylesheets\//
15
+ input_path = full_filepath.gsub(regex_path, '')
16
+
17
+ replacement_extension = '.js'
18
+ replacement_extension = '.css' if CSS_EXTENSIONS.include?(extension)
19
+ output_path = input_path.gsub(extension, replacement_extension)
20
+
21
+ puts output_path
22
+ assets[input_path].write_to("public/assets/#{output_path}")
23
+ end
24
+ end
25
+
26
+ FileUtils.cp_r(Dir['app/assets/images/*'], 'public/assets')
27
+ end
28
+ end
@@ -1,5 +1,5 @@
1
1
  module SinatraAssetPackager
2
- class Routes < Sinatra::Base
2
+ class Routes < ::Sinatra::Base
3
3
  get "/assets/*.js" do
4
4
  content_type("application/javascript")
5
5
  filepath = params[:splat][0]
@@ -1,3 +1,3 @@
1
1
  module SinatraAssetPackager
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,8 +1,11 @@
1
+ require "rake"
1
2
  require "sprockets"
2
3
  require "uglifier"
3
4
  require "yui/compressor"
5
+ require "sinatra/base"
4
6
  require "sinatra_asset_packager/version"
5
7
  require "sinatra_asset_packager/routes"
8
+ require "sinatra_asset_packager/rake"
6
9
 
7
10
  module SinatraAssetPackager
8
11
  extend self
@@ -11,13 +11,14 @@ Gem::Specification.new do |gem|
11
11
  gem.description = %q{Opinionated asset packaging for Sinatra done well.}
12
12
  gem.summary = %q{Opinionated asset packaging for Sinatra done well.}
13
13
  gem.homepage = "http://github.com/scottmotte/sinatra_asset_packager"
14
-
14
+
15
+ gem.add_dependency "rake"
16
+ gem.add_dependency "sinatra"
15
17
  gem.add_dependency "sprockets"
16
18
  gem.add_dependency "uglifier"
17
19
  gem.add_dependency "yui-compressor"
18
20
 
19
21
  gem.add_development_dependency "pry"
20
- gem.add_development_dependency "rake"
21
22
  gem.add_development_dependency "rspec"
22
23
 
23
24
  gem.files = `git ls-files`.split($/)
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SinatraAssetPackager do
4
- it { SinatraAssetPackager::VERSION.should eq "0.0.1" }
4
+ it { SinatraAssetPackager::VERSION.should eq "0.0.2" }
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra_asset_packager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ cert_chain: []
12
12
  date: 2013-05-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: sprockets
15
+ name: rake
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
@@ -28,7 +28,7 @@ dependencies:
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
- name: uglifier
31
+ name: sinatra
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
@@ -44,7 +44,7 @@ dependencies:
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
- name: yui-compressor
47
+ name: sprockets
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
@@ -60,14 +60,14 @@ dependencies:
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
- name: pry
63
+ name: uglifier
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
67
  - - ! '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
- type: :development
70
+ type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  none: false
@@ -76,7 +76,23 @@ dependencies:
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  - !ruby/object:Gem::Dependency
79
- name: rake
79
+ name: yui-compressor
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: pry
80
96
  requirement: !ruby/object:Gem::Requirement
81
97
  none: false
82
98
  requirements:
@@ -121,6 +137,7 @@ files:
121
137
  - README.md
122
138
  - Rakefile
123
139
  - lib/sinatra_asset_packager.rb
140
+ - lib/sinatra_asset_packager/rake.rb
124
141
  - lib/sinatra_asset_packager/routes.rb
125
142
  - lib/sinatra_asset_packager/version.rb
126
143
  - sinatra_asset_packager.gemspec
@@ -142,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
159
  version: '0'
143
160
  segments:
144
161
  - 0
145
- hash: 1582923288525123427
162
+ hash: 4351865812643374833
146
163
  required_rubygems_version: !ruby/object:Gem::Requirement
147
164
  none: false
148
165
  requirements:
@@ -151,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
168
  version: '0'
152
169
  segments:
153
170
  - 0
154
- hash: 1582923288525123427
171
+ hash: 4351865812643374833
155
172
  requirements: []
156
173
  rubyforge_project:
157
174
  rubygems_version: 1.8.23