vendorer 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +5 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +26 -0
- data/Rakefile +19 -0
- data/Readme.md +39 -0
- data/bin/vendorer +33 -0
- data/lib/vendorer.rb +49 -0
- data/lib/vendorer/version.rb +3 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/vendorer_spec.rb +162 -0
- data/vendorer.gemspec +12 -0
- metadata +77 -0
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
vendorer (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.3)
|
10
|
+
rake (0.9.2)
|
11
|
+
rspec (2.6.0)
|
12
|
+
rspec-core (~> 2.6.0)
|
13
|
+
rspec-expectations (~> 2.6.0)
|
14
|
+
rspec-mocks (~> 2.6.0)
|
15
|
+
rspec-core (2.6.4)
|
16
|
+
rspec-expectations (2.6.0)
|
17
|
+
diff-lcs (~> 1.1.2)
|
18
|
+
rspec-mocks (2.6.0)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
rake
|
25
|
+
rspec (~> 2)
|
26
|
+
vendorer!
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "bundler"
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
task :default do
|
5
|
+
sh "rspec spec/"
|
6
|
+
end
|
7
|
+
|
8
|
+
rule /^version:bump:.*/ do |t|
|
9
|
+
file = 'lib/vendorer/version.rb'
|
10
|
+
sh "git status | grep 'nothing to commit'" # ensure we are not dirty
|
11
|
+
index = ['major', 'minor','patch'].index(t.name.split(':').last)
|
12
|
+
version_file = File.read(file)
|
13
|
+
old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
|
14
|
+
version_parts[index] = version_parts[index].to_i + 1
|
15
|
+
new_version = version_parts * '.'
|
16
|
+
File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }
|
17
|
+
|
18
|
+
sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
|
19
|
+
end
|
data/Readme.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
Vendorer keeps your vendor files up to date.
|
2
|
+
|
3
|
+
- updateable AND documented dependencies
|
4
|
+
- copy-paste-free
|
5
|
+
- no unwanted/accidental updates
|
6
|
+
|
7
|
+
Install
|
8
|
+
=======
|
9
|
+
Install curl and git, then:
|
10
|
+
|
11
|
+
sudo gem install vendorer
|
12
|
+
|
13
|
+
Usage
|
14
|
+
=====
|
15
|
+
Add a Vendorfile to your project root:
|
16
|
+
|
17
|
+
file 'public/javascripts/jquery.min.js' => 'http://code.jquery.com/jquery-latest.min.js'
|
18
|
+
folder 'vendor/plugins/parallel_tests' => 'https://github.com/grosser/parallel_tests.git'
|
19
|
+
|
20
|
+
Call `vendorer`
|
21
|
+
|
22
|
+
If you added something new: `vendorer`
|
23
|
+
|
24
|
+
If you want to update all dependencies: `vendorer update`
|
25
|
+
|
26
|
+
If you want to update one dependencies: `vendorer update public/javasctips/jquery.min.js`
|
27
|
+
|
28
|
+
|
29
|
+
TODO
|
30
|
+
====
|
31
|
+
- git branch/commit support
|
32
|
+
- `folder 'vendor' do` which will remove everything that is not vendored via Vendorfile on `vendorer update` or `vendorer update vendor`
|
33
|
+
|
34
|
+
Author
|
35
|
+
======
|
36
|
+
[Michael Grosser](http://grosser.it)<br/>
|
37
|
+
michael@grosser.it<br/>
|
38
|
+
License: MIT<br/>
|
39
|
+
[![Build Status](https://secure.travis-ci.org/grosser/vendorer.png)](http://travis-ci.org/grosser/vendorer)
|
data/bin/vendorer
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
require 'optparse'
|
4
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
parser = OptionParser.new do |opts|
|
8
|
+
opts.banner = <<BANNER
|
9
|
+
Vendorer keeps your vendor files up to date.
|
10
|
+
|
11
|
+
Usage:
|
12
|
+
|
13
|
+
Create a Vendorfile in your project root with:
|
14
|
+
|
15
|
+
file 'public/javascripts/jquery.min.js' => 'http://code.jquery.com/jquery-latest.min.js'
|
16
|
+
folder 'vendor/plugins/parallel_tests' => 'https://github.com/grosser/parallel_tests.git'
|
17
|
+
|
18
|
+
Run `vendorer` to install.
|
19
|
+
Run `vendorer update` to update.
|
20
|
+
|
21
|
+
Options:
|
22
|
+
BANNER
|
23
|
+
opts.on("-v", "--version", "Show Version"){
|
24
|
+
require 'vendorer/version'
|
25
|
+
puts Vendorer::VERSION
|
26
|
+
exit
|
27
|
+
}
|
28
|
+
opts.on("-h", "--help", "Show this.") { puts opts; exit }
|
29
|
+
end
|
30
|
+
parser.parse!
|
31
|
+
|
32
|
+
require 'vendorer'
|
33
|
+
Vendorer.new(:update => (ARGV[1] || true if ARGV[0] == 'update'))
|
data/lib/vendorer.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
class Vendorer
|
2
|
+
def initialize(options)
|
3
|
+
@options = options
|
4
|
+
eval(File.read('Vendorfile'))
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def file(options)
|
10
|
+
options.each do |file, url|
|
11
|
+
update_or_not file do
|
12
|
+
run "mkdir -p #{File.dirname(file)}"
|
13
|
+
run "curl '#{url}' -o #{file}"
|
14
|
+
raise "Downloaded empty file" unless File.exist?(file)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def folder(options)
|
20
|
+
options.each do |path, url|
|
21
|
+
update_or_not path do
|
22
|
+
run "mkdir -p #{File.dirname(path)}"
|
23
|
+
run "git clone '#{url}' #{path}"
|
24
|
+
run "rm -rf #{path}/.git"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def update_or_not(path)
|
30
|
+
update_requested = (@options[:update] and (@options[:update] == true or @options[:update] == path))
|
31
|
+
if update_requested or not File.exist?(path)
|
32
|
+
puts "updating #{path}"
|
33
|
+
run "rm -rf #{path}"
|
34
|
+
yield
|
35
|
+
else
|
36
|
+
puts "keeping #{path}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def run(cmd)
|
41
|
+
output = ''
|
42
|
+
IO.popen(cmd + ' 2>&1') do |pipe|
|
43
|
+
while line = pipe.gets
|
44
|
+
output << line
|
45
|
+
end
|
46
|
+
end
|
47
|
+
raise output unless $?.success?
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vendorer do
|
4
|
+
before do
|
5
|
+
`rm -rf spec/tmp`
|
6
|
+
`mkdir spec/tmp`
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
`rm -rf spec/tmp`
|
11
|
+
end
|
12
|
+
|
13
|
+
def write(file, content)
|
14
|
+
File.open("spec/tmp/#{file}",'w'){|f| f.write(content) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def read(file)
|
18
|
+
File.read("spec/tmp/#{file}")
|
19
|
+
end
|
20
|
+
|
21
|
+
def size(file)
|
22
|
+
File.size("spec/tmp/#{file}")
|
23
|
+
end
|
24
|
+
|
25
|
+
def ls(path)
|
26
|
+
`ls spec/tmp/#{path} 2>&1`.split("\n")
|
27
|
+
end
|
28
|
+
|
29
|
+
def run(args='', options={})
|
30
|
+
out = `cd spec/tmp && bundle exec ../../bin/vendorer #{args} 2>&1`
|
31
|
+
raise out if $?.success? == !!options[:raise]
|
32
|
+
out
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'version' do
|
36
|
+
it "has a VERSION" do
|
37
|
+
Vendorer::VERSION.should =~ /^[\.\da-z]+$/
|
38
|
+
end
|
39
|
+
|
40
|
+
it "shows its version via -v" do
|
41
|
+
run('-v').should == "#{Vendorer::VERSION}\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "shows its version via --version" do
|
45
|
+
run('--version').should == "#{Vendorer::VERSION}\n"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'help' do
|
50
|
+
it "shows help via -h" do
|
51
|
+
run('-h').should include("Usage")
|
52
|
+
end
|
53
|
+
|
54
|
+
it "shows help via --help" do
|
55
|
+
run('--help').should include("Usage")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '.file' do
|
60
|
+
context "with working Vendorfile" do
|
61
|
+
before do
|
62
|
+
write 'Vendorfile', "file 'public/javascripts/jquery.min.js' => 'http://code.jquery.com/jquery-latest.min.js'"
|
63
|
+
run
|
64
|
+
end
|
65
|
+
|
66
|
+
it "can download via hash syntax" do
|
67
|
+
ls('public/javascripts').should == ["jquery.min.js"]
|
68
|
+
read('public/javascripts/jquery.min.js').should include('jQuery')
|
69
|
+
end
|
70
|
+
|
71
|
+
it "does not update an existing file" do
|
72
|
+
write('public/javascripts/jquery.min.js', 'Foo')
|
73
|
+
run
|
74
|
+
read('public/javascripts/jquery.min.js').should == 'Foo'
|
75
|
+
end
|
76
|
+
|
77
|
+
it "can update a file" do
|
78
|
+
write('public/javascripts/jquery.min.js', 'Foo')
|
79
|
+
run 'update'
|
80
|
+
read('public/javascripts/jquery.min.js').should include('jQuery')
|
81
|
+
end
|
82
|
+
|
83
|
+
it "can update a single file" do
|
84
|
+
write 'Vendorfile', "
|
85
|
+
file 'public/javascripts/jquery.min.js' => 'http://code.jquery.com/jquery-latest.min.js'
|
86
|
+
file 'public/javascripts/jquery.js' => 'http://code.jquery.com/jquery-latest.js'
|
87
|
+
"
|
88
|
+
run
|
89
|
+
read('public/javascripts/jquery.js').should include('jQuery')
|
90
|
+
read('public/javascripts/jquery.min.js').should include('jQuery')
|
91
|
+
|
92
|
+
write('public/javascripts/jquery.js', 'Foo')
|
93
|
+
write('public/javascripts/jquery.min.js', 'Foo')
|
94
|
+
run 'update public/javascripts/jquery.js'
|
95
|
+
size('public/javascripts/jquery.min.js').should == 3
|
96
|
+
size('public/javascripts/jquery.js').should > 300
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
it "fails with a nice message" do
|
101
|
+
write 'Vendorfile', "file 'xxx.js' => 'http://NOTFOUND'"
|
102
|
+
result = run '', :raise => true
|
103
|
+
result.should include('Downloaded empty file')
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe '.folder' do
|
108
|
+
it "can download via hash syntax" do
|
109
|
+
write 'Vendorfile', "folder 'vendor/plugins/parallel_tests' => 'https://github.com/grosser/parallel_tests.git'"
|
110
|
+
run
|
111
|
+
ls('vendor/plugins').should == ["parallel_tests"]
|
112
|
+
read('vendor/plugins/parallel_tests/Gemfile').should include('parallel')
|
113
|
+
end
|
114
|
+
|
115
|
+
it "reports errors" do
|
116
|
+
write 'Vendorfile', "folder 'vendor/plugins/parallel_tests' => 'https://blob'"
|
117
|
+
output = run '', :raise => true
|
118
|
+
output.should include('Connection refused')
|
119
|
+
end
|
120
|
+
|
121
|
+
context "with a fast,local repository" do
|
122
|
+
before do
|
123
|
+
write 'Vendorfile', "folder 'its_recursive' => '../../.git'"
|
124
|
+
run
|
125
|
+
end
|
126
|
+
|
127
|
+
it "can download" do
|
128
|
+
ls('').should == ["its_recursive", "Vendorfile"]
|
129
|
+
read('its_recursive/Gemfile').should include('rake')
|
130
|
+
end
|
131
|
+
|
132
|
+
it "does not keep .git folder so everything can be checked in" do
|
133
|
+
ls('its_recursive/.git').first.should include('cannot access')
|
134
|
+
end
|
135
|
+
|
136
|
+
it "does not update an existing folder" do
|
137
|
+
write('its_recursive/Gemfile', 'Foo')
|
138
|
+
run
|
139
|
+
read('its_recursive/Gemfile').should == 'Foo'
|
140
|
+
end
|
141
|
+
|
142
|
+
it "can update a folder" do
|
143
|
+
write('its_recursive/Gemfile', 'Foo')
|
144
|
+
run 'update'
|
145
|
+
read('its_recursive/Gemfile').should include('rake')
|
146
|
+
end
|
147
|
+
|
148
|
+
it "can update a single file" do
|
149
|
+
write 'Vendorfile', "
|
150
|
+
folder 'its_recursive' => '../../.git'
|
151
|
+
folder 'its_really_recursive' => '../../.git'
|
152
|
+
"
|
153
|
+
run
|
154
|
+
write('its_recursive/Gemfile', 'Foo')
|
155
|
+
write('its_really_recursive/Gemfile', 'Foo')
|
156
|
+
run 'update its_recursive'
|
157
|
+
size('its_really_recursive/Gemfile').should == 3
|
158
|
+
size('its_recursive/Gemfile').should > 30
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
data/vendorer.gemspec
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
2
|
+
name = "vendorer"
|
3
|
+
require "#{name}/version"
|
4
|
+
|
5
|
+
Gem::Specification.new name, Vendorer::VERSION do |s|
|
6
|
+
s.summary = "Keep your vendor files up to date"
|
7
|
+
s.authors = ["Michael Grosser"]
|
8
|
+
s.email = "michael@grosser.it"
|
9
|
+
s.homepage = "http://github.com/grosser/#{name}"
|
10
|
+
s.files = `git ls-files`.split("\n")
|
11
|
+
s.license = 'MIT'
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vendorer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Michael Grosser
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-12-12 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description:
|
23
|
+
email: michael@grosser.it
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .travis.yml
|
32
|
+
- Gemfile
|
33
|
+
- Gemfile.lock
|
34
|
+
- Rakefile
|
35
|
+
- Readme.md
|
36
|
+
- bin/vendorer
|
37
|
+
- lib/vendorer.rb
|
38
|
+
- lib/vendorer/version.rb
|
39
|
+
- spec/spec_helper.rb
|
40
|
+
- spec/vendorer_spec.rb
|
41
|
+
- vendorer.gemspec
|
42
|
+
has_rdoc: true
|
43
|
+
homepage: http://github.com/grosser/vendorer
|
44
|
+
licenses:
|
45
|
+
- MIT
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
hash: 3
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 1.6.2
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Keep your vendor files up to date
|
76
|
+
test_files: []
|
77
|
+
|