gjp 0.11.1 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/lib/gjp/cli.rb +23 -27
- data/lib/gjp/jar_table.rb +1 -3
- data/lib/gjp/limited_network_user.rb +1 -3
- data/lib/gjp/logger.rb +18 -8
- data/lib/gjp/maven_runner.rb +1 -3
- data/lib/gjp/maven_website.rb +1 -3
- data/lib/gjp/parent_pom_getter.rb +2 -5
- data/lib/gjp/pom_getter.rb +9 -11
- data/lib/gjp/project.rb +104 -77
- data/lib/gjp/source_address_getter.rb +5 -7
- data/lib/gjp/source_getter.rb +11 -11
- data/lib/gjp/version.rb +1 -1
- data/lib/gjp/version_matcher.rb +4 -6
- data/lib/template/file_lists/CONTENTS +3 -0
- data/lib/template/kit/CONTENTS +9 -0
- data/lib/template/kit/m2/settings.xml +257 -0
- data/lib/template/src/CONTENTS +13 -0
- data/spec/lib/limited_network_user_spec_interactive.rb +3 -4
- data/spec/lib/maven_website_spec.rb +0 -1
- data/spec/lib/parent_pom_getter_spec.rb +4 -2
- data/spec/lib/pom_getter_spec.rb +7 -5
- data/spec/lib/project_spec.rb +43 -54
- data/spec/lib/source_address_getter_spec.rb +5 -3
- data/spec/lib/source_getter_spec.rb +6 -4
- data/spec/lib/version_matcher_spec.rb +58 -51
- data/spec/spec_helper.rb +2 -6
- metadata +6 -2
@@ -3,12 +3,14 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Gjp::ParentPomGetter do
|
6
|
-
|
6
|
+
let(:parent_pom_getter) { Gjp::ParentPomGetter.new }
|
7
|
+
|
8
|
+
describe "#get_parent_pom" do
|
7
9
|
it "gets the the parent of a pom" do
|
8
10
|
dir_path = File.join("spec", "data", "commons-logging")
|
9
11
|
pom_path = File.join(dir_path, "pom.xml")
|
10
12
|
parent_pom_path = File.join(dir_path, "parent_pom.xml")
|
11
|
-
|
13
|
+
parent_pom_getter.get_parent_pom(pom_path).should eq(File.read(parent_pom_path))
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
data/spec/lib/pom_getter_spec.rb
CHANGED
@@ -3,32 +3,34 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Gjp::PomGetter do
|
6
|
-
|
6
|
+
let(:pom_getter) { Gjp::PomGetter.new }
|
7
|
+
|
8
|
+
describe "#get_pom" do
|
7
9
|
it "gets the pom from a directory" do
|
8
10
|
dir_path = File.join("spec", "data", "commons-logging")
|
9
11
|
pom_path = File.join(dir_path, "pom.xml")
|
10
|
-
|
12
|
+
pom_getter.get_pom(dir_path).should eq(File.read(pom_path))
|
11
13
|
end
|
12
14
|
|
13
15
|
it "gets the pom from a jar" do
|
14
16
|
dir_path = File.join("spec", "data", "commons-logging")
|
15
17
|
pom_path = File.join(dir_path, "pom.xml")
|
16
18
|
jar_path = File.join(dir_path, "commons-logging-1.1.1.jar")
|
17
|
-
|
19
|
+
pom_getter.get_pom(jar_path).should eq(File.read(pom_path))
|
18
20
|
end
|
19
21
|
|
20
22
|
it "gets the pom from sha1" do
|
21
23
|
dir_path = File.join("spec", "data", "antlr")
|
22
24
|
pom_path = File.join(dir_path, "pom.xml")
|
23
25
|
jar_path = File.join(dir_path, "antlr-2.7.2.jar")
|
24
|
-
|
26
|
+
pom_getter.get_pom(jar_path).should eq(File.read(pom_path))
|
25
27
|
end
|
26
28
|
|
27
29
|
it "gets the pom from a heuristic" do
|
28
30
|
dir_path = File.join("spec", "data", "nailgun")
|
29
31
|
pom_path = File.join(dir_path, "pom.xml")
|
30
32
|
jar_path = File.join(dir_path, "nailgun-0.7.1.jar")
|
31
|
-
|
33
|
+
pom_getter.get_pom(jar_path).should eq(File.read(pom_path))
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
data/spec/lib/project_spec.rb
CHANGED
@@ -50,139 +50,128 @@ describe Gjp::Project do
|
|
50
50
|
Dir.exists?(src_path).should be_true
|
51
51
|
|
52
52
|
@project.from_directory do
|
53
|
-
|
54
|
-
`git rev-list --all`.split("\n").length.should eq
|
53
|
+
@project.latest_snapshot_name.should eq "gjp_revertable_snapshot_1"
|
54
|
+
`git rev-list --all`.split("\n").length.should eq 2
|
55
55
|
end
|
56
|
+
|
57
|
+
@project.get_status.should eq :gathering
|
56
58
|
end
|
57
59
|
end
|
58
60
|
|
59
|
-
describe "
|
61
|
+
describe "#set_status" do
|
60
62
|
it "stores a project's status flag" do
|
61
63
|
@project.from_directory do
|
62
|
-
@project.set_status
|
64
|
+
@project.set_status :gathering
|
63
65
|
File.exists?(".gathering").should be_true
|
64
66
|
end
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
68
|
-
describe "
|
70
|
+
describe "#get_status" do
|
69
71
|
it "gets a project's status flag" do
|
70
72
|
@project.from_directory do
|
71
|
-
@project.get_status
|
72
|
-
|
73
|
-
@project.get_status
|
73
|
+
@project.get_status.should eq :gathering
|
74
|
+
@project.set_status nil
|
75
|
+
@project.get_status.should be_nil
|
74
76
|
end
|
75
77
|
end
|
76
78
|
end
|
77
79
|
|
78
|
-
describe "
|
79
|
-
it "clears a project's status flag" do
|
80
|
-
@project.from_directory do
|
81
|
-
`touch .gathering`
|
82
|
-
@project.get_status(:gathering).should be_true
|
83
|
-
|
84
|
-
@project.clear_status(:gathering)
|
85
|
-
@project.get_status(:gathering).should be_false
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe ".commit_all" do
|
80
|
+
describe "#take_snapshot" do
|
91
81
|
it "commits the project contents to git for later use" do
|
92
82
|
@project.from_directory do
|
93
83
|
`touch kit/test`
|
94
84
|
|
95
|
-
@project.
|
85
|
+
@project.take_snapshot "test", :revertable
|
96
86
|
|
97
|
-
`git rev-list --all`.split("\n").length.should eq
|
87
|
+
`git rev-list --all`.split("\n").length.should eq 3
|
88
|
+
@project.latest_snapshot_name.should eq "gjp_revertable_snapshot_2"
|
98
89
|
end
|
99
90
|
end
|
100
91
|
end
|
101
92
|
|
102
|
-
describe "
|
93
|
+
describe "#gather" do
|
103
94
|
it "starts a gathering phase" do
|
95
|
+
@project.finish.should eq :gathering
|
104
96
|
|
105
97
|
@project.from_directory do
|
106
98
|
`touch src/test`
|
107
99
|
end
|
108
100
|
|
109
|
-
@project.gather.should
|
101
|
+
@project.gather.should be_true
|
110
102
|
|
111
103
|
@project.from_directory do
|
112
|
-
@project.get_status
|
113
|
-
`git rev-list --all`.split("\n").length.should eq
|
104
|
+
@project.get_status.should eq :gathering
|
105
|
+
`git rev-list --all`.split("\n").length.should eq 5
|
114
106
|
`git diff-tree --no-commit-id --name-only -r HEAD`.split("\n").should include("src/test")
|
115
107
|
end
|
116
108
|
end
|
117
109
|
end
|
118
110
|
|
119
|
-
describe "
|
111
|
+
describe "#finish" do
|
120
112
|
it "ends the current gathering phase" do
|
121
|
-
@project.gather.should eq :done
|
122
|
-
|
123
113
|
@project.from_directory do
|
124
|
-
Dir.mkdir("src/
|
125
|
-
`touch src/
|
114
|
+
Dir.mkdir("src/a:b:c")
|
115
|
+
`touch src/a\:b\:c/test`
|
126
116
|
`touch kit/test`
|
127
117
|
end
|
128
118
|
|
129
119
|
@project.finish.should eq :gathering
|
130
|
-
@project.get_status
|
120
|
+
@project.get_status.should be_nil
|
131
121
|
|
132
122
|
@project.from_directory do
|
133
123
|
`git rev-list --all`.split("\n").length.should eq 5
|
134
|
-
`git diff-tree --no-commit-id --name-only -r HEAD~2`.split("\n").should include("src/
|
135
|
-
File.readlines("
|
136
|
-
File.readlines("
|
124
|
+
`git diff-tree --no-commit-id --name-only -r HEAD~2`.split("\n").should include("src/a:b:c/test")
|
125
|
+
File.readlines(File.join("file_lists", "a:b:c_input")).should include("test\n")
|
126
|
+
File.readlines(File.join("file_lists","kit")).should include("test\n")
|
137
127
|
end
|
138
128
|
end
|
139
129
|
|
140
130
|
it "ends the current dry-run phase" do
|
141
|
-
@project.gather.should eq :done
|
142
|
-
|
143
131
|
@project.from_directory do
|
144
|
-
Dir.mkdir("src/
|
145
|
-
`echo A > src/
|
132
|
+
Dir.mkdir("src/a:b:c")
|
133
|
+
`echo A > src/a\:b\:c/test`
|
146
134
|
end
|
147
135
|
|
148
136
|
@project.finish.should eq :gathering
|
149
137
|
|
150
|
-
@project.dry_run.should
|
138
|
+
@project.dry_run.should be_true
|
151
139
|
|
152
140
|
@project.from_directory do
|
153
|
-
`echo B > src/
|
154
|
-
`touch src/
|
141
|
+
`echo B > src/a\:b\:c/test`
|
142
|
+
`touch src/a\:b\:c/test2`
|
155
143
|
`touch kit/test`
|
156
144
|
end
|
157
145
|
|
158
146
|
@project.finish.should eq :dry_running
|
159
|
-
@project.get_status
|
147
|
+
@project.get_status.should be_nil
|
160
148
|
|
161
149
|
@project.from_directory do
|
162
150
|
`git rev-list --all`.split("\n").length.should eq 10
|
163
|
-
File.read("src/
|
164
|
-
File.readlines("
|
165
|
-
File.readlines("
|
151
|
+
File.read("src/a:b:c/test").should eq "A\n"
|
152
|
+
File.readlines(File.join("file_lists", "a:b:c_output")).should include("test2\n")
|
153
|
+
File.readlines(File.join("file_lists", "a:b:c_input")).should_not include("test2\n")
|
166
154
|
|
167
|
-
`git diff-tree --no-commit-id --name-only -r HEAD~2`.split("\n").should_not include("src/
|
168
|
-
File.exists?("src/
|
169
|
-
File.readlines("
|
155
|
+
`git diff-tree --no-commit-id --name-only -r HEAD~2`.split("\n").should_not include("src/a:b:c/test2")
|
156
|
+
File.exists?("src/a:b:c/test2").should be_false
|
157
|
+
File.readlines(File.join("file_lists", "kit")).should include("test\n")
|
170
158
|
end
|
171
159
|
end
|
172
160
|
end
|
173
161
|
|
174
|
-
describe "
|
162
|
+
describe "#dry_run" do
|
175
163
|
it "starts a dry running phase" do
|
164
|
+
@project.finish.should eq :gathering
|
176
165
|
|
177
166
|
@project.from_directory do
|
178
167
|
`touch src/test`
|
179
168
|
end
|
180
169
|
|
181
|
-
@project.dry_run.should
|
170
|
+
@project.dry_run.should be_true
|
182
171
|
|
183
172
|
@project.from_directory do
|
184
|
-
@project.get_status
|
185
|
-
`git rev-list --all`.split("\n").length.should eq
|
173
|
+
@project.get_status.should eq :dry_running
|
174
|
+
`git rev-list --all`.split("\n").length.should eq 5
|
186
175
|
`git diff-tree --no-commit-id --name-only -r HEAD`.split("\n").should include("src/test")
|
187
176
|
end
|
188
177
|
end
|
@@ -3,15 +3,17 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Gjp::SourceAddressGetter do
|
6
|
-
|
6
|
+
let(:source_address_getter) { Gjp::SourceAddressGetter.new }
|
7
|
+
|
8
|
+
describe "#get_source_address" do
|
7
9
|
it "gets the source address from a pom file" do
|
8
10
|
pom_path = File.join("spec", "data", "commons-logging", "pom.xml")
|
9
|
-
|
11
|
+
source_address_getter.get_source_address(pom_path).should eq "svn:http://svn.apache.org/repos/asf/commons/proper/logging/tags/commons-logging-1.1.1"
|
10
12
|
end
|
11
13
|
|
12
14
|
it "gets the source address from Github" do
|
13
15
|
pom_path = File.join("spec", "data", "antlr", "pom.xml")
|
14
|
-
|
16
|
+
source_address_getter.get_source_address(pom_path).should eq "git:https://github.com/antlr/antlr4"
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -4,7 +4,9 @@ require "spec_helper"
|
|
4
4
|
require "fileutils"
|
5
5
|
|
6
6
|
describe Gjp::SourceGetter do
|
7
|
-
|
7
|
+
let(:source_getter) { Gjp::SourceGetter.new }
|
8
|
+
|
9
|
+
describe "#get_source_from_git" do
|
8
10
|
it "gets the sources from a git repo" do
|
9
11
|
dir_path = File.join("spec", "data", "nailgun")
|
10
12
|
pom_path = File.join(dir_path, "pom.xml")
|
@@ -13,13 +15,13 @@ describe Gjp::SourceGetter do
|
|
13
15
|
|
14
16
|
FileUtils.rm_rf(repo_path)
|
15
17
|
|
16
|
-
|
18
|
+
source_getter.get_source("git:git@github.com:martylamb/nailgun.git", pom_path, dir_path)
|
17
19
|
|
18
20
|
File.open(file_path).readline.should eq "nailgun\n"
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
|
-
describe "
|
24
|
+
describe "#get_source_from_svn" do
|
23
25
|
it "gets the sources from an svn repo" do
|
24
26
|
dir_path = File.join("spec", "data", "struts-apps")
|
25
27
|
pom_path = File.join(dir_path, "pom.xml")
|
@@ -28,7 +30,7 @@ describe Gjp::SourceGetter do
|
|
28
30
|
|
29
31
|
FileUtils.rm_rf(repo_path)
|
30
32
|
|
31
|
-
|
33
|
+
source_getter.get_source("svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_14/apps", pom_path, dir_path)
|
32
34
|
|
33
35
|
File.open(file_path).readline.should eq "README.txt - showcase\n"
|
34
36
|
end
|
@@ -3,56 +3,63 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Gjp::VersionMatcher do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
6
|
+
let(:version_matcher) { Gjp::VersionMatcher.new }
|
7
|
+
|
8
|
+
describe "#split_version" do
|
9
|
+
it "splits full names into names and version numbers" do
|
10
|
+
version_matcher.split_version("moio-3.2beta1").should eq(["moio", "3.2beta1"])
|
11
|
+
version_matcher.split_version("3.2beta1").should eq(["", "3.2beta1"])
|
12
|
+
version_matcher.split_version("v3.2beta1").should eq(["v", "3.2beta1"])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#chunk_distance" do
|
17
|
+
it "computes chunk distances" do
|
18
|
+
version_matcher.chunk_distance(nil, "1").should eq(1)
|
19
|
+
version_matcher.chunk_distance("alpha", nil).should eq(5)
|
20
|
+
|
21
|
+
version_matcher.chunk_distance("1", "1").should eq(0)
|
22
|
+
version_matcher.chunk_distance("1", "9").should eq(8)
|
23
|
+
version_matcher.chunk_distance("1", "999").should eq(99)
|
24
|
+
|
25
|
+
version_matcher.chunk_distance("snap", "SNAP").should eq(0)
|
26
|
+
version_matcher.chunk_distance("snap", "snippete").should eq(5)
|
27
|
+
version_matcher.chunk_distance("snap", "l"*999).should eq(99)
|
28
|
+
|
29
|
+
version_matcher.chunk_distance("1", "SNAP").should eq(4)
|
30
|
+
|
31
|
+
version_matcher.chunk_distance("0", "10").should eq(10)
|
32
|
+
version_matcher.chunk_distance("0", "9").should eq(9)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#best_match" do
|
37
|
+
it "finds the best match" do
|
38
|
+
my_version = "1.0"
|
39
|
+
available_versions = ["1.0", "1", "2.0", "1.0.1", "4.5.6.7.8"]
|
40
|
+
version_matcher.best_match(my_version, available_versions).should eq("1.0")
|
41
|
+
|
42
|
+
available_versions = ["3.0", "2.0", "1.0.1"]
|
43
|
+
version_matcher.best_match(my_version, available_versions).should eq("1.0.1")
|
44
|
+
|
45
|
+
available_versions = ["1.snap", "2.0", "4.0.1"]
|
46
|
+
version_matcher.best_match(my_version, available_versions).should eq("1.snap")
|
47
|
+
|
48
|
+
available_versions = ["1.10", "1.9", "2.0", "3.0.1"]
|
49
|
+
version_matcher.best_match(my_version, available_versions).should eq("1.9")
|
50
|
+
|
51
|
+
my_version = "1.snap"
|
52
|
+
available_versions = ["1.snap", "1"]
|
53
|
+
version_matcher.best_match(my_version, available_versions).should eq("1.snap")
|
54
|
+
|
55
|
+
my_version = "1.very-very_very_longish"
|
56
|
+
available_versions = ["1.snap", "1"]
|
57
|
+
version_matcher.best_match(my_version, available_versions).should eq("1.snap")
|
58
|
+
|
59
|
+
my_version = "1.snap"
|
60
|
+
available_versions = []
|
61
|
+
version_matcher.best_match(my_version, available_versions).should be_nil
|
62
|
+
end
|
63
|
+
end
|
57
64
|
end
|
58
65
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require "gjp"
|
4
|
-
require "logger"
|
4
|
+
require "gjp/logger"
|
5
5
|
|
6
|
-
Gjp.
|
7
|
-
Gjp.logger.level = ::Logger::DEBUG
|
8
|
-
Gjp.logger.formatter = proc do |severity, datetime, progname, msg|
|
9
|
-
"#{severity.chars.first}: #{msg}\n"
|
10
|
-
end
|
6
|
+
Gjp::Logger.log.level = ::Logger::DEBUG
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gjp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -170,6 +170,10 @@ files:
|
|
170
170
|
- lib/gjp/source_getter.rb
|
171
171
|
- lib/gjp/version.rb
|
172
172
|
- lib/gjp/version_matcher.rb
|
173
|
+
- lib/template/file_lists/CONTENTS
|
174
|
+
- lib/template/kit/CONTENTS
|
175
|
+
- lib/template/kit/m2/settings.xml
|
176
|
+
- lib/template/src/CONTENTS
|
173
177
|
- spec/data/ant-super-simple-code/build.xml
|
174
178
|
- spec/data/ant-super-simple-code/build/HW.class
|
175
179
|
- spec/data/ant-super-simple-code/build/mypackage/HW.class
|