import_as 0.1.0 → 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/Gemfile.lock +1 -1
- data/import_as.gemspec +1 -0
- data/lib/import_as.rb +6 -14
- data/lib/import_as/version.rb +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a61c13065e4cee771ece7fdfde24bfd5e674984fb3858d233ca27f780c2abcd
|
4
|
+
data.tar.gz: 9394f7ae70d7cf67ef59655c1b9584bfdb9fc72f389f8e5caa6051f2fe87d7f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2deb4452e878c436b28fef0ad6a050d7878ea4551785f611fc7279b409964c083196cbb99029eaa03b05f7d93be411c83c28d83f84f8b47e57d24c2069cc803
|
7
|
+
data.tar.gz: 57ed548f3aac70fce9f06596fa5d06648f53ba49213a3d6eadadf3f2de1a0796a0a0ba9a26eb638a8376c9e24554aad748492ea6ae3b5b75de3299784d89f5aa
|
data/Gemfile.lock
CHANGED
data/import_as.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
+
spec.required_ruby_version =">= 2.6.0"
|
24
25
|
spec.add_development_dependency "bundler", "~> 2.0.a"
|
25
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
27
|
spec.add_development_dependency "rspec", "~> 3.0"
|
data/lib/import_as.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require "import_as/version"
|
2
2
|
require "ripper"
|
3
|
-
require "tempfile"
|
4
3
|
|
5
4
|
module ImportAs
|
6
5
|
class Error < StandardError; end
|
@@ -31,15 +30,8 @@ module ImportAs
|
|
31
30
|
end
|
32
31
|
|
33
32
|
def from(path)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
tf.write(new_source)
|
38
|
-
tf.flush
|
39
|
-
tf.close
|
40
|
-
|
41
|
-
load tf.path
|
42
|
-
end
|
33
|
+
new_source = rewrite(File.read(path))
|
34
|
+
eval(new_source, TOPLEVEL_BINDING, path)
|
43
35
|
end
|
44
36
|
|
45
37
|
private
|
@@ -54,19 +46,19 @@ module ImportAs
|
|
54
46
|
|
55
47
|
refine(RubyVM::AbstractSyntaxTree::Node) do
|
56
48
|
def array?
|
57
|
-
type ==
|
49
|
+
type == :ARRAY
|
58
50
|
end
|
59
51
|
|
60
52
|
def const?
|
61
|
-
type ==
|
53
|
+
type == :CONST
|
62
54
|
end
|
63
55
|
|
64
56
|
def fcall?
|
65
|
-
type ==
|
57
|
+
type == :FCALL
|
66
58
|
end
|
67
59
|
|
68
60
|
def scope?
|
69
|
-
type ==
|
61
|
+
type == :SCOPE
|
70
62
|
end
|
71
63
|
|
72
64
|
def const_pair
|
data/lib/import_as/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: import_as
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seiei Miyagi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -83,15 +83,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
83
|
requirements:
|
84
84
|
- - ">="
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
86
|
+
version: 2.6.0
|
87
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
89
|
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
|
-
|
94
|
-
rubygems_version: 2.7.8
|
93
|
+
rubygems_version: 3.0.1
|
95
94
|
signing_key:
|
96
95
|
specification_version: 4
|
97
96
|
summary: 'Add DSL: import { C as C2 }.from "./c.rb"'
|