maven-helper-script 0.1.1 → 0.1.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 CHANGED
@@ -2,7 +2,6 @@ source "http://rubygems.org"
2
2
 
3
3
  group :development do
4
4
  gem "rdoc", "~> 3.12"
5
- gem "bundler", "~> 1.2.0"
6
5
  gem "jeweler", "~> 1.8.4"
7
6
  gem "rspec", "~> 2.11.0"
8
7
  end
data/Gemfile.lock CHANGED
@@ -25,7 +25,6 @@ PLATFORMS
25
25
  x86-mingw32
26
26
 
27
27
  DEPENDENCIES
28
- bundler (~> 1.2.0)
29
28
  jeweler (~> 1.8.4)
30
29
  rdoc (~> 3.12)
31
30
  rspec (~> 2.11.0)
data/README.rdoc CHANGED
@@ -1,5 +1,7 @@
1
1
  = Maven Helper Script
2
2
 
3
+ {<img src="https://secure.travis-ci.org/kingOburgers/maven-helper-script.png" />}[http://travis-ci.org/kingOburgers/maven-helper-script]
4
+
3
5
  == What is it?
4
6
 
5
7
  A script to simplify how you execute Maven commands. For example, instead of:
@@ -10,6 +12,8 @@ You can do something like:
10
12
 
11
13
  m ci p ci d
12
14
 
15
+ == How?
16
+
13
17
  All you need is a YAML file with contents like this:
14
18
 
15
19
  modules:
@@ -19,7 +23,20 @@ All you need is a YAML file with contents like this:
19
23
  commands:
20
24
  - clean
21
25
  - install
22
- - jetty:run
26
+
27
+ arguments:
28
+ - -ff
29
+
30
+ Or you can supply a YAML file with your commands in a map, like this:
31
+
32
+ modules:
33
+ p: parent
34
+ d: domain
35
+
36
+ commands:
37
+ c: clean
38
+ i: install
39
+ cd: clean deploy
23
40
 
24
41
  arguments:
25
42
  - -ff
@@ -30,27 +47,34 @@ If you don't want to define a mapping for your module, you can use it's name.
30
47
 
31
48
  m ci parent ci d
32
49
 
33
- You can also create shorthand commands for various plugin phases. For example, executing "jetty:run" on your "web module could be:
50
+ You can also create shorthand commands for various plugin phases. For example, executing "jetty:run" on your "web" module could be:
34
51
 
35
52
  m jr web
36
53
 
54
+ if you provide a mapping file with either:
55
+
56
+ commands:
57
+ jr: jetty:run
58
+
59
+ or:
60
+
61
+ commands:
62
+ - jetty:run
63
+
64
+
37
65
  All parameters passed into the helper script are applied to every execution. So you only need to flag a command like offline mode once:
38
66
 
39
67
  m ci web ci parent -o
40
68
 
41
- Including the optional "arguments:" mapping in your m.yml file allows you to apply arguments without typing them in the command line. The example "m.yml above would trigger the "-ff" arg for maven.
69
+ Including the optional "arguments:" mapping in your m.yml file allows you to apply arguments without typing them in the command line. The example YAML files above would trigger the "-ff" arg for maven.
42
70
 
43
71
  Commands can be executed in any directory of your project, as long as there is an "m.yml" file in your project's top-level directory.
44
72
 
45
73
  == How do I use it?
46
74
  - Make sure you have ruby installed and on your path.
47
- - Check out the project to a directory on your machine.
48
- - From the checkout directory, type "rake install".
75
+ - In a command window, type "gem install maven-helper-script".
49
76
  - Find one of your existing maven projects and put an "m.yml" file like the one above in the top-level directory.
50
77
  - In a command window, "cd" to a directory in your project.
51
78
  - Execute a command.
52
79
 
53
- If you're having trouble, take a look at the sample-mvn-project located within the project on github.
54
-
55
- == To Do
56
- - Support commands in the form of a map, similar to how the modules are defined.
80
+ If you're having trouble, take a look at the wiki or sample-mvn-project located within the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,7 +5,7 @@ module MavenHelperScript
5
5
  class ArgumentParser
6
6
  def initialize(file)
7
7
  @projectPom = File.join(file, "pom.xml")
8
- @configChecker = MavenHelperScript::ConfigurationChecker.new(file)
8
+ @configChecker = MavenHelperScript::ConfigurationChecker.new(file, 'm.yml')
9
9
  end
10
10
 
11
11
  public
@@ -3,8 +3,8 @@ require 'yaml'
3
3
  module MavenHelperScript
4
4
 
5
5
  class ConfigurationChecker
6
- def initialize(file)
7
- @yml = YAML::load_file(File.join(file, 'm.yml'))
6
+ def initialize(file, configFileName)
7
+ @yml = YAML::load_file(File.join(file, configFileName))
8
8
  @commands = buildCommandKeys()
9
9
  end
10
10
 
@@ -23,34 +23,39 @@ module MavenHelperScript
23
23
  if !result
24
24
  result = ""
25
25
  mapping.each_char do |character|
26
- result << findCommandFor(character) << " "
26
+ command = findCommandFor(character)
27
+ if !command || command.empty?
28
+ raise "Unable to locate command for: " << character
29
+ end
30
+ result << command << " "
27
31
  end
28
32
  result.strip!
29
33
  end
30
34
 
31
-
32
- if !result || result.empty?
33
- raise "Unable to locate command for: " << mapping
34
- end
35
-
36
35
  result
37
36
  end
38
37
 
39
38
  private
40
39
  def buildCommandKeys()
41
- commandKeys = Hash.new()
42
- @yml['commands'].each do |phase|
43
- if phase.include? ':'
44
- key = ""
45
- phase.split(':').each do |part|
46
- key << part[0]
40
+ if @yml['commands'].class == Hash
41
+ #They are a map so you don't need to break them up.
42
+ return @yml['commands']
43
+ else
44
+ #Break the list up into a map keyed off the possible command values
45
+ commandKeys = Hash.new()
46
+ @yml['commands'].each do |phase|
47
+ if phase.include? ':'
48
+ key = ""
49
+ phase.split(':').each do |part|
50
+ key << part[0]
51
+ end
52
+ commandKeys[key] = phase
53
+ else
54
+ commandKeys[phase[0]] = phase
47
55
  end
48
- commandKeys[key] = phase
49
- else
50
- commandKeys[phase[0]] = phase
51
56
  end
57
+ return commandKeys
52
58
  end
53
- commandKeys
54
59
  end
55
60
 
56
61
  def findCommandFor(mapping)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "maven-helper-script"
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["kingOburgers"]
12
- s.date = "2012-09-09"
12
+ s.date = "2012-09-19"
13
13
  s.description = "Execute your complex maven commands faster with the shortened helper syntax. See the rdoc for more details and examples."
14
14
  s.email = "kieferfam@msn.com"
15
15
  s.executables = ["m"]
@@ -36,9 +36,12 @@ Gem::Specification.new do |s|
36
36
  "sample-mvn-project/parent/pom.xml",
37
37
  "sample-mvn-project/pom.xml",
38
38
  "test/argument_parser_spec.rb",
39
+ "test/configuration_checker_map_spec.rb",
39
40
  "test/configuration_checker_spec.rb",
40
41
  "test/m.yml",
41
- "test/project_home_finder_spec.rb"
42
+ "test/map.yml",
43
+ "test/project_home_finder_spec.rb",
44
+ "travis.yml"
42
45
  ]
43
46
  s.homepage = "http://github.com/kingOburgers/maven-helper-script"
44
47
  s.require_paths = ["lib"]
@@ -50,18 +53,15 @@ Gem::Specification.new do |s|
50
53
 
51
54
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
55
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
53
- s.add_development_dependency(%q<bundler>, ["~> 1.2.0"])
54
56
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
55
57
  s.add_development_dependency(%q<rspec>, ["~> 2.11.0"])
56
58
  else
57
59
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
58
- s.add_dependency(%q<bundler>, ["~> 1.2.0"])
59
60
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
60
61
  s.add_dependency(%q<rspec>, ["~> 2.11.0"])
61
62
  end
62
63
  else
63
64
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
64
- s.add_dependency(%q<bundler>, ["~> 1.2.0"])
65
65
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
66
66
  s.add_dependency(%q<rspec>, ["~> 2.11.0"])
67
67
  end
@@ -0,0 +1,38 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
2
+ require "configuration_checker"
3
+
4
+ describe MavenHelperScript::ConfigurationChecker do
5
+ before(:each) do
6
+ @checker = MavenHelperScript::ConfigurationChecker.new(File.join(File.dirname(__FILE__)), 'map.yml')
7
+ end
8
+
9
+ it "should find module by mapping" do
10
+ @checker.checkForModule("p").should == "parent"
11
+ end
12
+
13
+ it "should send back mapping name when no module found, assume that is the correct module name" do
14
+ @checker.checkForModule("boo").should == "boo"
15
+ end
16
+
17
+ it "should find command using first characters when not a plugin execution" do
18
+ @checker.checkForCommand("ci").should == "clean install"
19
+ end
20
+
21
+ it "should blow up if you can't find the other part of a command" do
22
+ expect {@checker.checkForCommand("cj") }.to raise_error(RuntimeError, "Unable to locate command for: j")
23
+ end
24
+
25
+ it "should find plugin execution" do
26
+ @checker.checkForCommand("jr").should == "jetty:run"
27
+ end
28
+
29
+ it "should blow up when can't find command" do
30
+ expect {@checker.checkForCommand("j") }.to raise_error(RuntimeError, "Unable to locate command for: j")
31
+ end
32
+
33
+ it "should return all command arguments" do
34
+ args = Array['-ff', '-DskipTests']
35
+ expect @checker.checkForArguments().should == args
36
+ end
37
+
38
+ end
@@ -3,7 +3,7 @@ require "configuration_checker"
3
3
 
4
4
  describe MavenHelperScript::ConfigurationChecker do
5
5
  before(:each) do
6
- @checker = MavenHelperScript::ConfigurationChecker.new(File.join(File.dirname(__FILE__)))
6
+ @checker = MavenHelperScript::ConfigurationChecker.new(File.join(File.dirname(__FILE__)), 'm.yml')
7
7
  end
8
8
 
9
9
  it "should find module by mapping" do
data/test/map.yml ADDED
@@ -0,0 +1,17 @@
1
+ modules:
2
+ p: parent
3
+ par: parent
4
+
5
+ commands:
6
+ c: clean
7
+ p: package
8
+ tc: test-compile
9
+ jr: jetty:run
10
+ i: install
11
+ d: deploy
12
+ ci: clean install
13
+
14
+ arguments:
15
+ - -ff
16
+ - -DskipTests
17
+
data/travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maven-helper-script
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.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: 2012-09-09 00:00:00.000000000 Z
12
+ date: 2012-09-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
@@ -27,22 +27,6 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: '3.12'
30
- - !ruby/object:Gem::Dependency
31
- name: bundler
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: 1.2.0
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 1.2.0
46
30
  - !ruby/object:Gem::Dependency
47
31
  name: jeweler
48
32
  requirement: !ruby/object:Gem::Requirement
@@ -103,9 +87,12 @@ files:
103
87
  - sample-mvn-project/parent/pom.xml
104
88
  - sample-mvn-project/pom.xml
105
89
  - test/argument_parser_spec.rb
90
+ - test/configuration_checker_map_spec.rb
106
91
  - test/configuration_checker_spec.rb
107
92
  - test/m.yml
93
+ - test/map.yml
108
94
  - test/project_home_finder_spec.rb
95
+ - travis.yml
109
96
  homepage: http://github.com/kingOburgers/maven-helper-script
110
97
  licenses: []
111
98
  post_install_message:
@@ -120,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
107
  version: '0'
121
108
  segments:
122
109
  - 0
123
- hash: -1037379277
110
+ hash: -317974925
124
111
  required_rubygems_version: !ruby/object:Gem::Requirement
125
112
  none: false
126
113
  requirements: