Class: Guard::Gradle
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::Gradle
- Defined in:
- lib/guard/gradle.rb
Instance Method Summary collapse
- #fire_command(command) ⇒ Object
-
#initialize(options = {}) ⇒ Gradle
constructor
A new instance of Gradle.
- #notify(summary, image) ⇒ Object
- #run_all ⇒ Object
- #run_on_changes(paths) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Gradle
Returns a new instance of Gradle.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/guard/gradle.rb', line 8 def initialize( = {}) @command = './gradlew' @task = 'test' @multi_projs = false @flags = false if .has_key? :multi_project @multi_projs = [:multi_project] end if .has_key? :command @command = [:command] end if .has_key? :task @task = [:task] end if .has_key? :flags @flags = [:flags] end @DEF_CMD = "#{@command} #{@task}" if @flags @DEF_CMD = "#{@DEF_CMD} #{@flags}" end super end |
Instance Method Details
#fire_command(command) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/guard/gradle.rb', line 55 def fire_command(command) UI.info "running #{command}" result = system command summary = result ? 'Success' : 'Failure' image = result ? :success : :failed notify(summary, image) end |
#notify(summary, image) ⇒ Object
63 64 65 |
# File 'lib/guard/gradle.rb', line 63 def notify(summary, image) ::Guard::Notifier.notify(summary, title: 'Gradle Test Results', image: image) end |
#run_all ⇒ Object
51 52 53 |
# File 'lib/guard/gradle.rb', line 51 def run_all fire_command @DEF_CMD end |
#run_on_changes(paths) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/guard/gradle.rb', line 35 def run_on_changes(paths) if paths.size == 1 && @multi_projs project = paths[0].split('/')[0] file = paths[0].split('/')[1] if Dir.glob("#{project}/src/test/**/#{file}*").size > 0 fire_command("#{@DEF_CMD} -p #{project} -Dtest.single=#{file} --daemon") else run_all end elsif(paths.size == 1) && (Dir.glob("src/test/**/#{paths[0]}*").size > 0) fire_command("#{@DEF_CMD} -Dtest.single=#{paths[0]} --daemon") else run_all end end |
#start ⇒ Object
67 68 69 |
# File 'lib/guard/gradle.rb', line 67 def start fire_command @DEF_CMD end |