proc_to_ast 0.0.5 → 0.0.6

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: 7154d3d9104765cba5474b644a7401f3afa599cf
4
- data.tar.gz: 2524064259c19cccdb92bb071d42390f874874fe
3
+ metadata.gz: 1f3724c4ba65ca104c10bbebb19d039786d27f3b
4
+ data.tar.gz: 83dd301e6bd1b425c366cd57b8861d577972f62c
5
5
  SHA512:
6
- metadata.gz: 5fae7228287b64ab740e6e1b725c75f95ffeaf30560fa3ef6a085b60e52de05ab70df542184026922e6b75eac79fe01bafd0f340d5f4fb5a8601ebfefa730a4f
7
- data.tar.gz: b983db0c5643c7589ee5329958a5f0b627e67bdbcf7a54656c25a69dfc610186ff752f3f1b364914319651aad58c69fdf6d3c2f2445d91c189daf77de950a8bc
6
+ metadata.gz: 437196f743ace174ca0ad6a4fd38e3f04cd32569fadf25dd0665de55cc3332f6d4b6c2a6d2a6264381fae6e01a1ece5feee27247e91e51413718e38897736441
7
+ data.tar.gz: e9bb92c73bf93b0def19b5fb76a91ca07117c9492f8582b8482d493f208761c91fa62c861e0f783d4ea06c742f87ca13c626ff2786f6ca2cf79a3ece8dd6e7f0
data/lib/proc_to_ast.rb CHANGED
@@ -109,4 +109,14 @@ class Proc
109
109
  source
110
110
  end
111
111
  end
112
+
113
+ def to_raw_source(highlight: false, retry_limit: 20)
114
+ source = to_ast(retry_limit).loc.expression.source
115
+
116
+ if highlight
117
+ CodeRay.scan(source, :ruby).terminal
118
+ else
119
+ source
120
+ end
121
+ end
112
122
  end
@@ -1,3 +1,3 @@
1
1
  module ProcToAst
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -125,4 +125,12 @@ describe Proc do
125
125
  expect(fuga.to_source(highlight: true)).to eq("lambda \e[32mdo\e[0m |a|\n p(a)\n\e[32mend\e[0m")
126
126
  end
127
127
  end
128
+
129
+ describe "#to_raw_source" do
130
+ it "return original source code" do
131
+ pr = ->(a) { a + 1 }
132
+
133
+ expect(pr.to_raw_source).to eq("->(a) { a + 1 }")
134
+ end
135
+ end
128
136
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proc_to_ast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - joker1007