sexp_info 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/lib/sexp_info.rb +11 -2
- data/lib/sexp_info/sexp_thing/class.rb +4 -0
- data/lib/sexp_info/sexp_thing/module.rb +5 -0
- data/spec/lib/sexp_info_spec.rb +12 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57e9e886d54dc00c0dd43eddd338c6f4a7dcfe88
|
4
|
+
data.tar.gz: 3b13759241d684b0d7f718f2a64a26267e8c5c37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b8c993c33798b03491ec288ed5f0b388e7284535f8b09fd69528443e10d11a754557fa22300bf36032c98b403664a1feb35c9fac9c8c410eb44bf80115b32b2
|
7
|
+
data.tar.gz: fcc11c85bf0af7aad0a11d7cebebfa170a2a9a80ffa671f615235ee6785c86c51253e868de341b056cc91b18b44e4e516f20fc26fa09393af898f666e2c6fe20
|
data/.gitignore
CHANGED
data/lib/sexp_info.rb
CHANGED
@@ -2,7 +2,7 @@ require 'active_support/all'
|
|
2
2
|
require 'sexp_info/sexp_thing/sexp_thing'
|
3
3
|
class SexpInfo
|
4
4
|
|
5
|
-
VERSION = "0.0.
|
5
|
+
VERSION = "0.0.4"
|
6
6
|
|
7
7
|
def initialize(sexp)
|
8
8
|
@sexp = sexp
|
@@ -20,12 +20,21 @@ class SexpInfo
|
|
20
20
|
defined(:class)
|
21
21
|
end
|
22
22
|
|
23
|
+
def to_h
|
24
|
+
Hash[children.map{|c| [c.name, c.to_h] }]
|
25
|
+
end
|
26
|
+
|
23
27
|
def defined_modules
|
24
28
|
defined(:module)
|
25
29
|
end
|
26
30
|
|
31
|
+
|
32
|
+
def children
|
33
|
+
defined_classes + defined_methods + defined_modules
|
34
|
+
end
|
35
|
+
|
27
36
|
def [](name)
|
28
|
-
(
|
37
|
+
(children).find{|m| m == name }
|
29
38
|
end
|
30
39
|
|
31
40
|
private
|
data/spec/lib/sexp_info_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe SexpInfo do
|
|
26
26
|
Then { sexp["StdClass"].defined_methods.should == ["optional_args"] }
|
27
27
|
end
|
28
28
|
|
29
|
-
context "
|
29
|
+
context "modules" do
|
30
30
|
Given(:modules) { File.read('spec/fixtures/modules.rb') }
|
31
31
|
Given(:rip) { Ripper.sexp(modules) }
|
32
32
|
Given(:sexp) { SexpInfo.new(rip) }
|
@@ -34,6 +34,17 @@ describe SexpInfo do
|
|
34
34
|
Then { sexp.defined_modules.should == ["StdModule"] }
|
35
35
|
Then { sexp["StdModule"].should be_a SexpThing::Module }
|
36
36
|
Then { sexp["StdModule"].defined_classes.should == ["StdClass"] }
|
37
|
+
Then { sexp.to_h.should == {
|
38
|
+
"StdModule" => {
|
39
|
+
:sexp => "StdModule",
|
40
|
+
"StdClass" => {
|
41
|
+
:sexp => "StdClass",
|
42
|
+
"optional_args" => "optional_args"
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
37
48
|
end
|
38
49
|
|
39
50
|
|