mvn_watch 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'jeweler'
2
+ Jeweler::Tasks.new do |gem|
3
+ gem.name = "mvn_watch"
4
+ gem.summary = %Q{A "continuous integration local tester" for maven projects (typically java), such that when you update a .java file, it will automatically run its unit test.}
5
+ gem.description = gem.summary
6
+ gem.email = "rogerdpack@gmail.com"
7
+ gem.homepage = "http://github.com/rdp/maven_watchr"
8
+ gem.authors = ["rdp"]
9
+ gem.add_dependency "sane"
10
+ gem.add_development_dependency "rspec", ">= 1.2.9"
11
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
data/bin/mvn_watch ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'sane'
3
+ require_relative '../lib/maven_watchr.rb'
4
+ MavenWatchr.new("mvn test -Dtest=").go_local_dir
@@ -0,0 +1,53 @@
1
+ require 'watchr'
2
+ require 'os'
3
+
4
+ begin
5
+ require 'snarl' if OS.windows?
6
+ rescue LoadError
7
+ puts 'snarl gem not available for popups'
8
+ end
9
+
10
+ class MavenWatchr
11
+ attr_accessor :stop_after_next
12
+
13
+
14
+ ##
15
+ # Note that this command will receive a single classname, like App from App.java, appended to it, when it's used
16
+ ##
17
+ def initialize command_to_run
18
+ @command_to_run = command_to_run
19
+ end
20
+
21
+ def go_local_dir
22
+ script = Watchr::Script.new
23
+ script.watch('.*/(.*)\.java') do |changed_file|
24
+ success = true
25
+ if changed_file[1] =~ /Test$/
26
+ if @command_to_run
27
+ command = @command_to_run + changed_file[1]
28
+ puts command
29
+ success = system(command)
30
+ end
31
+
32
+ else
33
+ if @command_to_run && Dir['**/' + changed_file[1] + 'Test*'].length > 0 # ltodo test this > 0
34
+ command = @command_to_run + changed_file[1] + 'Test'
35
+ puts command
36
+ success = system(command)
37
+ end
38
+ end
39
+ if OS.windows? && !success
40
+ Snarl.new 'failed:' + command if defined?(Snarl)
41
+ end
42
+ puts 'done'
43
+ raise 'done' if stop_after_next
44
+
45
+ end
46
+
47
+ contrl = Watchr::Controller.new(script, Watchr.handler.new)
48
+ contrl.run
49
+
50
+ Watchr::Controller.new(script, Watchr.handler.new).run
51
+ end
52
+
53
+ end
@@ -0,0 +1,37 @@
1
+ require 'fileutils'
2
+ require 'pathname'
3
+ require 'spec/autorun'
4
+ require 'sane'
5
+
6
+ require_relative './maven_watchr'
7
+
8
+ describe MavenWatchr do
9
+
10
+ before do
11
+ Dir.chdir 'testArtifactId' if File.exist? 'testArtifactId'
12
+ @subject = MavenWatchr.new
13
+ @subject.stop_after_next = true
14
+ Thread.new { @subject.go_local_dir }
15
 
16
+ end
17
+
18
+ it "should find java test file without .class and compile it "
19
+
20
+ it "should run unit test on one" do
21
+ compiled = Pathname('target/test-classes/testGroupId/AppTest.class')
22
+ compiled.delete if compiled.exist?
23
+ FileUtils.touch 'src/test/java/testGroupId/AppTest.java'
24
+ sleep 3.1 # should recompile its class
25
+ assert compiled.exist?
26
+
27
+ end
28
+
29
+ it "should run test on all"
30
+ it "should run test compile"
31
+
32
+ it "should run test compile on one" do
33
+ pending "figuring out if this is possible"
34
+ end
35
+
36
+ it "should use snarl optionally"
37
+
38
+ end
@@ -0,0 +1,18 @@
1
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
+ <modelVersion>4.0.0</modelVersion>
4
+ <groupId>testGroupId</groupId>
5
+ <artifactId>testArtifactId</artifactId>
6
+ <packaging>jar</packaging>
7
+ <version>1.0-SNAPSHOT</version>
8
+ <name>testArtifactId</name>
9
+ <url>http://maven.apache.org</url>
10
+ <dependencies>
11
+ <dependency>
12
+ <groupId>junit</groupId>
13
+ <artifactId>junit</artifactId>
14
+ <version>3.8.1</version>
15
+ <scope>test</scope>
16
+ </dependency>
17
+ </dependencies>
18
+ </project>
@@ -0,0 +1,13 @@
1
+ package testGroupId;
2
+
3
+ /**
4
+ * Hello world!
5
+ *
6
+ */
7
+ public class App
8
+ {
9
+ public static void main( String[] args )
10
+ {
11
+ System.out.println( "Hello World!" );
12
+ }
13
+ }
@@ -0,0 +1,38 @@
1
+ package testGroupId;
2
+
3
+ import junit.framework.Test;
4
+ import junit.framework.TestCase;
5
+ import junit.framework.TestSuite;
6
+
7
+ /**
8
+ * Unit test for simple App.
9
+ */
10
+ public class AppTest
11
+ extends TestCase
12
+ {
13
+ /**
14
+ * Create the test case
15
+ *
16
+ * @param testName name of the test case
17
+ */
18
+ public AppTest( String testName )
19
+ {
20
+ super( testName );
21
+ }
22
+
23
+ /**
24
+ * @return the suite of tests being tested
25
+ */
26
+ public static Test suite()
27
+ {
28
+ return new TestSuite( AppTest.class );
29
+ }
30
+
31
+ /**
32
+ * Rigourous Test :-)
33
+ */
34
+ public void testApp()
35
+ {
36
+ assertTrue( true );
37
+ }
38
+ }
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mvn_watch
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 1
9
+ version: 0.1.1
10
+ platform: ruby
11
+ authors:
12
+ - rdp
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-03-05 00:00:00 -07:00
18
+ default_executable: mvn_watch
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: sane
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: rspec
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 1
41
+ - 2
42
+ - 9
43
+ version: 1.2.9
44
+ type: :development
45
+ version_requirements: *id002
46
+ description: A "continuous integration local tester" for maven projects (typically java), such that when you update a .java file, it will automatically run its unit test.
47
+ email: rogerdpack@gmail.com
48
+ executables:
49
+ - mvn_watch
50
+ extensions: []
51
+
52
+ extra_rdoc_files:
53
+ - README
54
+ files:
55
+ - README
56
+ - Rakefile
57
+ - VERSION
58
+ - bin/mvn_watch
59
+ - lib/maven_watchr.rb
60
+ - spec/spec.maven_watchr.rb
61
+ - spec/testArtifactId/pom.xml
62
+ - spec/testArtifactId/src/main/java/testGroupId/App.java
63
+ - spec/testArtifactId/src/test/java/testGroupId/AppTest.java
64
+ - spec/testArtifactId/target/classes/testGroupId/App.class
65
+ has_rdoc: true
66
+ homepage: http://github.com/rdp/maven_watchr
67
+ licenses: []
68
+
69
+ post_install_message:
70
+ rdoc_options:
71
+ - --charset=UTF-8
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ requirements: []
89
+
90
+ rubyforge_project:
91
+ rubygems_version: 1.3.6
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: A "continuous integration local tester" for maven projects (typically java), such that when you update a .java file, it will automatically run its unit test.
95
+ test_files:
96
+ - spec/spec.maven_watchr.rb