engineyard-serverside 1.5.21 → 1.5.23.ruby19
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/engineyard-serverside/cli.rb +39 -45
- data/lib/engineyard-serverside/configuration.rb +28 -4
- data/lib/engineyard-serverside/deploy.rb +5 -4
- data/lib/engineyard-serverside/logged_output.rb +3 -5
- data/lib/engineyard-serverside/server.rb +26 -2
- data/lib/engineyard-serverside/task.rb +2 -4
- data/lib/engineyard-serverside/version.rb +1 -1
- data/lib/engineyard-serverside.rb +8 -20
- data/spec/basic_deploy_spec.rb +1 -1
- data/spec/bundler_deploy_spec.rb +1 -1
- data/spec/nodejs_deploy_spec.rb +1 -1
- data/spec/rails31_deploy_spec.rb +1 -1
- data/spec/services_deploy_spec.rb +1 -1
- metadata +80 -233
- data/lib/vendor/dataflow/HISTORY +0 -52
- data/lib/vendor/dataflow/LICENSE +0 -19
- data/lib/vendor/dataflow/README.textile +0 -290
- data/lib/vendor/dataflow/Rakefile +0 -36
- data/lib/vendor/dataflow/dataflow/actor.rb +0 -22
- data/lib/vendor/dataflow/dataflow/equality.rb +0 -44
- data/lib/vendor/dataflow/dataflow/future_queue.rb +0 -24
- data/lib/vendor/dataflow/dataflow/port.rb +0 -54
- data/lib/vendor/dataflow/dataflow.rb +0 -124
- data/lib/vendor/dataflow/examples/barrier.rb +0 -9
- data/lib/vendor/dataflow/examples/data_driven.rb +0 -17
- data/lib/vendor/dataflow/examples/dataflow_http_gets.rb +0 -13
- data/lib/vendor/dataflow/examples/flow.rb +0 -20
- data/lib/vendor/dataflow/examples/future_http_gets.rb +0 -12
- data/lib/vendor/dataflow/examples/future_queue.rb +0 -11
- data/lib/vendor/dataflow/examples/instance_variables.rb +0 -15
- data/lib/vendor/dataflow/examples/laziness.rb +0 -9
- data/lib/vendor/dataflow/examples/local_variables.rb +0 -11
- data/lib/vendor/dataflow/examples/messages.rb +0 -26
- data/lib/vendor/dataflow/examples/port_http_gets.rb +0 -13
- data/lib/vendor/dataflow/examples/port_send.rb +0 -10
- data/lib/vendor/dataflow/examples/ring.rb +0 -21
- data/lib/vendor/dataflow/spec/actor_spec.rb +0 -28
- data/lib/vendor/dataflow/spec/anonymous_variables_spec.rb +0 -21
- data/lib/vendor/dataflow/spec/barrier_spec.rb +0 -25
- data/lib/vendor/dataflow/spec/by_need_spec.rb +0 -55
- data/lib/vendor/dataflow/spec/dataflow_spec.rb +0 -151
- data/lib/vendor/dataflow/spec/equality_spec.rb +0 -40
- data/lib/vendor/dataflow/spec/flow_spec.rb +0 -25
- data/lib/vendor/dataflow/spec/forker_spec.rb +0 -28
- data/lib/vendor/dataflow/spec/future_queue_spec.rb +0 -31
- data/lib/vendor/dataflow/spec/inspect_spec.rb +0 -19
- data/lib/vendor/dataflow/spec/need_later_spec.rb +0 -12
- data/lib/vendor/dataflow/spec/port_spec.rb +0 -26
- data/lib/vendor/dataflow/spec/spec.opts +0 -1
- data/lib/vendor/dataflow/spec/spec_helper.rb +0 -10
- data/lib/vendor/escape/Readme +0 -21
- data/lib/vendor/escape/doc_include/template/qualitysmith.rb +0 -631
- data/lib/vendor/json_pure/CHANGES +0 -166
- data/lib/vendor/json_pure/COPYING +0 -58
- data/lib/vendor/json_pure/GPL +0 -340
- data/lib/vendor/json_pure/README +0 -358
- data/lib/vendor/json_pure/Rakefile +0 -292
- data/lib/vendor/json_pure/TODO +0 -1
- data/lib/vendor/json_pure/VERSION +0 -1
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +0 -52
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +0 -900
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +0 -901
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +0 -261
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +0 -262
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +0 -82
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +0 -34
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +0 -900
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +0 -901
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +0 -81
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +0 -82
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +0 -82
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +0 -1000
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +0 -1001
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +0 -82
- data/lib/vendor/json_pure/benchmarks/generator2_benchmark.rb +0 -222
- data/lib/vendor/json_pure/benchmarks/generator_benchmark.rb +0 -224
- data/lib/vendor/json_pure/benchmarks/ohai.json +0 -1216
- data/lib/vendor/json_pure/benchmarks/ohai.ruby +0 -1
- data/lib/vendor/json_pure/benchmarks/parser2_benchmark.rb +0 -251
- data/lib/vendor/json_pure/benchmarks/parser_benchmark.rb +0 -259
- data/lib/vendor/json_pure/bin/edit_json.rb +0 -9
- data/lib/vendor/json_pure/bin/prettify_json.rb +0 -75
- data/lib/vendor/json_pure/data/example.json +0 -1
- data/lib/vendor/json_pure/data/index.html +0 -38
- data/lib/vendor/json_pure/data/prototype.js +0 -4184
- data/lib/vendor/json_pure/ext/json/ext/generator/extconf.rb +0 -16
- data/lib/vendor/json_pure/ext/json/ext/generator/generator.c +0 -1323
- data/lib/vendor/json_pure/ext/json/ext/generator/generator.h +0 -170
- data/lib/vendor/json_pure/ext/json/ext/parser/extconf.rb +0 -15
- data/lib/vendor/json_pure/ext/json/ext/parser/parser.c +0 -1935
- data/lib/vendor/json_pure/ext/json/ext/parser/parser.h +0 -71
- data/lib/vendor/json_pure/ext/json/ext/parser/parser.rl +0 -792
- data/lib/vendor/json_pure/install.rb +0 -26
- data/lib/vendor/json_pure/tests/fixtures/fail1.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail10.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail11.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail12.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail13.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail14.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail18.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail19.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail2.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail20.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail21.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail22.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail23.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail24.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail25.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail27.json +0 -2
- data/lib/vendor/json_pure/tests/fixtures/fail28.json +0 -2
- data/lib/vendor/json_pure/tests/fixtures/fail3.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail4.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail5.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail6.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail7.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail8.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/fail9.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/pass1.json +0 -56
- data/lib/vendor/json_pure/tests/fixtures/pass15.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/pass16.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/pass17.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/pass2.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/pass26.json +0 -1
- data/lib/vendor/json_pure/tests/fixtures/pass3.json +0 -6
- data/lib/vendor/json_pure/tests/test_json.rb +0 -361
- data/lib/vendor/json_pure/tests/test_json_addition.rb +0 -162
- data/lib/vendor/json_pure/tests/test_json_encoding.rb +0 -68
- data/lib/vendor/json_pure/tests/test_json_fixtures.rb +0 -34
- data/lib/vendor/json_pure/tests/test_json_generate.rb +0 -122
- data/lib/vendor/json_pure/tests/test_json_rails.rb +0 -144
- data/lib/vendor/json_pure/tests/test_json_unicode.rb +0 -76
- data/lib/vendor/json_pure/tools/fuzz.rb +0 -139
- data/lib/vendor/json_pure/tools/server.rb +0 -61
- data/lib/vendor/open4/lib/open4.rb +0 -403
- data/lib/vendor/thor/CHANGELOG.rdoc +0 -89
- data/lib/vendor/thor/LICENSE +0 -20
- data/lib/vendor/thor/README.rdoc +0 -297
- data/lib/vendor/thor/Thorfile +0 -69
- data/lib/vendor/thor/bin/rake2thor +0 -86
- data/lib/vendor/thor/bin/thor +0 -6
- data/lib/vendor/thor/lib/thor/actions/create_file.rb +0 -103
- data/lib/vendor/thor/lib/thor/actions/directory.rb +0 -91
- data/lib/vendor/thor/lib/thor/actions/empty_directory.rb +0 -134
- data/lib/vendor/thor/lib/thor/actions/file_manipulation.rb +0 -223
- data/lib/vendor/thor/lib/thor/actions/inject_into_file.rb +0 -104
- data/lib/vendor/thor/lib/thor/actions.rb +0 -275
- data/lib/vendor/thor/lib/thor/base.rb +0 -540
- data/lib/vendor/thor/lib/thor/core_ext/file_binary_read.rb +0 -9
- data/lib/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +0 -75
- data/lib/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -100
- data/lib/vendor/thor/lib/thor/error.rb +0 -30
- data/lib/vendor/thor/lib/thor/group.rb +0 -271
- data/lib/vendor/thor/lib/thor/invocation.rb +0 -180
- data/lib/vendor/thor/lib/thor/parser/argument.rb +0 -67
- data/lib/vendor/thor/lib/thor/parser/arguments.rb +0 -150
- data/lib/vendor/thor/lib/thor/parser/option.rb +0 -128
- data/lib/vendor/thor/lib/thor/parser/options.rb +0 -169
- data/lib/vendor/thor/lib/thor/parser.rb +0 -4
- data/lib/vendor/thor/lib/thor/rake_compat.rb +0 -66
- data/lib/vendor/thor/lib/thor/runner.rb +0 -314
- data/lib/vendor/thor/lib/thor/shell/basic.rb +0 -239
- data/lib/vendor/thor/lib/thor/shell/color.rb +0 -108
- data/lib/vendor/thor/lib/thor/shell.rb +0 -83
- data/lib/vendor/thor/lib/thor/task.rb +0 -102
- data/lib/vendor/thor/lib/thor/util.rb +0 -230
- data/lib/vendor/thor/lib/thor/version.rb +0 -3
- data/lib/vendor/thor/lib/thor.rb +0 -244
- data/lib/vendor/thor/thor.gemspec +0 -120
@@ -1,314 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'thor/group'
|
3
|
-
require 'thor/core_ext/file_binary_read'
|
4
|
-
|
5
|
-
require 'fileutils'
|
6
|
-
require 'open-uri'
|
7
|
-
require 'yaml'
|
8
|
-
require 'digest/md5'
|
9
|
-
require 'pathname'
|
10
|
-
|
11
|
-
class Thor::Runner < Thor #:nodoc:
|
12
|
-
map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
|
13
|
-
|
14
|
-
# Override Thor#help so it can give information about any class and any method.
|
15
|
-
#
|
16
|
-
def help(meth=nil)
|
17
|
-
if meth && !self.respond_to?(meth)
|
18
|
-
initialize_thorfiles(meth)
|
19
|
-
klass, task = Thor::Util.find_class_and_task_by_namespace!(meth)
|
20
|
-
klass.start(["-h", task].compact, :shell => self.shell)
|
21
|
-
else
|
22
|
-
super
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# If a task is not found on Thor::Runner, method missing is invoked and
|
27
|
-
# Thor::Runner is then responsable for finding the task in all classes.
|
28
|
-
#
|
29
|
-
def method_missing(meth, *args)
|
30
|
-
meth = meth.to_s
|
31
|
-
initialize_thorfiles(meth)
|
32
|
-
klass, task = Thor::Util.find_class_and_task_by_namespace!(meth)
|
33
|
-
args.unshift(task) if task
|
34
|
-
klass.start(args, :shell => self.shell)
|
35
|
-
end
|
36
|
-
|
37
|
-
desc "install NAME", "Install an optionally named Thor file into your system tasks"
|
38
|
-
method_options :as => :string, :relative => :boolean, :force => :boolean
|
39
|
-
def install(name)
|
40
|
-
initialize_thorfiles
|
41
|
-
|
42
|
-
# If a directory name is provided as the argument, look for a 'main.thor'
|
43
|
-
# task in said directory.
|
44
|
-
begin
|
45
|
-
if File.directory?(File.expand_path(name))
|
46
|
-
base, package = File.join(name, "main.thor"), :directory
|
47
|
-
contents = open(base).read
|
48
|
-
else
|
49
|
-
base, package = name, :file
|
50
|
-
contents = open(name).read
|
51
|
-
end
|
52
|
-
rescue OpenURI::HTTPError
|
53
|
-
raise Error, "Error opening URI '#{name}'"
|
54
|
-
rescue Errno::ENOENT
|
55
|
-
raise Error, "Error opening file '#{name}'"
|
56
|
-
end
|
57
|
-
|
58
|
-
say "Your Thorfile contains:"
|
59
|
-
say contents
|
60
|
-
|
61
|
-
unless options["force"]
|
62
|
-
return false if no?("Do you wish to continue [y/N]?")
|
63
|
-
end
|
64
|
-
|
65
|
-
as = options["as"] || begin
|
66
|
-
first_line = contents.split("\n")[0]
|
67
|
-
(match = first_line.match(/\s*#\s*module:\s*([^\n]*)/)) ? match[1].strip : nil
|
68
|
-
end
|
69
|
-
|
70
|
-
unless as
|
71
|
-
basename = File.basename(name)
|
72
|
-
as = ask("Please specify a name for #{name} in the system repository [#{basename}]:")
|
73
|
-
as = basename if as.empty?
|
74
|
-
end
|
75
|
-
|
76
|
-
location = if options[:relative] || name =~ /^http:\/\//
|
77
|
-
name
|
78
|
-
else
|
79
|
-
File.expand_path(name)
|
80
|
-
end
|
81
|
-
|
82
|
-
thor_yaml[as] = {
|
83
|
-
:filename => Digest::MD5.hexdigest(name + as),
|
84
|
-
:location => location,
|
85
|
-
:namespaces => Thor::Util.namespaces_in_content(contents, base)
|
86
|
-
}
|
87
|
-
|
88
|
-
save_yaml(thor_yaml)
|
89
|
-
say "Storing thor file in your system repository"
|
90
|
-
destination = File.join(thor_root, thor_yaml[as][:filename])
|
91
|
-
|
92
|
-
if package == :file
|
93
|
-
File.open(destination, "w") { |f| f.puts contents }
|
94
|
-
else
|
95
|
-
FileUtils.cp_r(name, destination)
|
96
|
-
end
|
97
|
-
|
98
|
-
thor_yaml[as][:filename] # Indicate success
|
99
|
-
end
|
100
|
-
|
101
|
-
desc "version", "Show Thor version"
|
102
|
-
def version
|
103
|
-
require 'thor/version'
|
104
|
-
say "Thor #{Thor::VERSION}"
|
105
|
-
end
|
106
|
-
|
107
|
-
desc "uninstall NAME", "Uninstall a named Thor module"
|
108
|
-
def uninstall(name)
|
109
|
-
raise Error, "Can't find module '#{name}'" unless thor_yaml[name]
|
110
|
-
say "Uninstalling #{name}."
|
111
|
-
FileUtils.rm_rf(File.join(thor_root, "#{thor_yaml[name][:filename]}"))
|
112
|
-
|
113
|
-
thor_yaml.delete(name)
|
114
|
-
save_yaml(thor_yaml)
|
115
|
-
|
116
|
-
puts "Done."
|
117
|
-
end
|
118
|
-
|
119
|
-
desc "update NAME", "Update a Thor file from its original location"
|
120
|
-
def update(name)
|
121
|
-
raise Error, "Can't find module '#{name}'" if !thor_yaml[name] || !thor_yaml[name][:location]
|
122
|
-
|
123
|
-
say "Updating '#{name}' from #{thor_yaml[name][:location]}"
|
124
|
-
|
125
|
-
old_filename = thor_yaml[name][:filename]
|
126
|
-
self.options = self.options.merge("as" => name)
|
127
|
-
filename = install(thor_yaml[name][:location])
|
128
|
-
|
129
|
-
unless filename == old_filename
|
130
|
-
File.delete(File.join(thor_root, old_filename))
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
desc "installed", "List the installed Thor modules and tasks"
|
135
|
-
method_options :internal => :boolean
|
136
|
-
def installed
|
137
|
-
initialize_thorfiles(nil, true)
|
138
|
-
display_klasses(true, options["internal"])
|
139
|
-
end
|
140
|
-
|
141
|
-
desc "list [SEARCH]", "List the available thor tasks (--substring means .*SEARCH)"
|
142
|
-
method_options :substring => :boolean, :group => :string, :all => :boolean
|
143
|
-
def list(search="")
|
144
|
-
initialize_thorfiles
|
145
|
-
|
146
|
-
search = ".*#{search}" if options["substring"]
|
147
|
-
search = /^#{search}.*/i
|
148
|
-
group = options[:group] || "standard"
|
149
|
-
|
150
|
-
klasses = Thor::Base.subclasses.select do |k|
|
151
|
-
(options[:all] || k.group == group) && k.namespace =~ search
|
152
|
-
end
|
153
|
-
|
154
|
-
display_klasses(false, false, klasses)
|
155
|
-
end
|
156
|
-
|
157
|
-
private
|
158
|
-
|
159
|
-
def self.banner(task)
|
160
|
-
"thor " + task.formatted_usage(self, false)
|
161
|
-
end
|
162
|
-
|
163
|
-
def thor_root
|
164
|
-
Thor::Util.thor_root
|
165
|
-
end
|
166
|
-
|
167
|
-
def thor_yaml
|
168
|
-
@thor_yaml ||= begin
|
169
|
-
yaml_file = File.join(thor_root, "thor.yml")
|
170
|
-
yaml = YAML.load_file(yaml_file) if File.exists?(yaml_file)
|
171
|
-
yaml || {}
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
# Save the yaml file. If none exists in thor root, creates one.
|
176
|
-
#
|
177
|
-
def save_yaml(yaml)
|
178
|
-
yaml_file = File.join(thor_root, "thor.yml")
|
179
|
-
|
180
|
-
unless File.exists?(yaml_file)
|
181
|
-
FileUtils.mkdir_p(thor_root)
|
182
|
-
yaml_file = File.join(thor_root, "thor.yml")
|
183
|
-
FileUtils.touch(yaml_file)
|
184
|
-
end
|
185
|
-
|
186
|
-
File.open(yaml_file, "w") { |f| f.puts yaml.to_yaml }
|
187
|
-
end
|
188
|
-
|
189
|
-
def self.exit_on_failure?
|
190
|
-
true
|
191
|
-
end
|
192
|
-
|
193
|
-
# Load the thorfiles. If relevant_to is supplied, looks for specific files
|
194
|
-
# in the thor_root instead of loading them all.
|
195
|
-
#
|
196
|
-
# By default, it also traverses the current path until find Thor files, as
|
197
|
-
# described in thorfiles. This look up can be skipped by suppliying
|
198
|
-
# skip_lookup true.
|
199
|
-
#
|
200
|
-
def initialize_thorfiles(relevant_to=nil, skip_lookup=false)
|
201
|
-
thorfiles(relevant_to, skip_lookup).each do |f|
|
202
|
-
Thor::Util.load_thorfile(f) unless Thor::Base.subclass_files.keys.include?(File.expand_path(f))
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
# Finds Thorfiles by traversing from your current directory down to the root
|
207
|
-
# directory of your system. If at any time we find a Thor file, we stop.
|
208
|
-
#
|
209
|
-
# We also ensure that system-wide Thorfiles are loaded first, so local
|
210
|
-
# Thorfiles can override them.
|
211
|
-
#
|
212
|
-
# ==== Example
|
213
|
-
#
|
214
|
-
# If we start at /Users/wycats/dev/thor ...
|
215
|
-
#
|
216
|
-
# 1. /Users/wycats/dev/thor
|
217
|
-
# 2. /Users/wycats/dev
|
218
|
-
# 3. /Users/wycats <-- we find a Thorfile here, so we stop
|
219
|
-
#
|
220
|
-
# Suppose we start at c:\Documents and Settings\james\dev\thor ...
|
221
|
-
#
|
222
|
-
# 1. c:\Documents and Settings\james\dev\thor
|
223
|
-
# 2. c:\Documents and Settings\james\dev
|
224
|
-
# 3. c:\Documents and Settings\james
|
225
|
-
# 4. c:\Documents and Settings
|
226
|
-
# 5. c:\ <-- no Thorfiles found!
|
227
|
-
#
|
228
|
-
def thorfiles(relevant_to=nil, skip_lookup=false)
|
229
|
-
thorfiles = []
|
230
|
-
|
231
|
-
unless skip_lookup
|
232
|
-
Pathname.pwd.ascend do |path|
|
233
|
-
thorfiles = Thor::Util.globs_for(path).map { |g| Dir[g] }.flatten
|
234
|
-
break unless thorfiles.empty?
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
files = (relevant_to ? thorfiles_relevant_to(relevant_to) : Thor::Util.thor_root_glob)
|
239
|
-
files += thorfiles
|
240
|
-
files -= ["#{thor_root}/thor.yml"]
|
241
|
-
|
242
|
-
files.map! do |file|
|
243
|
-
File.directory?(file) ? File.join(file, "main.thor") : file
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
# Load thorfiles relevant to the given method. If you provide "foo:bar" it
|
248
|
-
# will load all thor files in the thor.yaml that has "foo" e "foo:bar"
|
249
|
-
# namespaces registered.
|
250
|
-
#
|
251
|
-
def thorfiles_relevant_to(meth)
|
252
|
-
lookup = [ meth, meth.split(":")[0...-1].join(":") ]
|
253
|
-
|
254
|
-
files = thor_yaml.select do |k, v|
|
255
|
-
v[:namespaces] && !(v[:namespaces] & lookup).empty?
|
256
|
-
end
|
257
|
-
|
258
|
-
files.map { |k, v| File.join(thor_root, "#{v[:filename]}") }
|
259
|
-
end
|
260
|
-
|
261
|
-
# Display information about the given klasses. If with_module is given,
|
262
|
-
# it shows a table with information extracted from the yaml file.
|
263
|
-
#
|
264
|
-
def display_klasses(with_modules=false, show_internal=false, klasses=Thor::Base.subclasses)
|
265
|
-
klasses -= [Thor, Thor::Runner, Thor::Group] unless show_internal
|
266
|
-
|
267
|
-
raise Error, "No Thor tasks available" if klasses.empty?
|
268
|
-
show_modules if with_modules && !thor_yaml.empty?
|
269
|
-
|
270
|
-
# Remove subclasses
|
271
|
-
klasses.dup.each do |klass|
|
272
|
-
klasses -= Thor::Util.thor_classes_in(klass)
|
273
|
-
end
|
274
|
-
|
275
|
-
list = Hash.new { |h,k| h[k] = [] }
|
276
|
-
groups = klasses.select { |k| k.ancestors.include?(Thor::Group) }
|
277
|
-
|
278
|
-
# Get classes which inherit from Thor
|
279
|
-
(klasses - groups).each { |k| list[k.namespace] += k.printable_tasks(false) }
|
280
|
-
|
281
|
-
# Get classes which inherit from Thor::Base
|
282
|
-
groups.map! { |k| k.printable_tasks(false).first }
|
283
|
-
list["root"] = groups
|
284
|
-
|
285
|
-
# Order namespaces with default coming first
|
286
|
-
list = list.sort{ |a,b| a[0].sub(/^default/, '') <=> b[0].sub(/^default/, '') }
|
287
|
-
list.each { |n, tasks| display_tasks(n, tasks) unless tasks.empty? }
|
288
|
-
end
|
289
|
-
|
290
|
-
def display_tasks(namespace, list) #:nodoc:
|
291
|
-
list.sort!{ |a,b| a[0] <=> b[0] }
|
292
|
-
|
293
|
-
say shell.set_color(namespace, :blue, true)
|
294
|
-
say "-" * namespace.size
|
295
|
-
|
296
|
-
print_table(list, :truncate => true)
|
297
|
-
say
|
298
|
-
end
|
299
|
-
|
300
|
-
def show_modules #:nodoc:
|
301
|
-
info = []
|
302
|
-
labels = ["Modules", "Namespaces"]
|
303
|
-
|
304
|
-
info << labels
|
305
|
-
info << [ "-" * labels[0].size, "-" * labels[1].size ]
|
306
|
-
|
307
|
-
thor_yaml.each do |name, hash|
|
308
|
-
info << [ name, hash[:namespaces].join(", ") ]
|
309
|
-
end
|
310
|
-
|
311
|
-
print_table info
|
312
|
-
say ""
|
313
|
-
end
|
314
|
-
end
|
@@ -1,239 +0,0 @@
|
|
1
|
-
require 'tempfile'
|
2
|
-
|
3
|
-
class Thor
|
4
|
-
module Shell
|
5
|
-
class Basic
|
6
|
-
attr_accessor :base, :padding
|
7
|
-
|
8
|
-
# Initialize base and padding to nil.
|
9
|
-
#
|
10
|
-
def initialize #:nodoc:
|
11
|
-
@base, @padding = nil, 0
|
12
|
-
end
|
13
|
-
|
14
|
-
# Sets the output padding, not allowing less than zero values.
|
15
|
-
#
|
16
|
-
def padding=(value)
|
17
|
-
@padding = [0, value].max
|
18
|
-
end
|
19
|
-
|
20
|
-
# Ask something to the user and receives a response.
|
21
|
-
#
|
22
|
-
# ==== Example
|
23
|
-
# ask("What is your name?")
|
24
|
-
#
|
25
|
-
def ask(statement, color=nil)
|
26
|
-
say("#{statement} ", color)
|
27
|
-
$stdin.gets.strip
|
28
|
-
end
|
29
|
-
|
30
|
-
# Say (print) something to the user. If the sentence ends with a whitespace
|
31
|
-
# or tab character, a new line is not appended (print + flush). Otherwise
|
32
|
-
# are passed straight to puts (behavior got from Highline).
|
33
|
-
#
|
34
|
-
# ==== Example
|
35
|
-
# say("I know you knew that.")
|
36
|
-
#
|
37
|
-
def say(message="", color=nil, force_new_line=(message.to_s !~ /( |\t)$/))
|
38
|
-
message = message.to_s
|
39
|
-
message = set_color(message, color) if color
|
40
|
-
|
41
|
-
if force_new_line
|
42
|
-
$stdout.puts(message)
|
43
|
-
else
|
44
|
-
$stdout.print(message)
|
45
|
-
$stdout.flush
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# Say a status with the given color and appends the message. Since this
|
50
|
-
# method is used frequently by actions, it allows nil or false to be given
|
51
|
-
# in log_status, avoiding the message from being shown. If a Symbol is
|
52
|
-
# given in log_status, it's used as the color.
|
53
|
-
#
|
54
|
-
def say_status(status, message, log_status=true)
|
55
|
-
return if quiet? || log_status == false
|
56
|
-
spaces = " " * (padding + 1)
|
57
|
-
color = log_status.is_a?(Symbol) ? log_status : :green
|
58
|
-
|
59
|
-
status = status.to_s.rjust(12)
|
60
|
-
status = set_color status, color, true if color
|
61
|
-
say "#{status}#{spaces}#{message}", nil, true
|
62
|
-
end
|
63
|
-
|
64
|
-
# Make a question the to user and returns true if the user replies "y" or
|
65
|
-
# "yes".
|
66
|
-
#
|
67
|
-
def yes?(statement, color=nil)
|
68
|
-
ask(statement, color) =~ is?(:yes)
|
69
|
-
end
|
70
|
-
|
71
|
-
# Make a question the to user and returns true if the user replies "n" or
|
72
|
-
# "no".
|
73
|
-
#
|
74
|
-
def no?(statement, color=nil)
|
75
|
-
!yes?(statement, color)
|
76
|
-
end
|
77
|
-
|
78
|
-
# Prints a table.
|
79
|
-
#
|
80
|
-
# ==== Parameters
|
81
|
-
# Array[Array[String, String, ...]]
|
82
|
-
#
|
83
|
-
# ==== Options
|
84
|
-
# ident<Integer>:: Ident the first column by ident value.
|
85
|
-
#
|
86
|
-
def print_table(table, options={})
|
87
|
-
return if table.empty?
|
88
|
-
|
89
|
-
formats, ident = [], options[:ident].to_i
|
90
|
-
options[:truncate] = terminal_width if options[:truncate] == true
|
91
|
-
|
92
|
-
0.upto(table.first.length - 2) do |i|
|
93
|
-
maxima = table.max{ |a,b| a[i].size <=> b[i].size }[i].size
|
94
|
-
formats << "%-#{maxima + 2}s"
|
95
|
-
end
|
96
|
-
|
97
|
-
formats[0] = formats[0].insert(0, " " * ident)
|
98
|
-
formats << "%s"
|
99
|
-
|
100
|
-
table.each do |row|
|
101
|
-
sentence = ""
|
102
|
-
|
103
|
-
row.each_with_index do |column, i|
|
104
|
-
sentence << formats[i] % column.to_s
|
105
|
-
end
|
106
|
-
|
107
|
-
sentence = truncate(sentence, options[:truncate]) if options[:truncate]
|
108
|
-
$stdout.puts sentence
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
# Deals with file collision and returns true if the file should be
|
113
|
-
# overwriten and false otherwise. If a block is given, it uses the block
|
114
|
-
# response as the content for the diff.
|
115
|
-
#
|
116
|
-
# ==== Parameters
|
117
|
-
# destination<String>:: the destination file to solve conflicts
|
118
|
-
# block<Proc>:: an optional block that returns the value to be used in diff
|
119
|
-
#
|
120
|
-
def file_collision(destination)
|
121
|
-
return true if @always_force
|
122
|
-
options = block_given? ? "[Ynaqdh]" : "[Ynaqh]"
|
123
|
-
|
124
|
-
while true
|
125
|
-
answer = ask %[Overwrite #{destination}? (enter "h" for help) #{options}]
|
126
|
-
|
127
|
-
case answer
|
128
|
-
when is?(:yes), is?(:force), ""
|
129
|
-
return true
|
130
|
-
when is?(:no), is?(:skip)
|
131
|
-
return false
|
132
|
-
when is?(:always)
|
133
|
-
return @always_force = true
|
134
|
-
when is?(:quit)
|
135
|
-
say 'Aborting...'
|
136
|
-
raise SystemExit
|
137
|
-
when is?(:diff)
|
138
|
-
show_diff(destination, yield) if block_given?
|
139
|
-
say 'Retrying...'
|
140
|
-
else
|
141
|
-
say file_collision_help
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
# Called if something goes wrong during the execution. This is used by Thor
|
147
|
-
# internally and should not be used inside your scripts. If someone went
|
148
|
-
# wrong, you can always raise an exception. If you raise a Thor::Error, it
|
149
|
-
# will be rescued and wrapped in the method below.
|
150
|
-
#
|
151
|
-
def error(statement)
|
152
|
-
$stderr.puts statement
|
153
|
-
end
|
154
|
-
|
155
|
-
# Apply color to the given string with optional bold. Disabled in the
|
156
|
-
# Thor::Shell::Basic class.
|
157
|
-
#
|
158
|
-
def set_color(string, color, bold=false) #:nodoc:
|
159
|
-
string
|
160
|
-
end
|
161
|
-
|
162
|
-
protected
|
163
|
-
|
164
|
-
def is?(value) #:nodoc:
|
165
|
-
value = value.to_s
|
166
|
-
|
167
|
-
if value.size == 1
|
168
|
-
/\A#{value}\z/i
|
169
|
-
else
|
170
|
-
/\A(#{value}|#{value[0,1]})\z/i
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
def file_collision_help #:nodoc:
|
175
|
-
<<HELP
|
176
|
-
Y - yes, overwrite
|
177
|
-
n - no, do not overwrite
|
178
|
-
a - all, overwrite this and all others
|
179
|
-
q - quit, abort
|
180
|
-
d - diff, show the differences between the old and the new
|
181
|
-
h - help, show this help
|
182
|
-
HELP
|
183
|
-
end
|
184
|
-
|
185
|
-
def show_diff(destination, content) #:nodoc:
|
186
|
-
diff_cmd = ENV['THOR_DIFF'] || ENV['RAILS_DIFF'] || 'diff -u'
|
187
|
-
|
188
|
-
Tempfile.open(File.basename(destination), File.dirname(destination)) do |temp|
|
189
|
-
temp.write content
|
190
|
-
temp.rewind
|
191
|
-
system %(#{diff_cmd} "#{destination}" "#{temp.path}")
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
def quiet? #:nodoc:
|
196
|
-
base && base.options[:quiet]
|
197
|
-
end
|
198
|
-
|
199
|
-
# This code was copied from Rake, available under MIT-LICENSE
|
200
|
-
# Copyright (c) 2003, 2004 Jim Weirich
|
201
|
-
def terminal_width
|
202
|
-
if ENV['THOR_COLUMNS']
|
203
|
-
result = ENV['THOR_COLUMNS'].to_i
|
204
|
-
else
|
205
|
-
result = unix? ? dynamic_width : 80
|
206
|
-
end
|
207
|
-
(result < 10) ? 80 : result
|
208
|
-
rescue
|
209
|
-
80
|
210
|
-
end
|
211
|
-
|
212
|
-
# Calculate the dynamic width of the terminal
|
213
|
-
def dynamic_width
|
214
|
-
@dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
|
215
|
-
end
|
216
|
-
|
217
|
-
def dynamic_width_stty
|
218
|
-
%x{stty size 2>/dev/null}.split[1].to_i
|
219
|
-
end
|
220
|
-
|
221
|
-
def dynamic_width_tput
|
222
|
-
%x{tput cols 2>/dev/null}.to_i
|
223
|
-
end
|
224
|
-
|
225
|
-
def unix?
|
226
|
-
RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
|
227
|
-
end
|
228
|
-
|
229
|
-
def truncate(string, width)
|
230
|
-
if string.length <= width
|
231
|
-
string
|
232
|
-
else
|
233
|
-
( string[0, width-3] || "" ) + "..."
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
require 'thor/shell/basic'
|
2
|
-
|
3
|
-
class Thor
|
4
|
-
module Shell
|
5
|
-
# Inherit from Thor::Shell::Basic and add set_color behavior. Check
|
6
|
-
# Thor::Shell::Basic to see all available methods.
|
7
|
-
#
|
8
|
-
class Color < Basic
|
9
|
-
# Embed in a String to clear all previous ANSI sequences.
|
10
|
-
CLEAR = "\e[0m"
|
11
|
-
# The start of an ANSI bold sequence.
|
12
|
-
BOLD = "\e[1m"
|
13
|
-
|
14
|
-
# Set the terminal's foreground ANSI color to black.
|
15
|
-
BLACK = "\e[30m"
|
16
|
-
# Set the terminal's foreground ANSI color to red.
|
17
|
-
RED = "\e[31m"
|
18
|
-
# Set the terminal's foreground ANSI color to green.
|
19
|
-
GREEN = "\e[32m"
|
20
|
-
# Set the terminal's foreground ANSI color to yellow.
|
21
|
-
YELLOW = "\e[33m"
|
22
|
-
# Set the terminal's foreground ANSI color to blue.
|
23
|
-
BLUE = "\e[34m"
|
24
|
-
# Set the terminal's foreground ANSI color to magenta.
|
25
|
-
MAGENTA = "\e[35m"
|
26
|
-
# Set the terminal's foreground ANSI color to cyan.
|
27
|
-
CYAN = "\e[36m"
|
28
|
-
# Set the terminal's foreground ANSI color to white.
|
29
|
-
WHITE = "\e[37m"
|
30
|
-
|
31
|
-
# Set the terminal's background ANSI color to black.
|
32
|
-
ON_BLACK = "\e[40m"
|
33
|
-
# Set the terminal's background ANSI color to red.
|
34
|
-
ON_RED = "\e[41m"
|
35
|
-
# Set the terminal's background ANSI color to green.
|
36
|
-
ON_GREEN = "\e[42m"
|
37
|
-
# Set the terminal's background ANSI color to yellow.
|
38
|
-
ON_YELLOW = "\e[43m"
|
39
|
-
# Set the terminal's background ANSI color to blue.
|
40
|
-
ON_BLUE = "\e[44m"
|
41
|
-
# Set the terminal's background ANSI color to magenta.
|
42
|
-
ON_MAGENTA = "\e[45m"
|
43
|
-
# Set the terminal's background ANSI color to cyan.
|
44
|
-
ON_CYAN = "\e[46m"
|
45
|
-
# Set the terminal's background ANSI color to white.
|
46
|
-
ON_WHITE = "\e[47m"
|
47
|
-
|
48
|
-
# Set color by using a string or one of the defined constants. If a third
|
49
|
-
# option is set to true, it also adds bold to the string. This is based
|
50
|
-
# on Highline implementation and it automatically appends CLEAR to the end
|
51
|
-
# of the returned String.
|
52
|
-
#
|
53
|
-
def set_color(string, color, bold=false)
|
54
|
-
color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol)
|
55
|
-
bold = bold ? BOLD : ""
|
56
|
-
"#{bold}#{color}#{string}#{CLEAR}"
|
57
|
-
end
|
58
|
-
|
59
|
-
protected
|
60
|
-
|
61
|
-
# Overwrite show_diff to show diff with colors if Diff::LCS is
|
62
|
-
# available.
|
63
|
-
#
|
64
|
-
def show_diff(destination, content) #:nodoc:
|
65
|
-
if diff_lcs_loaded? && ENV['THOR_DIFF'].nil? && ENV['RAILS_DIFF'].nil?
|
66
|
-
actual = File.binread(destination).to_s.split("\n")
|
67
|
-
content = content.to_s.split("\n")
|
68
|
-
|
69
|
-
Diff::LCS.sdiff(actual, content).each do |diff|
|
70
|
-
output_diff_line(diff)
|
71
|
-
end
|
72
|
-
else
|
73
|
-
super
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def output_diff_line(diff) #:nodoc:
|
78
|
-
case diff.action
|
79
|
-
when '-'
|
80
|
-
say "- #{diff.old_element.chomp}", :red, true
|
81
|
-
when '+'
|
82
|
-
say "+ #{diff.new_element.chomp}", :green, true
|
83
|
-
when '!'
|
84
|
-
say "- #{diff.old_element.chomp}", :red, true
|
85
|
-
say "+ #{diff.new_element.chomp}", :green, true
|
86
|
-
else
|
87
|
-
say " #{diff.old_element.chomp}", nil, true
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
# Check if Diff::LCS is loaded. If it is, use it to create pretty output
|
92
|
-
# for diff.
|
93
|
-
#
|
94
|
-
def diff_lcs_loaded? #:nodoc:
|
95
|
-
return true if defined?(Diff::LCS)
|
96
|
-
return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
|
97
|
-
|
98
|
-
@diff_lcs_loaded = begin
|
99
|
-
require 'diff/lcs'
|
100
|
-
true
|
101
|
-
rescue LoadError
|
102
|
-
false
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|