dissociated_introspection 0.3.1 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9a42a861612c49b10e198aa675c5ea86b5802d5
4
- data.tar.gz: 3ce894b45ba7bdda24ad8d4120a07ce24bde4206
3
+ metadata.gz: b87f194e1bad12f5d03f1607361fcf64d08bcfb7
4
+ data.tar.gz: 5f59172b7b25e8fbc90a606dd6cb25a4ecf2e23b
5
5
  SHA512:
6
- metadata.gz: 19ad771d2a31f1efe5ed4466d6461371edc78ab44b6820999f1e7987fbeb65b8a583339be0256e7c7208de6f0a8dcdfb450ff91eb52631b24cd9b7fa495f861f
7
- data.tar.gz: 071c6aedfffab0a6b1eed7a887dd69b14e3d54561c0c7f8197402e3b514c5bb4d4f04486380298382c3c3d8fe6788693309c91feccf840a5f7b98c95c727e01e
6
+ metadata.gz: f1e3f2b1e0c139c30a6c11d6488f23b272bdd47e7d73ddee922e8a59bf92c70d995979a7942f906ca923afca83f7652c29475aa939d746258106e0cca1457778
7
+ data.tar.gz: 2756ad073c45e86e3c61eb1a13f82f2eb7a14003fb30bd723a4047ae16e5f0aa87ecae6427b808352eb23bf08905b2c2eaa0a3c3aaf7072744191fef692476ba
data/.travis.yml CHANGED
@@ -1,7 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.6
4
- - 2.2.2
3
+ - 2.1.7
4
+ - 2.2.3
5
+ - 2.3.0
5
6
  addons:
6
7
  code_climate:
7
8
  repo_token: 9ee4de0c2f9b045b414b79b67a56bc98d1f365aee5e54ca9a119319b59d8ae52
@@ -39,7 +39,7 @@ module DissociatedIntrospection
39
39
  end
40
40
 
41
41
  def has_parent_class?
42
- return false if find_class.nil?
42
+ return false unless find_class
43
43
  find_class.to_a[1].try(:type) == :const
44
44
  end
45
45
 
@@ -81,6 +81,19 @@ module DissociatedIntrospection
81
81
  comments: comments)
82
82
  end
83
83
 
84
+ def module_nesting
85
+ ary = []
86
+ m = ast
87
+ while m
88
+ if (m = depth_first_search(m, :module))
89
+ name = m.to_a[0].to_a[1]
90
+ ary << name unless name.nil?
91
+ m = m.to_a[1]
92
+ end
93
+ end
94
+ ary
95
+ end
96
+
84
97
  private
85
98
 
86
99
  def scrub_inner_classes_ast
@@ -90,8 +103,19 @@ module DissociatedIntrospection
90
103
  end
91
104
 
92
105
  def find_class
93
- return ast if ast.try(:type) == :class
94
- ast.to_a.select { |n| n.try(:type) == :class }.first
106
+ depth_first_search(ast, :class)
107
+ end
108
+
109
+ def depth_first_search(node, target)
110
+ return false unless node.is_a?(Parser::AST::Node)
111
+ return node if node.type == target
112
+ if (children = node.children)
113
+ children.each do |kid|
114
+ v = depth_first_search(kid, target)
115
+ return v if v.is_a?(Parser::AST::Node)
116
+ end
117
+ end
118
+ return false
95
119
  end
96
120
 
97
121
  def nodes
@@ -1,3 +1,3 @@
1
1
  module DissociatedIntrospection
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dissociated_introspection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Zeisler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-17 00:00:00.000000000 Z
11
+ date: 2016-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser