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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86cf9cff8facbc13e13dca8fe4399f734a9c0601
4
- data.tar.gz: 0b2ac36a7bb59335b7026519e9e7428c45edc696
3
+ metadata.gz: a783bc0774369db2befc3887b41e955cae2adbe0
4
+ data.tar.gz: a5969647ad5a16adea6f8da5144c92acbc5011e7
5
5
  SHA512:
6
- metadata.gz: 3be12c7d6461d5586e5fd83c7001685a15af73dac62e23034226e64c458d4588062cf00f948421bda51c5bae79c8a241afd5894978843bf4973708350229e56d
7
- data.tar.gz: 2f121ff75f6c9c206720ffe28c5d7d6b4e11f91449a9799e32461a63c8e9a5495d24dacdbf166dc38a1be96cdbfd029cdc7ac5396b54475b1c6501c13acf0cae
6
+ metadata.gz: 8df94cd6b38513ad2f99b24b426f8275f929c1a98746a628ff6a47908c71372bc4bb379501c389d486b1b040435ed5a2185b4b72fe817eb51d32447d3e271203
7
+ data.tar.gz: 79ab182f79f99c14fe07e3dda0e6ddc99d587355b05d1cff763fe8fc2a054c24884628a45a2b323910ea95679d831fba5aa232354c9c3ad0278abfc5829efe2c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.0.16
4
+
5
+ * Add -v, --version cli option.
6
+ * Ouput file and line number if there's syntax error.
7
+ * Add check_syntax snippet.
8
+
3
9
  ## 0.0.15
4
10
 
5
11
  * Support attr_protected for strong_parameters snippet.
data/README.md CHANGED
@@ -29,6 +29,7 @@ Usage: synvert [project_path]
29
29
  -q, --query QUERY query specified snippets
30
30
  -s, --show SNIPPET_NAME show specified snippet description
31
31
  -r, --run SNIPPET_NAMES run specified snippets
32
+ -v, --version show this version
32
33
  ```
33
34
 
34
35
  e.g.
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
- puts "Error: " + e.message
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
@@ -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.to_s] = rewriter
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.to_s]
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.to_s])
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].
@@ -0,0 +1,5 @@
1
+ Synvert::Rewriter.new :check_syntax do
2
+ description "just used to check if there are syntax errors."
3
+
4
+ within_files "**/*.rb" do; end
5
+ end
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Synvert
4
- VERSION = "0.0.15"
4
+ VERSION = "0.0.16"
5
5
  end
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.15
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-08 00:00:00.000000000 Z
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