cuba-sprockets 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +9 -0
- data/cuba-sprockets.gemspec +26 -0
- data/lib/cuba/sprockets.rb +32 -0
- data/test/cuba/sprockets_test.rb +50 -0
- data/test/fixtures/manifest.json +1 -0
- data/test/helper.rb +8 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cefbd39eae5c0a7dc2e584ec8db15280d75876c0
|
4
|
+
data.tar.gz: a2e56858fceaaa4ecc731902d47f271fc5a7724a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f68089f744149af0f86388e535cff99cb01eb02a7911f89dce018b4aa88b6d441811b75eccbc3b31b25d2f0c30721753d9a05bed04104adcb75d7e10aa7d8c68
|
7
|
+
data.tar.gz: de6549e15aa3241ec841033bdd36010537de8a874295bb436ff265674fcc71e6d5fda0bc13524cfcb3c056212b89d622d0258bc54ef06d8c6377850e21bfd02e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Patricio Mac Adden
|
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,31 @@
|
|
1
|
+
# Cuba::Sprockets
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'cuba-sprockets'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install cuba-sprockets
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/cuba-sprockets/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'cuba-sprockets'
|
7
|
+
spec.version = '0.1.0'
|
8
|
+
spec.authors = ['Patricio Mac Adden']
|
9
|
+
spec.email = ['patriciomacadden@gmail.com']
|
10
|
+
spec.summary = %q{Sprockets plugin for Cuba.}
|
11
|
+
spec.description = %q{Sprockets plugin for Cuba.}
|
12
|
+
spec.homepage = 'https://github.com/patriciomacadden/cuba-sprockets'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
21
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
22
|
+
spec.add_development_dependency 'oktobertest'
|
23
|
+
|
24
|
+
spec.add_runtime_dependency 'cuba', '~> 3.3'
|
25
|
+
spec.add_runtime_dependency 'sprockets', '~> 3.0.0.beta.0'
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'sprockets'
|
2
|
+
|
3
|
+
module Cuba::Sprockets
|
4
|
+
def self.setup(app)
|
5
|
+
app.settings[:sprockets] ||= {}
|
6
|
+
app.settings[:sprockets][:path] ||= '/assets'
|
7
|
+
app.settings[:sprockets][:assets_path] ||= File.join Dir.pwd, 'assets'
|
8
|
+
app.settings[:sprockets][:manifest_path] ||= File.join Dir.pwd, 'public', 'assets'
|
9
|
+
app.settings[:sprockets][:fonts_path] ||= File.join app.settings[:sprockets][:assets_path], 'fonts'
|
10
|
+
app.settings[:sprockets][:images_path] ||= File.join app.settings[:sprockets][:assets_path], 'images'
|
11
|
+
app.settings[:sprockets][:javascripts_path] ||= File.join app.settings[:sprockets][:assets_path], 'javascripts'
|
12
|
+
app.settings[:sprockets][:stylesheets_path] ||= File.join app.settings[:sprockets][:assets_path], 'stylesheets'
|
13
|
+
end
|
14
|
+
|
15
|
+
def asset_path(file)
|
16
|
+
if ENV['RACK_ENV'] == 'production'
|
17
|
+
manifest = ::Sprockets::Manifest.new settings[:sprockets][:manifest_path]
|
18
|
+
"#{settings[:sprockets][:path]}/#{manifest.assets[file]}"
|
19
|
+
else
|
20
|
+
"#{settings[:sprockets][:path]}/#{file}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def sprockets
|
25
|
+
@sprockets ||= ::Sprockets::Environment.new do |env|
|
26
|
+
env.append_path settings[:sprockets][:fonts_path]
|
27
|
+
env.append_path settings[:sprockets][:images_path]
|
28
|
+
env.append_path settings[:sprockets][:javascripts_path]
|
29
|
+
env.append_path settings[:sprockets][:stylesheets_path]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
scope Cuba::Sprockets do
|
4
|
+
setup do
|
5
|
+
@app = Cuba.new
|
6
|
+
end
|
7
|
+
|
8
|
+
scope '::setup' do
|
9
|
+
test 'default values' do
|
10
|
+
assert @app.settings[:sprockets][:path] == '/assets'
|
11
|
+
assert @app.settings[:sprockets][:assets_path] == File.join(Dir.pwd, 'assets')
|
12
|
+
assert @app.settings[:sprockets][:manifest_path] == File.join(Dir.pwd, 'public', 'assets')
|
13
|
+
assert @app.settings[:sprockets][:fonts_path] == File.join(@app.settings[:sprockets][:assets_path], 'fonts')
|
14
|
+
assert @app.settings[:sprockets][:images_path] == File.join(@app.settings[:sprockets][:assets_path], 'images')
|
15
|
+
assert @app.settings[:sprockets][:javascripts_path] == File.join(@app.settings[:sprockets][:assets_path], 'javascripts')
|
16
|
+
assert @app.settings[:sprockets][:stylesheets_path] == File.join(@app.settings[:sprockets][:assets_path], 'stylesheets')
|
17
|
+
end
|
18
|
+
|
19
|
+
test 'override default values' do
|
20
|
+
Cuba.settings[:sprockets][:path] = '/stessa'
|
21
|
+
assert @app.settings[:sprockets][:path] == '/stessa'
|
22
|
+
# revert the setting
|
23
|
+
Cuba.settings[:sprockets][:path] = '/assets'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
scope '#asset_path' do
|
28
|
+
scope 'when RACK_ENV=production' do
|
29
|
+
test 'returns the path to the file' do
|
30
|
+
ENV['RACK_ENV'] = 'production'
|
31
|
+
@app.settings[:sprockets][:manifest_path] = File.join(Dir.pwd, 'test', 'fixtures', 'manifest.json')
|
32
|
+
assert '/assets/application-8dbe1c9019cacfa4af55c075d9c32b59dc0885212a00500ad08eb94001f5764a.css' == @app.asset_path('application.css')
|
33
|
+
ENV['RACK_ENV'] = 'test'
|
34
|
+
@app.settings[:sprockets][:manifest_path] = File.join(Dir.pwd, 'public', 'assets')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
scope 'when RACK_ENV=development (or test)' do
|
39
|
+
test 'returns the path to the file' do
|
40
|
+
assert '/assets/application.css' == @app.asset_path('application.css')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
scope '#sprockets' do
|
46
|
+
test 'returns a configured Sprockets::Environment instance' do
|
47
|
+
assert @app.sprockets.instance_of?(Sprockets::Environment)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"files":{"application-8dbe1c9019cacfa4af55c075d9c32b59dc0885212a00500ad08eb94001f5764a.css":{"logical_path":"application.css","mtime":"2015-02-10T20:52:16-03:00","size":24,"digest":"8dbe1c9019cacfa4af55c075d9c32b59dc0885212a00500ad08eb94001f5764a","integrity":"ni:///sha-256;jb4ckBnKz6SvVcB12cMrWdwIhSEqAFAK0I65QAH1dko?ct=text/css"}},"assets":{"application.css":"application-8dbe1c9019cacfa4af55c075d9c32b59dc0885212a00500ad08eb94001f5764a.css"}}
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cuba-sprockets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Patricio Mac Adden
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: oktobertest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: cuba
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sprockets
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.0.0.beta.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.0.0.beta.0
|
83
|
+
description: Sprockets plugin for Cuba.
|
84
|
+
email:
|
85
|
+
- patriciomacadden@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- cuba-sprockets.gemspec
|
96
|
+
- lib/cuba/sprockets.rb
|
97
|
+
- test/cuba/sprockets_test.rb
|
98
|
+
- test/fixtures/manifest.json
|
99
|
+
- test/helper.rb
|
100
|
+
homepage: https://github.com/patriciomacadden/cuba-sprockets
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.4.5.1
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Sprockets plugin for Cuba.
|
124
|
+
test_files:
|
125
|
+
- test/cuba/sprockets_test.rb
|
126
|
+
- test/fixtures/manifest.json
|
127
|
+
- test/helper.rb
|