dissociated_introspection 0.8.4 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d7a7d6a47b8a88dbfc78c0b1348c7c67c7e2020
4
- data.tar.gz: edce31e5e61d5f21ebd4df75320842216e039fb4
3
+ metadata.gz: d67a6f03dddec1841a73faf3719a24d8d4e83c94
4
+ data.tar.gz: f675c151f1955daf206dc6b2ac078ff6ccd2dce8
5
5
  SHA512:
6
- metadata.gz: add0a4bab5920ff3252a2b9ac819e4b8d76589e56e2c37ebfc67217d625c45800390ddf6b1db5ea7f0fe3309f489cb1a04f382619791274351675eda90c6ca73
7
- data.tar.gz: eef257c6c4b3f11cb759730d149378e8600c6f5b7de659663f6ff3e1b0bf2b1f42e29839049d6a9ddb256273b015c8b8a8f1dec3d889abea2903b0e4355b76cd
6
+ metadata.gz: cf46c36295438e615cdce18499f652e0d4175f0abd8cf9f8e79bef82d24e9fa0fa76015be53a72180e65a3fb6bd1bdbaeaeed2063f2bab30caca2a9bf0d67771
7
+ data.tar.gz: 37edd662fac563a6bb93b77e8c04981d207bf5066dfcb9555e6e14f3687c6cf78c29e21162c0d63e85cd01dccfc48cb83f03c513a71fb507db04211c72f0bb6e
data/CHANGELOG.md CHANGED
@@ -1,13 +1,18 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
+ ## 0.9.0 - 2018-01-16
4
+ ### Enhancement
5
+ - `DissociatedIntrospection::RubyClass#defined_nested_modules` and #defined_nested_classes returns an array of `RubyCode`.
6
+ For any internally defined within the class it's self.
7
+
3
8
 
4
9
  ## 0.8.4 - 2017-09-30
5
10
  ### Fix
6
- - DissociatedIntrospection::RubyClass#class_defs failed to parse a single class methods with `class >> self; end;`
11
+ - `DissociatedIntrospection::RubyClass#class_defs` failed to parse a single class methods with `class >> self; end;`
7
12
 
8
13
  ## 0.8.3 - 2017-09-30
9
14
  ### Fix
10
- - DissociatedIntrospection::RubyClass#class_defs failed to parse class methods with `class >> self; end;`
15
+ - `DissociatedIntrospection::RubyClass#class_defs` failed to parse class methods with `class >> self; end;`
11
16
 
12
17
  ## 0.8.2 - 2017-06-23
13
18
  ### Enhancement
@@ -19,13 +24,13 @@ All notable changes to this project will be documented in this file.
19
24
 
20
25
  ## 0.8.0 - 2017-03-24
21
26
  ### Enhancement
22
- - DissociatedIntrospection::RubyClass#class_defs returns same api as #defs
23
- - DissociatedIntrospection::RubyClass#class_method_calls inspect method name and its arguments ie. attr_reader :name
27
+ - `DissociatedIntrospection::RubyClass#class_defs` returns same api as #defs
28
+ - `DissociatedIntrospection::RubyClass#class_method_calls` inspect method name and its arguments ie. attr_reader :name
24
29
 
25
30
  ### Deprecated
26
- - DissociatedIntrospection::RubyClass#is_class? changed to #class?
27
- - DissociatedIntrospection::RubyClass#has_parent_class? changed to #parent_class?
28
- - DissociatedIntrospection::RubyCode#to_ruby_str changed to #source
31
+ - `DissociatedIntrospection::RubyClass#is_class?` changed to `#class?`
32
+ - `DissociatedIntrospection::RubyClass#has_parent_class?` changed to `#parent_class?`
33
+ - `DissociatedIntrospection::RubyCode#to_ruby_str` changed to `#source`
29
34
 
30
35
  ## 0.7.1 - 2016-10-20
31
36
  ### Fix
@@ -33,7 +38,7 @@ All notable changes to this project will be documented in this file.
33
38
 
34
39
  ## 0.7.0 - 2016-10-19
35
40
  ### Fix
36
- - DissociatedIntrospection::Inspection#parsed_source now returns RubyClass with comments
41
+ - `DissociatedIntrospection::Inspection#parsed_source` now returns `RubyClass` with comments
37
42
 
38
43
  ## 0.6.0 - 2016-09-08
39
44
  ### Enhancement
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.required_ruby_version = '>= 2.1'
23
23
 
24
- spec.add_runtime_dependency "parser", ">= 2.1"
25
- spec.add_runtime_dependency "unparser", "~> 0.2"
24
+ spec.add_runtime_dependency "parser", "~> 2.1", ">= 2.1.9"
25
+ spec.add_runtime_dependency "unparser", "~> 0.2", ">= 0.2.6"
26
26
 
27
27
  spec.add_development_dependency "bundler", "~> 1.9"
28
28
  spec.add_development_dependency "rake", "~> 10.0"
@@ -26,10 +26,12 @@ module DissociatedIntrospection
26
26
  ast.type == :class
27
27
  end
28
28
 
29
+ # @return [String]
29
30
  def class_name
30
31
  Unparser.unparse(find_class.to_a[0])
31
32
  end
32
33
 
34
+ # @return [String]
33
35
  def parent_class_name
34
36
  Unparser.unparse(find_class.to_a[1])
35
37
  end
@@ -39,6 +41,7 @@ module DissociatedIntrospection
39
41
  find_class.to_a[1].try(:type) == :const
40
42
  end
41
43
 
44
+ # @return [DissociatedIntrospection::RubyClass]
42
45
  def change_class_name(class_name)
43
46
  nodes = ast.to_a.dup
44
47
  nodes[0] = Parser::CurrentRuby.parse(class_name)
@@ -46,6 +49,7 @@ module DissociatedIntrospection
46
49
  self.class.new(ast: new_ast)
47
50
  end
48
51
 
52
+ # @return [DissociatedIntrospection::RubyClass]
49
53
  def modify_parent_class(parent_class)
50
54
  if parent_class?
51
55
  class_node = find_class.to_a.dup
@@ -60,10 +64,12 @@ module DissociatedIntrospection
60
64
  self.class.new(RubyCode.build_from_ast(new_ast, comments: comments))
61
65
  end
62
66
 
67
+ # @return [DissociatedIntrospection::RubyClass::Def]
63
68
  def defs
64
69
  class_begin.children.select { |n| n.try(:type) == :def }.map(&method(:create_def))
65
70
  end
66
71
 
72
+ # @return [DissociatedIntrospection::RubyClass::Def]
67
73
  def class_defs
68
74
  ns = class_begin.children.select { |n| :defs == n.try(:type) }.map do |n|
69
75
  create_def(n.updated(:def, n.children[1..-1]))
@@ -83,10 +89,7 @@ module DissociatedIntrospection
83
89
  end)
84
90
  end
85
91
 
86
- def class_begin
87
- find_class.children.find { |n| n.try(:type) == :begin } || find_class
88
- end
89
-
92
+ # @return [RubyClass]
90
93
  def scrub_inner_classes
91
94
  self.class.new RubyCode.build_from_ast(
92
95
  scrub_inner_classes_ast,
@@ -94,19 +97,38 @@ module DissociatedIntrospection
94
97
  )
95
98
  end
96
99
 
100
+ # @return [Array[Symbol]]
97
101
  def module_nesting
98
102
  ary = []
99
103
  m = ast
100
104
  while m
101
- if (m = depth_first_search(m, :module, :class))
102
- name = m.to_a[0].to_a[1]
103
- ary << name unless name.nil?
104
- m = m.to_a[1]
105
- end
105
+ next unless (m = depth_first_search(m, :module, :class))
106
+ name = m.to_a[0].to_a[1]
107
+ ary << name unless name.nil?
108
+ m = m.to_a[1]
106
109
  end
107
110
  ary
108
111
  end
109
112
 
113
+ # @return [Array<DissociatedIntrospection::RubyCode>]
114
+ def defined_nested_modules
115
+ class_begin.children.select { |n| n.try(:type) == :module }.map do |m|
116
+ RubyCode.build_from_ast(
117
+ m
118
+ )
119
+ end
120
+ end
121
+
122
+ # @return [Array<DissociatedIntrospection::RubyCode>]
123
+ def defined_nested_classes
124
+ class_begin.children.select { |n| n.try(:type) == :class }.map do |m|
125
+ RubyCode.build_from_ast(
126
+ m
127
+ )
128
+ end
129
+ end
130
+
131
+ # @return [DissociatedIntrospection::MethodCall]
110
132
  def class_method_calls
111
133
  class_begin.children.select { |n| n.try(:type) == :send }.map do |ast|
112
134
  MethodCall.new(RubyCode.build_from_ast(ast))
@@ -115,6 +137,10 @@ module DissociatedIntrospection
115
137
 
116
138
  private
117
139
 
140
+ def class_begin
141
+ find_class.children.find { |n| n.try(:type) == :begin } || find_class
142
+ end
143
+
118
144
  def create_def(n)
119
145
  def_comments = comments.select do |comment|
120
146
  comment.location.last_line+1 == n.location.first_line
@@ -1,3 +1,3 @@
1
1
  module DissociatedIntrospection
2
- VERSION = "0.8.4"
2
+ VERSION = "0.9.0"
3
3
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dissociated_introspection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.9.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: 2017-09-30 00:00:00.000000000 Z
11
+ date: 2018-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.1'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.1.9
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - ">="
27
+ - - "~>"
25
28
  - !ruby/object:Gem::Version
26
29
  version: '2.1'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.1.9
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: unparser
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -31,6 +37,9 @@ dependencies:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
39
  version: '0.2'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.2.6
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -38,6 +47,9 @@ dependencies:
38
47
  - - "~>"
39
48
  - !ruby/object:Gem::Version
40
49
  version: '0.2'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.2.6
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: bundler
43
55
  requirement: !ruby/object:Gem::Requirement
@@ -92,7 +104,6 @@ files:
92
104
  - ".rspec"
93
105
  - ".travis.yml"
94
106
  - CHANGELOG.md
95
- - CODE_OF_CONDUCT.md
96
107
  - Gemfile
97
108
  - LICENSE.txt
98
109
  - README.md
data/CODE_OF_CONDUCT.md DELETED
@@ -1,13 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
-
5
- We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
-
7
- Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
-
9
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
-
11
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
-
13
- This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)