gondler 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +2 -0
- data/lib/gondler/cli.rb +2 -0
- data/lib/gondler/env.rb +5 -0
- data/lib/gondler/gomfile.rb +28 -0
- data/lib/gondler/package.rb +42 -9
- data/lib/gondler/version.rb +1 -1
- data/spec/gondler/gomfile_spec.rb +40 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a4bbc74994c0cd4aeeba7733ca38b6682e97edb
|
4
|
+
data.tar.gz: dfb30ba73178a52fd6a6f98852db63a641e2074e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 990993d6c905170bfee5aa5bf7fe32ff146e571effc4090fe3e7a30f7b4a3d1fd60427d94dfd67eb6f571e04b1fed8baa9f7a6f039f865b73781f7accaeea456
|
7
|
+
data.tar.gz: abaa9acd45bd9b22e279fff1045aea87dc95ee42e77617a7c9fa79752c3c81db43c4582256f1075d02c9235196faa2c607521517082530ffb6d9f6ccf0d37362
|
data/Gemfile
CHANGED
data/README.md
CHANGED
data/lib/gondler/cli.rb
CHANGED
data/lib/gondler/env.rb
CHANGED
data/lib/gondler/gomfile.rb
CHANGED
@@ -5,12 +5,40 @@ module Gondler
|
|
5
5
|
def initialize(path)
|
6
6
|
raise NotFound, path unless File.exist?(path)
|
7
7
|
@packages = []
|
8
|
+
@itself = nil
|
8
9
|
|
9
10
|
load(path)
|
10
11
|
end
|
11
12
|
attr_reader :packages
|
12
13
|
|
14
|
+
def itself(name)
|
15
|
+
@itself = name
|
16
|
+
end
|
17
|
+
|
18
|
+
def itself_package
|
19
|
+
if !@itself && Gondler.env.orig_path
|
20
|
+
realpath = proc do |path|
|
21
|
+
if File.respond_to?(:realpath) # 1.9+
|
22
|
+
File.realpath(path)
|
23
|
+
else
|
24
|
+
path
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
orig_src = realpath[File.join(Gondler.env.orig_path, 'src')]
|
29
|
+
dir = realpath[File.dirname(@path)]
|
30
|
+
if dir.start_with?(orig_src)
|
31
|
+
@itself = dir[orig_src.size.succ .. -1]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
if @itself
|
36
|
+
Gondler::Package.new(@itself, :path => '.')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
13
40
|
def load(path)
|
41
|
+
@path = File.expand_path(path)
|
14
42
|
instance_eval(File.read(path))
|
15
43
|
end
|
16
44
|
|
data/lib/gondler/package.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'English'
|
2
|
+
require 'pathname'
|
2
3
|
|
3
4
|
module Gondler
|
4
5
|
class Package
|
@@ -14,8 +15,11 @@ module Gondler
|
|
14
15
|
@group = options[:group]
|
15
16
|
@fix = options[:fix] || false
|
16
17
|
@flag = options[:flag]
|
18
|
+
@path = options[:path]
|
17
19
|
end
|
18
20
|
|
21
|
+
attr_reader :name, :branch, :tag, :commit, :os, :group, :fix, :flag, :path
|
22
|
+
|
19
23
|
def os
|
20
24
|
case @os
|
21
25
|
when String
|
@@ -56,19 +60,14 @@ module Gondler
|
|
56
60
|
end
|
57
61
|
|
58
62
|
def get
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
result = `#{args.join(' ')} 2>&1`
|
64
|
-
|
65
|
-
unless $CHILD_STATUS.success?
|
66
|
-
raise InstallError.new("#{@name} download error\n" + result)
|
63
|
+
if @path
|
64
|
+
get_by_path
|
65
|
+
else
|
66
|
+
get_by_package
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
def checkout
|
71
|
-
src_path = Pathname.new(Gondler.env.path) + 'src'
|
72
71
|
@name.split('/').reduce(src_path) do |path, dir|
|
73
72
|
path += dir
|
74
73
|
if File.directory?(path + '.git')
|
@@ -107,5 +106,39 @@ module Gondler
|
|
107
106
|
def to_s
|
108
107
|
"#{@name}" + (target ? " (#{target})" : '')
|
109
108
|
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def env_path
|
113
|
+
Pathname.new(Gondler.env.path)
|
114
|
+
end
|
115
|
+
|
116
|
+
def src_path
|
117
|
+
env_path + 'src'
|
118
|
+
end
|
119
|
+
|
120
|
+
def get_by_path
|
121
|
+
target = src_path.join(@name)
|
122
|
+
FileUtils.mkdir_p(target.dirname)
|
123
|
+
FileUtils.remove_entry_secure(target) if target.exist?
|
124
|
+
if @path.to_s.start_with?('/') # absolute path
|
125
|
+
source = @path
|
126
|
+
else # relative path from Gomfile
|
127
|
+
source = env_path.dirname.join(@path).relative_path_from(target.dirname)
|
128
|
+
end
|
129
|
+
File.symlink(source, target)
|
130
|
+
end
|
131
|
+
|
132
|
+
def get_by_package
|
133
|
+
args = %w(go get -d -u)
|
134
|
+
args << '-fix' if @fix
|
135
|
+
args << @name
|
136
|
+
|
137
|
+
result = `#{args.join(' ')} 2>&1`
|
138
|
+
|
139
|
+
unless $CHILD_STATUS.success?
|
140
|
+
raise InstallError.new("#{@name} download error\n" + result)
|
141
|
+
end
|
142
|
+
end
|
110
143
|
end
|
111
144
|
end
|
data/lib/gondler/version.rb
CHANGED
@@ -1,17 +1,28 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
|
2
|
+
|
3
|
+
require 'tmpdir'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'pathname'
|
3
6
|
|
4
7
|
describe Gondler::Gomfile do
|
5
|
-
let(:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
8
|
+
let(:tmpdir) { Dir.mktmpdir("gondler-gomfile-spec") }
|
9
|
+
after { FileUtils.remove_entry_secure(tmpdir) }
|
10
|
+
|
11
|
+
let(:package_dir) do
|
12
|
+
Pathname.new(tmpdir).join('src', 'example.com', 'test').tap(&:mkpath)
|
11
13
|
end
|
12
|
-
|
14
|
+
|
15
|
+
let(:path) { package_dir.join('Gomfile') }
|
13
16
|
let(:content) { '' }
|
14
|
-
|
17
|
+
|
18
|
+
let(:gomfile) do
|
19
|
+
open(path, 'w') { |io| io.write content }
|
20
|
+
described_class.new(path)
|
21
|
+
end
|
22
|
+
|
23
|
+
before do
|
24
|
+
allow(Gondler.env).to receive(:orig_path) { tmpdir }
|
25
|
+
end
|
15
26
|
|
16
27
|
describe '#initialize' do
|
17
28
|
let(:path) { 'Gomfile' }
|
@@ -66,4 +77,24 @@ describe Gondler::Gomfile do
|
|
66
77
|
expect(gomfile.packages.first.os).to eq(%w(darwin linux))
|
67
78
|
end
|
68
79
|
end
|
80
|
+
|
81
|
+
describe "#itself_package" do
|
82
|
+
subject(:package) { gomfile.itself_package }
|
83
|
+
|
84
|
+
it "returns package for Gomfile's repo" do
|
85
|
+
expect(package.name).to eq 'example.com/test'
|
86
|
+
expect(package.path).to eq '.'
|
87
|
+
end
|
88
|
+
|
89
|
+
context "with itself(...)" do
|
90
|
+
before do
|
91
|
+
gomfile.itself 'example.org/test2'
|
92
|
+
end
|
93
|
+
|
94
|
+
it "returns package for Gomfile's repo, but different dir" do
|
95
|
+
expect(package.name).to eq 'example.org/test2'
|
96
|
+
expect(package.path).to eq '.'
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
69
100
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gondler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Kusano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
version: '0'
|
89
89
|
requirements: []
|
90
90
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.2.
|
91
|
+
rubygems_version: 2.2.2
|
92
92
|
signing_key:
|
93
93
|
specification_version: 4
|
94
94
|
summary: bundler for golang
|