bower 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/.gitignore +40 -0
- data/.rspec +3 -0
- data/.travis.yml +8 -0
- data/.yardopts +3 -0
- data/Gemfile +24 -0
- data/Guardfile +6 -0
- data/LICENSE.md +20 -0
- data/README.md +65 -0
- data/Rakefile +17 -0
- data/bower.gemspec +21 -0
- data/lib/bower.rb +19 -0
- data/lib/bower/environment.rb +43 -0
- data/lib/bower/railtie.rb +10 -0
- data/lib/bower/version.rb +3 -0
- data/lib/generators/bower/install_generator.rb +23 -0
- data/lib/generators/templates/bowerrc +6 -0
- data/lib/generators/templates/component.json +17 -0
- data/spec/bower/environment_spec.rb +71 -0
- data/spec/bower_spec.rb +25 -0
- data/spec/dummy/.bowerrc +6 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +14 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/static_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/static/home.html.erb +1 -0
- data/spec/dummy/components/component.json +7 -0
- data/spec/dummy/components/coolio/component.json +9 -0
- data/spec/dummy/components/coolio/coolio.js +1 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +64 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/features/bower_integration_spec.rb +25 -0
- data/spec/fixtures/.bowerrc +4 -0
- data/spec/generators/bower/install_generator_spec.rb +24 -0
- data/spec/spec_helper.rb +38 -0
- metadata +159 -0
data/.gemtest
ADDED
File without changes
|
data/.gitignore
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
*.sw[a-p]
|
4
|
+
*.tmproj
|
5
|
+
*.tmproject
|
6
|
+
*.un~
|
7
|
+
*~
|
8
|
+
.DS_Store
|
9
|
+
.Spotlight-V100
|
10
|
+
.Trashes
|
11
|
+
._*
|
12
|
+
.bundle
|
13
|
+
.config
|
14
|
+
.directory
|
15
|
+
.elc
|
16
|
+
.emacs.desktop
|
17
|
+
.emacs.desktop.lock
|
18
|
+
.redcar
|
19
|
+
.yardoc
|
20
|
+
Desktop.ini
|
21
|
+
Gemfile.lock
|
22
|
+
Icon?
|
23
|
+
InstalledFiles
|
24
|
+
Session.vim
|
25
|
+
Thumbs.db
|
26
|
+
\#*\#
|
27
|
+
_yardoc
|
28
|
+
auto-save-list
|
29
|
+
coverage
|
30
|
+
doc
|
31
|
+
lib/bundler/man
|
32
|
+
pkg
|
33
|
+
pkg/*
|
34
|
+
rdoc
|
35
|
+
spec/reports
|
36
|
+
test/tmp
|
37
|
+
test/version_tmp
|
38
|
+
tmp
|
39
|
+
tmtags
|
40
|
+
tramp
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/.yardopts
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rake'
|
4
|
+
gem 'yard'
|
5
|
+
gem 'multi_json'
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem 'kramdown'
|
9
|
+
gem 'guard-rspec'
|
10
|
+
end
|
11
|
+
|
12
|
+
group :test do
|
13
|
+
gem 'json', :platforms => :ruby_18
|
14
|
+
gem 'rspec-rails'
|
15
|
+
gem 'capybara'
|
16
|
+
gem 'jquery-rails'
|
17
|
+
gem "sprockets", "2.2.2.backport1"
|
18
|
+
gem 'rails', '~> 3.2.12'
|
19
|
+
gem 'sqlite3'
|
20
|
+
gem 'generator_spec'
|
21
|
+
gem 'simplecov', :require => false
|
22
|
+
end
|
23
|
+
|
24
|
+
gemspec
|
data/Guardfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Steve Agalloco
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Bower
|
2
|
+
|
3
|
+
[Bower](http://twitter.github.com/bower/) integration for your ruby apps.
|
4
|
+
|
5
|
+
## Usage with Sprockets
|
6
|
+
|
7
|
+
### Rails
|
8
|
+
|
9
|
+
Add `bower` to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'bower'
|
13
|
+
```
|
14
|
+
|
15
|
+
Rails 4 ships with an updated version of Sprockets that supports bower's `component.json` file. If you are running, Rails 3, then you need to require Sprockets [`2.2.2.backport1`](http://rubygems.org/gems/sprockets/versions/2.2.2.backport1):
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'sprockets', '2.2.2.backport1'
|
19
|
+
```
|
20
|
+
|
21
|
+
The gem includes a generator that sets up your project:
|
22
|
+
|
23
|
+
rails generate bower:install
|
24
|
+
|
25
|
+
This will install a `.bowerrc` file to your project's root directory that looks like this:
|
26
|
+
|
27
|
+
```json
|
28
|
+
{
|
29
|
+
"directory" : "components",
|
30
|
+
"json" : "components/component.json",
|
31
|
+
"endpoint" : "https://bower.herokuapp.com",
|
32
|
+
"searchpath" : []
|
33
|
+
}
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
Add your dependencies to `components/component.json` then use bower (`bower install`, etc.) as you would in any other project.
|
38
|
+
|
39
|
+
### Non-Rails Projects
|
40
|
+
|
41
|
+
While offering less capability than when used in Rails' asset pipeline, you can still use the `bower` gem in a non-Rails project. Just require the gem and append the corresponding directory to Sprocket's load path:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require 'sprockets'
|
45
|
+
require 'bower'
|
46
|
+
|
47
|
+
environment = Sprockets::Environment.new
|
48
|
+
environment.append_path Bower.environment.directory
|
49
|
+
```
|
50
|
+
|
51
|
+
## How this gem differs from other techniques
|
52
|
+
|
53
|
+
For Rails apps, integrating bower components into `lib/assets` and/or `vendor/assets` seems like the wrong approach. Since bower can support multiple searchpaths, the need to make a distinction between external dependencies and frameworks does not exist. It can all be managed in once place. This gem takes a more opinionated approach and installs components to `components/` in your project's root by default. You can always change it someplace
|
54
|
+
|
55
|
+
## TODO
|
56
|
+
|
57
|
+
When used with Sprockets, you still need to use a `require` directive in order to require a component's files. This seems like something that should just work.
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
Pull requests welcome: fork, make a topic branch, commit (squash when possible) *with tests* and I'll happily consider.
|
62
|
+
|
63
|
+
## Copyright
|
64
|
+
|
65
|
+
Copyright (c) 2013 Steve Agalloco. See [LICENSE](LICENSE.md) for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
task :default => :spec
|
9
|
+
task :test => :spec
|
10
|
+
|
11
|
+
require 'yard'
|
12
|
+
namespace :doc do
|
13
|
+
YARD::Rake::YardocTask.new do |task|
|
14
|
+
task.files = ['LICENSE.md', 'lib/**/*.rb']
|
15
|
+
task.options = ['--markup', 'markdown']
|
16
|
+
end
|
17
|
+
end
|
data/bower.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bower/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = 'bower'
|
8
|
+
gem.version = Bower::VERSION
|
9
|
+
gem.homepage = 'https://github.com/spagalloco/bower'
|
10
|
+
|
11
|
+
gem.author = "Steve Agalloco"
|
12
|
+
gem.email = 'steve.agalloco@gmail.com'
|
13
|
+
gem.description = 'Bower integration for your ruby projects.'
|
14
|
+
gem.summary = 'Bower integration for your ruby projects.'
|
15
|
+
|
16
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
|
17
|
+
gem.files = `git ls-files`.split("\n")
|
18
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
|
20
|
+
gem.require_paths = ['lib']
|
21
|
+
end
|
data/lib/bower.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'bower/environment'
|
2
|
+
|
3
|
+
module Bower
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def install
|
7
|
+
environment.install
|
8
|
+
end
|
9
|
+
|
10
|
+
def update
|
11
|
+
environment.update
|
12
|
+
end
|
13
|
+
|
14
|
+
def environment
|
15
|
+
@environment ||= Bower::Environment.setup('.bowerrc')
|
16
|
+
end
|
17
|
+
|
18
|
+
require "bower/railtie" if defined?(::Rails)
|
19
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'multi_json'
|
2
|
+
|
3
|
+
module Bower
|
4
|
+
class Environment
|
5
|
+
attr_accessor :directory, :json
|
6
|
+
|
7
|
+
DEFAULT_DIRECTORY = 'components'
|
8
|
+
DEFAULT_JSON = 'component.json'
|
9
|
+
|
10
|
+
def self.setup(bowerrc=nil)
|
11
|
+
if bowerrc && File.exists?(bowerrc)
|
12
|
+
conf = MultiJson.load(File.open(bowerrc))
|
13
|
+
Environment.new(conf)
|
14
|
+
else
|
15
|
+
Environment.new
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(config={})
|
20
|
+
@directory = config['directory'] || DEFAULT_DIRECTORY
|
21
|
+
@json = config['json'] || DEFAULT_JSON
|
22
|
+
end
|
23
|
+
|
24
|
+
def install
|
25
|
+
run('bower install')
|
26
|
+
end
|
27
|
+
|
28
|
+
def update
|
29
|
+
run('bower update')
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def run(cmd)
|
35
|
+
return unless Dir.exists?(directory)
|
36
|
+
|
37
|
+
Dir.chdir(directory) do
|
38
|
+
`#{cmd}` if File.exists?(json)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
3
|
+
module Bower
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("../../templates", __FILE__)
|
7
|
+
|
8
|
+
desc "Creates a Devise initializer and copy locale files to your application."
|
9
|
+
|
10
|
+
def create_components_directory
|
11
|
+
empty_directory 'components/javascripts'
|
12
|
+
end
|
13
|
+
|
14
|
+
def copy_component_json
|
15
|
+
copy_file 'component.json', 'components/javascripts/component.json'
|
16
|
+
end
|
17
|
+
|
18
|
+
def copy_config
|
19
|
+
copy_file "bowerrc", ".bowerrc"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
// Define your dependencies below, here's an example:
|
2
|
+
|
3
|
+
// {
|
4
|
+
// "name": "myProject",
|
5
|
+
// "version": "1.0.0",
|
6
|
+
// "main": "./path/to/main.css",
|
7
|
+
// "dependencies": {
|
8
|
+
// "jquery": "~1.7.2"
|
9
|
+
// }
|
10
|
+
// }
|
11
|
+
|
12
|
+
{
|
13
|
+
"name": "",
|
14
|
+
"version": "",
|
15
|
+
"main": "",
|
16
|
+
"dependencies": {}
|
17
|
+
}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Bower::Environment do
|
4
|
+
context 'when initializing from a file' do
|
5
|
+
subject { Bower::Environment.setup(File.join(fixture_path, '.bowerrc')) }
|
6
|
+
|
7
|
+
it 'uses the specified directory' do
|
8
|
+
expect(subject.directory).to eq('lib/assets/javascripts')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'uses the specified json' do
|
12
|
+
expect(subject.json).to eq('bower.json')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'defaults' do
|
17
|
+
subject { Bower::Environment.setup }
|
18
|
+
|
19
|
+
it 'uses a default directory' do
|
20
|
+
expect(subject.directory).to eq('components')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'uses a default json' do
|
24
|
+
expect(subject.json).to eq('component.json')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#install' do
|
29
|
+
subject { Bower::Environment.new }
|
30
|
+
|
31
|
+
it 'invokes "bower update"' do
|
32
|
+
subject.should_receive(:run).with('bower install').and_return(true)
|
33
|
+
subject.install
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#update' do
|
38
|
+
subject { Bower::Environment.new }
|
39
|
+
|
40
|
+
it 'invokes "bower update"' do
|
41
|
+
subject.should_receive(:run).with('bower update').and_return(true)
|
42
|
+
subject.update
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#run' do
|
47
|
+
subject { Bower::Environment.new }
|
48
|
+
it 'returns nil when the directory does not exist' do
|
49
|
+
Dir.stub(:exists?).and_return(false)
|
50
|
+
|
51
|
+
expect(subject.send(:run, 'bower update')).to be_nil
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'returns nil when the component file does not exist' do
|
55
|
+
Dir.stub(:exists?).with(subject.directory).and_return(true)
|
56
|
+
Dir.should_receive(:chdir).with(subject.directory).and_yield
|
57
|
+
File.stub(:exists?).and_return(false)
|
58
|
+
|
59
|
+
expect(subject.send(:run, 'bower update')).to be_nil
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'invokes the shell command wheh the component file exists' do
|
63
|
+
Dir.stub(:exists?).with(subject.directory).and_return(true)
|
64
|
+
Dir.stub(:chdir).with(subject.directory).and_yield
|
65
|
+
File.stub(:exists?).and_return(true)
|
66
|
+
subject.should_receive(:`).and_return
|
67
|
+
|
68
|
+
expect(subject.send(:run, 'bower update')).to be_nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/spec/bower_spec.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Bower do
|
4
|
+
|
5
|
+
describe '.install' do
|
6
|
+
it 'invokes install on the environment' do
|
7
|
+
Bower.environment.should_receive(:install).and_return
|
8
|
+
Bower.install
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '.update' do
|
13
|
+
it 'invokes update on the environment' do
|
14
|
+
Bower.environment.should_receive(:update).and_return
|
15
|
+
Bower.update
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '.environment' do
|
20
|
+
it 'returns a Bower::Environment' do
|
21
|
+
Bower.environment.should be_a(Bower::Environment)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|