dissociated_introspection 0.1.6 → 0.2.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: 7052a41ca167f0a3c71da1b189c65b2f1bb4b4de
4
- data.tar.gz: 64f62516603fcb83ac64e1c8c1030909d42e4bed
3
+ metadata.gz: d52a5954cb2475630f4bc5b5bf6f7c2da5d7f725
4
+ data.tar.gz: 40245585bd9ace7f23b553c96f74338999c475ca
5
5
  SHA512:
6
- metadata.gz: 6e1fc88468c673b89e02bf72fd254631afdce81eb6e3369113fb03e1b91576ee213d72ca81e9d6d483546470cf31ee82f112c5a730765e04f80ef51773680353
7
- data.tar.gz: 09f111b9848cdbe7101c17e6e79a0a88129db5ad8d285f100349947b9b8347106cf843778e7edfd9d934d86b77638bf6642c0578e665d33d93ad88821e86c687
6
+ metadata.gz: 3e5bdfb47e27e052dc08aa9318100964115918c90cbd52d1697bc45c8e2fbd1a6c57704bda52c58fdf626d17abd99951ebef9c93c2846c1a5db7657f2851ebe6
7
+ data.tar.gz: 2c56974c1bcf78f779ff30778ad92dff8c469900cb554927345550904daf0c55ead6bdba9c4135042b51117fb6d06fced33c784718c3d3b1095ffbc7dc0bbc02
@@ -89,8 +89,26 @@ module DissociatedIntrospection
89
89
  self.class.new(ast: find_class.updated(find_class.type, class_begin.updated(class_begin.type, class_begin.children.reject { |n| n.try(:type) == :class })))
90
90
  end
91
91
 
92
+ def wrap_in_modules(modules)
93
+ return self if modules.nil? || modules.empty?
94
+ ruby_string = to_ruby_str
95
+ modules.split("::").reverse.each do |module_name|
96
+ ruby_string = wrap_module(module_name, ruby_string)
97
+ end
98
+ wrapped_ast = Parser::CurrentRuby.parse(ruby_string)
99
+ self.class.new(ast: wrapped_ast)
100
+ end
101
+
92
102
  private
93
103
 
104
+ def wrap_module(module_name, ruby)
105
+ <<-RUBY
106
+ module #{module_name}
107
+ #{ruby}
108
+ end
109
+ RUBY
110
+ end
111
+
94
112
  attr_reader :source
95
113
 
96
114
  def find_class
@@ -1,3 +1,3 @@
1
1
  module DissociatedIntrospection
2
- VERSION = "0.1.6"
2
+ VERSION = "0.2.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.1.6
4
+ version: 0.2.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: 2015-12-09 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser