sinatra_asset_packager 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/sinatra_asset_packager.rb +24 -0
- data/lib/sinatra_asset_packager/routes.rb +22 -0
- data/lib/sinatra_asset_packager/version.rb +3 -0
- data/sinatra_asset_packager.gemspec +27 -0
- data/spec/sinatra_asset_packager/routes_spec.rb +5 -0
- data/spec/sinatra_asset_packager/version_spec.rb +5 -0
- data/spec/sinatra_asset_packager_spec.rb +19 -0
- data/spec/spec_helper.rb +9 -0
- metadata +165 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 scottmotte
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Sinatra::AssetPackager
|
2
|
+
|
3
|
+
Opinionated asset packaging for Sinatra done well.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'sinatra-assetpackager'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install sinatra-assetpackager
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "sprockets"
|
2
|
+
require "uglifier"
|
3
|
+
require "yui/compressor"
|
4
|
+
require "sinatra_asset_packager/version"
|
5
|
+
require "sinatra_asset_packager/routes"
|
6
|
+
|
7
|
+
module SinatraAssetPackager
|
8
|
+
extend self
|
9
|
+
|
10
|
+
def environment(compress=false)
|
11
|
+
environment = (Sprockets::Environment.new { |env|
|
12
|
+
env.append_path("app/assets/images")
|
13
|
+
env.append_path("app/assets/javascripts")
|
14
|
+
env.append_path("app/assets/stylesheets")
|
15
|
+
|
16
|
+
if !!compress || ["production", "staging"].include?(ENV["RACK_ENV"])
|
17
|
+
env.js_compressor = Uglifier.new(mangle: true)
|
18
|
+
env.css_compressor = YUI::CssCompressor.new
|
19
|
+
end
|
20
|
+
})
|
21
|
+
|
22
|
+
return environment
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module SinatraAssetPackager
|
2
|
+
class Routes < Sinatra::Base
|
3
|
+
get "/assets/*.js" do
|
4
|
+
content_type("application/javascript")
|
5
|
+
filepath = params[:splat][0]
|
6
|
+
SinatraAssetPackager.environment["#{filepath}.js"]
|
7
|
+
end
|
8
|
+
|
9
|
+
get "/assets/*.css" do |path|
|
10
|
+
content_type "text/css", charset: "utf-8"
|
11
|
+
filepath = params[:splat][0]
|
12
|
+
SinatraAssetPackager.environment["#{filepath}.css"]
|
13
|
+
end
|
14
|
+
|
15
|
+
%w{jpg png gif}.each do |format|
|
16
|
+
get "/assets/*.#{format}" do
|
17
|
+
content_type("image/#{format}")
|
18
|
+
SinatraAssetPackager.environment["#{params[:splat][0]}.#{format}"]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sinatra_asset_packager/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "sinatra_asset_packager"
|
8
|
+
gem.version = SinatraAssetPackager::VERSION
|
9
|
+
gem.authors = ["scottmotte"]
|
10
|
+
gem.email = ["scott@scottmotte.com"]
|
11
|
+
gem.description = %q{Opinionated asset packaging for Sinatra done well.}
|
12
|
+
gem.summary = %q{Opinionated asset packaging for Sinatra done well.}
|
13
|
+
gem.homepage = "http://github.com/scottmotte/sinatra_asset_packager"
|
14
|
+
|
15
|
+
gem.add_dependency "sprockets"
|
16
|
+
gem.add_dependency "uglifier"
|
17
|
+
gem.add_dependency "yui-compressor"
|
18
|
+
|
19
|
+
gem.add_development_dependency "pry"
|
20
|
+
gem.add_development_dependency "rake"
|
21
|
+
gem.add_development_dependency "rspec"
|
22
|
+
|
23
|
+
gem.files = `git ls-files`.split($/)
|
24
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
25
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
26
|
+
gem.require_paths = ["lib"]
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SinatraAssetPackager do
|
4
|
+
subject { SinatraAssetPackager }
|
5
|
+
|
6
|
+
describe "defaults" do
|
7
|
+
let(:environment) { subject.environment }
|
8
|
+
|
9
|
+
it { environment.should_not be_nil }
|
10
|
+
it { environment.paths.length.should eq 3 }
|
11
|
+
|
12
|
+
context "compile is true" do
|
13
|
+
let(:environment) { subject.environment(true) }
|
14
|
+
|
15
|
+
it { environment.should_not be_nil }
|
16
|
+
it { environment.paths.length.should eq 3 }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sinatra_asset_packager
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- scottmotte
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sprockets
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: uglifier
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: yui-compressor
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: pry
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rake
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
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: rspec
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: Opinionated asset packaging for Sinatra done well.
|
111
|
+
email:
|
112
|
+
- scott@scottmotte.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- .gitignore
|
118
|
+
- .rspec
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- lib/sinatra_asset_packager.rb
|
124
|
+
- lib/sinatra_asset_packager/routes.rb
|
125
|
+
- lib/sinatra_asset_packager/version.rb
|
126
|
+
- sinatra_asset_packager.gemspec
|
127
|
+
- spec/sinatra_asset_packager/routes_spec.rb
|
128
|
+
- spec/sinatra_asset_packager/version_spec.rb
|
129
|
+
- spec/sinatra_asset_packager_spec.rb
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
homepage: http://github.com/scottmotte/sinatra_asset_packager
|
132
|
+
licenses: []
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
segments:
|
144
|
+
- 0
|
145
|
+
hash: 1582923288525123427
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ! '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
segments:
|
153
|
+
- 0
|
154
|
+
hash: 1582923288525123427
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 1.8.23
|
158
|
+
signing_key:
|
159
|
+
specification_version: 3
|
160
|
+
summary: Opinionated asset packaging for Sinatra done well.
|
161
|
+
test_files:
|
162
|
+
- spec/sinatra_asset_packager/routes_spec.rb
|
163
|
+
- spec/sinatra_asset_packager/version_spec.rb
|
164
|
+
- spec/sinatra_asset_packager_spec.rb
|
165
|
+
- spec/spec_helper.rb
|