quir 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/quir.rb +2 -5
- data/lib/quir/binding.rb +5 -0
- data/lib/quir/loader.rb +12 -8
- data/lib/quir/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03d1af642be46bf1ec5ef4c044f69a4ca8c44fd9
|
4
|
+
data.tar.gz: 7afe9fc14a8522877c95c808ec6e8df55d0e11fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c828cc56b042bb34449454f74044979eff1d8298257cddedc56c276b5db726fa55929645714bce33993f490001fd67eb939622d597300b4066bcfbb039d2d0b1
|
7
|
+
data.tar.gz: ebf72fe1d99c44aef6c3019bac38fab829b4a5c378d662a95a7ad92a5062805fe54b9048b6c9807f593c8a57b435c02a6b5f89b8c2c477689fa7ba19ecb5f659
|
data/lib/quir.rb
CHANGED
@@ -4,11 +4,8 @@ module Quir
|
|
4
4
|
autoload :Loader, 'quir/loader'
|
5
5
|
autoload :Inflection, 'quir/inflection'
|
6
6
|
|
7
|
-
def self.
|
7
|
+
def self.autoload!(&block)
|
8
8
|
raise "No block given." unless block
|
9
|
-
|
10
|
-
dir = block.binding.eval('__FILE__').sub(/\.rb$/, '')
|
11
|
-
loader = Loader.new(mod, dir)
|
12
|
-
loader.run
|
9
|
+
Loader.from_binding(block.binding).autoload!
|
13
10
|
end
|
14
11
|
end
|
data/lib/quir/binding.rb
ADDED
data/lib/quir/loader.rb
CHANGED
@@ -2,26 +2,30 @@ using Quir::Inflection
|
|
2
2
|
|
3
3
|
module Quir
|
4
4
|
class Loader
|
5
|
-
attr_reader :binding
|
6
|
-
|
7
5
|
def initialize(mod, dir)
|
8
6
|
@module = mod
|
9
7
|
@dir = dir
|
10
8
|
end
|
11
9
|
|
10
|
+
def self.from_binding(binding)
|
11
|
+
mod = binding.eval('self')
|
12
|
+
dir = binding.eval('__FILE__').sub(/\.rb$/, '')
|
13
|
+
Loader.new(mod, dir)
|
14
|
+
end
|
15
|
+
|
12
16
|
attr_reader :module, :dir
|
13
17
|
|
14
|
-
def
|
18
|
+
def autoload!
|
15
19
|
::Dir.glob("#{dir}/*") do |f|
|
16
20
|
if ::File.directory?(f)
|
17
|
-
|
21
|
+
autoload_directory f
|
18
22
|
elsif /\.rb$/ =~ f
|
19
|
-
|
23
|
+
autoload_ruby_file f
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
24
|
-
def
|
28
|
+
def autoload_directory(d)
|
25
29
|
return if ::File.exist?("#{dir}/#{d}.rb")
|
26
30
|
name = d.split(/\//)[-1].pascalize
|
27
31
|
return if self.module.const_defined?(name, false)
|
@@ -29,10 +33,10 @@ module Quir
|
|
29
33
|
self.module.const_set name, m
|
30
34
|
m.name # fix module's name
|
31
35
|
loader = ::Quir::Loader.new(m, d)
|
32
|
-
loader.
|
36
|
+
loader.autoload!
|
33
37
|
end
|
34
38
|
|
35
|
-
def
|
39
|
+
def autoload_ruby_file(f)
|
36
40
|
name = f.split(/\//)[-1].sub(/\.rb$/, '').pascalize
|
37
41
|
self.module.autoload name, f unless self.module.autoload?(name)
|
38
42
|
end
|
data/lib/quir/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mosop
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- bin/console
|
69
69
|
- bin/setup
|
70
70
|
- lib/quir.rb
|
71
|
+
- lib/quir/binding.rb
|
71
72
|
- lib/quir/inflection.rb
|
72
73
|
- lib/quir/inflection/string.rb
|
73
74
|
- lib/quir/inflection/string/pascalize.rb
|