guard-gradle 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bfd3695ea8f4aa6b55bf39505e482c3ab4134c7a
4
- data.tar.gz: af822d9c0f4a9cfc6ac096c50345902c3232b13e
3
+ metadata.gz: 1b1f3da1851ff47c413cf7b45452c2ca3820e418
4
+ data.tar.gz: d2649e74fc3b109554389e3bee9825f62adb0352
5
5
  SHA512:
6
- metadata.gz: 7983230c702ad23e8c42f0870d196336c6c9df124a4795c87b6a0da31328f8ab2c30474bd52e33c0df833ba0590558288074455972bed9f3230a7f196667bdc6
7
- data.tar.gz: e02f26953d514ede284a0724856bc46cda73fc382063443ca6b79ffd944a3679ec2f67a63cc8e29bdd27727900c7b17e93e8ded2699654d023790c5a136e11c7
6
+ metadata.gz: d53bf238ba73c694f7550a3f12baf00795d2a227856c6216d559faffa50b1a34a98394f384709c18c86820a2fd0a1e8152f3c25092a197fbad96868a636d5fab
7
+ data.tar.gz: 45c6639da23227888c4e80b8cdbe6cc6c354fbeede73ec2e350b013210ec57ee18bc8c3d2acf877de17e23125c0368c8427818eb05a7df3d181cc55b7e9c702e
data/README.md CHANGED
@@ -99,7 +99,7 @@ For example, if you change the file `DataCentuar.groovy`, if there is a correspo
99
99
 
100
100
  ### Multi-project builds
101
101
 
102
- If you have a multi-project build, you can still use Guard:Gradle. You'll need to edit your `Guardfile` slightly by adding a special `multi_project` flag and passing in the project names. For instance, if you have a multi-project with two projects named "Foo" and "Bar", your `Guardfile` will need to look like so:
102
+ If you have a multi-project build, you can still use Guard::Gradle. You'll need to edit your `Guardfile` slightly by adding a special `multi_project` flag and passing in the project names. For instance, if you have a multi-project with two projects named "Foo" and "Bar", your `Guardfile` will need to look like so:
103
103
 
104
104
  ```ruby
105
105
  guard :gradle, multi_project: true do
@@ -109,6 +109,27 @@ end
109
109
  ```
110
110
  Be sure to have this `Guardfile` in the root of your project.
111
111
 
112
+ ### Configurable command/task/flags
113
+
114
+ If you want to customize how gradle runs, there are several configuration flags
115
+ available.
116
+
117
+ * `command` specifies the command line program to run. Can be useful if your
118
+ team wants to use globally installed gradle instead of the gradle wrapper. Default is
119
+ `./gradlew`
120
+ * `task` specifies the gradle task. Default is `test`
121
+ * `flags` allows additional gradle command line flags, such as `--quiet`,
122
+ `--stacktrace` or others. Default is false (no flags)
123
+
124
+ For example, if you want to run with quiet logging, using a global gradle, and
125
+ the `cleanTest test` gradle task, your `Guardfile` would look something like this:
126
+
127
+ ```ruby
128
+ guard :gradle, command: 'gradle', task: 'cleanTest test', flags: '--quiet' do
129
+ watch(%r{^src/main/(.+)\.*$}) { |m| m[1].split('.')[0].split('/')[-1] }
130
+ end
131
+ ```
132
+
112
133
  ## Notifications
113
134
 
114
135
  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.
@@ -121,4 +142,4 @@ For instance, as I use [Growl](http://growl.info/), I have updated my `Gemfile`
121
142
  2. Create your feature branch (`git checkout -b my-new-feature`)
122
143
  3. Commit your changes (`git commit -am 'Add some feature'`)
123
144
  4. Push to the branch (`git push origin my-new-feature`)
124
- 5. Create new Pull Request
145
+ 5. Create new Pull Request
data/lib/guard/gradle.rb CHANGED
@@ -4,15 +4,31 @@ require 'guard/plugin'
4
4
 
5
5
  module Guard
6
6
  class Gradle < Plugin
7
-
8
- DEF_CMD = './gradlew test'
9
-
10
- @multi_projs = false
11
7
 
12
8
  def initialize(options = {})
9
+ @command = './gradlew'
10
+ @task = 'test'
11
+ @multi_projs = false
12
+ @flags = false
13
+
13
14
  if options.has_key? :multi_project
14
15
  @multi_projs = options[:multi_project]
15
16
  end
17
+ if options.has_key? :command
18
+ @command = options[:command]
19
+ end
20
+ if options.has_key? :task
21
+ @task = options[:task]
22
+ end
23
+ if options.has_key? :flags
24
+ @flags = options[:flags]
25
+ end
26
+
27
+ @DEF_CMD = "#{@command} #{@task}"
28
+ if @flags
29
+ @DEF_CMD = "#{@DEF_CMD} #{@flags}"
30
+ end
31
+
16
32
  super
17
33
  end
18
34
 
@@ -21,19 +37,19 @@ module Guard
21
37
  project = paths[0].split('/')[0]
22
38
  file = paths[0].split('/')[1]
23
39
  if Dir.glob("#{project}/src/test/**/#{file}*").size > 0
24
- fire_command("#{DEF_CMD} -p #{project} -Dtest.single=#{file} --daemon")
40
+ fire_command("#{@DEF_CMD} -p #{project} -Dtest.single=#{file} --daemon")
25
41
  else
26
42
  run_all
27
43
  end
28
44
  elsif(paths.size == 1) && (Dir.glob("src/test/**/#{paths[0]}*").size > 0)
29
- fire_command("#{DEF_CMD} -Dtest.single=#{paths[0]} --daemon")
45
+ fire_command("#{@DEF_CMD} -Dtest.single=#{paths[0]} --daemon")
30
46
  else
31
47
  run_all
32
48
  end
33
49
  end
34
50
 
35
51
  def run_all
36
- fire_command DEF_CMD
52
+ fire_command @DEF_CMD
37
53
  end
38
54
 
39
55
  def fire_command(command)
@@ -49,11 +65,11 @@ module Guard
49
65
  end
50
66
 
51
67
  def start
52
- fire_command DEF_CMD
68
+ fire_command @DEF_CMD
53
69
  end
54
70
 
55
71
  def run_all
56
- fire_command DEF_CMD
72
+ fire_command @DEF_CMD
57
73
  end
58
74
  end
59
75
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module GradleVersion
3
- VERSION = '0.3.1'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
@@ -29,4 +29,28 @@ class GuardGradleTest < Test::Unit::TestCase
29
29
  Dir.expects(:glob).returns([true])
30
30
  plugin.run_on_changes [expected]
31
31
  end
32
- end
32
+
33
+ def test_for_configurable_command
34
+ plugin = Guard::Gradle.new({command: 'gradle'})
35
+ expected = 'User'
36
+ plugin.expects(:fire_command).with("gradle test -Dtest.single=#{expected} --daemon")
37
+ Dir.expects(:glob).returns([true])
38
+ plugin.run_on_changes [expected]
39
+ end
40
+
41
+ def test_for_configurable_task
42
+ plugin = Guard::Gradle.new({task: 'mySpecialTask'})
43
+ expected = 'User'
44
+ plugin.expects(:fire_command).with("./gradlew mySpecialTask -Dtest.single=#{expected} --daemon")
45
+ Dir.expects(:glob).returns([true])
46
+ plugin.run_on_changes [expected]
47
+ end
48
+
49
+ def test_for_configurable_flags
50
+ plugin = Guard::Gradle.new({flags: '-q -s'})
51
+ expected = 'User'
52
+ plugin.expects(:fire_command).with("./gradlew test -q -s -Dtest.single=#{expected} --daemon")
53
+ Dir.expects(:glob).returns([true])
54
+ plugin.run_on_changes [expected]
55
+ end
56
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-gradle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Ricker
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-06 00:00:00.000000000 Z
12
+ date: 2014-07-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard