gjp 0.11.1 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,6 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Gjp::MavenWebsite do
6
-
7
6
  let(:site) { Gjp::MavenWebsite.new }
8
7
 
9
8
  describe "#search_by_sha1" do
@@ -3,12 +3,14 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Gjp::ParentPomGetter do
6
- describe ".get_parent_pom" do
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
- Gjp::ParentPomGetter.get_parent_pom(pom_path).should eq(File.read(parent_pom_path))
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
@@ -3,32 +3,34 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Gjp::PomGetter do
6
- describe ".get_pom" do
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
- Gjp::PomGetter.get_pom(dir_path).should eq(File.read(pom_path))
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
- Gjp::PomGetter.get_pom(jar_path).should eq(File.read(pom_path))
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
- Gjp::PomGetter.get_pom(jar_path).should eq(File.read(pom_path))
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
- Gjp::PomGetter.get_pom(jar_path).should eq(File.read(pom_path))
33
+ pom_getter.get_pom(jar_path).should eq(File.read(pom_path))
32
34
  end
33
35
  end
34
36
  end
@@ -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
- `git tag`.strip.should eq("init")
54
- `git rev-list --all`.split("\n").length.should eq 1
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 ".set_status" do
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(:gathering)
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 ".get_status" do
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(:gathering).should be_false
72
- `touch .gathering`
73
- @project.get_status(:gathering).should be_true
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 ".clear_status" do
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.commit_all "test"
85
+ @project.take_snapshot "test", :revertable
96
86
 
97
- `git rev-list --all`.split("\n").length.should eq 2
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 ".gather" do
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 eq :done
101
+ @project.gather.should be_true
110
102
 
111
103
  @project.from_directory do
112
- @project.get_status(:gathering).should be_true
113
- `git rev-list --all`.split("\n").length.should eq 2
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 ".finish" do
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/a_b_c")
125
- `touch src/a_b_c/test`
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(:gathering).should be_false
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/a_b_c/test")
135
- File.readlines("gjp_a_b_c_file_list").should include("test\n")
136
- File.readlines("gjp_kit_file_list").should include("test\n")
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/a_b_c")
145
- `echo A > src/a_b_c/test`
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 eq :done
138
+ @project.dry_run.should be_true
151
139
 
152
140
  @project.from_directory do
153
- `echo B > src/a_b_c/test`
154
- `touch src/a_b_c/test2`
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(:dry_running).should be_false
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/a_b_c/test").should eq "A\n"
164
- File.readlines("gjp_a_b_c_produced_file_list").should include("test2\n")
165
- File.readlines("gjp_a_b_c_file_list").should_not include("test2\n")
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/a_b_c/test2")
168
- File.exists?("src/a_b_c/test2").should be_false
169
- File.readlines("gjp_kit_file_list").should include("test\n")
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 ".dry_run" do
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 eq :done
170
+ @project.dry_run.should be_true
182
171
 
183
172
  @project.from_directory do
184
- @project.get_status(:dry_running).should be_true
185
- `git rev-list --all`.split("\n").length.should eq 2
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
- describe ".get_source_address" do
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
- Gjp::SourceAddressGetter.get_source_address(pom_path).should eq "svn:http://svn.apache.org/repos/asf/commons/proper/logging/tags/commons-logging-1.1.1"
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
- Gjp::SourceAddressGetter.get_source_address(pom_path).should eq "git:https://github.com/antlr/antlr4"
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
- describe ".get_source_from_git" do
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
- Gjp::SourceGetter.get_source("git:git@github.com:martylamb/nailgun.git", pom_path, dir_path)
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 ".get_source_from_svn" do
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
- Gjp::SourceGetter.get_source("svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_14/apps", pom_path, dir_path)
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
- it "splits full names into names and version numbers" do
8
- Gjp::VersionMatcher.split_version("moio-3.2beta1").should eq(["moio", "3.2beta1"])
9
- Gjp::VersionMatcher.split_version("3.2beta1").should eq(["", "3.2beta1"])
10
- Gjp::VersionMatcher.split_version("v3.2beta1").should eq(["v", "3.2beta1"])
11
- end
12
-
13
- it "computes chunk distances" do
14
- Gjp::VersionMatcher.chunk_distance(nil, "1").should eq(1)
15
- Gjp::VersionMatcher.chunk_distance("alpha", nil).should eq(5)
16
-
17
- Gjp::VersionMatcher.chunk_distance("1", "1").should eq(0)
18
- Gjp::VersionMatcher.chunk_distance("1", "9").should eq(8)
19
- Gjp::VersionMatcher.chunk_distance("1", "999").should eq(99)
20
-
21
- Gjp::VersionMatcher.chunk_distance("snap", "SNAP").should eq(0)
22
- Gjp::VersionMatcher.chunk_distance("snap", "snippete").should eq(5)
23
- Gjp::VersionMatcher.chunk_distance("snap", "l"*999).should eq(99)
24
-
25
- Gjp::VersionMatcher.chunk_distance("1", "SNAP").should eq(4)
26
-
27
- Gjp::VersionMatcher.chunk_distance("0", "10").should eq(10)
28
- Gjp::VersionMatcher.chunk_distance("0", "9").should eq(9)
29
- end
30
-
31
- it "finds the best match" do
32
- my_version = "1.0"
33
- available_versions = ["1.0", "1", "2.0", "1.0.1", "4.5.6.7.8"]
34
- Gjp::VersionMatcher.best_match(my_version, available_versions).should eq("1.0")
35
-
36
- available_versions = ["3.0", "2.0", "1.0.1"]
37
- Gjp::VersionMatcher.best_match(my_version, available_versions).should eq("1.0.1")
38
-
39
- available_versions = ["1.snap", "2.0", "4.0.1"]
40
- Gjp::VersionMatcher.best_match(my_version, available_versions).should eq("1.snap")
41
-
42
- available_versions = ["1.10", "1.9", "2.0", "3.0.1"]
43
- Gjp::VersionMatcher.best_match(my_version, available_versions).should eq("1.9")
44
-
45
- my_version = "1.snap"
46
- available_versions = ["1.snap", "1"]
47
- Gjp::VersionMatcher.best_match(my_version, available_versions).should eq("1.snap")
48
-
49
- my_version = "1.very-very_very_longish"
50
- available_versions = ["1.snap", "1"]
51
- Gjp::VersionMatcher.best_match(my_version, available_versions).should eq("1.snap")
52
-
53
- my_version = "1.snap"
54
- available_versions = []
55
- Gjp::VersionMatcher.best_match(my_version, available_versions).should be_nil
56
- end
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
 
@@ -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.logger = ::Logger.new(STDERR)
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.1
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-09 00:00:00.000000000 Z
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