impromptu 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/impromptu.gemspec +65 -67
- data/lib/impromptu/autoload.rb +9 -1
- data/lib/impromptu/resource.rb +2 -1
- data/lib/impromptu/symbol.rb +15 -2
- data/test/framework/private/klass.rb +5 -0
- data/test/test_autoload.rb +44 -0
- data/test/test_symbol.rb +28 -0
- metadata +6 -7
- data/.gitignore +0 -21
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/impromptu.gemspec
CHANGED
@@ -1,93 +1,91 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{impromptu}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Will Cannings"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-16}
|
13
13
|
s.description = %q{Component and dependency manager for Ruby}
|
14
14
|
s.email = %q{me@willcannings.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
"test/test_symbol.rb"
|
21
|
+
"LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"impromptu.gemspec",
|
26
|
+
"lib/impromptu.rb",
|
27
|
+
"lib/impromptu/autoload.rb",
|
28
|
+
"lib/impromptu/component.rb",
|
29
|
+
"lib/impromptu/component_set.rb",
|
30
|
+
"lib/impromptu/file.rb",
|
31
|
+
"lib/impromptu/folder.rb",
|
32
|
+
"lib/impromptu/impromptu.rb",
|
33
|
+
"lib/impromptu/ordered_set.rb",
|
34
|
+
"lib/impromptu/resource.rb",
|
35
|
+
"lib/impromptu/symbol.rb",
|
36
|
+
"test/framework/copies/extra_klass2.rb",
|
37
|
+
"test/framework/copies/new_klass.rb",
|
38
|
+
"test/framework/copies/new_unseen.rb",
|
39
|
+
"test/framework/copies/original_klass.rb",
|
40
|
+
"test/framework/ext/extensions.rb",
|
41
|
+
"test/framework/ext/extensions/blog.rb",
|
42
|
+
"test/framework/lib/group/klass2.rb",
|
43
|
+
"test/framework/lib/klass.rb",
|
44
|
+
"test/framework/other/also.rb",
|
45
|
+
"test/framework/other/ignore.rb",
|
46
|
+
"test/framework/other/load.rb",
|
47
|
+
"test/framework/other/two.rb",
|
48
|
+
"test/framework/private/klass.rb",
|
49
|
+
"test/framework/test.components",
|
50
|
+
"test/helper.rb",
|
51
|
+
"test/test_autoload.rb",
|
52
|
+
"test/test_component.rb",
|
53
|
+
"test/test_component_set.rb",
|
54
|
+
"test/test_folder.rb",
|
55
|
+
"test/test_impromptu.rb",
|
56
|
+
"test/test_integration.rb",
|
57
|
+
"test/test_ordered_set.rb",
|
58
|
+
"test/test_resource.rb",
|
59
|
+
"test/test_symbol.rb"
|
61
60
|
]
|
62
61
|
s.homepage = %q{http://github.com/willcannings/impromptu}
|
63
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
64
62
|
s.require_paths = ["lib"]
|
65
63
|
s.rubygems_version = %q{1.3.7}
|
66
64
|
s.summary = %q{Component and dependency manager for Ruby}
|
67
65
|
s.test_files = [
|
68
66
|
"test/framework/copies/extra_klass2.rb",
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
67
|
+
"test/framework/copies/new_klass.rb",
|
68
|
+
"test/framework/copies/new_unseen.rb",
|
69
|
+
"test/framework/copies/original_klass.rb",
|
70
|
+
"test/framework/ext/extensions.rb",
|
71
|
+
"test/framework/ext/extensions/blog.rb",
|
72
|
+
"test/framework/lib/group/klass2.rb",
|
73
|
+
"test/framework/lib/klass.rb",
|
74
|
+
"test/framework/other/also.rb",
|
75
|
+
"test/framework/other/ignore.rb",
|
76
|
+
"test/framework/other/load.rb",
|
77
|
+
"test/framework/other/two.rb",
|
78
|
+
"test/framework/private/klass.rb",
|
79
|
+
"test/helper.rb",
|
80
|
+
"test/test_autoload.rb",
|
81
|
+
"test/test_component.rb",
|
82
|
+
"test/test_component_set.rb",
|
83
|
+
"test/test_folder.rb",
|
84
|
+
"test/test_impromptu.rb",
|
85
|
+
"test/test_integration.rb",
|
86
|
+
"test/test_ordered_set.rb",
|
87
|
+
"test/test_resource.rb",
|
88
|
+
"test/test_symbol.rb"
|
91
89
|
]
|
92
90
|
|
93
91
|
if s.respond_to? :specification_version then
|
data/lib/impromptu/autoload.rb
CHANGED
@@ -10,9 +10,17 @@ module Impromptu
|
|
10
10
|
# to it. If it is, then something very screwy has gone on and Ruby
|
11
11
|
# cannot locate an already loaded resource.
|
12
12
|
def const_missing(symbol)
|
13
|
+
# namespace the missing resource with the name of the
|
14
|
+
# current class or module
|
15
|
+
if self == Object
|
16
|
+
namespaced_symbol = symbol
|
17
|
+
else
|
18
|
+
namespaced_symbol = "#{self.name}::#{symbol}".to_sym
|
19
|
+
end
|
20
|
+
|
13
21
|
# walk the resource tree and get a reference to the
|
14
22
|
# resource or nil if we're not tracking it
|
15
|
-
resource = Impromptu.root_resource.child(
|
23
|
+
resource = Impromptu.root_resource.child(namespaced_symbol)
|
16
24
|
|
17
25
|
# if we don't know about the symbol, send the method to
|
18
26
|
# Object which will raise an exception
|
data/lib/impromptu/resource.rb
CHANGED
@@ -52,6 +52,7 @@ module Impromptu
|
|
52
52
|
else
|
53
53
|
@files.first.reload
|
54
54
|
end
|
55
|
+
self.reference.extend(Impromptu::Autoload)
|
55
56
|
end
|
56
57
|
|
57
58
|
# Unload the resource by undefining the constant representing it.
|
@@ -151,7 +152,7 @@ module Impromptu
|
|
151
152
|
# resource doesn't exist, nil is returned
|
152
153
|
def child(name)
|
153
154
|
return nil unless name.is_a?(Symbol)
|
154
|
-
return @children[name] if name.unnested?
|
155
|
+
return @children[name.without_leading_colons.to_sym] if name.unnested?
|
155
156
|
|
156
157
|
# if the name is nested, walk the resource tree to return the
|
157
158
|
# resource under this branch. rerturn nil if we reach a
|
data/lib/impromptu/symbol.rb
CHANGED
@@ -4,7 +4,7 @@ class Symbol
|
|
4
4
|
# True if this symbol contains namespaces (is a nested
|
5
5
|
# symbol such as A::B).
|
6
6
|
def nested?
|
7
|
-
self.
|
7
|
+
self.without_leading_colons.include? '::'
|
8
8
|
end
|
9
9
|
|
10
10
|
# True if this symbol contains no namespaces (is a root
|
@@ -16,7 +16,7 @@ class Symbol
|
|
16
16
|
# Split a symbol into its component names (A::B =>
|
17
17
|
# [:A, :B])
|
18
18
|
def nested_symbols
|
19
|
-
self.
|
19
|
+
self.without_leading_colons.split('::').collect(&:to_sym)
|
20
20
|
end
|
21
21
|
|
22
22
|
# Retrieve the base (end or final) symbol name from this
|
@@ -40,4 +40,17 @@ class Symbol
|
|
40
40
|
name
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
# Strip leading colons from a symbol name. Two leading
|
45
|
+
# colons indicate a symbol is relative to the root
|
46
|
+
# namespace (Object) but should be removed when determining
|
47
|
+
# nesting and nested symbols.
|
48
|
+
def without_leading_colons
|
49
|
+
str = self.to_s
|
50
|
+
if str.start_with?('::')
|
51
|
+
str[2..-1]
|
52
|
+
else
|
53
|
+
str
|
54
|
+
end
|
55
|
+
end
|
43
56
|
end
|
data/test/test_autoload.rb
CHANGED
@@ -29,4 +29,48 @@ class TestAutload < Test::Unit::TestCase
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
|
+
|
33
|
+
context "The 'private' folder" do
|
34
|
+
setup do
|
35
|
+
Impromptu.reset
|
36
|
+
Impromptu.define_components do
|
37
|
+
component 'framework' do
|
38
|
+
namespace :Framework
|
39
|
+
folder 'test/framework/private' do
|
40
|
+
file 'klass.rb', :provides => [:Klass, :SubComponent, :'Subcomponent::Leaf']
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
should "have a single component with a namespace" do
|
47
|
+
assert_equal 1, Impromptu.components.size
|
48
|
+
assert_equal :Framework, Impromptu.components['framework'].namespace
|
49
|
+
assert_not_nil Impromptu.root_resource.child(:Framework)
|
50
|
+
end
|
51
|
+
|
52
|
+
should "be able to have the namespace loaded using the autoload extension" do
|
53
|
+
assert_nothing_raised do
|
54
|
+
::Framework
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
should "raise an appropriate exception when accessing a non existant resource" do
|
59
|
+
assert_raise NameError do
|
60
|
+
::IDontExistSoRaiseAnException
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
should "be able to load namespace subcomponents using the autoload extension" do
|
65
|
+
assert_nothing_raised do
|
66
|
+
::Framework::Klass
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
should "be able to load resource subcomponents using the autoload extension" do
|
71
|
+
assert_nothing_raised do
|
72
|
+
::Framework::SubComponent::Leaf
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
32
76
|
end
|
data/test/test_symbol.rb
CHANGED
@@ -95,5 +95,33 @@ class TestResource < Test::Unit::TestCase
|
|
95
95
|
assert_equal [:TopLevel, :'TopLevel::BottomLevel'], symbols
|
96
96
|
end
|
97
97
|
end
|
98
|
+
|
99
|
+
# ----------------------------------------
|
100
|
+
# Prefixed Symbol
|
101
|
+
# ----------------------------------------
|
102
|
+
context "which is prefixed" do
|
103
|
+
setup { @symbol = :'::A' }
|
104
|
+
should "return false for nested?" do
|
105
|
+
assert_equal false, @symbol.nested?
|
106
|
+
end
|
107
|
+
|
108
|
+
should "return true for unnested?" do
|
109
|
+
assert_equal true, @symbol.unnested?
|
110
|
+
end
|
111
|
+
|
112
|
+
should "return a single symbol from nested_symbols" do
|
113
|
+
assert_instance_of Array, @symbol.nested_symbols
|
114
|
+
assert_equal 1, @symbol.nested_symbols.size
|
115
|
+
assert_instance_of Symbol, @symbol.nested_symbols[0]
|
116
|
+
end
|
117
|
+
|
118
|
+
should "return itself for base_symbol" do
|
119
|
+
assert_equal :A, @symbol.base_symbol
|
120
|
+
end
|
121
|
+
|
122
|
+
should "return itself for root_symbol" do
|
123
|
+
assert_equal :A, @symbol.root_symbol
|
124
|
+
end
|
125
|
+
end
|
98
126
|
end
|
99
127
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
8
|
+
- 1
|
9
|
+
version: 1.0.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Will Cannings
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-11-16 00:00:00 +11:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -41,7 +41,6 @@ extra_rdoc_files:
|
|
41
41
|
- README.rdoc
|
42
42
|
files:
|
43
43
|
- .document
|
44
|
-
- .gitignore
|
45
44
|
- LICENSE
|
46
45
|
- README.rdoc
|
47
46
|
- Rakefile
|
@@ -86,8 +85,8 @@ homepage: http://github.com/willcannings/impromptu
|
|
86
85
|
licenses: []
|
87
86
|
|
88
87
|
post_install_message:
|
89
|
-
rdoc_options:
|
90
|
-
|
88
|
+
rdoc_options: []
|
89
|
+
|
91
90
|
require_paths:
|
92
91
|
- lib
|
93
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -118,8 +117,8 @@ test_files:
|
|
118
117
|
- test/framework/copies/new_klass.rb
|
119
118
|
- test/framework/copies/new_unseen.rb
|
120
119
|
- test/framework/copies/original_klass.rb
|
121
|
-
- test/framework/ext/extensions/blog.rb
|
122
120
|
- test/framework/ext/extensions.rb
|
121
|
+
- test/framework/ext/extensions/blog.rb
|
123
122
|
- test/framework/lib/group/klass2.rb
|
124
123
|
- test/framework/lib/klass.rb
|
125
124
|
- test/framework/other/also.rb
|