vendorise 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -4
- data/lib/vendorise/arborist.rb +4 -3
- data/lib/vendorise/tasks.rb +5 -3
- data/lib/vendorise/version.rb +1 -1
- data/spec/lib/vendorise/arborist_spec.rb +18 -8
- data/spec/lib/vendorise/tasks_spec.rb +1 -11
- data/spec/lib/vendorise_spec.rb +15 -0
- data/spec/spec_helper.rb +9 -0
- data/vendorise.gemspec +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee24cab1f977ae4b06b7a2b3df21bb6af37d6fb5
|
4
|
+
data.tar.gz: 92026fd2c0f054e609a8006ca08ff20f8fafc8cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c23f6adf41ac307fa4f17ede9a8455ed77f5a8466a3f4e543a9489e4e637735c8bd87eda17162b9fc60c318ffd7946319f3b5c22478c718cb448012ef40529d0
|
7
|
+
data.tar.gz: 7ca3d7d635936ff7e23ac6d1261e1276d463df262f6999bf99729a4f43ac9bf31c8affc3edb96f03f9b7dda6014abd95bab3324449fb133e90a9faa5b6247025
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Vendorise
|
2
2
|
|
3
|
-
[![Gem Version](
|
4
|
-
[![Build Status](
|
3
|
+
[![Gem Version](http://img.shields.io/gem/v/vendorise.svg)](http://rubygems.org/gems/vendorise)
|
4
|
+
[![Build Status](http://img.shields.io/travis/iainbeeston/vendorise/master.svg)](https://travis-ci.org/iainbeeston/vendorise)
|
5
5
|
|
6
6
|
Sometimes you need to use a gem that is only available in a private git repository. There are a few ways to do this:
|
7
7
|
|
@@ -27,8 +27,12 @@ Or if you don't use bundler:
|
|
27
27
|
|
28
28
|
## Usage
|
29
29
|
|
30
|
-
1. Run `rake vendorise:gem[repo_url]` to vendorise the gem hosted at `repo_url` into `/vendor/gems`.
|
30
|
+
1. Run `rake "vendorise:gem[repo_url]"` to vendorise the gem hosted at `repo_url` into `/vendor/gems`.
|
31
31
|
2. Add `gem '<gem_name>', path: 'vendor/gems/<gem_name>'` to your Gemfile
|
32
32
|
|
33
|
-
You can update the gem at any time by running the rake task again.
|
33
|
+
You can update the gem at any time by running the rake task again.
|
34
|
+
|
35
|
+
By default the `vendorise:gem` rake task will use the master branch. To use another branch (or tag) specify it as the second parameter, like this:
|
36
|
+
|
37
|
+
rake "vendorise:gem[repo_url, branch]"
|
34
38
|
|
data/lib/vendorise/arborist.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module Vendorise
|
2
2
|
class Arborist
|
3
|
-
attr_reader :path, :url
|
3
|
+
attr_reader :path, :url, :branch
|
4
4
|
|
5
|
-
def initialize(path, url)
|
5
|
+
def initialize(path, url, branch)
|
6
6
|
@path = path
|
7
7
|
@url = url
|
8
|
+
@branch = branch
|
8
9
|
end
|
9
10
|
|
10
11
|
def subtree_already_exists?
|
@@ -13,7 +14,7 @@ module Vendorise
|
|
13
14
|
|
14
15
|
def subtree_command
|
15
16
|
cmd = subtree_already_exists? ? "pull" : "add"
|
16
|
-
"git subtree #{cmd} --prefix #{path} #{url}
|
17
|
+
"git subtree #{cmd} --prefix #{path} #{url} #{branch} --squash"
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
data/lib/vendorise/tasks.rb
CHANGED
@@ -4,12 +4,14 @@ require_relative "arborist"
|
|
4
4
|
|
5
5
|
namespace :vendorise do
|
6
6
|
desc "Installs a gem from the specified url to /vendor/gems"
|
7
|
-
task :gem, :url do |t, args|
|
7
|
+
task :gem, [:url, :branch] do |t, args|
|
8
|
+
args.with_defaults(branch: "master")
|
8
9
|
parser = Vendorise::Parser.new(args[:url])
|
9
10
|
url = parser.gem_url or raise "Please specify a valid url for the gem"
|
11
|
+
branch = args[:branch]
|
10
12
|
|
11
|
-
command = Vendorise::Arborist.new("vendor/gems/#{parser.gem_name}", url).subtree_command
|
13
|
+
command = Vendorise::Arborist.new("vendor/gems/#{parser.gem_name}", url, branch).subtree_command
|
12
14
|
|
13
|
-
|
15
|
+
sh(command)
|
14
16
|
end
|
15
17
|
end
|
data/lib/vendorise/version.rb
CHANGED
@@ -3,21 +3,31 @@ require_relative "../../../lib/vendorise/arborist"
|
|
3
3
|
|
4
4
|
module Vendorise
|
5
5
|
describe Arborist do
|
6
|
-
|
7
|
-
subject { Arborist.new "foo/bar", "git@github.com:New-Bamboo/vendorise.git" }
|
6
|
+
let(:subtree_already_exists?) { false }
|
8
7
|
|
9
|
-
|
10
|
-
before { allow(subject).to receive(:subtree_already_exists?).and_return(false) }
|
8
|
+
before { allow(subject).to receive(:subtree_already_exists?).and_return(subtree_already_exists?) }
|
11
9
|
|
12
|
-
|
10
|
+
context "when branch is specified in the constructor" do
|
11
|
+
subject { Arborist.new "foo/bar", "git@github.com:New-Bamboo/vendorise.git", "development" }
|
12
|
+
|
13
|
+
it "makes #subtree_command use that branch" do
|
14
|
+
expect(subject.subtree_command).to eq "git subtree add --prefix foo/bar git@github.com:New-Bamboo/vendorise.git development --squash"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe :subtree_already_exists? do
|
19
|
+
subject { Arborist.new "foo/bar", "git@github.com:New-Bamboo/vendorise.git", "master" }
|
20
|
+
|
21
|
+
context "is false" do
|
22
|
+
it "makes #subtree_command use 'git subtree add'" do
|
13
23
|
expect(subject.subtree_command).to eq "git subtree add --prefix foo/bar git@github.com:New-Bamboo/vendorise.git master --squash"
|
14
24
|
end
|
15
25
|
end
|
16
26
|
|
17
|
-
context "
|
18
|
-
|
27
|
+
context "is true" do
|
28
|
+
let(:subtree_already_exists?) { true }
|
19
29
|
|
20
|
-
it "
|
30
|
+
it "makes #subtree_command use 'git subtree pull'" do
|
21
31
|
expect(subject.subtree_command).to eq "git subtree pull --prefix foo/bar git@github.com:New-Bamboo/vendorise.git master --squash"
|
22
32
|
end
|
23
33
|
end
|
@@ -10,17 +10,7 @@ module Vendorise
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it "accepts a url argument" do
|
13
|
-
expect(task.arg_names).to match_array [:url]
|
14
|
-
end
|
15
|
-
|
16
|
-
it "creates a new arborist and passes it's command to system" do
|
17
|
-
fake_arborist = double("Arborist", subtree_command: "touch foo.tmp")
|
18
|
-
allow(Vendorise::Arborist).to receive(:new).with("vendor/gems/vendorise", "git@github.com:New-Bamboo/vendorise.git").and_return(fake_arborist)
|
19
|
-
|
20
|
-
task.invoke("git@github.com:New-Bamboo/vendorise.git")
|
21
|
-
|
22
|
-
expect(File.exist?("foo.tmp")).to be true
|
23
|
-
File.delete("foo.tmp")
|
13
|
+
expect(task.arg_names).to match_array [:url, :branch]
|
24
14
|
end
|
25
15
|
end
|
26
16
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative "../spec_helper"
|
2
|
+
require_relative "../../lib/vendorise"
|
3
|
+
|
4
|
+
describe "vendorise" do
|
5
|
+
it "adds a rake task to run git subtree", :clear_mocks do
|
6
|
+
expect_any_instance_of(Rake::FileUtilsExt).to receive(:sh).with("git subtree add --prefix vendor/gems/sinatra git@github.com:sinatra/sinatra.git master --squash")
|
7
|
+
Rake.application.invoke_task "vendorise:gem[git@github.com:sinatra/sinatra.git]"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "uses the (optional) second argument to select the branch", :clear_mocks do
|
11
|
+
expect_any_instance_of(Rake::FileUtilsExt).to receive(:sh).with("git subtree add --prefix vendor/gems/sinatra git@github.com:sinatra/sinatra.git 1.3.x --squash")
|
12
|
+
Rake.application.invoke_task "vendorise:gem[git@github.com:sinatra/sinatra.git, 1.3.x]"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -2,4 +2,13 @@ RSpec.configure do |config|
|
|
2
2
|
config.order = 'random'
|
3
3
|
config.expect_with(:rspec){ |c| c.syntax = :expect }
|
4
4
|
config.mock_with(:rspec){ |c| c.syntax = :expect }
|
5
|
+
|
6
|
+
# don't complain that I'm using symbols as metadata...
|
7
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
8
|
+
# reseting the mock space doesn't seem to work on jruby
|
9
|
+
config.filter_run_excluding :clear_mocks if RUBY_ENGINE == "jruby"
|
10
|
+
config.after(:each, :clear_mocks) do
|
11
|
+
# expect_any_instance_of hangs around between specs
|
12
|
+
RSpec::Mocks.space.reset_all
|
13
|
+
end
|
5
14
|
end
|
data/vendorise.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["iain.beeston@gmail.com"]
|
11
11
|
spec.description = %q{A reusable rake task to vendorise a gem hosted in a private git repo}
|
12
12
|
spec.summary = %q{Uses git subtree to download the source for a gem into /vendor/gems}
|
13
|
-
spec.homepage = "http://github.com/
|
13
|
+
spec.homepage = "http://github.com/iainbeeston/vendorise"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vendorise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Iain Beeston
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -73,9 +73,10 @@ files:
|
|
73
73
|
- spec/lib/vendorise/arborist_spec.rb
|
74
74
|
- spec/lib/vendorise/parser_spec.rb
|
75
75
|
- spec/lib/vendorise/tasks_spec.rb
|
76
|
+
- spec/lib/vendorise_spec.rb
|
76
77
|
- spec/spec_helper.rb
|
77
78
|
- vendorise.gemspec
|
78
|
-
homepage: http://github.com/
|
79
|
+
homepage: http://github.com/iainbeeston/vendorise
|
79
80
|
licenses:
|
80
81
|
- MIT
|
81
82
|
metadata: {}
|
@@ -103,4 +104,5 @@ test_files:
|
|
103
104
|
- spec/lib/vendorise/arborist_spec.rb
|
104
105
|
- spec/lib/vendorise/parser_spec.rb
|
105
106
|
- spec/lib/vendorise/tasks_spec.rb
|
107
|
+
- spec/lib/vendorise_spec.rb
|
106
108
|
- spec/spec_helper.rb
|