engineyard-serverside 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/bin/engineyard-serverside +10 -0
- data/lib/engineyard-serverside.rb +49 -0
- data/lib/engineyard-serverside/bundle_installer.rb +4 -0
- data/lib/engineyard-serverside/cli.rb +146 -0
- data/lib/engineyard-serverside/configuration.rb +130 -0
- data/lib/engineyard-serverside/default_maintenance_page.html +29 -0
- data/lib/engineyard-serverside/deploy.rb +321 -0
- data/lib/engineyard-serverside/deploy_hook.rb +80 -0
- data/lib/engineyard-serverside/lockfile_parser.rb +55 -0
- data/lib/engineyard-serverside/logged_output.rb +78 -0
- data/lib/engineyard-serverside/server.rb +70 -0
- data/lib/engineyard-serverside/strategies/git.rb +136 -0
- data/lib/engineyard-serverside/task.rb +62 -0
- data/lib/engineyard-serverside/version.rb +3 -0
- data/lib/vendor/dataflow/HISTORY +52 -0
- data/lib/vendor/dataflow/LICENSE +19 -0
- data/lib/vendor/dataflow/README.textile +290 -0
- data/lib/vendor/dataflow/Rakefile +36 -0
- data/lib/vendor/dataflow/dataflow.rb +120 -0
- data/lib/vendor/dataflow/dataflow/actor.rb +22 -0
- data/lib/vendor/dataflow/dataflow/equality.rb +28 -0
- data/lib/vendor/dataflow/dataflow/future_queue.rb +24 -0
- data/lib/vendor/dataflow/dataflow/port.rb +54 -0
- data/lib/vendor/dataflow/examples/barrier.rb +9 -0
- data/lib/vendor/dataflow/examples/data_driven.rb +17 -0
- data/lib/vendor/dataflow/examples/dataflow_http_gets.rb +13 -0
- data/lib/vendor/dataflow/examples/flow.rb +20 -0
- data/lib/vendor/dataflow/examples/future_http_gets.rb +12 -0
- data/lib/vendor/dataflow/examples/future_queue.rb +11 -0
- data/lib/vendor/dataflow/examples/instance_variables.rb +15 -0
- data/lib/vendor/dataflow/examples/laziness.rb +9 -0
- data/lib/vendor/dataflow/examples/local_variables.rb +11 -0
- data/lib/vendor/dataflow/examples/messages.rb +26 -0
- data/lib/vendor/dataflow/examples/port_http_gets.rb +13 -0
- data/lib/vendor/dataflow/examples/port_send.rb +10 -0
- data/lib/vendor/dataflow/examples/ring.rb +21 -0
- data/lib/vendor/dataflow/spec/actor_spec.rb +28 -0
- data/lib/vendor/dataflow/spec/anonymous_variables_spec.rb +21 -0
- data/lib/vendor/dataflow/spec/barrier_spec.rb +25 -0
- data/lib/vendor/dataflow/spec/by_need_spec.rb +55 -0
- data/lib/vendor/dataflow/spec/dataflow_spec.rb +151 -0
- data/lib/vendor/dataflow/spec/equality_spec.rb +40 -0
- data/lib/vendor/dataflow/spec/flow_spec.rb +25 -0
- data/lib/vendor/dataflow/spec/forker_spec.rb +28 -0
- data/lib/vendor/dataflow/spec/future_queue_spec.rb +31 -0
- data/lib/vendor/dataflow/spec/inspect_spec.rb +19 -0
- data/lib/vendor/dataflow/spec/need_later_spec.rb +12 -0
- data/lib/vendor/dataflow/spec/port_spec.rb +26 -0
- data/lib/vendor/dataflow/spec/spec.opts +1 -0
- data/lib/vendor/dataflow/spec/spec_helper.rb +10 -0
- data/lib/vendor/escape/Readme +21 -0
- data/lib/vendor/escape/doc_include/template/qualitysmith.rb +631 -0
- data/lib/vendor/escape/lib/escape.rb +247 -0
- data/lib/vendor/json_pure/CHANGES +166 -0
- data/lib/vendor/json_pure/COPYING +58 -0
- data/lib/vendor/json_pure/GPL +340 -0
- data/lib/vendor/json_pure/README +358 -0
- data/lib/vendor/json_pure/Rakefile +292 -0
- data/lib/vendor/json_pure/TODO +1 -0
- data/lib/vendor/json_pure/VERSION +1 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +52 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +900 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +901 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +261 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +262 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +82 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +34 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +900 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +901 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +81 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +82 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +82 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +1000 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +1001 -0
- data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +82 -0
- data/lib/vendor/json_pure/benchmarks/generator2_benchmark.rb +222 -0
- data/lib/vendor/json_pure/benchmarks/generator_benchmark.rb +224 -0
- data/lib/vendor/json_pure/benchmarks/ohai.json +1216 -0
- data/lib/vendor/json_pure/benchmarks/ohai.ruby +1 -0
- data/lib/vendor/json_pure/benchmarks/parser2_benchmark.rb +251 -0
- data/lib/vendor/json_pure/benchmarks/parser_benchmark.rb +259 -0
- data/lib/vendor/json_pure/bin/edit_json.rb +9 -0
- data/lib/vendor/json_pure/bin/prettify_json.rb +75 -0
- data/lib/vendor/json_pure/data/example.json +1 -0
- data/lib/vendor/json_pure/data/index.html +38 -0
- data/lib/vendor/json_pure/data/prototype.js +4184 -0
- data/lib/vendor/json_pure/ext/json/ext/generator/extconf.rb +16 -0
- data/lib/vendor/json_pure/ext/json/ext/generator/generator.c +1323 -0
- data/lib/vendor/json_pure/ext/json/ext/generator/generator.h +170 -0
- data/lib/vendor/json_pure/ext/json/ext/parser/extconf.rb +15 -0
- data/lib/vendor/json_pure/ext/json/ext/parser/parser.c +1935 -0
- data/lib/vendor/json_pure/ext/json/ext/parser/parser.h +71 -0
- data/lib/vendor/json_pure/ext/json/ext/parser/parser.rl +792 -0
- data/lib/vendor/json_pure/install.rb +26 -0
- data/lib/vendor/json_pure/lib/json.rb +10 -0
- data/lib/vendor/json_pure/lib/json/Array.xpm +21 -0
- data/lib/vendor/json_pure/lib/json/FalseClass.xpm +21 -0
- data/lib/vendor/json_pure/lib/json/Hash.xpm +21 -0
- data/lib/vendor/json_pure/lib/json/Key.xpm +73 -0
- data/lib/vendor/json_pure/lib/json/NilClass.xpm +21 -0
- data/lib/vendor/json_pure/lib/json/Numeric.xpm +28 -0
- data/lib/vendor/json_pure/lib/json/String.xpm +96 -0
- data/lib/vendor/json_pure/lib/json/TrueClass.xpm +21 -0
- data/lib/vendor/json_pure/lib/json/add/core.rb +148 -0
- data/lib/vendor/json_pure/lib/json/add/rails.rb +58 -0
- data/lib/vendor/json_pure/lib/json/common.rb +397 -0
- data/lib/vendor/json_pure/lib/json/editor.rb +1371 -0
- data/lib/vendor/json_pure/lib/json/ext.rb +15 -0
- data/lib/vendor/json_pure/lib/json/json.xpm +1499 -0
- data/lib/vendor/json_pure/lib/json/pure.rb +77 -0
- data/lib/vendor/json_pure/lib/json/pure/generator.rb +452 -0
- data/lib/vendor/json_pure/lib/json/pure/parser.rb +307 -0
- data/lib/vendor/json_pure/lib/json/version.rb +8 -0
- data/lib/vendor/json_pure/tests/fixtures/fail1.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail10.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail11.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail12.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail13.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail14.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail18.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail19.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail2.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail20.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail21.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail22.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail23.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail24.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail25.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail27.json +2 -0
- data/lib/vendor/json_pure/tests/fixtures/fail28.json +2 -0
- data/lib/vendor/json_pure/tests/fixtures/fail3.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail4.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail5.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail6.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail7.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail8.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/fail9.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/pass1.json +56 -0
- data/lib/vendor/json_pure/tests/fixtures/pass15.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/pass16.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/pass17.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/pass2.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/pass26.json +1 -0
- data/lib/vendor/json_pure/tests/fixtures/pass3.json +6 -0
- data/lib/vendor/json_pure/tests/test_json.rb +361 -0
- data/lib/vendor/json_pure/tests/test_json_addition.rb +162 -0
- data/lib/vendor/json_pure/tests/test_json_encoding.rb +68 -0
- data/lib/vendor/json_pure/tests/test_json_fixtures.rb +34 -0
- data/lib/vendor/json_pure/tests/test_json_generate.rb +122 -0
- data/lib/vendor/json_pure/tests/test_json_rails.rb +144 -0
- data/lib/vendor/json_pure/tests/test_json_unicode.rb +76 -0
- data/lib/vendor/json_pure/tools/fuzz.rb +139 -0
- data/lib/vendor/json_pure/tools/server.rb +61 -0
- data/lib/vendor/open4/lib/open4.rb +403 -0
- data/lib/vendor/thor/CHANGELOG.rdoc +89 -0
- data/lib/vendor/thor/LICENSE +20 -0
- data/lib/vendor/thor/README.rdoc +297 -0
- data/lib/vendor/thor/Thorfile +69 -0
- data/lib/vendor/thor/bin/rake2thor +86 -0
- data/lib/vendor/thor/bin/thor +6 -0
- data/lib/vendor/thor/lib/thor.rb +244 -0
- data/lib/vendor/thor/lib/thor/actions.rb +275 -0
- data/lib/vendor/thor/lib/thor/actions/create_file.rb +103 -0
- data/lib/vendor/thor/lib/thor/actions/directory.rb +91 -0
- data/lib/vendor/thor/lib/thor/actions/empty_directory.rb +134 -0
- data/lib/vendor/thor/lib/thor/actions/file_manipulation.rb +223 -0
- data/lib/vendor/thor/lib/thor/actions/inject_into_file.rb +104 -0
- data/lib/vendor/thor/lib/thor/base.rb +540 -0
- data/lib/vendor/thor/lib/thor/core_ext/file_binary_read.rb +9 -0
- data/lib/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +75 -0
- data/lib/vendor/thor/lib/thor/core_ext/ordered_hash.rb +100 -0
- data/lib/vendor/thor/lib/thor/error.rb +30 -0
- data/lib/vendor/thor/lib/thor/group.rb +271 -0
- data/lib/vendor/thor/lib/thor/invocation.rb +180 -0
- data/lib/vendor/thor/lib/thor/parser.rb +4 -0
- data/lib/vendor/thor/lib/thor/parser/argument.rb +67 -0
- data/lib/vendor/thor/lib/thor/parser/arguments.rb +150 -0
- data/lib/vendor/thor/lib/thor/parser/option.rb +128 -0
- data/lib/vendor/thor/lib/thor/parser/options.rb +169 -0
- data/lib/vendor/thor/lib/thor/rake_compat.rb +66 -0
- data/lib/vendor/thor/lib/thor/runner.rb +314 -0
- data/lib/vendor/thor/lib/thor/shell.rb +83 -0
- data/lib/vendor/thor/lib/thor/shell/basic.rb +239 -0
- data/lib/vendor/thor/lib/thor/shell/color.rb +108 -0
- data/lib/vendor/thor/lib/thor/task.rb +102 -0
- data/lib/vendor/thor/lib/thor/util.rb +230 -0
- data/lib/vendor/thor/lib/thor/version.rb +3 -0
- data/lib/vendor/thor/thor.gemspec +120 -0
- data/spec/custom_deploy_spec.rb +95 -0
- data/spec/deploy_hook_spec.rb +211 -0
- data/spec/fixtures/gitrepo.tar.gz +0 -0
- data/spec/fixtures/gitrepo/foo +0 -0
- data/spec/fixtures/invalid_hook.rb +1 -0
- data/spec/fixtures/valid_hook.rb +1 -0
- data/spec/git_strategy_spec.rb +22 -0
- data/spec/lockfile_parser_spec.rb +30 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/support/lockfiles/0.9-no-bundler +111 -0
- data/spec/support/lockfiles/0.9-with-bundler +117 -0
- data/spec/support/lockfiles/1.0-no-bundler +54 -0
- data/spec/support/lockfiles/1.0.0.rc.1-with-bundler +162 -0
- data/spec/support/lockfiles/not-a-lockfile +10 -0
- metadata +279 -0
@@ -0,0 +1,230 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
|
3
|
+
class Thor
|
4
|
+
module Sandbox #:nodoc:
|
5
|
+
end
|
6
|
+
|
7
|
+
# This module holds several utilities:
|
8
|
+
#
|
9
|
+
# 1) Methods to convert thor namespaces to constants and vice-versa.
|
10
|
+
#
|
11
|
+
# Thor::Utils.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz"
|
12
|
+
#
|
13
|
+
# 2) Loading thor files and sandboxing:
|
14
|
+
#
|
15
|
+
# Thor::Utils.load_thorfile("~/.thor/foo")
|
16
|
+
#
|
17
|
+
module Util
|
18
|
+
|
19
|
+
# Receives a namespace and search for it in the Thor::Base subclasses.
|
20
|
+
#
|
21
|
+
# ==== Parameters
|
22
|
+
# namespace<String>:: The namespace to search for.
|
23
|
+
#
|
24
|
+
def self.find_by_namespace(namespace)
|
25
|
+
namespace = "default#{namespace}" if namespace.empty? || namespace =~ /^:/
|
26
|
+
Thor::Base.subclasses.find { |klass| klass.namespace == namespace }
|
27
|
+
end
|
28
|
+
|
29
|
+
# Receives a constant and converts it to a Thor namespace. Since Thor tasks
|
30
|
+
# can be added to a sandbox, this method is also responsable for removing
|
31
|
+
# the sandbox namespace.
|
32
|
+
#
|
33
|
+
# This method should not be used in general because it's used to deal with
|
34
|
+
# older versions of Thor. On current versions, if you need to get the
|
35
|
+
# namespace from a class, just call namespace on it.
|
36
|
+
#
|
37
|
+
# ==== Parameters
|
38
|
+
# constant<Object>:: The constant to be converted to the thor path.
|
39
|
+
#
|
40
|
+
# ==== Returns
|
41
|
+
# String:: If we receive Foo::Bar::Baz it returns "foo:bar:baz"
|
42
|
+
#
|
43
|
+
def self.namespace_from_thor_class(constant)
|
44
|
+
constant = constant.to_s.gsub(/^Thor::Sandbox::/, "")
|
45
|
+
constant = snake_case(constant).squeeze(":")
|
46
|
+
constant
|
47
|
+
end
|
48
|
+
|
49
|
+
# Given the contents, evaluate it inside the sandbox and returns the
|
50
|
+
# namespaces defined in the sandbox.
|
51
|
+
#
|
52
|
+
# ==== Parameters
|
53
|
+
# contents<String>
|
54
|
+
#
|
55
|
+
# ==== Returns
|
56
|
+
# Array[Object]
|
57
|
+
#
|
58
|
+
def self.namespaces_in_content(contents, file=__FILE__)
|
59
|
+
old_constants = Thor::Base.subclasses.dup
|
60
|
+
Thor::Base.subclasses.clear
|
61
|
+
|
62
|
+
load_thorfile(file, contents)
|
63
|
+
|
64
|
+
new_constants = Thor::Base.subclasses.dup
|
65
|
+
Thor::Base.subclasses.replace(old_constants)
|
66
|
+
|
67
|
+
new_constants.map!{ |c| c.namespace }
|
68
|
+
new_constants.compact!
|
69
|
+
new_constants
|
70
|
+
end
|
71
|
+
|
72
|
+
# Returns the thor classes declared inside the given class.
|
73
|
+
#
|
74
|
+
def self.thor_classes_in(klass)
|
75
|
+
stringfied_constants = klass.constants.map { |c| c.to_s }
|
76
|
+
Thor::Base.subclasses.select do |subclass|
|
77
|
+
next unless subclass.name
|
78
|
+
stringfied_constants.include?(subclass.name.gsub("#{klass.name}::", ''))
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Receives a string and convert it to snake case. SnakeCase returns snake_case.
|
83
|
+
#
|
84
|
+
# ==== Parameters
|
85
|
+
# String
|
86
|
+
#
|
87
|
+
# ==== Returns
|
88
|
+
# String
|
89
|
+
#
|
90
|
+
def self.snake_case(str)
|
91
|
+
return str.downcase if str =~ /^[A-Z_]+$/
|
92
|
+
str.gsub(/\B[A-Z]/, '_\&').squeeze('_') =~ /_*(.*)/
|
93
|
+
return $+.downcase
|
94
|
+
end
|
95
|
+
|
96
|
+
# Receives a string and convert it to camel case. camel_case returns CamelCase.
|
97
|
+
#
|
98
|
+
# ==== Parameters
|
99
|
+
# String
|
100
|
+
#
|
101
|
+
# ==== Returns
|
102
|
+
# String
|
103
|
+
#
|
104
|
+
def self.camel_case(str)
|
105
|
+
return str if str !~ /_/ && str =~ /[A-Z]+.*/
|
106
|
+
str.split('_').map { |i| i.capitalize }.join
|
107
|
+
end
|
108
|
+
|
109
|
+
# Receives a namespace and tries to retrieve a Thor or Thor::Group class
|
110
|
+
# from it. It first searches for a class using the all the given namespace,
|
111
|
+
# if it's not found, removes the highest entry and searches for the class
|
112
|
+
# again. If found, returns the highest entry as the class name.
|
113
|
+
#
|
114
|
+
# ==== Examples
|
115
|
+
#
|
116
|
+
# class Foo::Bar < Thor
|
117
|
+
# def baz
|
118
|
+
# end
|
119
|
+
# end
|
120
|
+
#
|
121
|
+
# class Baz::Foo < Thor::Group
|
122
|
+
# end
|
123
|
+
#
|
124
|
+
# Thor::Util.namespace_to_thor_class("foo:bar") #=> Foo::Bar, nil # will invoke default task
|
125
|
+
# Thor::Util.namespace_to_thor_class("baz:foo") #=> Baz::Foo, nil
|
126
|
+
# Thor::Util.namespace_to_thor_class("foo:bar:baz") #=> Foo::Bar, "baz"
|
127
|
+
#
|
128
|
+
# ==== Parameters
|
129
|
+
# namespace<String>
|
130
|
+
#
|
131
|
+
def self.find_class_and_task_by_namespace(namespace)
|
132
|
+
if namespace.include?(?:)
|
133
|
+
pieces = namespace.split(":")
|
134
|
+
task = pieces.pop
|
135
|
+
klass = Thor::Util.find_by_namespace(pieces.join(":"))
|
136
|
+
end
|
137
|
+
|
138
|
+
unless klass
|
139
|
+
klass, task = Thor::Util.find_by_namespace(namespace), nil
|
140
|
+
end
|
141
|
+
|
142
|
+
return klass, task
|
143
|
+
end
|
144
|
+
|
145
|
+
# The same as namespace_to_thor_class_and_task!, but raises an error if a klass
|
146
|
+
# could not be found.
|
147
|
+
def self.find_class_and_task_by_namespace!(namespace)
|
148
|
+
klass, task = find_class_and_task_by_namespace(namespace)
|
149
|
+
raise Error, "Could not find namespace or task #{namespace.inspect}." unless klass
|
150
|
+
return klass, task
|
151
|
+
end
|
152
|
+
|
153
|
+
# Receives a path and load the thor file in the path. The file is evaluated
|
154
|
+
# inside the sandbox to avoid namespacing conflicts.
|
155
|
+
#
|
156
|
+
def self.load_thorfile(path, content=nil)
|
157
|
+
content ||= File.binread(path)
|
158
|
+
|
159
|
+
begin
|
160
|
+
Thor::Sandbox.class_eval(content, path)
|
161
|
+
rescue Exception => e
|
162
|
+
$stderr.puts "WARNING: unable to load thorfile #{path.inspect}: #{e.message}"
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def self.user_home
|
167
|
+
@@user_home ||= if ENV["HOME"]
|
168
|
+
ENV["HOME"]
|
169
|
+
elsif ENV["USERPROFILE"]
|
170
|
+
ENV["USERPROFILE"]
|
171
|
+
elsif ENV["HOMEDRIVE"] && ENV["HOMEPATH"]
|
172
|
+
File.join(ENV["HOMEDRIVE"], ENV["HOMEPATH"])
|
173
|
+
elsif ENV["APPDATA"]
|
174
|
+
ENV["APPDATA"]
|
175
|
+
else
|
176
|
+
begin
|
177
|
+
File.expand_path("~")
|
178
|
+
rescue
|
179
|
+
if File::ALT_SEPARATOR
|
180
|
+
"C:/"
|
181
|
+
else
|
182
|
+
"/"
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
# Returns the root where thor files are located, dependending on the OS.
|
189
|
+
#
|
190
|
+
def self.thor_root
|
191
|
+
File.join(user_home, ".thor").gsub(/\\/, '/')
|
192
|
+
end
|
193
|
+
|
194
|
+
# Returns the files in the thor root. On Windows thor_root will be something
|
195
|
+
# like this:
|
196
|
+
#
|
197
|
+
# C:\Documents and Settings\james\.thor
|
198
|
+
#
|
199
|
+
# If we don't #gsub the \ character, Dir.glob will fail.
|
200
|
+
#
|
201
|
+
def self.thor_root_glob
|
202
|
+
files = Dir["#{thor_root}/*"]
|
203
|
+
|
204
|
+
files.map! do |file|
|
205
|
+
File.directory?(file) ? File.join(file, "main.thor") : file
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
# Where to look for Thor files.
|
210
|
+
#
|
211
|
+
def self.globs_for(path)
|
212
|
+
["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"]
|
213
|
+
end
|
214
|
+
|
215
|
+
# Return the path to the ruby interpreter taking into account multiple
|
216
|
+
# installations and windows extensions.
|
217
|
+
#
|
218
|
+
def self.ruby_command
|
219
|
+
@ruby_command ||= begin
|
220
|
+
ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
221
|
+
ruby << Config::CONFIG['EXEEXT']
|
222
|
+
|
223
|
+
# escape string in case path to ruby executable contain spaces.
|
224
|
+
ruby.sub!(/.*\s.*/m, '"\&"')
|
225
|
+
ruby
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Thorfile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{thor}
|
8
|
+
s.version = "0.13.3"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Yehuda Katz", "Jos\303\251 Valim"]
|
12
|
+
s.date = %q{2010-02-17}
|
13
|
+
s.description = %q{A scripting framework that replaces rake, sake and rubigen}
|
14
|
+
s.email = %q{ruby-thor@googlegroups.com}
|
15
|
+
s.executables = ["thor", "rake2thor"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"CHANGELOG.rdoc",
|
18
|
+
"LICENSE",
|
19
|
+
"README.rdoc",
|
20
|
+
"Thorfile"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
"CHANGELOG.rdoc",
|
24
|
+
"LICENSE",
|
25
|
+
"README.rdoc",
|
26
|
+
"Thorfile",
|
27
|
+
"bin/rake2thor",
|
28
|
+
"bin/thor",
|
29
|
+
"lib/thor.rb",
|
30
|
+
"lib/thor/actions.rb",
|
31
|
+
"lib/thor/actions/create_file.rb",
|
32
|
+
"lib/thor/actions/directory.rb",
|
33
|
+
"lib/thor/actions/empty_directory.rb",
|
34
|
+
"lib/thor/actions/file_manipulation.rb",
|
35
|
+
"lib/thor/actions/inject_into_file.rb",
|
36
|
+
"lib/thor/base.rb",
|
37
|
+
"lib/thor/core_ext/file_binary_read.rb",
|
38
|
+
"lib/thor/core_ext/hash_with_indifferent_access.rb",
|
39
|
+
"lib/thor/core_ext/ordered_hash.rb",
|
40
|
+
"lib/thor/error.rb",
|
41
|
+
"lib/thor/group.rb",
|
42
|
+
"lib/thor/invocation.rb",
|
43
|
+
"lib/thor/parser.rb",
|
44
|
+
"lib/thor/parser/argument.rb",
|
45
|
+
"lib/thor/parser/arguments.rb",
|
46
|
+
"lib/thor/parser/option.rb",
|
47
|
+
"lib/thor/parser/options.rb",
|
48
|
+
"lib/thor/rake_compat.rb",
|
49
|
+
"lib/thor/runner.rb",
|
50
|
+
"lib/thor/shell.rb",
|
51
|
+
"lib/thor/shell/basic.rb",
|
52
|
+
"lib/thor/shell/color.rb",
|
53
|
+
"lib/thor/task.rb",
|
54
|
+
"lib/thor/util.rb",
|
55
|
+
"lib/thor/version.rb"
|
56
|
+
]
|
57
|
+
s.homepage = %q{http://yehudakatz.com}
|
58
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
59
|
+
s.require_paths = ["lib"]
|
60
|
+
s.rubyforge_project = %q{textmate}
|
61
|
+
s.rubygems_version = %q{1.3.5}
|
62
|
+
s.summary = %q{A scripting framework that replaces rake, sake and rubigen}
|
63
|
+
s.test_files = [
|
64
|
+
"spec/actions/create_file_spec.rb",
|
65
|
+
"spec/actions/directory_spec.rb",
|
66
|
+
"spec/actions/empty_directory_spec.rb",
|
67
|
+
"spec/actions/file_manipulation_spec.rb",
|
68
|
+
"spec/actions/inject_into_file_spec.rb",
|
69
|
+
"spec/actions_spec.rb",
|
70
|
+
"spec/base_spec.rb",
|
71
|
+
"spec/core_ext/hash_with_indifferent_access_spec.rb",
|
72
|
+
"spec/core_ext/ordered_hash_spec.rb",
|
73
|
+
"spec/fixtures/application.rb",
|
74
|
+
"spec/fixtures/bundle/execute.rb",
|
75
|
+
"spec/fixtures/doc/config.rb",
|
76
|
+
"spec/group_spec.rb",
|
77
|
+
"spec/invocation_spec.rb",
|
78
|
+
"spec/parser/argument_spec.rb",
|
79
|
+
"spec/parser/arguments_spec.rb",
|
80
|
+
"spec/parser/option_spec.rb",
|
81
|
+
"spec/parser/options_spec.rb",
|
82
|
+
"spec/rake_compat_spec.rb",
|
83
|
+
"spec/runner_spec.rb",
|
84
|
+
"spec/shell/basic_spec.rb",
|
85
|
+
"spec/shell/color_spec.rb",
|
86
|
+
"spec/shell_spec.rb",
|
87
|
+
"spec/spec_helper.rb",
|
88
|
+
"spec/task_spec.rb",
|
89
|
+
"spec/thor_spec.rb",
|
90
|
+
"spec/util_spec.rb",
|
91
|
+
"spec/actions",
|
92
|
+
"spec/core_ext",
|
93
|
+
"spec/fixtures",
|
94
|
+
"spec/fixtures/bundle",
|
95
|
+
"spec/fixtures/bundle/main.thor",
|
96
|
+
"spec/fixtures/doc",
|
97
|
+
"spec/fixtures/doc/%file_name%.rb.tt",
|
98
|
+
"spec/fixtures/doc/components",
|
99
|
+
"spec/fixtures/doc/README",
|
100
|
+
"spec/fixtures/group.thor",
|
101
|
+
"spec/fixtures/invoke.thor",
|
102
|
+
"spec/fixtures/script.thor",
|
103
|
+
"spec/fixtures/task.thor",
|
104
|
+
"spec/parser",
|
105
|
+
"spec/sandbox",
|
106
|
+
"spec/shell",
|
107
|
+
"spec/spec.opts"
|
108
|
+
]
|
109
|
+
|
110
|
+
if s.respond_to? :specification_version then
|
111
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
112
|
+
s.specification_version = 3
|
113
|
+
|
114
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
115
|
+
else
|
116
|
+
end
|
117
|
+
else
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "the EY::Deploy API" do
|
4
|
+
it "calls tasks in the right order" do
|
5
|
+
class TestDeploy < EY::Deploy
|
6
|
+
# This happens before require_custom_tasks, so it's not
|
7
|
+
# overrideable. That's why it's not in @call_order.
|
8
|
+
def update_repository_cache() end
|
9
|
+
|
10
|
+
# cheat a bit; we don't actually want to do these things
|
11
|
+
def require_custom_tasks() end
|
12
|
+
def callback(*_) end
|
13
|
+
def puts(*_) 'stfu' end
|
14
|
+
|
15
|
+
attr_reader :call_order
|
16
|
+
def initialize(*a)
|
17
|
+
super
|
18
|
+
@call_order = []
|
19
|
+
end
|
20
|
+
|
21
|
+
def push_code() @call_order << 'push_code' end
|
22
|
+
def copy_repository_cache() @call_order << 'copy_repository_cache' end
|
23
|
+
def create_revision_file() @call_order << 'create_revision_file' end
|
24
|
+
def bundle() @call_order << 'bundle' end
|
25
|
+
def symlink_configs() @call_order << 'symlink_configs' end
|
26
|
+
def migrate() @call_order << 'migrate' end
|
27
|
+
def symlink() @call_order << 'symlink' end
|
28
|
+
def restart() @call_order << 'restart' end
|
29
|
+
def cleanup_old_releases() @call_order << 'cleanup_old_releases' end
|
30
|
+
def conditionally_enable_maintenance_page() @call_order << 'conditionally_enable_maintenance_page' end
|
31
|
+
def disable_maintenance_page() @call_order << 'disable_maintenance_page' end
|
32
|
+
end
|
33
|
+
|
34
|
+
td = TestDeploy.new(EY::Deploy::Configuration.new)
|
35
|
+
td.deploy
|
36
|
+
td.call_order.should == %w(
|
37
|
+
push_code
|
38
|
+
copy_repository_cache
|
39
|
+
create_revision_file
|
40
|
+
bundle
|
41
|
+
symlink_configs
|
42
|
+
conditionally_enable_maintenance_page
|
43
|
+
migrate
|
44
|
+
symlink
|
45
|
+
restart
|
46
|
+
disable_maintenance_page
|
47
|
+
cleanup_old_releases)
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "task overrides" do
|
51
|
+
class TestQuietDeploy < EY::Deploy
|
52
|
+
def puts(*_) 'quiet' end
|
53
|
+
end
|
54
|
+
|
55
|
+
before(:each) do
|
56
|
+
@tempdir = `mktemp -d -t custom_deploy_spec`.strip
|
57
|
+
@config = EY::Deploy::Configuration.new('repository_cache' => @tempdir)
|
58
|
+
@deploy = TestQuietDeploy.new(@config)
|
59
|
+
end
|
60
|
+
|
61
|
+
def write_eydeploy(relative_path, contents = "def got_new_methods() 'from the file on disk' end")
|
62
|
+
FileUtils.mkdir_p(File.join(
|
63
|
+
@tempdir,
|
64
|
+
File.dirname(relative_path)))
|
65
|
+
|
66
|
+
File.open(File.join(@tempdir, relative_path), 'w') do |f|
|
67
|
+
f.write contents
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
it "requires 'eydeploy.rb' and adds any defined methods to the deploy" do
|
72
|
+
write_eydeploy 'eydeploy.rb'
|
73
|
+
@deploy.require_custom_tasks.should be_true
|
74
|
+
@deploy.got_new_methods.should == 'from the file on disk'
|
75
|
+
end
|
76
|
+
|
77
|
+
it "falls back to 'config/eydeploy.rb'" do
|
78
|
+
write_eydeploy 'config/eydeploy.rb'
|
79
|
+
@deploy.require_custom_tasks.should be_true
|
80
|
+
@deploy.got_new_methods.should == 'from the file on disk'
|
81
|
+
end
|
82
|
+
|
83
|
+
it "lets you super up from any defined methods" do
|
84
|
+
write_eydeploy 'eydeploy.rb', "def value() super << ' + derived' end"
|
85
|
+
|
86
|
+
class TestDeploySuper < TestQuietDeploy
|
87
|
+
def value() 'base' end
|
88
|
+
end
|
89
|
+
|
90
|
+
deploy = TestDeploySuper.new(@config)
|
91
|
+
deploy.require_custom_tasks.should be_true
|
92
|
+
deploy.value.should == "base + derived"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|