pangolin 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +13 -0
- data/README.rdoc +72 -0
- data/Rakefile +40 -0
- data/VERSION +1 -0
- data/examples/compile/Rakefile +16 -0
- data/examples/compile/src/com/example/HelloWorld.java +10 -0
- data/examples/package/Rakefile +24 -0
- data/examples/package/src/com/example/HelloWorld.java +10 -0
- data/examples/test/Rakefile +21 -0
- data/examples/test/src/com/example/HelloWorld.java +10 -0
- data/examples/test/test/com/example/TestHelloWorld.java +31 -0
- data/java_tools.gemspec +74 -0
- data/lib/pangolin.rb +143 -0
- data/lib/pangolin/jar.rb +179 -0
- data/lib/pangolin/javac.rb +128 -0
- data/lib/pangolin/junit.rb +120 -0
- data/lib/pangolin/output/formatting.rb +65 -0
- data/spec/jar_cmd_spec.rb +121 -0
- data/spec/jar_spec.rb +259 -0
- data/spec/javac_cmd_spec.rb +101 -0
- data/spec/javac_spec.rb +203 -0
- data/spec/junit_cmd_spec.rb +24 -0
- data/spec/junit_spec.rb +24 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +1 -0
- data/tasks/gem.rake +21 -0
- data/tasks/rdoc.rake +10 -0
- data/tasks/spec.rake +9 -0
- metadata +89 -0
data/spec/javac_spec.rb
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
describe Javac do
|
2
|
+
|
3
|
+
before(:each) do
|
4
|
+
@javac = Javac.new
|
5
|
+
end
|
6
|
+
|
7
|
+
describe " defaults" do
|
8
|
+
|
9
|
+
it "should default to an empty array as source path" do
|
10
|
+
@javac.source_path.should be_empty
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should default to using 'build' as destination" do
|
14
|
+
@javac.destination.should == 'build'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should have an empty source files list" do
|
18
|
+
@javac.source_files.should be_empty
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have an empty classpath" do
|
22
|
+
@javac.class_path.should be_empty
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should compile with deprecation warnings" do
|
26
|
+
@javac.deprecation_warnings.should be_true
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have no specified encoding" do
|
30
|
+
@javac.encoding.should be_nil
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should show warnings" do
|
34
|
+
@javac.warnings.should be_true
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#initialize' do
|
40
|
+
|
41
|
+
it "should take the source files as arguments to the constructor" do
|
42
|
+
f1 = 'one/two/three.java'
|
43
|
+
f2 = 'four/five/six.java'
|
44
|
+
|
45
|
+
javac = Javac.new(f1, f2)
|
46
|
+
|
47
|
+
javac.source_files.include?(f1).should be_true
|
48
|
+
javac.source_files.include?(f2).should be_true
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#command_args' do
|
54
|
+
|
55
|
+
it "should include all named source files in the command args" do
|
56
|
+
source_files = ['Main.java', 'com/example/Something.java']
|
57
|
+
|
58
|
+
@javac.source_files = source_files
|
59
|
+
|
60
|
+
source_files.each do |file_name|
|
61
|
+
@javac.command_args.include?(file_name)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should set the sourcepath to include the specified directory, when specified as a one item array" do
|
66
|
+
@javac.source_path = ['path/to/src']
|
67
|
+
|
68
|
+
@javac.command_args.join(' ').should include('-sourcepath path/to/src')
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should set the sourcepath to include the specified directory, when specified as a string" do
|
72
|
+
@javac.source_path = 'path/to/src'
|
73
|
+
|
74
|
+
@javac.command_args.join(' ').should include('-sourcepath path/to/src')
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should set the sourcepath to include the specified directories" do
|
78
|
+
@javac.source_path = ['path/to/src', 'another/path', 'sources']
|
79
|
+
|
80
|
+
@javac.command_args.join(' ').should include('-sourcepath path/to/src:another/path:sources')
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should not add the sourcepath flag if source_path is empty" do
|
84
|
+
@javac.source_path = [ ]
|
85
|
+
|
86
|
+
@javac.command_args.should_not include('-sourcepath')
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should set the destination directory to the specified directory" do
|
90
|
+
@javac.destination = 'path/to/build'
|
91
|
+
|
92
|
+
@javac.command_args.join(' ').should include('-d path/to/build')
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should not add the d flag if destination is nil" do
|
96
|
+
@javac.destination = nil
|
97
|
+
|
98
|
+
@javac.command_args.join(' ').should_not match(/-d\b/)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should not add the d flag if destination is an empty string" do
|
102
|
+
@javac.destination = ""
|
103
|
+
|
104
|
+
@javac.command_args.join(' ').should_not match(/-d\b/)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should not add the d flag if destination is only whitespace" do
|
108
|
+
@javac.destination = " \t"
|
109
|
+
|
110
|
+
@javac.command_args.join(' ').should_not match(/-d\b/)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should set the deprecation flag when deprecation_warnings is true" do
|
114
|
+
@javac.deprecation_warnings = true
|
115
|
+
|
116
|
+
@javac.command_args.should include('-deprecation')
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should not set the deprecation flag when deprecation_warnings is false" do
|
120
|
+
@javac.deprecation_warnings = false
|
121
|
+
|
122
|
+
@javac.command_args.should_not include('-deprecation')
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should set the classpath to the specified directory, when specified as a one item array" do
|
126
|
+
@javac.class_path = ['path/to/classes']
|
127
|
+
|
128
|
+
@javac.command_args.join(' ').should include('-classpath path/to/classes')
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should set the classpath to the specified directory, when specified as a string" do
|
132
|
+
@javac.class_path = 'path/to/classes'
|
133
|
+
|
134
|
+
@javac.command_args.join(' ').should include('-classpath path/to/classes')
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should set the classpath to the specified directories and files" do
|
138
|
+
@javac.class_path = ['path/to/classes', 'lib/dependency.jar']
|
139
|
+
|
140
|
+
@javac.command_args.join(' ').should include('-classpath path/to/classes:lib/dependency.jar')
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should not set the encoding flag if encoding is nil" do
|
144
|
+
@javac.encoding = nil
|
145
|
+
|
146
|
+
@javac.command_args.should_not include('-encoding')
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should set the encoding flag when encoding is set" do
|
150
|
+
@javac.encoding = 'Shift_JIS'
|
151
|
+
|
152
|
+
@javac.command_args.join(' ').should include('-encoding Shift_JIS')
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should set the nowarn flag when warnings is false" do
|
156
|
+
@javac.warnings = false
|
157
|
+
|
158
|
+
@javac.command_args.should include('-nowarn')
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should not set the nowarn flag when warnings is true" do
|
162
|
+
@javac.warnings = true
|
163
|
+
|
164
|
+
@javac.command_args.should_not include('-nowarn')
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'should set -Xlint:abc for all values in the lint options' do
|
168
|
+
@javac.lint << 'empty'
|
169
|
+
@javac.lint << '-cast'
|
170
|
+
@javac.lint << 'divzero'
|
171
|
+
|
172
|
+
@javac.command_args.should include('-Xlint:empty')
|
173
|
+
@javac.command_args.should include('-Xlint:-cast')
|
174
|
+
@javac.command_args.should include('-Xlint:divzero')
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'should not set any -Xlint:abc flags when the lint option is empty' do
|
178
|
+
@javac.command_args.join(' ').should_not include('-Xlint')
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'should set -Xmaxerrs when the max_errors option is set' do
|
182
|
+
@javac.max_errors = 10
|
183
|
+
|
184
|
+
@javac.command_args.join(' ').should include('-Xmaxerrs 10')
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'should not -Xmaxerrs when the max_errors option is not set' do
|
188
|
+
@javac.command_args.should_not include('-Xmaxerrs')
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'should set -Xmaxwarns when the max_warnings option is set' do
|
192
|
+
@javac.max_warnings = 5
|
193
|
+
|
194
|
+
@javac.command_args.join(' ').should include('-Xmaxwarns 5')
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'should not -Xmaxerrs when the max_errors option is not set' do
|
198
|
+
@javac.command_args.should_not include('-Xmaxwarns')
|
199
|
+
end
|
200
|
+
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
describe 'junit command' do
|
2
|
+
|
3
|
+
before do
|
4
|
+
@mock_junit = mock('junit')
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'passes the first argument to the constructor of Junit' do
|
8
|
+
@mock_junit.should_receive(:execute).and_return(true)
|
9
|
+
|
10
|
+
Junit.should_receive(:new).with('one', 'two').and_return(@mock_junit)
|
11
|
+
|
12
|
+
junit ['one', 'two']
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'fails if #execute returns false' do
|
16
|
+
@mock_junit.should_receive(:execute).and_return(false)
|
17
|
+
|
18
|
+
Junit.should_receive(:new).and_return(@mock_junit)
|
19
|
+
|
20
|
+
lambda { junit ['Class'] }.should raise_error
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
data/spec/junit_spec.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
describe Junit do
|
2
|
+
|
3
|
+
describe 'defaults' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@junit = Junit.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'has an empty list of classes by default' do
|
10
|
+
@junit.classes.should be_empty
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#initialize' do
|
16
|
+
|
17
|
+
it 'takes a list of classes as argument' do
|
18
|
+
@junit = Junit.new('com.example.HelloWorld', 'com.example.FooBar')
|
19
|
+
@junit.classes.should eql(['com.example.HelloWorld', 'com.example.FooBar'])
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
include Pangolin
|
data/tasks/gem.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
|
4
|
+
CLEAN.include('pkg')
|
5
|
+
|
6
|
+
Jeweler::Tasks.new do |gemspec|
|
7
|
+
gemspec.name = "pangolin"
|
8
|
+
gemspec.summary = "Ruby wrappers for javac and jar that don't just exec"
|
9
|
+
gemspec.description = "Ant is a nice tool for writing Java build scripts, but Rake is nicer. The only thing missing from Rake is a way to run javac and jar, and although it's easy to run these as shell scripts you have to wait for the JVM to start. In combination with JRuby this gem lets you run javac and jar in your Rake scripts without exec'ing."
|
10
|
+
gemspec.email = "theo@iconara.net"
|
11
|
+
gemspec.homepage = "http://github.com/iconara/pangolin"
|
12
|
+
gemspec.authors = ["Theo Hultberg"]
|
13
|
+
gemspec.extensions = 'Rakefile'
|
14
|
+
gemspec.files.exclude '**/.gitignore'
|
15
|
+
#gemspec.platform = 'java'
|
16
|
+
end
|
17
|
+
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
21
|
+
end
|
data/tasks/rdoc.rake
ADDED
data/tasks/spec.rake
ADDED
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pangolin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Theo Hultberg
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-29 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Ant is a nice tool for writing Java build scripts, but Rake is nicer. The only thing missing from Rake is a way to run javac and jar, and although it's easy to run these as shell scripts you have to wait for the JVM to start. In combination with JRuby this gem lets you run javac and jar in your Rake scripts without exec'ing.
|
17
|
+
email: theo@iconara.net
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- Rakefile
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.rdoc
|
25
|
+
files:
|
26
|
+
- LICENSE
|
27
|
+
- README.rdoc
|
28
|
+
- Rakefile
|
29
|
+
- VERSION
|
30
|
+
- examples/compile/Rakefile
|
31
|
+
- examples/compile/src/com/example/HelloWorld.java
|
32
|
+
- examples/package/Rakefile
|
33
|
+
- examples/package/src/com/example/HelloWorld.java
|
34
|
+
- examples/test/Rakefile
|
35
|
+
- examples/test/src/com/example/HelloWorld.java
|
36
|
+
- examples/test/test/com/example/TestHelloWorld.java
|
37
|
+
- java_tools.gemspec
|
38
|
+
- lib/pangolin.rb
|
39
|
+
- lib/pangolin/jar.rb
|
40
|
+
- lib/pangolin/javac.rb
|
41
|
+
- lib/pangolin/junit.rb
|
42
|
+
- lib/pangolin/output/formatting.rb
|
43
|
+
- spec/jar_cmd_spec.rb
|
44
|
+
- spec/jar_spec.rb
|
45
|
+
- spec/javac_cmd_spec.rb
|
46
|
+
- spec/javac_spec.rb
|
47
|
+
- spec/junit_cmd_spec.rb
|
48
|
+
- spec/junit_spec.rb
|
49
|
+
- spec/spec.opts
|
50
|
+
- spec/spec_helper.rb
|
51
|
+
- tasks/gem.rake
|
52
|
+
- tasks/rdoc.rake
|
53
|
+
- tasks/spec.rake
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: http://github.com/iconara/pangolin
|
56
|
+
licenses: []
|
57
|
+
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options:
|
60
|
+
- --charset=UTF-8
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.3.3
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Ruby wrappers for javac and jar that don't just exec
|
82
|
+
test_files:
|
83
|
+
- spec/jar_cmd_spec.rb
|
84
|
+
- spec/jar_spec.rb
|
85
|
+
- spec/javac_cmd_spec.rb
|
86
|
+
- spec/javac_spec.rb
|
87
|
+
- spec/junit_cmd_spec.rb
|
88
|
+
- spec/junit_spec.rb
|
89
|
+
- spec/spec_helper.rb
|