-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from fuzzygroup/master
Add template to server as a guide for extending Betty
- Loading branch information
Showing
5 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Git | ||
def self.interpret(command) | ||
responses = [] | ||
|
||
if command.match(/^undo\s+git\s+add$/i) | ||
responses << { | ||
:say => "To undo a single file use\n\ngit reset filespec\n\n\nTo undo ALL files added (i.e. you want to undo git add .) then use\n\ngit reset" | ||
} | ||
end | ||
|
||
responses | ||
end | ||
|
||
def self.help | ||
commands = [] | ||
commands << { | ||
:category => "Git", | ||
:usage => ["undo git add"] | ||
} | ||
commands | ||
end | ||
end | ||
|
||
$executors << Git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# | ||
# This file is a template that is designed to give you a starting point for extending Betty | ||
# Copy this file to what you want to extend Betty with. Personally I wrote this as a precursor to | ||
# extending Betty to supporting git development so my first step would be | ||
# | ||
# cp lib/_template.rb lib/git.rb | ||
# | ||
|
||
module Template | ||
# | ||
# If you need unit conversions or other meta methods you'd want to locate them here at the top to be consistent with the code base | ||
# See process.rb for examples or convert.rb | ||
|
||
# | ||
# You need a self.interpret method which grabs the command and deals with it | ||
# | ||
def self.interpret(command) | ||
responses = [] | ||
|
||
# | ||
# The guts generally boil down to one or more regular expression matcher against the user's command | ||
# | ||
# Remember to use \s+ as a token delimiter and use () for grouping | ||
# | ||
if command.match(/^$/) | ||
search_term = $1.gsub(' ', '%20') | ||
|
||
# | ||
# Build a hash of the possible responses to the user (Note :url is a new idea that I'm floating here) | ||
# | ||
# Your typical options are :command, :say, :explanation | ||
# :command represents the command you want to give the user | ||
# :say is something to be said out loud | ||
# :explanation is what we're teaching the user | ||
# :url is an web url where more details are available | ||
# | ||
# Use Command.browser(url) as a way to open a url | ||
# | ||
responses << { | ||
:command => "", | ||
:explanation => "" | ||
} | ||
end | ||
|
||
# | ||
# Return responses | ||
# | ||
responses | ||
end | ||
|
||
# | ||
# The help structure | ||
# | ||
def self.help | ||
commands = [] | ||
commands << { | ||
:category => "", | ||
:description => '', | ||
:usage => [""] | ||
} | ||
commands | ||
end | ||
end | ||
|
||
# this last line is where the magic actually happens; you need to take the executors and assign it to something that does the work | ||
# here it is commented out since this is, well, a template | ||
#$executors << Some Class Goes Here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'spec_helper' | ||
|
||
describe 'Fun' do | ||
|
||
context 'undo git add' do | ||
it { responds_with say: "To undo a single file use\n\ngit reset filespec\n\n\nTo undo ALL files added (i.e. you want to undo git add .) then use\n\ngit reset" } | ||
end | ||
|
||
end |