synvert 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -0
- data/lib/synvert/cli.rb +12 -2
- data/lib/synvert/rewriter.rb +6 -6
- data/lib/synvert/snippets/check_syntax.rb +5 -0
- data/lib/synvert/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: a783bc0774369db2befc3887b41e955cae2adbe0
|
4
|
+
data.tar.gz: a5969647ad5a16adea6f8da5144c92acbc5011e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8df94cd6b38513ad2f99b24b426f8275f929c1a98746a628ff6a47908c71372bc4bb379501c389d486b1b040435ed5a2185b4b72fe817eb51d32447d3e271203
|
7
|
+
data.tar.gz: 79ab182f79f99c14fe07e3dda0e6ddc99d587355b05d1cff763fe8fc2a054c24884628a45a2b323910ea95679d831fba5aa232354c9c3ad0278abfc5829efe2c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/lib/synvert/cli.rb
CHANGED
@@ -40,8 +40,14 @@ module Synvert
|
|
40
40
|
true
|
41
41
|
rescue SystemExit
|
42
42
|
true
|
43
|
+
rescue Parser::SyntaxError => e
|
44
|
+
puts "Syntax error: #{e.message}"
|
45
|
+
puts "file #{e.diagnostic.location.source_buffer.name}"
|
46
|
+
puts "line #{e.diagnostic.location.line}"
|
47
|
+
false
|
43
48
|
rescue Exception => e
|
44
|
-
|
49
|
+
print "Error: "
|
50
|
+
p e
|
45
51
|
false
|
46
52
|
end
|
47
53
|
|
@@ -68,6 +74,10 @@ module Synvert
|
|
68
74
|
opts.on '-r', '--run SNIPPET_NAMES', 'run specified snippets' do |snippet_names|
|
69
75
|
@options[:snippet_names] = snippet_names.split(',').map(&:strip)
|
70
76
|
end
|
77
|
+
opts.on '-v', '--version', 'show this version' do
|
78
|
+
puts Synvert::VERSION
|
79
|
+
exit
|
80
|
+
end
|
71
81
|
end
|
72
82
|
paths = optparse.parse(args)
|
73
83
|
Configuration.instance.set :path, paths.first || Dir.pwd
|
@@ -90,7 +100,7 @@ module Synvert
|
|
90
100
|
# List and print all available rewriters.
|
91
101
|
def list_available_rewriters
|
92
102
|
Rewriter.availables.each do |rewriter|
|
93
|
-
print rewriter.name + " "
|
103
|
+
print rewriter.name.to_s + " "
|
94
104
|
end
|
95
105
|
puts
|
96
106
|
end
|
data/lib/synvert/rewriter.rb
CHANGED
@@ -41,7 +41,7 @@ module Synvert
|
|
41
41
|
# @param rewriter [Synvert::Rewriter] the rewriter to register.
|
42
42
|
def register(name, rewriter)
|
43
43
|
@rewriters ||= {}
|
44
|
-
@rewriters[name
|
44
|
+
@rewriters[name] = rewriter
|
45
45
|
end
|
46
46
|
|
47
47
|
# Fetch a rewriter by name.
|
@@ -49,7 +49,7 @@ module Synvert
|
|
49
49
|
# @param name [String] rewrtier name.
|
50
50
|
# @return [Synvert::Rewriter] the matching rewriter.
|
51
51
|
def fetch(name)
|
52
|
-
@rewriters[name
|
52
|
+
@rewriters[name]
|
53
53
|
end
|
54
54
|
|
55
55
|
# Get a registered rewriter by name and process that rewriter.
|
@@ -58,7 +58,7 @@ module Synvert
|
|
58
58
|
# @return [Synvert::Rewriter] the registered rewriter.
|
59
59
|
# @raise [Synvert::RewriterNotFound] if the registered rewriter is not found.
|
60
60
|
def call(name)
|
61
|
-
if (rewriter = @rewriters[name
|
61
|
+
if (rewriter = @rewriters[name])
|
62
62
|
rewriter.process
|
63
63
|
rewriter
|
64
64
|
else
|
@@ -92,11 +92,11 @@ module Synvert
|
|
92
92
|
# @param block [Block] a block defines the behaviors of the rewriter, block code won't be called when initialization.
|
93
93
|
# @return [Synvert::Rewriter]
|
94
94
|
def initialize(name, &block)
|
95
|
-
@name = name
|
95
|
+
@name = name.to_s
|
96
96
|
@block = block
|
97
97
|
@helpers = []
|
98
98
|
@sub_snippets = []
|
99
|
-
self.class.register(name, self)
|
99
|
+
self.class.register(@name, self)
|
100
100
|
end
|
101
101
|
|
102
102
|
# Process the rewriter.
|
@@ -173,7 +173,7 @@ module Synvert
|
|
173
173
|
#
|
174
174
|
# @param name [String] name of another rewriter.
|
175
175
|
def add_snippet(name)
|
176
|
-
@sub_snippets << self.class.call(name)
|
176
|
+
@sub_snippets << self.class.call(name.to_s)
|
177
177
|
end
|
178
178
|
|
179
179
|
# Parse helper_method dsl, it defines helper method for [Synvert::Rewriter::Instance].
|
data/lib/synvert/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synvert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
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-04-
|
11
|
+
date: 2014-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- lib/synvert/rewriter/gem_spec.rb
|
123
123
|
- lib/synvert/rewriter/instance.rb
|
124
124
|
- lib/synvert/rewriter/scope.rb
|
125
|
+
- lib/synvert/snippets/check_syntax.rb
|
125
126
|
- lib/synvert/snippets/factory_girl/syntax_methods.rb
|
126
127
|
- lib/synvert/snippets/rails/convert_dynamic_finders.rb
|
127
128
|
- lib/synvert/snippets/rails/strong_parameters.rb
|