maven-helper-script 0.2.1 → 0.3.0
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.
- checksums.yaml +4 -4
- data/README.rdoc +1 -0
- data/VERSION +1 -1
- data/lib/argument_parser.rb +21 -21
- data/lib/configuration_checker.rb +15 -15
- data/lib/invalid_command_exception.rb +3 -3
- data/lib/project_home_finder.rb +10 -10
- data/lib/script_runner.rb +2 -2
- data/maven-helper-script.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6735e925cc7aea71a4d75e1388edc202fd61c25a
|
4
|
+
data.tar.gz: 6b03de03bbad10422f62f02ce6c31edb30248476
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5cd565157132dbb1bcb0fe0d65a0a05171ef911e5473f0624ebba20aadec7fc745d2aa499aeec2f87821cb1e0891b31151a36a680a49eeb9d9548c96eb962df
|
7
|
+
data.tar.gz: 34a6b4cb3854e3c907f1b9dc5b7687152b9e9fe651188ba57f581183f4b8d37ee68612a3789f626aa6719268c999482bfd9d39a9111b1d1f999e26b03c629e9a
|
data/README.rdoc
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
= Maven Helper Script
|
2
2
|
|
3
3
|
{<img src="https://secure.travis-ci.org/benkiefer/maven-helper-script.png" />}[http://travis-ci.org/benkiefer/maven-helper-script]
|
4
|
+
{<img src="https://badge.fury.io/rb/maven-helper-script.svg" alt="Gem Version" />}[http://badge.fury.io/rb/maven-helper-script]
|
4
5
|
|
5
6
|
== What is it?
|
6
7
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/argument_parser.rb
CHANGED
@@ -1,52 +1,52 @@
|
|
1
|
-
|
1
|
+
require 'configuration_checker'
|
2
2
|
|
3
3
|
module MavenHelperScript
|
4
4
|
|
5
5
|
class ArgumentParser
|
6
6
|
def initialize(file)
|
7
|
-
@
|
8
|
-
@
|
7
|
+
@project_pom = File.join(file, "pom.xml")
|
8
|
+
@config_checker = MavenHelperScript::ConfigurationChecker.new(file, 'm.yml')
|
9
9
|
end
|
10
10
|
|
11
11
|
public
|
12
12
|
def parse(args)
|
13
|
-
|
14
|
-
|
13
|
+
resulting_commands = Array[]
|
14
|
+
specialty_commands = @config_checker.check_for_arguments
|
15
15
|
result = ""
|
16
|
-
|
16
|
+
processing_command = true
|
17
17
|
|
18
18
|
args.each do |arg|
|
19
|
-
if
|
20
|
-
|
19
|
+
if is_specialty_command arg
|
20
|
+
specialty_commands << arg
|
21
21
|
else
|
22
|
-
if
|
23
|
-
result << "mvn " << @
|
24
|
-
|
22
|
+
if processing_command
|
23
|
+
result << "mvn " << @config_checker.check_for_command(arg)
|
24
|
+
processing_command = false
|
25
25
|
else
|
26
|
-
|
27
|
-
result << " -pl " <<
|
28
|
-
|
26
|
+
found_module = @config_checker.check_for_module(arg)
|
27
|
+
result << " -pl " << found_module << " -f " << @project_pom
|
28
|
+
resulting_commands << result
|
29
29
|
result = ""
|
30
|
-
|
30
|
+
processing_command = true
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
apply_specialty_commands_to(specialty_commands, resulting_commands)
|
36
36
|
|
37
|
-
|
37
|
+
resulting_commands
|
38
38
|
end
|
39
39
|
|
40
40
|
private
|
41
|
-
def
|
42
|
-
|
43
|
-
|
41
|
+
def apply_specialty_commands_to(specialty_commands, resulting_commands)
|
42
|
+
specialty_commands.each do |command|
|
43
|
+
resulting_commands.each do |it|
|
44
44
|
it = it << " " << command
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
def
|
49
|
+
def is_specialty_command(command)
|
50
50
|
if command.start_with?('-')
|
51
51
|
return true
|
52
52
|
end
|
@@ -1,30 +1,30 @@
|
|
1
1
|
require 'yaml'
|
2
|
-
|
2
|
+
require 'invalid_command_exception'
|
3
3
|
|
4
4
|
module MavenHelperScript
|
5
5
|
|
6
6
|
class ConfigurationChecker
|
7
|
-
def initialize(file,
|
8
|
-
@yml = YAML::load_file(File.join(file,
|
9
|
-
@commands =
|
7
|
+
def initialize(file, config_file_name)
|
8
|
+
@yml = YAML::load_file(File.join(file, config_file_name))
|
9
|
+
@commands = build_command_keys
|
10
10
|
end
|
11
11
|
|
12
12
|
public
|
13
|
-
def
|
13
|
+
def check_for_arguments
|
14
14
|
@yml['arguments'] || Array[]
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def check_for_module(mapping)
|
18
18
|
@yml['modules'][mapping] || mapping
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
21
|
+
def check_for_command(mapping)
|
22
22
|
result = @commands[mapping]
|
23
23
|
|
24
|
-
|
24
|
+
unless result
|
25
25
|
result = ""
|
26
26
|
mapping.each_char do |character|
|
27
|
-
command =
|
27
|
+
command = find_command_for(character)
|
28
28
|
if !command || command.empty?
|
29
29
|
raise MavenHelperScript::InvalidCommandException.new(@commands, mapping)
|
30
30
|
end
|
@@ -37,29 +37,29 @@ module MavenHelperScript
|
|
37
37
|
end
|
38
38
|
|
39
39
|
private
|
40
|
-
def
|
40
|
+
def build_command_keys
|
41
41
|
if @yml['commands'].class == Hash
|
42
42
|
#They are a map so you don't need to break them up.
|
43
43
|
return @yml['commands']
|
44
44
|
else
|
45
45
|
#Break the list up into a map keyed off the possible command values
|
46
|
-
|
46
|
+
command_keys = Hash.new
|
47
47
|
@yml['commands'].each do |phase|
|
48
48
|
if phase.include? ':'
|
49
49
|
key = ""
|
50
50
|
phase.split(':').each do |part|
|
51
51
|
key << part[0]
|
52
52
|
end
|
53
|
-
|
53
|
+
command_keys[key] = phase
|
54
54
|
else
|
55
|
-
|
55
|
+
command_keys[phase[0]] = phase
|
56
56
|
end
|
57
57
|
end
|
58
|
-
return
|
58
|
+
return command_keys
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
def
|
62
|
+
def find_command_for(mapping)
|
63
63
|
@commands[mapping] || ""
|
64
64
|
end
|
65
65
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module MavenHelperScript
|
2
2
|
|
3
3
|
class InvalidCommandException < Exception
|
4
|
-
def initialize(commands,
|
4
|
+
def initialize(commands, failed_command)
|
5
5
|
@commands = commands
|
6
|
-
@
|
6
|
+
@failed_command = failed_command
|
7
7
|
end
|
8
8
|
|
9
9
|
def commands
|
@@ -11,7 +11,7 @@ module MavenHelperScript
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def failedCommand
|
14
|
-
return @
|
14
|
+
return @failed_command
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
data/lib/project_home_finder.rb
CHANGED
@@ -4,15 +4,15 @@ module MavenHelperScript
|
|
4
4
|
|
5
5
|
class ProjectHomeFinder
|
6
6
|
public
|
7
|
-
def
|
8
|
-
@
|
9
|
-
@path = @
|
7
|
+
def find_project_directory(file)
|
8
|
+
@original_path = Pathname.new(File.expand_path(file))
|
9
|
+
@path = @original_path
|
10
10
|
found = false
|
11
11
|
|
12
|
-
|
13
|
-
found =
|
14
|
-
|
15
|
-
if !
|
12
|
+
until found
|
13
|
+
found = found_project_artifacts(File.join(@path))
|
14
|
+
unless found
|
15
|
+
if !out_of_directories_to_check @path
|
16
16
|
@path = @path.parent
|
17
17
|
else
|
18
18
|
raise MavenHelperScript::MissingProjectFolderException.new
|
@@ -24,11 +24,11 @@ module MavenHelperScript
|
|
24
24
|
end
|
25
25
|
|
26
26
|
private
|
27
|
-
def
|
28
|
-
|
27
|
+
def out_of_directories_to_check(current_path)
|
28
|
+
current_path == current_path.parent
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def found_project_artifacts(file)
|
32
32
|
FileTest.exist?(File.join(file, 'm.yml')) && FileTest.exist?(File.join(file, 'pom.xml'))
|
33
33
|
end
|
34
34
|
|
data/lib/script_runner.rb
CHANGED
@@ -10,9 +10,9 @@ module MavenHelperScript
|
|
10
10
|
finder = MavenHelperScript::ProjectHomeFinder.new
|
11
11
|
|
12
12
|
file = File.expand_path(".")
|
13
|
-
|
13
|
+
project_folder = finder.find_project_directory(file)
|
14
14
|
|
15
|
-
parser = MavenHelperScript::ArgumentParser.new(
|
15
|
+
parser = MavenHelperScript::ArgumentParser.new(project_folder)
|
16
16
|
|
17
17
|
commands = parser.parse(args)
|
18
18
|
|
data/maven-helper-script.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: maven-helper-script 0.
|
5
|
+
# stub: maven-helper-script 0.3.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "maven-helper-script"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.3.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|