vendorer 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/Readme.md +1 -0
- data/lib/vendorer/version.rb +1 -1
- data/lib/vendorer.rb +38 -9
- data/spec/vendorer_spec.rb +113 -10
- metadata +23 -35
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
@@ -72,6 +72,7 @@ Author
|
|
72
72
|
### [Contributors](http://github.com/grosser/vendorer/contributors)
|
73
73
|
- [Kurtis Rainbolt-Greene](https://github.com/krainboltgreene)
|
74
74
|
- [Ivan K.](https://github.com/divout)
|
75
|
+
- [Matt Brictson](https://github.com/mbrictson)
|
75
76
|
|
76
77
|
[Michael Grosser](http://grosser.it)<br/>
|
77
78
|
michael@grosser.it<br/>
|
data/lib/vendorer/version.rb
CHANGED
data/lib/vendorer.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'tempfile'
|
2
|
+
require 'tmpdir'
|
2
3
|
|
3
4
|
class Vendorer
|
4
5
|
def initialize(options={})
|
@@ -10,28 +11,31 @@ class Vendorer
|
|
10
11
|
eval(content, nil, 'Vendorfile', 1)
|
11
12
|
end
|
12
13
|
|
13
|
-
def file(path, url)
|
14
|
+
def file(path, url=nil)
|
14
15
|
path = complete_path(path)
|
15
16
|
update_or_not path do
|
16
17
|
run "mkdir -p #{File.dirname(path)}"
|
17
|
-
|
18
|
-
|
18
|
+
if @copy_from_url
|
19
|
+
copy_from_path(path, url)
|
20
|
+
else
|
21
|
+
run "curl '#{url}' -L -o #{path}"
|
22
|
+
raise "Downloaded empty file" unless File.exist?(path)
|
23
|
+
end
|
19
24
|
yield path if block_given?
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
23
28
|
def folder(path, url=nil, options={})
|
24
|
-
if url
|
29
|
+
if @copy_from_path or url
|
25
30
|
path = complete_path(path)
|
26
31
|
update_or_not path do
|
27
32
|
run "rm -rf #{path}"
|
28
33
|
run "mkdir -p #{File.dirname(path)}"
|
29
|
-
|
30
|
-
|
31
|
-
|
34
|
+
if @copy_from_path
|
35
|
+
copy_from_path(path, url)
|
36
|
+
else
|
37
|
+
download_repository(url, path, options)
|
32
38
|
end
|
33
|
-
run("cd #{path} && git submodule update --init --recursive")
|
34
|
-
run "rm -rf #{path}/.git"
|
35
39
|
yield path if block_given?
|
36
40
|
end
|
37
41
|
else
|
@@ -59,6 +63,15 @@ class Vendorer
|
|
59
63
|
File.open('Vendorfile', 'w') { |f| f.write(examples.strip) }
|
60
64
|
end
|
61
65
|
|
66
|
+
def from(url, options={})
|
67
|
+
Dir.mktmpdir do |tmpdir|
|
68
|
+
download_repository url, tmpdir, options
|
69
|
+
@copy_from_url, @copy_from_path = url, tmpdir
|
70
|
+
yield
|
71
|
+
@copy_from_url = @copy_from_path = nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
62
75
|
private
|
63
76
|
|
64
77
|
def update_or_not(path)
|
@@ -84,4 +97,20 @@ class Vendorer
|
|
84
97
|
def complete_path(path)
|
85
98
|
File.join(@sub_path + [path])
|
86
99
|
end
|
100
|
+
|
101
|
+
def download_repository(url, to, options)
|
102
|
+
run "git clone '#{url}' #{to}"
|
103
|
+
if commit = (options[:ref] || options[:tag] || options[:branch])
|
104
|
+
run "cd #{to} && git checkout '#{commit}'"
|
105
|
+
end
|
106
|
+
run "cd #{to} && git submodule update --init --recursive"
|
107
|
+
run "rm -rf #{to}/.git"
|
108
|
+
end
|
109
|
+
|
110
|
+
def copy_from_path(dest_path, src_path)
|
111
|
+
src_path ||= dest_path
|
112
|
+
copy_from = File.join(@copy_from_path, src_path)
|
113
|
+
raise "'#{src_path}' not found in #{@copy_from_url}" unless File.exist?(copy_from)
|
114
|
+
run "cp -Rp #{copy_from} #{dest_path}"
|
115
|
+
end
|
87
116
|
end
|
data/spec/vendorer_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe Vendorer do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def write(file, content)
|
16
|
-
File.open(file,'w'){|f| f.write(content) }
|
16
|
+
File.open(file, 'w') { |f| f.write(content) }
|
17
17
|
end
|
18
18
|
|
19
19
|
def read(file)
|
@@ -138,9 +138,9 @@ describe Vendorer do
|
|
138
138
|
simple_vendorfile
|
139
139
|
vendorer
|
140
140
|
run 'chmod 711 public/javascripts/jquery.min.js'
|
141
|
-
lambda{
|
141
|
+
lambda {
|
142
142
|
vendorer 'update'
|
143
|
-
}.should_not change{ run('ls -l public/javascripts').split("\n") }
|
143
|
+
}.should_not change { run('ls -l public/javascripts').split("\n") }
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
@@ -170,7 +170,7 @@ describe Vendorer do
|
|
170
170
|
write 'Vendorfile', "folder 'vendor/plugins/parallel_tests', 'https://github.com/grosser/parallel_tests.git'"
|
171
171
|
vendorer
|
172
172
|
ls('vendor/plugins').should == ["parallel_tests"]
|
173
|
-
read('vendor/plugins/parallel_tests/Gemfile').should include('
|
173
|
+
read('vendor/plugins/parallel_tests/Gemfile').should include('cucumber')
|
174
174
|
end
|
175
175
|
|
176
176
|
it "reports errors when the Vendorfile is broken" do
|
@@ -280,7 +280,7 @@ describe Vendorer do
|
|
280
280
|
|
281
281
|
it "can update a nested file" do
|
282
282
|
vendorer
|
283
|
-
write('public/javascripts/jquery.js','Foo')
|
283
|
+
write('public/javascripts/jquery.js', 'Foo')
|
284
284
|
vendorer 'update'
|
285
285
|
read('public/javascripts/jquery.js').should include('jQuery')
|
286
286
|
end
|
@@ -293,8 +293,8 @@ describe Vendorer do
|
|
293
293
|
file 'xxx.js', 'http://code.jquery.com/jquery-latest.min.js'
|
294
294
|
"
|
295
295
|
vendorer
|
296
|
-
write('public/javascripts/jquery.js','Foo')
|
297
|
-
write('xxx.js','Foo')
|
296
|
+
write('public/javascripts/jquery.js', 'Foo')
|
297
|
+
write('xxx.js', 'Foo')
|
298
298
|
vendorer 'update public/javascripts'
|
299
299
|
read('xxx.js').should == "Foo"
|
300
300
|
read('public/javascripts/jquery.js').should include('jQuery')
|
@@ -330,9 +330,10 @@ describe Vendorer do
|
|
330
330
|
run "cd #{folder} && git commit -am 'initial'"
|
331
331
|
end
|
332
332
|
|
333
|
-
let(:vendorer){
|
333
|
+
let(:vendorer) {
|
334
334
|
v = Vendorer.new
|
335
|
-
def v.puts(x)
|
335
|
+
def v.puts(x) # silence
|
336
|
+
end
|
336
337
|
v
|
337
338
|
}
|
338
339
|
|
@@ -422,7 +423,7 @@ describe Vendorer do
|
|
422
423
|
|
423
424
|
it "created Vendorfile contains commented out examples" do
|
424
425
|
Vendorer.new('init').init
|
425
|
-
read("Vendorfile").split("\n").each{|l| l.should =~ /^(#|\s*$)/ }
|
426
|
+
read("Vendorfile").split("\n").each { |l| l.should =~ /^(#|\s*$)/ }
|
426
427
|
end
|
427
428
|
|
428
429
|
it "created Vendorfile contains many examples" do
|
@@ -441,4 +442,106 @@ describe Vendorer do
|
|
441
442
|
end
|
442
443
|
end
|
443
444
|
end
|
445
|
+
|
446
|
+
describe "#from" do
|
447
|
+
it "returns to normal after the block" do
|
448
|
+
write "Vendorfile", "
|
449
|
+
from '../../.git' do
|
450
|
+
file 'Readme.md'
|
451
|
+
end
|
452
|
+
file 'jquery.js', 'http://code.jquery.com/jquery-latest.min.js'
|
453
|
+
"
|
454
|
+
vendorer
|
455
|
+
ls(".").should =~ ['Readme.md', 'Vendorfile', 'jquery.js']
|
456
|
+
read('jquery.js').should include("jQuery")
|
457
|
+
end
|
458
|
+
|
459
|
+
it "can checkout a specific version" do
|
460
|
+
write "Vendorfile", "
|
461
|
+
from '../../.git', :tag => 'v0.1.0' do
|
462
|
+
file 'lib/vendorer/version.rb'
|
463
|
+
end
|
464
|
+
"
|
465
|
+
vendorer
|
466
|
+
read('lib/vendorer/version.rb').should include("0.1.0")
|
467
|
+
end
|
468
|
+
|
469
|
+
context "with file" do
|
470
|
+
it "copies" do
|
471
|
+
write "Vendorfile", "
|
472
|
+
from '../../.git' do
|
473
|
+
file 'Readme.md'
|
474
|
+
end
|
475
|
+
"
|
476
|
+
vendorer
|
477
|
+
ls(".").should == ['Readme.md', 'Vendorfile']
|
478
|
+
end
|
479
|
+
|
480
|
+
it "copies to/from a nested location" do
|
481
|
+
write "Vendorfile", "
|
482
|
+
from '../../.git' do
|
483
|
+
file 'foo/bar/renamed.rb', 'lib/vendorer.rb'
|
484
|
+
end
|
485
|
+
"
|
486
|
+
vendorer
|
487
|
+
ls(".").should == ['foo', 'Vendorfile']
|
488
|
+
ls("./foo/bar").should == ['renamed.rb']
|
489
|
+
end
|
490
|
+
|
491
|
+
it "renames" do
|
492
|
+
write "Vendorfile", "
|
493
|
+
from '../../.git' do
|
494
|
+
file 'Readme.renamed', 'Readme.md'
|
495
|
+
end
|
496
|
+
"
|
497
|
+
vendorer
|
498
|
+
ls(".").should == ['Readme.renamed', 'Vendorfile']
|
499
|
+
end
|
500
|
+
end
|
501
|
+
|
502
|
+
context "with folder" do
|
503
|
+
it "copies" do
|
504
|
+
write "Vendorfile", "
|
505
|
+
from '../../.git' do
|
506
|
+
folder 'lib'
|
507
|
+
end
|
508
|
+
"
|
509
|
+
vendorer
|
510
|
+
ls(".").should == ['lib', 'Vendorfile']
|
511
|
+
ls("./lib").should == ['vendorer', 'vendorer.rb']
|
512
|
+
end
|
513
|
+
|
514
|
+
it "copies to/from a nested location" do
|
515
|
+
write "Vendorfile", "
|
516
|
+
from '../../.git' do
|
517
|
+
folder 'foo/bar', 'lib/vendorer'
|
518
|
+
end
|
519
|
+
"
|
520
|
+
vendorer
|
521
|
+
ls(".").should == ['foo', 'Vendorfile']
|
522
|
+
ls("./foo/bar").should == ['version.rb']
|
523
|
+
end
|
524
|
+
|
525
|
+
it "renames" do
|
526
|
+
write "Vendorfile", "
|
527
|
+
from '../../.git' do
|
528
|
+
folder 'foo', 'lib'
|
529
|
+
end
|
530
|
+
"
|
531
|
+
vendorer
|
532
|
+
ls(".").should == ['foo', 'Vendorfile']
|
533
|
+
ls("./foo").should == ['vendorer', 'vendorer.rb']
|
534
|
+
end
|
535
|
+
end
|
536
|
+
|
537
|
+
it "gives 'not found' error for non-existent file" do
|
538
|
+
write "Vendorfile", "
|
539
|
+
from '../../.git', :tag => 'b1e6460' do
|
540
|
+
file 'bogus'
|
541
|
+
end
|
542
|
+
"
|
543
|
+
output = vendorer '', :raise => true
|
544
|
+
output.should include("'bogus' not found in ../../.git")
|
545
|
+
end
|
546
|
+
end
|
444
547
|
end
|
metadata
CHANGED
@@ -1,32 +1,23 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: vendorer
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.11
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 10
|
10
|
-
version: 0.1.10
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Michael Grosser
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2012-02-28 00:00:00 Z
|
12
|
+
date: 2012-04-06 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
14
|
description:
|
22
15
|
email: michael@grosser.it
|
23
|
-
executables:
|
16
|
+
executables:
|
24
17
|
- vendorer
|
25
18
|
extensions: []
|
26
|
-
|
27
19
|
extra_rdoc_files: []
|
28
|
-
|
29
|
-
files:
|
20
|
+
files:
|
30
21
|
- .travis.yml
|
31
22
|
- Gemfile
|
32
23
|
- Gemfile.lock
|
@@ -39,37 +30,34 @@ files:
|
|
39
30
|
- spec/vendorer_spec.rb
|
40
31
|
- vendorer.gemspec
|
41
32
|
homepage: http://github.com/grosser/vendorer
|
42
|
-
licenses:
|
33
|
+
licenses:
|
43
34
|
- MIT
|
44
35
|
post_install_message:
|
45
36
|
rdoc_options: []
|
46
|
-
|
47
|
-
require_paths:
|
37
|
+
require_paths:
|
48
38
|
- lib
|
49
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
40
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
55
|
-
segments:
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
segments:
|
56
46
|
- 0
|
57
|
-
|
58
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
hash: 1583849555704471697
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
49
|
none: false
|
60
|
-
requirements:
|
61
|
-
- -
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
|
64
|
-
segments:
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
segments:
|
65
55
|
- 0
|
66
|
-
|
56
|
+
hash: 1583849555704471697
|
67
57
|
requirements: []
|
68
|
-
|
69
58
|
rubyforge_project:
|
70
59
|
rubygems_version: 1.8.15
|
71
60
|
signing_key:
|
72
61
|
specification_version: 3
|
73
62
|
summary: Keep your vendor files up to date
|
74
63
|
test_files: []
|
75
|
-
|