guard-gradle 0.1.0 → 0.2.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/.gitignore +1 -0
- data/CHANGELOG.md +2 -0
- data/README.md +71 -16
- data/Rakefile +8 -1
- data/etc/installer.sh +31 -0
- data/guard-gradle.gemspec +11 -9
- data/lib/guard/gradle.rb +32 -4
- data/lib/guard/gradle/templates/Guardfile +2 -3
- data/lib/guard/gradle/version.rb +1 -1
- data/test/guard_gradle_test.rb +24 -0
- metadata +41 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cb85e6018f4c8d2b272916f0d4dce1dc74b2760
|
4
|
+
data.tar.gz: 9723e9296516b46914266bc8d858317a64811a91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19da8eb01d58929f2dde5e5b0a9b6d7ff3440c39aa313a5c2b4dd770b3fea10167eb2962aa25e2c077e0a5a0b24c6e8e3590675f3eb79350216260dfcc1ced58
|
7
|
+
data.tar.gz: 4afc6c2878ad62569f9ae19a281962a5397a6b0d871fce835a229bf8b18281dfc0d4f8702820b2c489741d7203d212039aee9e746df3654db71b6d66417f4ff3
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,52 +1,107 @@
|
|
1
1
|
# Guard::Gradle
|
2
2
|
|
3
|
-
|
3
|
+
Continuously integrate while you work. Run those tests without thinking. It's the ying to your testing yang, baby.
|
4
4
|
|
5
|
+
### WTF?
|
5
6
|
|
6
|
-
|
7
|
+
Because once on [Guard](http://guardgem.org/) you become hooked. No need to manually run your tests -- they are run _automatically_ when a file changes.
|
7
8
|
|
8
|
-
|
9
|
-
useful features at the command line or Sublime plugins.
|
9
|
+
What's Guard you ask? Good question Ruby tyro.
|
10
10
|
|
11
|
+
>Guard is a command line tool to easily handle events on file system modifications.
|
11
12
|
|
12
13
|
## Installation
|
13
14
|
|
14
|
-
|
15
|
+
It's assumed you're more familiar with Java than you are with Ruby (after all, this is a Gradle tool, right?!); consequently, it's super easy to get going with Guard::Gradle _provided you have Ruby installed_.
|
16
|
+
|
17
|
+
Open up a terminal and type:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
$ ruby -v
|
21
|
+
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]
|
22
|
+
```
|
23
|
+
|
24
|
+
If you see something like `ruby: command not found` then you need to [install Ruby](https://www.ruby-lang.org/en/installation/).
|
25
|
+
|
26
|
+
#### For those who want to get going ASAP
|
27
|
+
|
28
|
+
We've made this super easy. Open up a terminal, `cd` to your desired project, and type:
|
29
|
+
|
30
|
+
```bash
|
31
|
+
wget --no-check-certificate https://github.com/aglover/guard-gradle/blob/master/etc/installer.sh && bash installer.sh
|
32
|
+
```
|
33
|
+
|
34
|
+
It's important you do this in the root directory of a project you wish to use Gradle::Guard in. This plugin is designed to work on individual project instances, much like a `build.gradle` file is unique to a project.
|
35
|
+
|
36
|
+
The above script will install:
|
37
|
+
* Bundler
|
38
|
+
* Guard::Gradle
|
39
|
+
* Create default Guard file
|
40
|
+
* Create a Guard launcher script
|
41
|
+
|
42
|
+
Therefore, after you run the command above, you'll be left with a script dubbed `guard.sh` -- just execute that script to start Guard::Gradle!
|
43
|
+
|
44
|
+
#### For those familiar w/Ruby
|
45
|
+
|
46
|
+
Guard::Gradle is intended to work with project instances; accordingly, you'll need to follow these steps for each project.
|
47
|
+
|
48
|
+
If you already haven't installed [Bundler](http://bundler.io/), go ahead and install it (`sudo gem install bundler`).
|
49
|
+
|
50
|
+
In the root of your project, create a `Gemfile` that looks like:
|
15
51
|
|
16
52
|
```ruby
|
17
|
-
source
|
53
|
+
source 'https://rubygems.org'
|
18
54
|
gem 'guard-gradle'
|
19
55
|
```
|
20
56
|
|
21
|
-
|
57
|
+
Save the file and then run:
|
22
58
|
|
23
59
|
```
|
24
|
-
bundle install
|
60
|
+
$ bundle install --path vendor
|
25
61
|
```
|
26
62
|
|
27
|
-
|
63
|
+
Then create a `Guardfile` with the recommended configuration by running:
|
28
64
|
|
29
65
|
```
|
30
|
-
bundle exec guard init gradle
|
66
|
+
$ bundle exec guard init gradle
|
67
|
+
```
|
68
|
+
|
69
|
+
The default `Guardfile` will look like this:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
guard :nebula do
|
73
|
+
watch(%r{^src/main/(.+)\.*$}) { |m| m[1].split('.')[0].split('/')[-1] }
|
74
|
+
end
|
31
75
|
```
|
32
76
|
|
77
|
+
For those who give a flip: `watch` watches all files in the `src/main` directory of your project and if a file happens to change, the corresponding file is parsed out -- i.e. `src/main/groovy/org/github/aglover/prattle/Prattle.groovy` becomes `Prattle`. The resultant file name is then passed into the Gradle `test` task (more or less -- see usage details below for exact behavior).
|
33
78
|
|
34
79
|
## Usage
|
35
80
|
|
36
|
-
|
81
|
+
To fire up Guard, type:
|
37
82
|
|
38
83
|
```
|
39
|
-
|
84
|
+
$ bundle exec guard
|
40
85
|
```
|
41
86
|
|
42
|
-
|
87
|
+
(I highly recommend you alias `bundle exec` to `be`)
|
88
|
+
|
89
|
+
|
90
|
+
This Guard plugin simply runs the `test` task on your Gradle project; the exact command it runs is:
|
43
91
|
|
44
92
|
```
|
45
|
-
|
93
|
+
./gradlew test
|
46
94
|
```
|
47
95
|
|
48
|
-
|
96
|
+
Note, the plugin will try and execute the exact corresponding test for a changed file.
|
97
|
+
|
98
|
+
For example, if you change the file `DataCentuar.groovy`, if there is a corresponding `DataCentuarTest` or `DataCentuarSpec` _only_ that test is executed via the `-Dsingle.run` Gradle parameter. Otherwise, if no analogous test is found, the entire test suite is run.
|
99
|
+
|
100
|
+
## Notifications
|
101
|
+
|
102
|
+
Guard works natively with Growl. There are other options as well -- feel free to check out the [Guard wiki page](https://github.com/guard/guard/wiki/System-notifications) for more information.
|
49
103
|
|
104
|
+
For instance, as I use [Growl](http://growl.info/), I have updated my `Gemfile` to include `gem 'growl'`. After a `bundle install` I can then update my `Guardfile` with this line: `notification :growl`, which will force Guard to use Growl (instead of any default notifiers).
|
50
105
|
|
51
106
|
## Contributing
|
52
107
|
|
@@ -54,4 +109,4 @@ The default Guardfile assumes that your project will follow the standard Gradle
|
|
54
109
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
55
110
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
56
111
|
4. Push to the branch (`git push origin my-new-feature`)
|
57
|
-
5. Create new Pull Request
|
112
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
data/etc/installer.sh
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
echo 'Installing Ruby Bundler'
|
4
|
+
echo 'You may need to enter your password'
|
5
|
+
sleep 1
|
6
|
+
sudo gem install bundler
|
7
|
+
|
8
|
+
cat <<EOF > Gemfile
|
9
|
+
source 'https://rubygems.org'
|
10
|
+
gem 'guard-gradle'
|
11
|
+
EOF
|
12
|
+
|
13
|
+
echo 'Now installing required Guard::Gradle'
|
14
|
+
sleep 1
|
15
|
+
bundle install --path vendor
|
16
|
+
|
17
|
+
echo 'Initializing the Guard Nebula plugin'
|
18
|
+
sleep 1
|
19
|
+
bundle exec guard init nebula
|
20
|
+
|
21
|
+
echo 'This file will delete itself. Going forward to start Guard, run the guard.sh script'
|
22
|
+
|
23
|
+
cat <<EOF > guard.sh
|
24
|
+
bundle exec guard
|
25
|
+
EOF
|
26
|
+
|
27
|
+
chmod +x guard.sh
|
28
|
+
|
29
|
+
sleep 1
|
30
|
+
|
31
|
+
rm install-guard.sh
|
data/guard-gradle.gemspec
CHANGED
@@ -4,19 +4,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'guard/gradle/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'guard-gradle'
|
8
8
|
spec.version = Guard::GradleVersion::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.description = %q{Guard plugin for Gradle
|
12
|
-
spec.summary = %q{Build your Java projects as you work.}
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ['Bryan Ricker', 'Andrew Glover']
|
10
|
+
spec.email = ['bricker88@gmail.com', 'ajglover@gmail.com']
|
11
|
+
spec.description = %q{Continuous Testing Guard plugin for Gradle}
|
12
|
+
spec.summary = %q{Build & test your Java projects continuously as you work.}
|
13
|
+
spec.homepage = 'https://github.com/bricker/guard-gradle'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency 'guard',
|
21
|
+
spec.add_dependency 'guard', '~> 2.6.1'
|
22
|
+
spec.add_development_dependency 'test-unit', '>= 2.5.5'
|
23
|
+
spec.add_development_dependency 'mocha', '>= 1.0.0'
|
22
24
|
end
|
data/lib/guard/gradle.rb
CHANGED
@@ -1,13 +1,41 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'guard/gradle/version'
|
3
2
|
require 'guard'
|
4
3
|
require 'guard/plugin'
|
5
4
|
|
6
5
|
module Guard
|
7
6
|
class Gradle < Plugin
|
7
|
+
|
8
|
+
DEF_CMD = './gradlew test'
|
9
|
+
|
8
10
|
def run_on_changes(paths)
|
9
|
-
|
10
|
-
|
11
|
+
if(paths.size == 1) && (Dir.glob("src/test/**/#{paths[0]}*").size > 0)
|
12
|
+
fire_command("#{DEF_CMD} -Dtest.single=#{paths[0]} --daemon")
|
13
|
+
else
|
14
|
+
run_all
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def run_all
|
19
|
+
fire_command DEF_CMD
|
20
|
+
end
|
21
|
+
|
22
|
+
def fire_command(command)
|
23
|
+
result = system command
|
24
|
+
summary = result ? 'Success' : 'Failure'
|
25
|
+
image = result ? :success : :failed
|
26
|
+
notify(summary, image)
|
27
|
+
end
|
28
|
+
|
29
|
+
def notify(summary, image)
|
30
|
+
::Guard::Notifier.notify(summary, title: 'Gradle Test Results', image: image)
|
31
|
+
end
|
32
|
+
|
33
|
+
def start
|
34
|
+
fire_command DEF_CMD
|
35
|
+
end
|
36
|
+
|
37
|
+
def run_all
|
38
|
+
fire_command DEF_CMD
|
11
39
|
end
|
12
40
|
end
|
13
41
|
end
|
data/lib/guard/gradle/version.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'mocha/test_unit'
|
4
|
+
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/guard/gradle')
|
6
|
+
|
7
|
+
class GuardGradleTest < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_single_should_be_executed
|
10
|
+
plugin = Guard::Gradle.new
|
11
|
+
expected = 'User'
|
12
|
+
plugin.expects(:fire_command).with("./gradlew test -Dtest.single=#{expected} --daemon")
|
13
|
+
Dir.expects(:glob).returns([true])
|
14
|
+
plugin.run_on_changes [expected]
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_all_when_file_not_found
|
18
|
+
plugin = Guard::Gradle.new
|
19
|
+
expected = 'User'
|
20
|
+
plugin.expects(:fire_command).with('./gradlew test')
|
21
|
+
Dir.expects(:glob).returns([])
|
22
|
+
plugin.run_on_changes [expected]
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-gradle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Ricker
|
8
|
+
- Andrew Glover
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-
|
12
|
+
date: 2014-06-05 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: guard
|
@@ -16,17 +17,46 @@ dependencies:
|
|
16
17
|
requirements:
|
17
18
|
- - ~>
|
18
19
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
20
|
+
version: 2.6.1
|
20
21
|
type: :runtime
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
25
|
- - ~>
|
25
26
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
27
|
-
|
27
|
+
version: 2.6.1
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: test-unit
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.5.5
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 2.5.5
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: mocha
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.0.0
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.0.0
|
56
|
+
description: Continuous Testing Guard plugin for Gradle
|
28
57
|
email:
|
29
58
|
- bricker88@gmail.com
|
59
|
+
- ajglover@gmail.com
|
30
60
|
executables: []
|
31
61
|
extensions: []
|
32
62
|
extra_rdoc_files: []
|
@@ -37,10 +67,12 @@ files:
|
|
37
67
|
- MIT-LICENSE
|
38
68
|
- README.md
|
39
69
|
- Rakefile
|
70
|
+
- etc/installer.sh
|
40
71
|
- guard-gradle.gemspec
|
41
72
|
- lib/guard/gradle.rb
|
42
73
|
- lib/guard/gradle/templates/Guardfile
|
43
74
|
- lib/guard/gradle/version.rb
|
75
|
+
- test/guard_gradle_test.rb
|
44
76
|
homepage: https://github.com/bricker/guard-gradle
|
45
77
|
licenses:
|
46
78
|
- MIT
|
@@ -61,9 +93,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
93
|
version: '0'
|
62
94
|
requirements: []
|
63
95
|
rubyforge_project:
|
64
|
-
rubygems_version: 2.0.
|
96
|
+
rubygems_version: 2.0.14
|
65
97
|
signing_key:
|
66
98
|
specification_version: 4
|
67
|
-
summary: Build your Java projects as you work.
|
68
|
-
test_files:
|
69
|
-
|
99
|
+
summary: Build & test your Java projects continuously as you work.
|
100
|
+
test_files:
|
101
|
+
- test/guard_gradle_test.rb
|