rudy 0.8.1 → 0.8.2
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.
- data/CHANGES.txt +21 -8
- data/README.rdoc +43 -1
- data/Rudyfile +28 -27
- data/bin/rudy +8 -15
- data/lib/rudy.rb +2 -2
- data/lib/rudy/cli/routines.rb +4 -20
- data/lib/rudy/config.rb +1 -0
- data/lib/rudy/config/objects.rb +29 -33
- data/lib/rudy/huxtable.rb +9 -1
- data/lib/rudy/routines.rb +113 -96
- data/lib/rudy/routines/helper.rb +3 -3
- data/lib/rudy/routines/helpers/dependshelper.rb +1 -1
- data/lib/rudy/routines/helpers/diskhelper.rb +3 -3
- data/lib/rudy/routines/helpers/scripthelper.rb +41 -39
- data/lib/rudy/routines/helpers/userhelper.rb +5 -5
- data/lib/rudy/routines/passthrough.rb +11 -11
- data/lib/rudy/routines/startup.rb +1 -1
- data/rudy.gemspec +4 -37
- metadata +5 -38
- data/examples/README.md +0 -10
- data/examples/debian-sinatra-passenger/commands.rb +0 -19
- data/examples/debian-sinatra-passenger/machines.rb +0 -32
- data/examples/debian-sinatra-passenger/routines.rb +0 -30
- data/examples/debian-sinatra-thin/commands.rb +0 -17
- data/examples/debian-sinatra-thin/machines.rb +0 -35
- data/examples/debian-sinatra-thin/routines.rb +0 -72
- data/lib/rudy/routines/helpers/scmhelper.rb +0 -39
- data/lib/rudy/routines/release.rb +0 -48
- data/lib/rudy/scm.rb +0 -75
- data/lib/rudy/scm/git.rb +0 -217
- data/lib/rudy/scm/svn.rb +0 -110
- data/test/01_mixins/10_hash_test.rb +0 -25
- data/test/10_config/00_setup_test.rb +0 -20
- data/test/10_config/30_machines_test.rb +0 -69
- data/test/15_scm/00_setup_test.rb +0 -20
- data/test/15_scm/20_git_test.rb +0 -61
- data/test/20_sdb/00_setup_test.rb +0 -16
- data/test/20_sdb/10_domains_test.rb +0 -115
- data/test/25_ec2/00_setup_test.rb +0 -29
- data/test/25_ec2/10_keypairs_test.rb +0 -41
- data/test/25_ec2/20_groups_test.rb +0 -131
- data/test/25_ec2/30_addresses_test.rb +0 -38
- data/test/25_ec2/40_volumes_test.rb +0 -49
- data/test/25_ec2/50_snapshots_test.rb +0 -74
- data/test/26_ec2_instances/00_setup_test.rb +0 -28
- data/test/26_ec2_instances/10_instances_test.rb +0 -83
- data/test/26_ec2_instances/50_images_test.rb +0 -13
- data/test/30_sdb_metadata/00_setup_test.rb +0 -21
- data/test/30_sdb_metadata/10_disks_test.rb +0 -109
- data/test/30_sdb_metadata/20_backups_test.rb +0 -102
- data/test/coverage.txt +0 -51
- data/test/helper.rb +0 -36
data/CHANGES.txt
CHANGED
@@ -1,11 +1,25 @@
|
|
1
1
|
RUDY, CHANGES
|
2
2
|
|
3
3
|
|
4
|
+
|
5
|
+
#### 0.8.2 (2009-06-01) ###############################
|
6
|
+
|
7
|
+
* CHANGE: Removed release routine code (it's now a passthrough) and scmhelper. All release stuff should
|
8
|
+
be implemented using the routine blocks.
|
9
|
+
* CHANGE: Passthrough routines no longer check if machine group is running.
|
10
|
+
* CHANGE: Local routines blocks now run from current working directory
|
11
|
+
* CHANGE: Removed SCM classes (moved logic to the Arcade)
|
12
|
+
* CHANGE: Moved examples to the Arcade (experimental)
|
13
|
+
* CHANGE: Command output in routines is now displayed only when verbose is 1 or more.
|
14
|
+
* ADDED: Routine blocks now receive command line options and arguments
|
15
|
+
* ADDED: Commands configuration now supports inline blocks
|
16
|
+
* ADDED: Rudy now looks for ~/.rudy/*.rb config files.
|
17
|
+
|
18
|
+
|
4
19
|
#### 0.8.1 (2009-05-18) ###############################
|
5
20
|
|
6
21
|
* FIXED: The shutdown routine was not working for Windows instances
|
7
22
|
|
8
|
-
|
9
23
|
#### 0.8.0 (2009-05-18) ###############################
|
10
24
|
|
11
25
|
* ADDED: Better windows instance support during routines
|
@@ -20,12 +34,12 @@ RUDY, CHANGES
|
|
20
34
|
* CHANGE: rudy-ec2 console now displays windows password automatically if keypair is supplied.
|
21
35
|
* ADDED: register and destroy commands to rudy-ec2 images
|
22
36
|
|
23
|
-
|
24
37
|
#### 0.7.4 (2009-05-10) ###############################
|
25
38
|
|
26
39
|
* CHANGE: Keypairs now include zone. This was necessary to allow US and EU keypairs to
|
27
|
-
be stored in the same directory.
|
28
|
-
* CHANGE: Moved non-rudy specific modules to separate projects (storable, sysinfo, annoy,
|
40
|
+
be stored in the same directory.
|
41
|
+
* CHANGE: Moved non-rudy specific modules to separate projects (storable, sysinfo, annoy,
|
42
|
+
console -> Drydock, escape -> Rye, tryouts -> tryouts/).
|
29
43
|
* CHANGE: Renamed restart routine to reboot to make it clear it's about the machine
|
30
44
|
* CHANGE: Renamed Rudy::Disk to Rudy::MetaData::Disk
|
31
45
|
* CHANGE: Short alias for rudy-ec2 snapshot is now 's' (instead of 't')
|
@@ -44,7 +58,6 @@ be stored in the same directory.
|
|
44
58
|
* FIXED: Corrected a few minor interface errors in rudy-ec2
|
45
59
|
* ADDED: rudy-ec2 console can now display the decoded admin password for Windows instances.
|
46
60
|
|
47
|
-
|
48
61
|
#### 0.7.2 (2009-05-04) ###############################
|
49
62
|
|
50
63
|
* FIXED: cli/routine.rb release method wasn't sending command alias (which broke rerelease)
|
@@ -90,7 +103,7 @@ to maintain consistency in documentation.
|
|
90
103
|
|
91
104
|
* ADDED: rudy-ec2 status can now display EU status
|
92
105
|
* FIXED: Fixed bug on instance create. Instance.groups was nil, now it returns
|
93
|
-
empty Array.
|
106
|
+
empty Array.
|
94
107
|
|
95
108
|
#### 0.6.6 (2009-04-22) ###############################
|
96
109
|
|
@@ -179,9 +192,9 @@ NOTE: This is a complete re-write from 0.1
|
|
179
192
|
* CHANGE: upgrade to drydock 0.3.3
|
180
193
|
* ADDED: All time references are converted to UTC
|
181
194
|
* ADDED: Safer "Are you sure?". Number of characters to enter is
|
182
|
-
|
195
|
+
commiserate with amount of danger.
|
183
196
|
* ADDED: CLIs: myaddress, addresses, images, instances,
|
184
|
-
|
197
|
+
disks, connect, copy, stage, backups, volumes
|
185
198
|
* ADDED: Metadata storage to SimpleDB for disks, backups
|
186
199
|
* ADDED: Creates EBS volumes based on startup from metadata
|
187
200
|
* ADDED: Automated release process
|
data/README.rdoc
CHANGED
@@ -18,6 +18,48 @@ All configuration is organized into the zones, environments, and roles that you
|
|
18
18
|
|
19
19
|
<em>NOTE: This is a BETA release. That means Rudy's not ready for production use! See Project-Status[http://wiki.github.com/solutious/rudy/project-status].</em>
|
20
20
|
|
21
|
+
== Configuration
|
22
|
+
|
23
|
+
=== Machines
|
24
|
+
|
25
|
+
The machines configuration describes the "physical" characteristics of your infrastructure.
|
26
|
+
|
27
|
+
env :stage do # Define an environment
|
28
|
+
ami 'ami-e348af8a'
|
29
|
+
|
30
|
+
role :app do # Define a role
|
31
|
+
addresses '11.22.33.44' # Use elastic IPs
|
32
|
+
|
33
|
+
disks do # Create EBS volumes
|
34
|
+
path "/rudy/disk1" do
|
35
|
+
size 100
|
36
|
+
device "/dev/sdr"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
=== Routines
|
43
|
+
|
44
|
+
The routines configuration describes repeatable processes that you can execute on your machines.
|
45
|
+
|
46
|
+
startup do # $ rudy startup
|
47
|
+
adduser :rudy
|
48
|
+
authorize :rudy # Enable passwordless login
|
49
|
+
|
50
|
+
disks do # Create a disk
|
51
|
+
restore "/rudy/disk1" # from a backup
|
52
|
+
end
|
53
|
+
|
54
|
+
after :rudy do # Run remote SSH commands
|
55
|
+
mkdir :p, "great" # $ mkdir -p great
|
56
|
+
touch "great/scott" # $ touch great/scott
|
57
|
+
ls :l, :a # $ ls -l -a
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
|
21
63
|
== Features
|
22
64
|
|
23
65
|
* Create complex environments with a single command
|
@@ -112,7 +154,7 @@ I'm very open to contributions!
|
|
112
154
|
* Rubber -- http://github.com/wr0ngway/rubber/wikis
|
113
155
|
* Moonshine -- http://github.com/railsmachine/moonshine/tree
|
114
156
|
* Boto -- http://code.google.com/p/boto/
|
115
|
-
|
157
|
+
* Fabric -- http://www.nongnu.org/fab/
|
116
158
|
|
117
159
|
== License
|
118
160
|
|
data/Rudyfile
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
# ./.rudy/config
|
7
7
|
# ~/.rudy/config
|
8
8
|
#
|
9
|
+
# ~/.rudy/*.rb
|
9
10
|
# ./Rudyfile
|
10
11
|
# ./machines.rb, ./routines.rb, ./commands.rb
|
11
12
|
# ./config/rudy/*.rb
|
@@ -48,9 +49,9 @@ machines do
|
|
48
49
|
#addresses '11.22.33.44' # Define an elastic IP to reuse
|
49
50
|
|
50
51
|
disks do # Define EBS volumes
|
51
|
-
path
|
52
|
+
path '/rudy/disk1' do # The paths can be anything but
|
52
53
|
size 2 # they must be unique.
|
53
|
-
device
|
54
|
+
device '/dev/sdr' # Devices must be unique too.
|
54
55
|
end
|
55
56
|
end
|
56
57
|
end
|
@@ -92,11 +93,12 @@ end
|
|
92
93
|
#
|
93
94
|
commands do
|
94
95
|
allow :make
|
95
|
-
allow :gem_install,
|
96
|
-
allow :apt_get,
|
96
|
+
allow :gem_install, '/usr/bin/gem', 'install', :V, '--no-rdoc', '--no-ri'
|
97
|
+
allow :apt_get, 'apt-get', :y, :q
|
98
|
+
allow :floo, :time, 1 do
|
99
|
+
end
|
97
100
|
end
|
98
101
|
|
99
|
-
|
100
102
|
# ----------------------------------------------------------- ROUTINES --------
|
101
103
|
# The routines block describes the repeatable processes for each machine group.
|
102
104
|
# To run a routine, specify its name on the command-line: rudy startup
|
@@ -104,28 +106,28 @@ routines do
|
|
104
106
|
|
105
107
|
env :stage, :prod do # We'll define routines for the stage-app
|
106
108
|
role :app do # and prod-app machine groups
|
107
|
-
|
109
|
+
|
108
110
|
startup do # $ rudy startup
|
109
|
-
adduser :rudy # Create a user called
|
111
|
+
adduser :rudy # Create a user called 'rudy'
|
110
112
|
authorize :rudy # Enable passwordless logins as rudy
|
111
113
|
#
|
112
114
|
disks do # Define EBS volume routines
|
113
|
-
create
|
115
|
+
create '/rudy/disk1' # Create an EBS volume, attach it, give
|
114
116
|
end # it a filesystem, and mount it.
|
115
117
|
#
|
116
118
|
after :rudy do # Run remote SSH commands after startup
|
117
|
-
mkdir :p,
|
118
|
-
touch
|
119
|
-
ls :l, :a
|
119
|
+
mkdir :p, 'great' # $ mkdir -p great
|
120
|
+
touch 'great/scott' # $ touch great/scott
|
121
|
+
ls :l, :a, '*' # $ ls -l -a *
|
120
122
|
end
|
121
123
|
end
|
122
124
|
|
123
125
|
shutdown do # $ rudy shutdown
|
124
|
-
|
126
|
+
script :root do # Run remote SSH commands before shutdown
|
125
127
|
uptime
|
126
128
|
end
|
127
129
|
disks do
|
128
|
-
destroy
|
130
|
+
destroy '/rudy/disk1' # Unmount and destroy the EBS volume
|
129
131
|
end
|
130
132
|
end
|
131
133
|
|
@@ -140,14 +142,14 @@ routines do
|
|
140
142
|
|
141
143
|
backup do # $ rudy backup
|
142
144
|
disks do # A simple routine that creates an EBS
|
143
|
-
snapshot
|
145
|
+
snapshot '/rudy/disk1' # snapshot of the specified volume.
|
144
146
|
end
|
145
147
|
end
|
146
148
|
|
147
|
-
|
149
|
+
restore do # $ rudy restore
|
148
150
|
disks do # A contrived example of restoring a
|
149
|
-
destroy
|
150
|
-
restore
|
151
|
+
destroy '/rudy/disk1' # disk from a backup. NOTE: You'll need
|
152
|
+
restore '/rudy/disk1' # to run 'rudy backup' at least once
|
151
153
|
end # before otherise there are no backups
|
152
154
|
end # to restore from.
|
153
155
|
|
@@ -157,28 +159,27 @@ routines do
|
|
157
159
|
# Define global routines available to all machine groups
|
158
160
|
# This routine will update a basic Debian machine and
|
159
161
|
# install essential libraries.
|
160
|
-
# See
|
162
|
+
# See http://github.com/rudy/arcade
|
161
163
|
sysupdate do # $ rudy sysupdate
|
162
164
|
before :root do
|
163
|
-
apt_get
|
164
|
-
apt_get
|
165
|
-
apt_get
|
165
|
+
apt_get 'update' # Update debian / ubuntu
|
166
|
+
apt_get 'install', 'build-essential', 'sqlite3', 'libsqlite3-dev'
|
167
|
+
apt_get 'install', 'apache2-prefork-dev', 'libapr1-dev'
|
166
168
|
gem_install 'rudy'
|
167
169
|
end
|
168
170
|
end
|
169
171
|
|
170
172
|
anything do # $ rudy anything
|
171
|
-
before :
|
172
|
-
|
173
|
+
before :uptime # Specify a dependency
|
174
|
+
script_local do # This is Ruby, so any valid syntax
|
173
175
|
ls :l # can be used in the definitions.
|
174
176
|
end # See: SysInfo gem for more info.
|
175
177
|
end
|
176
178
|
|
177
|
-
|
178
|
-
|
179
|
-
uptime
|
179
|
+
uptime do # $ rudy uptime
|
180
|
+
script_local do
|
181
|
+
uptime
|
180
182
|
end
|
181
183
|
end
|
182
|
-
|
183
184
|
end
|
184
185
|
|
data/bin/rudy
CHANGED
@@ -21,8 +21,8 @@ require 'rudy/cli'
|
|
21
21
|
class RudyCLI < Rudy::CLI::Base
|
22
22
|
|
23
23
|
debug :off
|
24
|
-
default :machines
|
25
|
-
trawler :passthrough
|
24
|
+
default :machines # when no command is provided
|
25
|
+
trawler :passthrough # unknown command names will forward here.
|
26
26
|
|
27
27
|
# ------------------------------------------ RUDY GLOBALS --------
|
28
28
|
# ------------------------------------------------------------------
|
@@ -62,33 +62,26 @@ class RudyCLI < Rudy::CLI::Base
|
|
62
62
|
|
63
63
|
# A "do nothing" routine. Passthrough simply executes a routine
|
64
64
|
# config block. Drydock's trawler uses this for unknown commands.
|
65
|
-
about "A
|
65
|
+
about "A passthrough for custom routines"
|
66
|
+
usage "rudy [custom-routine]"
|
67
|
+
option :m, :message, String, "A message"
|
66
68
|
command :passthrough => Rudy::CLI::Routines
|
67
69
|
|
68
70
|
about "Startup a machine group"
|
69
71
|
usage "rudy startup"
|
72
|
+
option :m, :message, String, "A message"
|
70
73
|
command :startup => Rudy::CLI::Routines
|
71
74
|
|
72
75
|
about "Shutdown a machine group"
|
73
76
|
usage "rudy shutdown"
|
77
|
+
option :m, :message, String, "A message"
|
74
78
|
command :shutdown => Rudy::CLI::Routines
|
75
79
|
|
76
80
|
about "Reboot a machine group"
|
77
81
|
usage "rudy reboot"
|
82
|
+
option :m, :message, String, "A message"
|
78
83
|
command :reboot => Rudy::CLI::Routines
|
79
84
|
|
80
|
-
about "Create a release"
|
81
|
-
usage "rudy release"
|
82
|
-
command :release => Rudy::CLI::Routines
|
83
|
-
command_alias :release, :rerelease
|
84
|
-
|
85
|
-
#about "Update the release currently running in a machine group"
|
86
|
-
#command :rerelease => Rudy::CLI::Routines
|
87
|
-
#command_alias :rerelease, :rere
|
88
|
-
|
89
|
-
#about "Deploy disk snapshots from one machine to another"
|
90
|
-
#command :deploy => Rudy::CLI::Routines
|
91
|
-
|
92
85
|
|
93
86
|
# ------------------------------------ RUDY MISCELLANEOUS --------
|
94
87
|
# ------------------------------------------------------------------
|
data/lib/rudy.rb
CHANGED
@@ -38,7 +38,7 @@ module Rudy
|
|
38
38
|
unless defined?(MAJOR)
|
39
39
|
MAJOR = 0.freeze
|
40
40
|
MINOR = 8.freeze
|
41
|
-
TINY =
|
41
|
+
TINY = 2.freeze
|
42
42
|
end
|
43
43
|
def self.to_s; [MAJOR, MINOR, TINY].join('.'); end
|
44
44
|
def self.to_f; self.to_s.to_f; end
|
@@ -163,6 +163,6 @@ require 'rudy/aws' # is
|
|
163
163
|
require 'rudy/metadata' # important
|
164
164
|
require 'rudy/machines'
|
165
165
|
require 'rudy/routines'
|
166
|
-
|
166
|
+
|
167
167
|
|
168
168
|
|
data/lib/rudy/cli/routines.rb
CHANGED
@@ -4,7 +4,7 @@ module Rudy; module CLI;
|
|
4
4
|
class Routines < Rudy::CLI::CommandBase
|
5
5
|
|
6
6
|
def startup_valid?
|
7
|
-
@rr = Rudy::Routines::Startup.new
|
7
|
+
@rr = Rudy::Routines::Startup.new(@alias, @option, @argv)
|
8
8
|
@rr.raise_early_exceptions
|
9
9
|
true
|
10
10
|
end
|
@@ -17,7 +17,7 @@ module Rudy; module CLI;
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def reboot_valid?
|
20
|
-
@rr = Rudy::Routines::Reboot.new
|
20
|
+
@rr = Rudy::Routines::Reboot.new(@alias, @option, @argv)
|
21
21
|
@rr.raise_early_exceptions
|
22
22
|
true
|
23
23
|
end
|
@@ -29,24 +29,8 @@ module Rudy; module CLI;
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def release_valid?
|
33
|
-
@rr = Rudy::Routines::Release.new(@alias) # Important: could be rerelease
|
34
|
-
@rr.raise_early_exceptions
|
35
|
-
true
|
36
|
-
end
|
37
|
-
def release
|
38
|
-
machines = @rr.execute
|
39
|
-
|
40
|
-
unless machines.empty?
|
41
|
-
puts $/, "The following machines were processed:"
|
42
|
-
machines.each do |machine|
|
43
|
-
puts machine.to_s
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
32
|
def passthrough_valid?
|
49
|
-
@rr = Rudy::Routines::Passthrough.new(@alias)
|
33
|
+
@rr = Rudy::Routines::Passthrough.new(@alias, @option, @argv)
|
50
34
|
@rr.raise_early_exceptions
|
51
35
|
true
|
52
36
|
end
|
@@ -76,7 +60,7 @@ module Rudy; module CLI;
|
|
76
60
|
end
|
77
61
|
|
78
62
|
def shutdown_valid?
|
79
|
-
@rr = Rudy::Routines::Shutdown.new
|
63
|
+
@rr = Rudy::Routines::Shutdown.new(@alias, @option, @argv)
|
80
64
|
@rr.raise_early_exceptions
|
81
65
|
true
|
82
66
|
end
|
data/lib/rudy/config.rb
CHANGED
@@ -64,6 +64,7 @@ module Rudy
|
|
64
64
|
typelist = self.keys.collect { |g| "#{g}.rb" }.join(',')
|
65
65
|
|
66
66
|
# Rudy then looks for the rest of the config in these locations
|
67
|
+
@paths += Dir.glob(File.join(Rudy.sysinfo.home, '.rudy', '*.rb')) || []
|
67
68
|
@paths += Dir.glob(File.join(cwd, 'Rudyfile')) || []
|
68
69
|
@paths += Dir.glob(File.join(cwd, 'config', 'rudy', '*.rb')) || []
|
69
70
|
@paths += Dir.glob(File.join(cwd, '.rudy', '*.rb')) || []
|
data/lib/rudy/config/objects.rb
CHANGED
@@ -33,11 +33,14 @@ class Rudy::Config
|
|
33
33
|
@@processed = false
|
34
34
|
forced_array :allow
|
35
35
|
forced_array :deny
|
36
|
+
chill :allow
|
37
|
+
|
36
38
|
def init
|
37
39
|
# We can't process the Rye::Cmd commands here because the
|
38
40
|
# DSL hasn't been parsed yet so Rudy::Config.postprocess
|
39
41
|
# called the following postprocess method after parsing.
|
40
42
|
end
|
43
|
+
|
41
44
|
# Process the directives specified in the commands config.
|
42
45
|
# NOTE: This affects the processing of the routines config
|
43
46
|
# which only works if commands is parsed first. This works
|
@@ -54,52 +57,45 @@ class Rudy::Config
|
|
54
57
|
# commands do
|
55
58
|
# allow :kill
|
56
59
|
# allow :custom_script, '/full/path/2/custom_script'
|
57
|
-
# allow :git_clone,
|
60
|
+
# allow :git_clone, '/usr/bin/git', 'clone'
|
58
61
|
# end
|
59
62
|
#
|
60
63
|
# * Tells Routines to force_array on the command name.
|
61
64
|
# This is important b/c of the way we parse commands
|
62
65
|
self.allow.each do |cmd|
|
63
|
-
cmd,
|
64
|
-
|
65
|
-
# If no path was specified, we can assume cmd is in the remote path so
|
66
|
-
# when we add the method to Rye::Cmd, we'll it the path is "cmd".
|
67
|
-
path ||= cmd.to_s
|
68
|
-
|
69
|
-
# We cannot allow new commands to be defined that conflict use known
|
70
|
-
# routines keywords. This is based on keywords in the current config.
|
71
|
-
# NOTE: We can't check for this right now b/c the routines config
|
72
|
-
# won't necessarily have been parsed yet. TODO: Figure it out!
|
73
|
-
#if Caesars.known_symbol_by_glass?(:routines, cmd)
|
74
|
-
# raise ReservedKeyword.new(:commands, cmd)
|
75
|
-
#end
|
66
|
+
cmd, *args = *cmd
|
76
67
|
|
77
68
|
# We can allow existing commands to be overridden but we
|
78
69
|
# print a message to STDERR so the user knows what's up.
|
79
|
-
STDERR.puts "
|
80
|
-
|
81
|
-
# The second argument if supplied must be a filesystem path
|
82
|
-
raise PathNotString.new(:commands, cmd) if path && !path.is_a?(String)
|
70
|
+
STDERR.puts "Redefining #{cmd}" if Rye::Cmd.can?(cmd)
|
83
71
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
72
|
+
if args.last.is_a?(Proc)
|
73
|
+
block = args.pop
|
74
|
+
Rye::Cmd.add_command(cmd, nil, args, &block)
|
75
|
+
else
|
76
|
+
# If no path was specified, we can assume cmd is in the remote path so
|
77
|
+
# when we add the method to Rye::Cmd, we'll it the path is "cmd".
|
78
|
+
path = args.shift || cmd.to_s
|
79
|
+
|
80
|
+
raise PathNotString.new(:commands, cmd) if path && !path.is_a?(String)
|
81
|
+
|
82
|
+
Rye::Cmd.add_command cmd, path, args
|
83
|
+
|
92
84
|
end
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
85
|
+
|
86
|
+
|
87
|
+
## We cannot allow new commands to be defined that conflict use known
|
88
|
+
## routines keywords. This is based on keywords in the current config.
|
89
|
+
## NOTE: We can't check for this right now b/c the routines config
|
90
|
+
## won't necessarily have been parsed yet. TODO: Figure it out!
|
91
|
+
##if Caesars.known_symbol_by_glass?(:routines, cmd)
|
92
|
+
## raise ReservedKeyword.new(:commands, cmd)
|
93
|
+
##end
|
99
94
|
|
100
95
|
end
|
96
|
+
|
101
97
|
## NOTE: We now process command blocks as Procs rather than individual commands.
|
102
|
-
|
98
|
+
## There's currently no need to ForceRefresh here
|
103
99
|
##raise Caesars::Config::ForceRefresh.new(:routines)
|
104
100
|
end
|
105
101
|
end
|