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.
@@ -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
@@ -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