contextify 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/{History.txt → History.rdoc} +11 -0
- data/Manifest.txt +3 -3
- data/{README.txt → README.rdoc} +1 -5
- data/Rakefile +10 -11
- data/lib/contextify/class_methods.rb +51 -0
- data/lib/contextify/contextify.rb +194 -240
- data/lib/contextify/pending_context.rb +34 -0
- data/lib/contextify/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +45 -14
- metadata.gz.sig +0 -0
- data/tasks/spec.rb +0 -10
data.tar.gz.sig
CHANGED
Binary file
|
@@ -1,3 +1,14 @@
|
|
1
|
+
=== 0.1.4 / 2009-01-30
|
2
|
+
|
3
|
+
* Require RSpec >= 1.3.0.
|
4
|
+
* Require YARD >= 0.5.3.
|
5
|
+
* Added {Contextify::ClassMethods}.
|
6
|
+
* Added {Contextify::PendingContext#each_class}.
|
7
|
+
* Added {Contextify::PendingContext#each}.
|
8
|
+
* Fixed a bug in {Contextify::PendingContext#each_block}.
|
9
|
+
* Fixed a typo where {Contextify} methods where being defined within
|
10
|
+
the {Contextify.included} method.
|
11
|
+
|
1
12
|
=== 0.1.3 / 2009-09-21
|
2
13
|
|
3
14
|
* Require Hoe >= 2.3.3.
|
data/Manifest.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
History.
|
1
|
+
History.rdoc
|
2
2
|
Manifest.txt
|
3
|
-
README.
|
3
|
+
README.rdoc
|
4
4
|
Rakefile
|
5
5
|
lib/contextify.rb
|
6
6
|
lib/contextify/exceptions.rb
|
@@ -10,6 +10,7 @@ lib/contextify/extensions.rb
|
|
10
10
|
lib/contextify/extensions/meta.rb
|
11
11
|
lib/contextify/extensions/meta/object.rb
|
12
12
|
lib/contextify/pending_context.rb
|
13
|
+
lib/contextify/class_methods.rb
|
13
14
|
lib/contextify/contextify.rb
|
14
15
|
lib/contextify/version.rb
|
15
16
|
lib/contextify/yard.rb
|
@@ -20,4 +21,3 @@ lib/contextify/yard/handlers/ruby/legacy.rb
|
|
20
21
|
lib/contextify/yard/handlers/ruby/legacy/contextify_handler.rb
|
21
22
|
spec/contextify_spec.rb
|
22
23
|
spec/spec_helper.rb
|
23
|
-
tasks/spec.rb
|
data/{README.txt → README.rdoc}
RENAMED
@@ -44,10 +44,6 @@ classes named like the file.
|
|
44
44
|
controller.test2('one two three')
|
45
45
|
# => "Hello one two three"
|
46
46
|
|
47
|
-
== REQUIREMENTS:
|
48
|
-
|
49
|
-
* {YARD}[http://yard.soen.ca/] >= 0.2.3.5
|
50
|
-
|
51
47
|
== INSTALL:
|
52
48
|
|
53
49
|
$ sudo gem install contextify
|
@@ -56,7 +52,7 @@ classes named like the file.
|
|
56
52
|
|
57
53
|
The MIT License
|
58
54
|
|
59
|
-
Copyright (c) 2008-
|
55
|
+
Copyright (c) 2008-2010 Hal Brodigan
|
60
56
|
|
61
57
|
Permission is hereby granted, free of charge, to any person obtaining
|
62
58
|
a copy of this software and associated documentation files (the
|
data/Rakefile
CHANGED
@@ -3,22 +3,21 @@
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'hoe'
|
5
5
|
require 'hoe/signing'
|
6
|
-
|
7
|
-
|
6
|
+
|
7
|
+
Hoe.plugin :yard
|
8
8
|
|
9
9
|
Hoe.spec('contextify') do
|
10
|
-
self.rubyforge_name = 'contextify'
|
11
10
|
self.developer('Postmodern', 'postmodern.mod3@gmail.com')
|
12
|
-
self.remote_rdoc_dir = ''
|
13
|
-
self.extra_deps = [
|
14
|
-
['yard', '>=0.2.3.5']
|
15
|
-
]
|
16
11
|
|
17
|
-
self.
|
18
|
-
['rspec', '>=1.2.8']
|
19
|
-
]
|
12
|
+
self.rspec_options += ['--colour', '--format', 'specdoc']
|
20
13
|
|
21
|
-
self.
|
14
|
+
self.yard_options += ['--protected']
|
15
|
+
self.remote_yard_dir = ''
|
16
|
+
|
17
|
+
self.extra_dev_deps += [
|
18
|
+
['rspec', '>=1.3.0'],
|
19
|
+
['yard', '>=0.5.3']
|
20
|
+
]
|
22
21
|
end
|
23
22
|
|
24
23
|
# vim: syntax=Ruby
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'contextify/extensions'
|
2
|
+
|
3
|
+
module Contextify
|
4
|
+
module ClassMethods
|
5
|
+
#
|
6
|
+
# Contextifies the class.
|
7
|
+
#
|
8
|
+
# @param [Symbol, String] name
|
9
|
+
# The context name to assign to the class.
|
10
|
+
#
|
11
|
+
def contextify(name)
|
12
|
+
name = name.to_s
|
13
|
+
|
14
|
+
Contextify.contexts[name] = self
|
15
|
+
|
16
|
+
meta_def(:context_name) { name }
|
17
|
+
|
18
|
+
meta_def(:load_context_block) do |path|
|
19
|
+
Contextify.load_block(name,path)
|
20
|
+
end
|
21
|
+
|
22
|
+
meta_def(:load_context) do |path,*args|
|
23
|
+
pending = Contextify.load_blocks(path)
|
24
|
+
|
25
|
+
context, block = pending.find do |name,block|
|
26
|
+
Contextify.contexts[name].ancestors.include?(self)
|
27
|
+
end
|
28
|
+
|
29
|
+
if (context && block)
|
30
|
+
obj = Contextify.contexts[name].new(*args)
|
31
|
+
obj.instance_eval(&block)
|
32
|
+
obj
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# define the top-level context wrappers
|
37
|
+
Kernel.module_eval %{
|
38
|
+
def #{name}(*args,&block)
|
39
|
+
if (args.empty? && ::Contextify.is_pending?)
|
40
|
+
::Contextify.pending.blocks[#{name.dump}] = block
|
41
|
+
return nil
|
42
|
+
else
|
43
|
+
new_context = #{self}.new(*args)
|
44
|
+
new_context.instance_eval(&block) if block
|
45
|
+
return new_context
|
46
|
+
end
|
47
|
+
end
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -1,275 +1,229 @@
|
|
1
1
|
require 'contextify/exceptions'
|
2
|
-
require 'contextify/
|
2
|
+
require 'contextify/class_methods'
|
3
3
|
require 'contextify/pending_context'
|
4
4
|
|
5
5
|
module Contextify
|
6
6
|
def self.included(base)
|
7
|
-
base.
|
8
|
-
|
9
|
-
# Contextifies the class.
|
10
|
-
#
|
11
|
-
# @param [Symbol, String] name
|
12
|
-
# The context name to assign to the class.
|
13
|
-
#
|
14
|
-
def self.contextify(name)
|
15
|
-
name = name.to_s
|
16
|
-
|
17
|
-
Contextify.contexts[name] = self
|
7
|
+
base.extend ClassMethods
|
8
|
+
end
|
18
9
|
|
19
|
-
|
10
|
+
#
|
11
|
+
# All contextified classes.
|
12
|
+
#
|
13
|
+
# @return [Hash{Symbol => Class}]
|
14
|
+
# All defined contexts and their classes.
|
15
|
+
#
|
16
|
+
def Contextify.contexts
|
17
|
+
@@contextify_contexts ||= {}
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
#
|
21
|
+
# Determines whether a context with a specific name has been defined.
|
22
|
+
#
|
23
|
+
# @param [Symbol, String] name
|
24
|
+
# The name of the context to search for.
|
25
|
+
#
|
26
|
+
# @return [Boolean]
|
27
|
+
# Specifies whether there is a context defined with the specified
|
28
|
+
# name.
|
29
|
+
#
|
30
|
+
def Contextify.is_context?(name)
|
31
|
+
Contextify.contexts.has_key?(name.to_s)
|
32
|
+
end
|
24
33
|
|
25
|
-
|
26
|
-
|
34
|
+
#
|
35
|
+
# The contexts waiting to be fully loaded.
|
36
|
+
#
|
37
|
+
# @return [Array<PendingContext>]
|
38
|
+
# Contexts which are waiting to be loaded.
|
39
|
+
#
|
40
|
+
def Contextify.waiting
|
41
|
+
@@contextify_waiting_contexts ||= []
|
42
|
+
end
|
27
43
|
|
28
|
-
|
29
|
-
|
30
|
-
|
44
|
+
#
|
45
|
+
# The first context waiting to be fully loaded.
|
46
|
+
#
|
47
|
+
# @return [PendingContext]
|
48
|
+
# The pending context being loaded.
|
49
|
+
#
|
50
|
+
def Contextify.pending
|
51
|
+
Contextify.waiting.first
|
52
|
+
end
|
31
53
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
54
|
+
#
|
55
|
+
# Determines whether there are pending contexts.
|
56
|
+
#
|
57
|
+
# @return [Boolean]
|
58
|
+
# Specifies whether there is a pending context present.
|
59
|
+
#
|
60
|
+
def Contextify.is_pending?
|
61
|
+
!(Contextify.waiting.empty?)
|
62
|
+
end
|
38
63
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
64
|
+
#
|
65
|
+
# Finds the first pending context being loaded from a specific path.
|
66
|
+
#
|
67
|
+
# @param [String] path
|
68
|
+
# The path which is being loaded.
|
69
|
+
#
|
70
|
+
# @return [PendingContext]
|
71
|
+
# The first pending context with the specified path.
|
72
|
+
#
|
73
|
+
def Contextify.loading(path)
|
74
|
+
Contextify.waiting.each do |pending|
|
75
|
+
if pending.path == path
|
76
|
+
return pending
|
52
77
|
end
|
53
78
|
end
|
54
79
|
|
55
|
-
|
56
|
-
|
57
|
-
#
|
58
|
-
# @return [Hash{Symbol => Class}]
|
59
|
-
# All defined contexts and their classes.
|
60
|
-
#
|
61
|
-
def Contextify.contexts
|
62
|
-
@@contextify_contexts ||= {}
|
63
|
-
end
|
64
|
-
|
65
|
-
#
|
66
|
-
# Determines whether a context with a specific name has been defined.
|
67
|
-
#
|
68
|
-
# @param [Symbol, String] name
|
69
|
-
# The name of the context to search for.
|
70
|
-
#
|
71
|
-
# @return [Boolean]
|
72
|
-
# Specifies whether there is a context defined with the specified
|
73
|
-
# name.
|
74
|
-
#
|
75
|
-
def Contextify.is_context?(name)
|
76
|
-
Contextify.contexts.has_key?(name.to_s)
|
77
|
-
end
|
78
|
-
|
79
|
-
#
|
80
|
-
# The contexts waiting to be fully loaded.
|
81
|
-
#
|
82
|
-
# @return [Array<PendingContext>]
|
83
|
-
# Contexts which are waiting to be loaded.
|
84
|
-
#
|
85
|
-
def Contextify.waiting
|
86
|
-
@@contextify_waiting_contexts ||= []
|
87
|
-
end
|
80
|
+
return nil
|
81
|
+
end
|
88
82
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
83
|
+
#
|
84
|
+
# Determines whether contexts are being loaded from a specific path.
|
85
|
+
#
|
86
|
+
# @param [String] path
|
87
|
+
# The path to check if contexts are being loaded from.
|
88
|
+
#
|
89
|
+
# @return [Boolean]
|
90
|
+
# Specifies whether pending contexts are being loaded from the
|
91
|
+
# specified path.
|
92
|
+
#
|
93
|
+
def Contextify.is_loading?(path)
|
94
|
+
!(Contextify.loading(path).nil?)
|
95
|
+
end
|
98
96
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
97
|
+
#
|
98
|
+
# Loads all context blocks from a specific path.
|
99
|
+
#
|
100
|
+
# @param [String] path
|
101
|
+
# The path to load all context blocks from.
|
102
|
+
#
|
103
|
+
# @return [PendingContext]
|
104
|
+
# The pending context which contains the blocks.
|
105
|
+
#
|
106
|
+
def Contextify.load_blocks(path,&block)
|
107
|
+
path = File.expand_path(path)
|
108
|
+
|
109
|
+
unless File.file?(path)
|
110
|
+
raise(ContextNotFound,"context #{path.dump} doest not exist",caller)
|
107
111
|
end
|
108
112
|
|
109
|
-
#
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
# The path which is being loaded.
|
114
|
-
#
|
115
|
-
# @return [PendingContext]
|
116
|
-
# The first pending context with the specified path.
|
117
|
-
#
|
118
|
-
def Contextify.loading(path)
|
119
|
-
Contextify.waiting.each do |pending|
|
120
|
-
if pending.path == path
|
121
|
-
return pending
|
122
|
-
end
|
123
|
-
end
|
113
|
+
# prevent circular loading of contexts
|
114
|
+
unless Contextify.is_pending?
|
115
|
+
# push on the new pending context
|
116
|
+
Contextify.waiting.unshift(PendingContext.new(path))
|
124
117
|
|
125
|
-
|
118
|
+
load(path)
|
126
119
|
end
|
127
120
|
|
128
|
-
#
|
129
|
-
|
130
|
-
#
|
131
|
-
# @param [String] path
|
132
|
-
# The path to check if contexts are being loaded from.
|
133
|
-
#
|
134
|
-
# @return [Boolean]
|
135
|
-
# Specifies whether pending contexts are being loaded from the
|
136
|
-
# specified path.
|
137
|
-
#
|
138
|
-
def Contextify.is_loading?(path)
|
139
|
-
!(Contextify.loading(path).nil?)
|
140
|
-
end
|
121
|
+
# pop off and return the pending context
|
122
|
+
pending_context = Contextify.waiting.shift
|
141
123
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
# @param [String] path
|
146
|
-
# The path to load all context blocks from.
|
147
|
-
#
|
148
|
-
# @return [PendingContext]
|
149
|
-
# The pending context which contains the blocks.
|
150
|
-
#
|
151
|
-
def Contextify.load_blocks(path,&block)
|
152
|
-
path = File.expand_path(path)
|
153
|
-
|
154
|
-
unless File.file?(path)
|
155
|
-
raise(ContextNotFound,"context #{path.dump} doest not exist",caller)
|
156
|
-
end
|
157
|
-
|
158
|
-
# prevent circular loading of contexts
|
159
|
-
unless Contextify.is_pending?
|
160
|
-
# push on the new pending context
|
161
|
-
Contextify.waiting.unshift(PendingContext.new(path))
|
162
|
-
|
163
|
-
load(path)
|
164
|
-
end
|
124
|
+
block.call(pending_context) if block
|
125
|
+
return pending_context
|
126
|
+
end
|
165
127
|
|
166
|
-
|
167
|
-
|
128
|
+
#
|
129
|
+
# Loads the context block for the context with the specific name
|
130
|
+
# from a specific path.
|
131
|
+
#
|
132
|
+
# @param [Symbol, String] name
|
133
|
+
# The name of the context to load the block for.
|
134
|
+
#
|
135
|
+
# @param [String] path
|
136
|
+
# The path to load the context block from.
|
137
|
+
#
|
138
|
+
# @yield [block]
|
139
|
+
# The block which will receive the context block.
|
140
|
+
#
|
141
|
+
# @yieldparam [Proc] block
|
142
|
+
# The context block loaded from the specified _path_.
|
143
|
+
#
|
144
|
+
# @return [Proc]
|
145
|
+
# The block for the context with the specified _name_.
|
146
|
+
#
|
147
|
+
# @example
|
148
|
+
# Contextify.load_block(:exploit,'/path/to/my_exploit.rb')
|
149
|
+
# # => Proc
|
150
|
+
#
|
151
|
+
# @example
|
152
|
+
# Contextify.load_block(:shellcode,'/path/to/execve.rb') do |block|
|
153
|
+
# # ...
|
154
|
+
# end
|
155
|
+
#
|
156
|
+
def Contextify.load_block(name,path,&block)
|
157
|
+
context_block = Contextify.load_blocks(path).blocks[name.to_s]
|
158
|
+
|
159
|
+
block.call(context_block) if block
|
160
|
+
return context_block
|
161
|
+
end
|
168
162
|
|
169
|
-
|
170
|
-
|
163
|
+
#
|
164
|
+
# Loads the context object of a specific name and from the specific
|
165
|
+
# path.
|
166
|
+
#
|
167
|
+
# @param [Symbol, String] name
|
168
|
+
# The name of the context to load.
|
169
|
+
#
|
170
|
+
# @param [String] path
|
171
|
+
# The path to load the context object from.
|
172
|
+
#
|
173
|
+
# @return [Object]
|
174
|
+
# The loaded context object.
|
175
|
+
#
|
176
|
+
# @raise [UnknownContext]
|
177
|
+
# No context was defined with the specific name.
|
178
|
+
#
|
179
|
+
# @example
|
180
|
+
# Contextify.load_context(:note,'/path/to/my_notes.rb')
|
181
|
+
# # => Note
|
182
|
+
#
|
183
|
+
def Contextify.load_context(name,path,*arguments)
|
184
|
+
name = name.to_s
|
185
|
+
|
186
|
+
unless Contextify.is_context?(name)
|
187
|
+
raise(UnknownContext,"unknown context #{name.dump}",caller)
|
171
188
|
end
|
172
189
|
|
173
|
-
|
174
|
-
# Loads the context block for the context with the specific name
|
175
|
-
# from a specific path.
|
176
|
-
#
|
177
|
-
# @param [Symbol, String] name
|
178
|
-
# The name of the context to load the block for.
|
179
|
-
#
|
180
|
-
# @param [String] path
|
181
|
-
# The path to load the context block from.
|
182
|
-
#
|
183
|
-
# @yield [block]
|
184
|
-
# The block which will receive the context block.
|
185
|
-
#
|
186
|
-
# @yieldparam [Proc] block
|
187
|
-
# The context block loaded from the specified _path_.
|
188
|
-
#
|
189
|
-
# @return [Proc]
|
190
|
-
# The block for the context with the specified _name_.
|
191
|
-
#
|
192
|
-
# @example
|
193
|
-
# Contextify.load_block(:exploit,'/path/to/my_exploit.rb')
|
194
|
-
# # => Proc
|
195
|
-
#
|
196
|
-
# @example
|
197
|
-
# Contextify.load_block(:shellcode,'/path/to/execve.rb') do |block|
|
198
|
-
# # ...
|
199
|
-
# end
|
200
|
-
#
|
201
|
-
def Contextify.load_block(name,path,&block)
|
202
|
-
context_block = Contextify.load_blocks(path).blocks[name.to_s]
|
190
|
+
new_context = Contextify.contexts[name].new(*arguments)
|
203
191
|
|
204
|
-
|
205
|
-
|
192
|
+
Contextify.load_block(name,path) do |context_block|
|
193
|
+
new_context.instance_eval(&context_block) if context_block
|
206
194
|
end
|
207
195
|
|
208
|
-
|
209
|
-
|
210
|
-
# path.
|
211
|
-
#
|
212
|
-
# @param [Symbol, String] name
|
213
|
-
# The name of the context to load.
|
214
|
-
#
|
215
|
-
# @param [String] path
|
216
|
-
# The path to load the context object from.
|
217
|
-
#
|
218
|
-
# @return [Object]
|
219
|
-
# The loaded context object.
|
220
|
-
#
|
221
|
-
# @raise [UnknownContext]
|
222
|
-
# No context was defined with the specific name.
|
223
|
-
#
|
224
|
-
# @example
|
225
|
-
# Contextify.load_context(:note,'/path/to/my_notes.rb')
|
226
|
-
# # => Note
|
227
|
-
#
|
228
|
-
def Contextify.load_context(name,path,*arguments)
|
229
|
-
name = name.to_s
|
230
|
-
|
231
|
-
unless Contextify.is_context?(name)
|
232
|
-
raise(UnknownContext,"unknown context #{name.dump}",caller)
|
233
|
-
end
|
234
|
-
|
235
|
-
new_context = Contextify.contexts[name].new(*arguments)
|
236
|
-
|
237
|
-
Contextify.load_block(name,path) do |context_block|
|
238
|
-
new_context.instance_eval(&context_block) if context_block
|
239
|
-
end
|
240
|
-
|
241
|
-
return new_context
|
242
|
-
end
|
243
|
-
|
244
|
-
#
|
245
|
-
# Loads all context objects from a specific path.
|
246
|
-
#
|
247
|
-
# @param [String] path
|
248
|
-
# The path to load all context objects from.
|
249
|
-
#
|
250
|
-
# @return [Array]
|
251
|
-
# The array of loaded context objects.
|
252
|
-
#
|
253
|
-
# @example
|
254
|
-
# Contextify.load_contexts('/path/to/misc_contexts.rb')
|
255
|
-
# # => [...]
|
256
|
-
#
|
257
|
-
def Contextify.load_contexts(path,&block)
|
258
|
-
new_objs = []
|
259
|
-
|
260
|
-
Contextify.load_blocks(path) do |pending|
|
261
|
-
pending.each_block do |name,context_block|
|
262
|
-
if Contextify.is_context?(name)
|
263
|
-
new_obj = Contextify.contexts[name].new
|
264
|
-
new_obj.instance_eval(&context_block)
|
196
|
+
return new_context
|
197
|
+
end
|
265
198
|
|
266
|
-
|
267
|
-
|
268
|
-
|
199
|
+
#
|
200
|
+
# Loads all context objects from a specific path.
|
201
|
+
#
|
202
|
+
# @param [String] path
|
203
|
+
# The path to load all context objects from.
|
204
|
+
#
|
205
|
+
# @return [Array]
|
206
|
+
# The array of loaded context objects.
|
207
|
+
#
|
208
|
+
# @example
|
209
|
+
# Contextify.load_contexts('/path/to/misc_contexts.rb')
|
210
|
+
# # => [...]
|
211
|
+
#
|
212
|
+
def Contextify.load_contexts(path,&block)
|
213
|
+
new_objs = []
|
214
|
+
|
215
|
+
Contextify.load_blocks(path) do |pending|
|
216
|
+
pending.each do |name,context_block|
|
217
|
+
if Contextify.is_context?(name)
|
218
|
+
new_obj = Contextify.contexts[name].new
|
219
|
+
new_obj.instance_eval(&context_block)
|
220
|
+
|
221
|
+
block.call(new_obj) if block
|
222
|
+
new_objs << new_obj
|
269
223
|
end
|
270
224
|
end
|
271
|
-
|
272
|
-
return new_objs
|
273
225
|
end
|
226
|
+
|
227
|
+
return new_objs
|
274
228
|
end
|
275
229
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Contextify
|
2
2
|
class PendingContext
|
3
3
|
|
4
|
+
include Enumerable
|
5
|
+
|
4
6
|
# The path being loaded
|
5
7
|
attr_reader :path
|
6
8
|
|
@@ -18,6 +20,21 @@ module Contextify
|
|
18
20
|
@blocks = {}
|
19
21
|
end
|
20
22
|
|
23
|
+
#
|
24
|
+
# Iterates over each context name in the pending context.
|
25
|
+
#
|
26
|
+
# @yield [name]
|
27
|
+
# The block will be passed each name of the pending context blocks.
|
28
|
+
#
|
29
|
+
# @yieldparam [String] name
|
30
|
+
# The name of a pending context block.
|
31
|
+
#
|
32
|
+
def each_class(&block)
|
33
|
+
@blocks.each_key do |name|
|
34
|
+
block.call(Contextify.contexts[name])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
21
38
|
#
|
22
39
|
# Iterates over each block in the pending context.
|
23
40
|
#
|
@@ -28,6 +45,23 @@ module Contextify
|
|
28
45
|
# A pending context block.
|
29
46
|
#
|
30
47
|
def each_block(&block)
|
48
|
+
@blocks.each_value(&block)
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# Iterates over each context name and block in the pending context.
|
53
|
+
#
|
54
|
+
# @yield [name, block]
|
55
|
+
# The block will be passed each pending context block and it's
|
56
|
+
# context name.
|
57
|
+
#
|
58
|
+
# @yieldparam [String] name
|
59
|
+
# The context name of the block.
|
60
|
+
#
|
61
|
+
# @yieldparam [Proc] block
|
62
|
+
# A pending context block.
|
63
|
+
#
|
64
|
+
def each(&block)
|
31
65
|
@blocks.each(&block)
|
32
66
|
end
|
33
67
|
|
data/lib/contextify/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contextify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
@@ -30,18 +30,38 @@ cert_chain:
|
|
30
30
|
pDj+ws7QjtH/Qcrr1l9jfN0ehDs=
|
31
31
|
-----END CERTIFICATE-----
|
32
32
|
|
33
|
-
date:
|
33
|
+
date: 2010-01-30 00:00:00 -08:00
|
34
34
|
default_executable:
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
type: :
|
37
|
+
name: rubyforge
|
38
|
+
type: :development
|
39
|
+
version_requirement:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 2.0.3
|
45
|
+
version:
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: gemcutter
|
48
|
+
type: :development
|
39
49
|
version_requirement:
|
40
50
|
version_requirements: !ruby/object:Gem::Requirement
|
41
51
|
requirements:
|
42
52
|
- - ">="
|
43
53
|
- !ruby/object:Gem::Version
|
44
|
-
version: 0.
|
54
|
+
version: 0.3.0
|
55
|
+
version:
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: hoe-yard
|
58
|
+
type: :development
|
59
|
+
version_requirement:
|
60
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 0.1.2
|
45
65
|
version:
|
46
66
|
- !ruby/object:Gem::Dependency
|
47
67
|
name: rspec
|
@@ -51,7 +71,17 @@ dependencies:
|
|
51
71
|
requirements:
|
52
72
|
- - ">="
|
53
73
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
74
|
+
version: 1.3.0
|
75
|
+
version:
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: yard
|
78
|
+
type: :development
|
79
|
+
version_requirement:
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 0.5.3
|
55
85
|
version:
|
56
86
|
- !ruby/object:Gem::Dependency
|
57
87
|
name: hoe
|
@@ -61,7 +91,7 @@ dependencies:
|
|
61
91
|
requirements:
|
62
92
|
- - ">="
|
63
93
|
- !ruby/object:Gem::Version
|
64
|
-
version: 2.
|
94
|
+
version: 2.5.0
|
65
95
|
version:
|
66
96
|
description: |-
|
67
97
|
Load Objects from Ruby files without having to use YAML or define
|
@@ -73,13 +103,12 @@ executables: []
|
|
73
103
|
extensions: []
|
74
104
|
|
75
105
|
extra_rdoc_files:
|
76
|
-
- History.txt
|
77
106
|
- Manifest.txt
|
78
|
-
-
|
107
|
+
- History.rdoc
|
79
108
|
files:
|
80
|
-
- History.
|
109
|
+
- History.rdoc
|
81
110
|
- Manifest.txt
|
82
|
-
- README.
|
111
|
+
- README.rdoc
|
83
112
|
- Rakefile
|
84
113
|
- lib/contextify.rb
|
85
114
|
- lib/contextify/exceptions.rb
|
@@ -89,6 +118,7 @@ files:
|
|
89
118
|
- lib/contextify/extensions/meta.rb
|
90
119
|
- lib/contextify/extensions/meta/object.rb
|
91
120
|
- lib/contextify/pending_context.rb
|
121
|
+
- lib/contextify/class_methods.rb
|
92
122
|
- lib/contextify/contextify.rb
|
93
123
|
- lib/contextify/version.rb
|
94
124
|
- lib/contextify/yard.rb
|
@@ -99,15 +129,16 @@ files:
|
|
99
129
|
- lib/contextify/yard/handlers/ruby/legacy/contextify_handler.rb
|
100
130
|
- spec/contextify_spec.rb
|
101
131
|
- spec/spec_helper.rb
|
102
|
-
- tasks/spec.rb
|
103
132
|
has_rdoc: yard
|
104
133
|
homepage: http://contextify.rubyforge.org/
|
105
134
|
licenses: []
|
106
135
|
|
107
136
|
post_install_message:
|
108
137
|
rdoc_options:
|
109
|
-
- --
|
110
|
-
-
|
138
|
+
- --protected
|
139
|
+
- --title
|
140
|
+
- Contextify Documentation
|
141
|
+
- --quiet
|
111
142
|
require_paths:
|
112
143
|
- lib
|
113
144
|
required_ruby_version: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|
data/tasks/spec.rb
DELETED