mvnizer 0.0.1 → 0.0.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.
@@ -1,10 +1,35 @@
1
- module Mvnizer
2
- class Project
3
- attr_reader :group_id, :artifact_id, :version
4
- def initialize(group_id, artifact_id, version)
5
- @group_id = group_id
6
- @artifact_id = artifact_id
7
- @version = version
8
- end
9
- end
10
- end
1
+ module Mvnizer
2
+ # Class representing a project coordinates.
3
+ # The elements of the coordinates are read-only.
4
+ class Project
5
+ include Erbicole
6
+ attr_reader :group_id, :artifact_id, :version, :type, :dependencies, :scope
7
+
8
+ def initialize(group_id, artifact_id, version, type, dependencies = [], scope = nil)
9
+ @group_id = group_id
10
+ @artifact_id = artifact_id
11
+ @version = version
12
+ @type = type
13
+ @dependencies = dependencies
14
+ @scope = scope
15
+ end
16
+
17
+ def add_dependency(dependency)
18
+ @dependencies << dependency
19
+ end
20
+
21
+ # Check whether the project coordinates of this project
22
+ # match the ones of the other project.
23
+ def ==(project)
24
+ (group_id == project.group_id \
25
+ && artifact_id == project.artifact_id \
26
+ && version == project.version \
27
+ && type == project.type)
28
+ end
29
+
30
+ # Converts project into its coordinates representation.
31
+ def to_s
32
+ "#{group_id}:#{artifact_id}:#{version}:#{type}:#{scope}"
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,6 @@
1
+ <dependency>
2
+ <groupId><%= group_id %></groupId>
3
+ <artifactId><%= artifact_id %></artifactId>
4
+ <version><%= version %></version>
5
+ <% if scope && scope != "compile" %><scope><%= scope %></scope><% end %>
6
+ </dependency>
@@ -1,37 +1,33 @@
1
- <project xmlns="http://maven.apache.org/POM/4.0.0"
2
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
- <modelVersion>4.0.0</modelVersion>
5
-
6
- <groupId><%= group_id %></groupId>
7
- <artifactId><%= artifact_id %></artifactId>
8
- <version><%= version %></version>
9
- <name><%= artifact_id %></name>
10
-
11
- <properties>
12
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13
- </properties>
14
-
15
- <dependencies>
16
- <dependency>
17
- <groupId>junit</groupId>
18
- <artifactId>junit</artifactId>
19
- <version>4.8.2</version>
20
- <scope>test</scope>
21
- </dependency>
22
- </dependencies>
23
-
24
- <build>
25
- <plugins>
26
- <plugin>
27
- <artifactId>maven-compiler-plugin</artifactId>
28
- <version>2.3.2</version>
29
- <configuration>
30
- <source>1.6</source>
31
- <target>1.6</target>
32
- </configuration>
33
- </plugin>
34
- </plugins>
35
- </build>
36
-
37
- </project>
1
+ <project xmlns="http://maven.apache.org/POM/4.0.0"
2
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
+ <modelVersion>4.0.0</modelVersion>
5
+
6
+ <groupId><%= group_id %></groupId>
7
+ <artifactId><%= artifact_id %></artifactId>
8
+ <version><%= version %></version>
9
+ <name><%= artifact_id %></name>
10
+ <% if type != 'jar' %><packaging><%= type %></packaging><% end %>
11
+
12
+ <properties>
13
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14
+ </properties>
15
+
16
+ <dependencies>
17
+ <% dependencies.each do |d| if d %><%= render('_dependency.xml.erb', d) %><% end; end %>
18
+ </dependencies>
19
+
20
+ <build>
21
+ <plugins>
22
+ <plugin>
23
+ <artifactId>maven-compiler-plugin</artifactId>
24
+ <version>2.3.2</version>
25
+ <configuration>
26
+ <source>1.6</source>
27
+ <target>1.6</target>
28
+ </configuration>
29
+ </plugin>
30
+ </plugins>
31
+ </build>
32
+
33
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" ?>
2
+ <web-app xmlns="http://java.sun.com/xml/ns/javaee"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
5
+ version="3.0">
6
+ </web-app>
@@ -1,5 +1,5 @@
1
1
  module Mvnizer
2
2
  module Version
3
- STRING = '0.0.1'
3
+ STRING = '0.0.2'
4
4
  end
5
5
  end
data/lib/mvnizer.rb CHANGED
@@ -1,9 +1,15 @@
1
- $:.unshift File.dirname(__FILE__)
2
-
3
- require 'mvnizer/version'
4
- require 'mvnizer/configuration'
5
- require 'mvnizer/pom_generator'
6
- require 'mvnizer/dir_creator'
7
- require 'mvnizer/mvnize'
8
-
9
-
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ require 'erb'
4
+
5
+ require 'mvnizer/version'
6
+ require 'mvnizer/erb_helper'
7
+ require 'mvnizer/project'
8
+ require 'mvnizer/configuration'
9
+ require 'mvnizer/commands'
10
+ require 'mvnizer/coordinate_parser'
11
+ require 'mvnizer/pom_generator'
12
+ require 'mvnizer/dir_creator'
13
+ require 'mvnizer/mvnize'
14
+
15
+
data/mvnizer.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "mvnizer"
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["S\u{e9}bastien Le Callonnec"]
12
- s.date = "2012-09-13"
12
+ s.date = "2012-09-21"
13
13
  s.description = "Bootstrap a Maven project without the pain of archetypes."
14
14
  s.email = "sebastien@weblogism.com"
15
15
  s.executables = ["mvnizer"]
@@ -24,18 +24,34 @@ Gem::Specification.new do |s|
24
24
  "LICENSE.txt",
25
25
  "README.md",
26
26
  "Rakefile",
27
+ "TODO.md",
27
28
  "bin/mvnizer",
28
29
  "conf/default.yml",
29
30
  "lib/mvnizer.rb",
31
+ "lib/mvnizer/commands.rb",
32
+ "lib/mvnizer/commands/new_project.rb",
33
+ "lib/mvnizer/commands/new_war_project.rb",
34
+ "lib/mvnizer/commands/project_factory.rb",
30
35
  "lib/mvnizer/configuration.rb",
36
+ "lib/mvnizer/coordinate_parser.rb",
31
37
  "lib/mvnizer/dir_creator.rb",
38
+ "lib/mvnizer/erb_helper.rb",
32
39
  "lib/mvnizer/mvnize.rb",
33
40
  "lib/mvnizer/pom_generator.rb",
34
41
  "lib/mvnizer/project.rb",
42
+ "lib/mvnizer/templates/_dependency.xml.erb",
35
43
  "lib/mvnizer/templates/pom.xml.erb",
44
+ "lib/mvnizer/templates/web.xml.erb",
36
45
  "lib/mvnizer/version.rb",
37
46
  "mvnizer.gemspec",
47
+ "ragel/coordinate.rb",
48
+ "ragel/coordinate.rl",
49
+ "ragel/test_coord.rb",
50
+ "spec/commands/new_project_spec.rb",
51
+ "spec/commands/new_war_project_spec.rb",
52
+ "spec/commands/project_factory_spec.rb",
38
53
  "spec/configuration_spec.rb",
54
+ "spec/coordinate_parser_spec.rb",
39
55
  "spec/dir_creator_spec.rb",
40
56
  "spec/generator_spec.rb",
41
57
  "spec/mvnize_spec.rb",
@@ -0,0 +1,385 @@
1
+
2
+ # line 1 "coordinate.rl"
3
+ # coordinate.rl
4
+
5
+ module Mvnizer
6
+ class CoordinateLexer
7
+
8
+
9
+
10
+ # line 33 "coordinate.rl"
11
+
12
+
13
+
14
+ def initialize
15
+ @group_found = false
16
+
17
+ # line 18 "coordinate.rb"
18
+ class << self
19
+ attr_accessor :_coordinate_lexer_actions
20
+ private :_coordinate_lexer_actions, :_coordinate_lexer_actions=
21
+ end
22
+ self._coordinate_lexer_actions = [
23
+ 0, 1, 2, 1, 5, 1, 6, 1,
24
+ 7, 1, 8, 2, 0, 1, 2, 3,
25
+ 4
26
+ ]
27
+
28
+ class << self
29
+ attr_accessor :_coordinate_lexer_key_offsets
30
+ private :_coordinate_lexer_key_offsets, :_coordinate_lexer_key_offsets=
31
+ end
32
+ self._coordinate_lexer_key_offsets = [
33
+ 0, 0, 1, 2, 3, 11, 20, 26,
34
+ 35
35
+ ]
36
+
37
+ class << self
38
+ attr_accessor :_coordinate_lexer_trans_keys
39
+ private :_coordinate_lexer_trans_keys, :_coordinate_lexer_trans_keys=
40
+ end
41
+ self._coordinate_lexer_trans_keys = [
42
+ 106, 97, 114, 45, 46, 48, 57, 65,
43
+ 90, 97, 122, 97, 45, 46, 48, 57,
44
+ 65, 90, 98, 122, 58, 106, 65, 90,
45
+ 97, 122, 58, 45, 46, 48, 57, 65,
46
+ 90, 97, 122, 58, 114, 45, 46, 48,
47
+ 57, 65, 90, 97, 122, 0
48
+ ]
49
+
50
+ class << self
51
+ attr_accessor :_coordinate_lexer_single_lengths
52
+ private :_coordinate_lexer_single_lengths, :_coordinate_lexer_single_lengths=
53
+ end
54
+ self._coordinate_lexer_single_lengths = [
55
+ 0, 1, 1, 1, 0, 1, 2, 1,
56
+ 2
57
+ ]
58
+
59
+ class << self
60
+ attr_accessor :_coordinate_lexer_range_lengths
61
+ private :_coordinate_lexer_range_lengths, :_coordinate_lexer_range_lengths=
62
+ end
63
+ self._coordinate_lexer_range_lengths = [
64
+ 0, 0, 0, 0, 4, 4, 2, 4,
65
+ 4
66
+ ]
67
+
68
+ class << self
69
+ attr_accessor :_coordinate_lexer_index_offsets
70
+ private :_coordinate_lexer_index_offsets, :_coordinate_lexer_index_offsets=
71
+ end
72
+ self._coordinate_lexer_index_offsets = [
73
+ 0, 0, 2, 4, 6, 11, 17, 22,
74
+ 28
75
+ ]
76
+
77
+ class << self
78
+ attr_accessor :_coordinate_lexer_indicies
79
+ private :_coordinate_lexer_indicies, :_coordinate_lexer_indicies=
80
+ end
81
+ self._coordinate_lexer_indicies = [
82
+ 0, 1, 2, 1, 3, 1, 5, 5,
83
+ 5, 5, 4, 6, 5, 5, 5, 5,
84
+ 1, 7, 9, 8, 8, 1, 11, 5,
85
+ 5, 5, 5, 10, 11, 8, 5, 5,
86
+ 5, 5, 10, 0
87
+ ]
88
+
89
+ class << self
90
+ attr_accessor :_coordinate_lexer_trans_targs
91
+ private :_coordinate_lexer_trans_targs, :_coordinate_lexer_trans_targs=
92
+ end
93
+ self._coordinate_lexer_trans_targs = [
94
+ 2, 0, 3, 6, 6, 7, 8, 1,
95
+ 4, 5, 6, 6
96
+ ]
97
+
98
+ class << self
99
+ attr_accessor :_coordinate_lexer_trans_actions
100
+ private :_coordinate_lexer_trans_actions, :_coordinate_lexer_trans_actions=
101
+ end
102
+ self._coordinate_lexer_trans_actions = [
103
+ 0, 0, 0, 5, 9, 0, 14, 0,
104
+ 0, 0, 7, 3
105
+ ]
106
+
107
+ class << self
108
+ attr_accessor :_coordinate_lexer_to_state_actions
109
+ private :_coordinate_lexer_to_state_actions, :_coordinate_lexer_to_state_actions=
110
+ end
111
+ self._coordinate_lexer_to_state_actions = [
112
+ 0, 0, 0, 0, 0, 0, 11, 0,
113
+ 0
114
+ ]
115
+
116
+ class << self
117
+ attr_accessor :_coordinate_lexer_from_state_actions
118
+ private :_coordinate_lexer_from_state_actions, :_coordinate_lexer_from_state_actions=
119
+ end
120
+ self._coordinate_lexer_from_state_actions = [
121
+ 0, 0, 0, 0, 0, 0, 1, 0,
122
+ 0
123
+ ]
124
+
125
+ class << self
126
+ attr_accessor :_coordinate_lexer_eof_trans
127
+ private :_coordinate_lexer_eof_trans, :_coordinate_lexer_eof_trans=
128
+ end
129
+ self._coordinate_lexer_eof_trans = [
130
+ 0, 0, 0, 0, 5, 0, 0, 11,
131
+ 11
132
+ ]
133
+
134
+ class << self
135
+ attr_accessor :coordinate_lexer_start
136
+ end
137
+ self.coordinate_lexer_start = 6;
138
+ class << self
139
+ attr_accessor :coordinate_lexer_first_final
140
+ end
141
+ self.coordinate_lexer_first_final = 6;
142
+ class << self
143
+ attr_accessor :coordinate_lexer_error
144
+ end
145
+ self.coordinate_lexer_error = 0;
146
+
147
+ class << self
148
+ attr_accessor :coordinate_lexer_en_main
149
+ end
150
+ self.coordinate_lexer_en_main = 6;
151
+
152
+
153
+ # line 39 "coordinate.rl"
154
+ end
155
+
156
+ def scan(data)
157
+ # convert string into an array of 8-bit signed integers.
158
+ data = data.unpack("c*") if(data.is_a?(String))
159
+ eof = pe = data.length
160
+ ts = te = 0
161
+
162
+
163
+ # line 164 "coordinate.rb"
164
+ begin
165
+ p ||= 0
166
+ pe ||= data.length
167
+ cs = coordinate_lexer_start
168
+ ts = nil
169
+ te = nil
170
+ act = 0
171
+ end
172
+
173
+ # line 48 "coordinate.rl"
174
+
175
+ # line 176 "coordinate.rb"
176
+ begin
177
+ _klen, _trans, _keys, _acts, _nacts = nil
178
+ _goto_level = 0
179
+ _resume = 10
180
+ _eof_trans = 15
181
+ _again = 20
182
+ _test_eof = 30
183
+ _out = 40
184
+ while true
185
+ _trigger_goto = false
186
+ if _goto_level <= 0
187
+ if p == pe
188
+ _goto_level = _test_eof
189
+ next
190
+ end
191
+ if cs == 0
192
+ _goto_level = _out
193
+ next
194
+ end
195
+ end
196
+ if _goto_level <= _resume
197
+ _acts = _coordinate_lexer_from_state_actions[cs]
198
+ _nacts = _coordinate_lexer_actions[_acts]
199
+ _acts += 1
200
+ while _nacts > 0
201
+ _nacts -= 1
202
+ _acts += 1
203
+ case _coordinate_lexer_actions[_acts - 1]
204
+ when 2 then
205
+ # line 1 "NONE"
206
+ begin
207
+ ts = p
208
+ end
209
+ # line 210 "coordinate.rb"
210
+ end # from state action switch
211
+ end
212
+ if _trigger_goto
213
+ next
214
+ end
215
+ _keys = _coordinate_lexer_key_offsets[cs]
216
+ _trans = _coordinate_lexer_index_offsets[cs]
217
+ _klen = _coordinate_lexer_single_lengths[cs]
218
+ _break_match = false
219
+
220
+ begin
221
+ if _klen > 0
222
+ _lower = _keys
223
+ _upper = _keys + _klen - 1
224
+
225
+ loop do
226
+ break if _upper < _lower
227
+ _mid = _lower + ( (_upper - _lower) >> 1 )
228
+
229
+ if data[p].ord < _coordinate_lexer_trans_keys[_mid]
230
+ _upper = _mid - 1
231
+ elsif data[p].ord > _coordinate_lexer_trans_keys[_mid]
232
+ _lower = _mid + 1
233
+ else
234
+ _trans += (_mid - _keys)
235
+ _break_match = true
236
+ break
237
+ end
238
+ end # loop
239
+ break if _break_match
240
+ _keys += _klen
241
+ _trans += _klen
242
+ end
243
+ _klen = _coordinate_lexer_range_lengths[cs]
244
+ if _klen > 0
245
+ _lower = _keys
246
+ _upper = _keys + (_klen << 1) - 2
247
+ loop do
248
+ break if _upper < _lower
249
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1)
250
+ if data[p].ord < _coordinate_lexer_trans_keys[_mid]
251
+ _upper = _mid - 2
252
+ elsif data[p].ord > _coordinate_lexer_trans_keys[_mid+1]
253
+ _lower = _mid + 2
254
+ else
255
+ _trans += ((_mid - _keys) >> 1)
256
+ _break_match = true
257
+ break
258
+ end
259
+ end # loop
260
+ break if _break_match
261
+ _trans += _klen
262
+ end
263
+ end while false
264
+ _trans = _coordinate_lexer_indicies[_trans]
265
+ end
266
+ if _goto_level <= _eof_trans
267
+ cs = _coordinate_lexer_trans_targs[_trans]
268
+ if _coordinate_lexer_trans_actions[_trans] != 0
269
+ _acts = _coordinate_lexer_trans_actions[_trans]
270
+ _nacts = _coordinate_lexer_actions[_acts]
271
+ _acts += 1
272
+ while _nacts > 0
273
+ _nacts -= 1
274
+ _acts += 1
275
+ case _coordinate_lexer_actions[_acts - 1]
276
+ when 3 then
277
+ # line 1 "NONE"
278
+ begin
279
+ te = p+1
280
+ end
281
+ when 4 then
282
+ # line 26 "coordinate.rl"
283
+ begin
284
+ act = 2; end
285
+ when 5 then
286
+ # line 25 "coordinate.rl"
287
+ begin
288
+ te = p+1
289
+ begin puts "#{ts} => #{te} #{data[ts...te].pack("c*")} " end
290
+ end
291
+ when 6 then
292
+ # line 27 "coordinate.rl"
293
+ begin
294
+ te = p+1
295
+ begin puts "Doh" end
296
+ end
297
+ when 7 then
298
+ # line 26 "coordinate.rl"
299
+ begin
300
+ te = p
301
+ p = p - 1; begin puts "Blah" end
302
+ end
303
+ when 8 then
304
+ # line 1 "NONE"
305
+ begin
306
+ case act
307
+ when 0 then
308
+ begin begin
309
+ cs = 0
310
+ _trigger_goto = true
311
+ _goto_level = _again
312
+ break
313
+ end
314
+ end
315
+ when 2 then
316
+ begin begin p = ((te))-1; end
317
+ puts "Blah" end
318
+ end
319
+ end
320
+ # line 321 "coordinate.rb"
321
+ end # action switch
322
+ end
323
+ end
324
+ if _trigger_goto
325
+ next
326
+ end
327
+ end
328
+ if _goto_level <= _again
329
+ _acts = _coordinate_lexer_to_state_actions[cs]
330
+ _nacts = _coordinate_lexer_actions[_acts]
331
+ _acts += 1
332
+ while _nacts > 0
333
+ _nacts -= 1
334
+ _acts += 1
335
+ case _coordinate_lexer_actions[_acts - 1]
336
+ when 0 then
337
+ # line 1 "NONE"
338
+ begin
339
+ ts = nil; end
340
+ when 1 then
341
+ # line 1 "NONE"
342
+ begin
343
+ act = 0
344
+ end
345
+ # line 346 "coordinate.rb"
346
+ end # to state action switch
347
+ end
348
+ if _trigger_goto
349
+ next
350
+ end
351
+ if cs == 0
352
+ _goto_level = _out
353
+ next
354
+ end
355
+ p += 1
356
+ if p != pe
357
+ _goto_level = _resume
358
+ next
359
+ end
360
+ end
361
+ if _goto_level <= _test_eof
362
+ if p == eof
363
+ if _coordinate_lexer_eof_trans[cs] > 0
364
+ _trans = _coordinate_lexer_eof_trans[cs] - 1;
365
+ _goto_level = _eof_trans
366
+ next;
367
+ end
368
+ end
369
+ end
370
+ if _goto_level <= _out
371
+ break
372
+ end
373
+ end
374
+ end
375
+
376
+ # line 49 "coordinate.rl"
377
+ end
378
+
379
+ private
380
+
381
+ def get_string(data, p)
382
+ data[@start_string...p].pack("c*")
383
+ end
384
+ end
385
+ end
@@ -0,0 +1,57 @@
1
+ # coordinate.rl
2
+
3
+ module Mvnizer
4
+ class CoordinateLexer
5
+
6
+
7
+ %%{
8
+
9
+ machine coordinate_lexer;
10
+
11
+ type = 'jar';
12
+ separator = ':';
13
+ identifier = ([a-zA-Z][a-zA-Z0-9\.\-]+) - type;
14
+ group = (identifier separator)?;
15
+ name = identifier;
16
+ packaging = (separator type)?;
17
+
18
+ action start_string { @start_string = p }
19
+
20
+ action group_string { puts "Group: #{get_string(data,p)}" }
21
+ action name_string { puts "Name: #{get_string(data,p)}" }
22
+ action type_string { puts "Type: #{get_string(data,p)}" }
23
+
24
+ main := |*
25
+ group => { puts "#{ts} => #{te} #{data[ts...te].pack("c*")} " };
26
+ name => { puts "Blah" };
27
+ packaging => { puts "Doh" };
28
+ # (( identifier >start_string %group_string separator )? ;
29
+ # identifier >start_string %name_string ) ;
30
+ # ( separator type >start_string %type_string )?;
31
+ *|;
32
+
33
+ }%%
34
+
35
+
36
+ def initialize
37
+ @group_found = false
38
+ %% write data;
39
+ end
40
+
41
+ def scan(data)
42
+ # convert string into an array of 8-bit signed integers.
43
+ data = data.unpack("c*") if(data.is_a?(String))
44
+ eof = pe = data.length
45
+ ts = te = 0
46
+
47
+ %% write init;
48
+ %% write exec;
49
+ end
50
+
51
+ private
52
+
53
+ def get_string(data, p)
54
+ data[@start_string...p].pack("c*")
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,5 @@
1
+ require 'coordinate'
2
+
3
+ Mvnizer::CoordinateLexer.new.scan("com.weblogism:name")
4
+ puts "---"
5
+ Mvnizer::CoordinateLexer.new.scan("name:jar")