synvert-core 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/synvert/core/rewriter/helper.rb +37 -0
- data/lib/synvert/core/rewriter/instance.rb +2 -0
- data/lib/synvert/core/rewriter.rb +2 -0
- data/lib/synvert/core/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a3cff654eae485c77411077c8e1ee126a29afb6
|
4
|
+
data.tar.gz: 21dcd6b6f868b4ccc9c35176578d01a060971e4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ae01938e470eba926eaaa5d7564bdf2342ad6138938c67c400540f99872dcadf42fb5eb4363623edf133da1870c62b94cf12bf5112da01961730f561341ae5e
|
7
|
+
data.tar.gz: dab94a1c780431350248d454331144c72a11b4e26e63431a5fe9c5fc03f79f35d7cab1928ec9bf897ce7133a35b849005784120c0ec43008d8216ca5c4d90289
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Synvert::Core
|
4
|
+
# Rewriter::Helper provides some helper methods to make it easier to write a snippet.
|
5
|
+
module Rewriter::Helper
|
6
|
+
# Add receiver to code if necessary.
|
7
|
+
#
|
8
|
+
# @param code [String] old code
|
9
|
+
# @return [String] new code
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
#
|
13
|
+
# add_receiver_if_necessary("{{message}} {{arguments}}")
|
14
|
+
#
|
15
|
+
# if current_node doesn't have a receiver, it returns "{{message}} {{arguments}}"
|
16
|
+
# if current_node has a receiver, it returns "{{receiver}}.{{message}} {{arguments}}"
|
17
|
+
def add_receiver_if_necessary(code)
|
18
|
+
if node.receiver
|
19
|
+
"{{receiver}}.#{code}"
|
20
|
+
else
|
21
|
+
code
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Remove leading and trailing brackets.
|
26
|
+
#
|
27
|
+
# @param code [String] old code
|
28
|
+
# @return [String] new code
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
#
|
32
|
+
# strip_brackets("(1..100)") #=> "1..100"
|
33
|
+
def strip_brackets(code)
|
34
|
+
code.sub(/^[{(\[]/, '').sub(/[})\]]$/, '')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -35,6 +35,8 @@ module Synvert::Core
|
|
35
35
|
autoload :UnlessExistCondition, 'synvert/core/rewriter/condition'
|
36
36
|
autoload :IfOnlyExistCondition, 'synvert/core/rewriter/condition'
|
37
37
|
|
38
|
+
autoload :Helper, 'synvert/core/rewriter/helper'
|
39
|
+
|
38
40
|
autoload :GemSpec, 'synvert/core/rewriter/gem_spec'
|
39
41
|
|
40
42
|
class <<self
|
data/lib/synvert/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synvert-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- lib/synvert/core/rewriter/action.rb
|
120
120
|
- lib/synvert/core/rewriter/condition.rb
|
121
121
|
- lib/synvert/core/rewriter/gem_spec.rb
|
122
|
+
- lib/synvert/core/rewriter/helper.rb
|
122
123
|
- lib/synvert/core/rewriter/instance.rb
|
123
124
|
- lib/synvert/core/rewriter/scope.rb
|
124
125
|
- lib/synvert/core/rewriter/warning.rb
|