wycats-thor 0.9.8 → 0.10.26
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +26 -3
- data/README.markdown +213 -42
- data/bin/rake2thor +4 -0
- data/bin/thor +1 -1
- data/lib/thor/actions/copy_file.rb +32 -0
- data/lib/thor/actions/create_file.rb +49 -0
- data/lib/thor/actions/directory.rb +76 -0
- data/lib/thor/actions/empty_directory.rb +30 -0
- data/lib/thor/actions/get.rb +58 -0
- data/lib/thor/actions/inject_into_file.rb +93 -0
- data/lib/thor/actions/template.rb +38 -0
- data/lib/thor/actions/templater.rb +195 -0
- data/lib/thor/actions.rb +328 -0
- data/lib/thor/base.rb +520 -0
- data/lib/thor/core_ext/hash_with_indifferent_access.rb +75 -0
- data/lib/thor/core_ext/ordered_hash.rb +102 -0
- data/lib/thor/error.rb +25 -1
- data/lib/thor/group.rb +72 -0
- data/lib/thor/invocation.rb +161 -0
- data/lib/thor/parser/argument.rb +67 -0
- data/lib/thor/parser/arguments.rb +145 -0
- data/lib/thor/parser/option.rb +125 -0
- data/lib/thor/parser/options.rb +135 -0
- data/lib/thor/parser.rb +4 -0
- data/lib/thor/runner.rb +239 -230
- data/lib/thor/shell/basic.rb +221 -0
- data/lib/thor/shell/color.rb +106 -0
- data/lib/thor/shell.rb +72 -0
- data/lib/thor/task.rb +89 -60
- data/lib/thor/tasks/install.rb +35 -0
- data/lib/thor/tasks/package.rb +26 -13
- data/lib/thor/tasks/spec.rb +70 -0
- data/lib/thor/tasks.rb +3 -76
- data/lib/thor/util.rb +213 -41
- data/lib/thor.rb +206 -118
- metadata +38 -13
- data/lib/thor/options.rb +0 -242
- data/lib/thor/ordered_hash.rb +0 -64
- data/lib/thor/task_hash.rb +0 -22
data/lib/thor/ordered_hash.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
class Thor
|
2
|
-
# This class is based on the Ruby 1.9 ordered hashes.
|
3
|
-
# It keeps the semantics and most of the efficiency of normal hashes
|
4
|
-
# while also keeping track of the order in which elements were set.
|
5
|
-
class OrderedHash
|
6
|
-
Node = Struct.new(:key, :value, :next, :prev)
|
7
|
-
include Enumerable
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
@hash = {}
|
11
|
-
end
|
12
|
-
|
13
|
-
def initialize_copy(other)
|
14
|
-
@hash = other.instance_variable_get('@hash').clone
|
15
|
-
end
|
16
|
-
|
17
|
-
def [](key)
|
18
|
-
@hash[key] && @hash[key].value
|
19
|
-
end
|
20
|
-
|
21
|
-
def []=(key, value)
|
22
|
-
node = Node.new(key, value)
|
23
|
-
|
24
|
-
if old = @hash[key]
|
25
|
-
if old.prev
|
26
|
-
old.prev.next = old.next
|
27
|
-
else # old is @first and @last
|
28
|
-
@first = @last = nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
if @first.nil?
|
33
|
-
@first = @last = node
|
34
|
-
else
|
35
|
-
node.prev = @last
|
36
|
-
@last.next = node
|
37
|
-
@last = node
|
38
|
-
end
|
39
|
-
|
40
|
-
@hash[key] = node
|
41
|
-
value
|
42
|
-
end
|
43
|
-
|
44
|
-
def each
|
45
|
-
return unless @first
|
46
|
-
yield [@first.key, @first.value]
|
47
|
-
node = @first
|
48
|
-
yield [node.key, node.value] while node = node.next
|
49
|
-
self
|
50
|
-
end
|
51
|
-
|
52
|
-
def values
|
53
|
-
self.map { |k, v| v }
|
54
|
-
end
|
55
|
-
|
56
|
-
def +(other)
|
57
|
-
new = clone
|
58
|
-
other.each do |key, value|
|
59
|
-
new[key] = value unless self[key]
|
60
|
-
end
|
61
|
-
new
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
data/lib/thor/task_hash.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'thor/ordered_hash'
|
2
|
-
require 'thor/task'
|
3
|
-
|
4
|
-
class Thor::TaskHash < Thor::OrderedHash
|
5
|
-
def initialize(klass)
|
6
|
-
super()
|
7
|
-
@klass = klass
|
8
|
-
end
|
9
|
-
|
10
|
-
def each(local = false, &block)
|
11
|
-
super() { |k, t| yield k, t.with_klass(@klass) }
|
12
|
-
@klass.superclass.tasks.each { |k, t| yield k, t.with_klass(@klass) } unless local || @klass == Thor
|
13
|
-
end
|
14
|
-
|
15
|
-
def [](name)
|
16
|
-
if task = super(name) || (@klass == Thor && @klass.superclass.tasks[name])
|
17
|
-
return task.with_klass(@klass)
|
18
|
-
end
|
19
|
-
|
20
|
-
Thor::Task.dynamic(name, @klass)
|
21
|
-
end
|
22
|
-
end
|