Skip to content

Commit

Permalink
dump Guard:guard + fix specs (stub verification)
Browse files Browse the repository at this point in the history
  • Loading branch information
e2 committed Jun 11, 2014
1 parent 9ca7229 commit dd3ba3e
Show file tree
Hide file tree
Showing 35 changed files with 503 additions and 545 deletions.
36 changes: 20 additions & 16 deletions lib/guard/commands/all.rb
@@ -1,33 +1,37 @@
module Guard
# Command to run all default plugin tasks
class Interactor
ALL = Pry::CommandSet.new do
create_command 'all' do
# required for async_queue_add
require 'guard'

group 'Guard'
description 'Run all plugins.'
module Guard
module Commands
class All
def self.import
Pry::Commands.create_command 'all' do
group 'Guard'
description 'Run all plugins.'

banner <<-BANNER
banner <<-BANNER
Usage: all <scope>
Run the Guard plugin `run_all` action.
You may want to specify an optional scope to the action,
either the name of a Guard plugin or a plugin group.
BANNER
BANNER

def process(*entries)
scopes, unknown = ::Guard::Interactor.convert_scope(entries)

def process(*entries)
scopes, rest = ::Guard::Interactor.convert_scope(entries)
unless unknown.empty?
output.puts "Unknown scopes: #{ unknown.join(', ') }"
return
end

if rest.empty?
::Guard.async_queue_add([:guard_run_all, scopes])
else
output.puts "Unknown scope #{ rest.join(', ') }"
Guard.async_queue_add([:guard_run_all, scopes])
end
end
end
end
end
end

Pry.commands.import ::Guard::Interactor::ALL
Guard::Commands::All.import
30 changes: 14 additions & 16 deletions lib/guard/commands/change.rb
@@ -1,31 +1,29 @@
module Guard
# Command to simulate file change events
class Interactor
CHANGE = Pry::CommandSet.new do
create_command 'change' do
module Commands
class Change
def self.import
Pry::Commands.create_command 'change' do
group 'Guard'
description 'Trigger a file change.'

group 'Guard'
description 'Trigger a file change.'

banner <<-BANNER
banner <<-BANNER
Usage: change <file> <other_file>
Pass the given files to the Guard plugin `run_on_changes` action.
BANNER
BANNER

def process(*entries)
_, files = ::Guard::Interactor.convert_scope(entries)
def process(*files)
if files.empty?
output.puts 'Please specify a file.'
return
end

if files.empty?
output.puts 'Please specify a file.'
else
::Guard.async_queue_add(modified: files, added: [], removed: [])
end
end

end
end
end
end

Pry.commands.import ::Guard::Interactor::CHANGE
Guard::Commands::Change.import
24 changes: 12 additions & 12 deletions lib/guard/commands/notification.rb
@@ -1,26 +1,26 @@
require 'guard/notifier'

module Guard
# Command to toggle notifications on and off
class Interactor
NOTIFICATION = Pry::CommandSet.new do
create_command 'notification' do
module Commands
class Notification
def self.import
Pry::Commands.create_command 'notification' do
group 'Guard'
description 'Toggles the notifications.'

group 'Guard'
description 'Toggles the notifications.'

banner <<-BANNER
banner <<-BANNER
Usage: notification
Toggles the notifications on and off.
BANNER
BANNER

def process
::Guard::Notifier.toggle
def process
::Guard::Notifier.toggle
end
end
end
end
end
end

Pry.commands.import ::Guard::Interactor::NOTIFICATION
Guard::Commands::Notification.import
23 changes: 12 additions & 11 deletions lib/guard/commands/pause.rb
@@ -1,26 +1,27 @@
module Guard
class Interactor
PAUSE = Pry::CommandSet.new do
create_command 'pause' do
module Commands
class Pause
def self.import
Pry::Commands.create_command 'pause' do
group 'Guard'
description 'Toggles the file listener.'

group 'Guard'
description 'Toggles the file listener.'

banner <<-BANNER
banner <<-BANNER
Usage: pause
Toggles the file listener on and off.
When the file listener is paused, the default Guard Pry
prompt will show the pause sign `[p]`.
BANNER
BANNER

def process
::Guard.async_queue_add([:guard_pause])
def process
::Guard.async_queue_add([:guard_pause])
end
end
end
end
end
end

Pry.commands.import ::Guard::Interactor::PAUSE
Guard::Commands::Pause.import
33 changes: 17 additions & 16 deletions lib/guard/commands/reload.rb
@@ -1,33 +1,34 @@
module Guard
class Interactor
RELOAD = Pry::CommandSet.new do
create_command 'reload' do

group 'Guard'
description 'Reload all plugins.'

banner <<-BANNER
module Commands
class Reload
def self.import
Pry::Commands.create_command 'reload' do
group 'Guard'
description 'Reload all plugins.'

banner <<-BANNER
Usage: reload <scope>
Run the Guard plugin `reload` action.
You may want to specify an optional scope to the action,
either the name of a Guard plugin or a plugin group.
BANNER
BANNER

def process(*entries)
scopes, rest = ::Guard::Interactor.convert_scope(entries)
def process(*entries)
scopes, unknown = ::Guard::Interactor.convert_scope(entries)

unless unknown.empty?
output.puts "Unknown scopes: #{ unknown.join(', ') }"
return
end

if rest.empty?
::Guard.async_queue_add([:guard_reload, scopes])
else
output.puts "Unknown scope #{ rest.join(', ') }"
end
end

end
end
end
end

Pry.commands.import ::Guard::Interactor::RELOAD
Guard::Commands::Reload.import
37 changes: 22 additions & 15 deletions lib/guard/commands/scope.rb
@@ -1,29 +1,36 @@
module Guard
class Interactor
SCOPE = Pry::CommandSet.new do
create_command 'scope' do
group 'Guard'
description 'Scope Guard actions to groups and plugins.'
module Commands
class Scope
def self.import
Pry::Commands.create_command 'scope' do
group 'Guard'
description 'Scope Guard actions to groups and plugins.'

banner <<-BANNER
banner <<-BANNER
Usage: scope <scope>
Set the global Guard scope.
BANNER
BANNER

def process(*entries)
scope, _ = ::Guard::Interactor.convert_scope(entries)
def process(*entries)
scope, unknown = Guard::Interactor.convert_scope(entries)

if scope[:plugins].empty? && scope[:groups].empty?
output.puts 'Usage: scope <scope>'
else
::Guard.scope = scope
unless unknown.empty?
output.puts "Unknown scopes: #{unknown.join(',') }"
return
end

if scope[:plugins].empty? && scope[:groups].empty?
output.puts 'Usage: scope <scope>'
return
end

Guard.scope = scope
end
end

end
end
end
end

Pry.commands.import ::Guard::Interactor::SCOPE
Guard::Commands::Scope.import
25 changes: 12 additions & 13 deletions lib/guard/commands/show.rb
@@ -1,25 +1,24 @@
require 'guard/dsl_describer'

module Guard
class Interactor
SHOW = Pry::CommandSet.new do
create_command 'show' do

group 'Guard'
description 'Show all Guard plugins.'
module Commands
class Show
def self.import
Pry::Commands.create_command 'show' do
group 'Guard'
description 'Show all Guard plugins.'

banner <<-BANNER
banner <<-BANNER
Usage: show
Show all defined Guard plugins and their options.
BANNER
BANNER

def process
::Guard.async_queue_add([:guard_show])
def process
::Guard.async_queue_add([:guard_show])
end
end
end
end
end
end

Pry.commands.import ::Guard::Interactor::SHOW
Guard::Commands::Show.import
42 changes: 0 additions & 42 deletions lib/guard/guard.rb

This file was deleted.

4 changes: 4 additions & 0 deletions lib/guard/plugin_util.rb
Expand Up @@ -37,6 +37,10 @@ def self.plugin_names
end
end
else
Guard::UI.deprecation \
'Rubygems version prior to 1.8.0 are no longer supported'\
' and may not work'

Gem.source_index.find_name(/^guard-/)
end.map { |x| x.name.sub(/^guard-/, '') }.uniq
end
Expand Down

0 comments on commit dd3ba3e

Please sign in to comment.