synvert 0.5.3 → 0.9.0

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: a42d9821a0cadf0a178273ad48106b8352107f29
4
- data.tar.gz: 0b9005a3ad6c93016765948b9593d6b35119a798
3
+ metadata.gz: 8941e003bae93eb24a188ff2dbcb48dbad8cc2b6
4
+ data.tar.gz: e796edccc2f96ff9ea1f3303c51360ffdbdf90a3
5
5
  SHA512:
6
- metadata.gz: 1abba44772e6cb2ee3af4330b0b1b974acf6ed95d6a5df6f7995e2036302522a3c8440bd1c68d726aebc8a1aced997c77d608b70ada82a84e3de7c8b6faf0233
7
- data.tar.gz: af7a2a479daaf9cf65ac81a85f2c9c1bfe7ce11cc930622e02321d3946fc3082bb02eb46ebda4097ba4fe8cff4aaf06f1720967b5fed80c1159c83c30fdad5dc
6
+ metadata.gz: 77e919724aa7ec0508621a38a7a5cea5d85ec05925bf8b0bdacb9e6509cb5ce5593ebc5b96110d90d771d7ef936891e5a6c48de8303e427602d7d11ff350da32
7
+ data.tar.gz: 7ec460303474e7f5116983c6e6097cb9338e9f8c40eb93dad50d9978e0a1fa1beda9cd86fa6937588a99e68d17b3769206ef69b08004a3835d758ec26c334b2a
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ Try to keep same version to gem `synvert-core`.
4
+
5
+ ## 0.9.0
6
+
7
+ * Add `-o` or `--open` option` to open a snippet
8
+
3
9
  ## 0.5.3
4
10
 
5
11
  * Show warning message if rewriter not found
data/README.md CHANGED
@@ -12,6 +12,7 @@ Synvert is tested against MRI 1.9.3, 2.0.0 and 2.1.1.
12
12
  Synvert is composed by synvert-core and synvert-snippets.
13
13
 
14
14
  [synvert-core][1] provides a dsl to convert ruby code.
15
+
15
16
  [synvert-snippets][2] lists all snippets to convert ruby code based on
16
17
  synvert-core.
17
18
 
@@ -45,7 +46,7 @@ $ synvert --sync
45
46
  ```
46
47
 
47
48
  ```
48
- $ synvert -r factory_girl_short_syntax,upgrade_rails_3_2_to_4_0 ~/Sites/railsbp/rails-bestpractices.com
49
+ $ synvert -r factory_girl/use_short_syntax,rails/upgrade_3_2_to_4_0 ~/Sites/railsbp/rails-bestpractices.com
49
50
  ```
50
51
 
51
52
  ## Documentation
@@ -24,14 +24,23 @@ module Synvert
24
24
  # @return [Boolean] true if command runs successfully.
25
25
  def run(args)
26
26
  run_option_parser(args)
27
- load_rewriters
28
27
 
29
28
  case @options[:command]
30
- when 'list' then list_available_rewriters
31
- when 'query' then query_available_rewriters
32
- when 'show' then show_rewriter
33
- when 'sync' then sync_snippets
29
+ when 'list'
30
+ load_rewriters
31
+ list_available_rewriters
32
+ when 'open'
33
+ open_rewriter
34
+ when 'query'
35
+ load_rewriters
36
+ query_available_rewriters
37
+ when 'show'
38
+ load_rewriters
39
+ show_rewriter
40
+ when 'sync'
41
+ sync_snippets
34
42
  else
43
+ load_rewriters
35
44
  @options[:snippet_names].each do |snippet_name|
36
45
  puts "===== #{snippet_name} started ====="
37
46
  group, name = snippet_name.split('/')
@@ -56,7 +65,7 @@ module Synvert
56
65
  false
57
66
  end
58
67
 
59
- private
68
+ private
60
69
 
61
70
  # Run OptionParser to parse arguments.
62
71
  def run_option_parser(args)
@@ -68,6 +77,10 @@ module Synvert
68
77
  opts.on '-l', '--list', 'list all available snippets' do
69
78
  @options[:command] = 'list'
70
79
  end
80
+ opts.on '-o', '--open SNIPPET_NAME', 'Open a snippet' do |snippet_name|
81
+ @options[:command] = 'open'
82
+ @options[:snippet_name] = snippet_name
83
+ end
71
84
  opts.on '-q', '--query QUERY', 'query specified snippets' do |query|
72
85
  @options[:command] = 'query'
73
86
  @options[:query] = query
@@ -103,7 +116,6 @@ module Synvert
103
116
 
104
117
  # Load all rewriters.
105
118
  def load_rewriters
106
- default_snippets_path = Core::Configuration.instance.get :default_snippets_path
107
119
  Dir.glob(File.join(default_snippets_path, 'lib/**/*.rb')).each { |file| eval(File.read(file)) }
108
120
 
109
121
  @options[:custom_snippet_paths].each do |snippet_path|
@@ -134,6 +146,19 @@ module Synvert
134
146
  end
135
147
  end
136
148
 
149
+ # Open one rewriter.
150
+ def open_rewriter
151
+ editor = [ENV['SYNVERT_EDITOR'], ENV['EDITOR']].find { |e| !e.nil? && !e.empty? }
152
+ return puts "To open a synvert snippet, set $EDITOR or $SYNVERT_EDITOR" unless editor
153
+
154
+ path = File.expand_path(File.join(default_snippets_path, "lib/#{@options[:snippet_name]}.rb"))
155
+ if File.exist? path
156
+ system editor, path
157
+ else
158
+ puts "Can't run #{editor} #{path}"
159
+ end
160
+ end
161
+
137
162
  # Query and print available rewriters.
138
163
  def query_available_rewriters
139
164
  Core::Rewriter.availables.each do |group, rewriters|
@@ -180,5 +205,9 @@ module Synvert
180
205
  puts "synvert-core is updated, please install synvert-core #{core_version}"
181
206
  end
182
207
  end
208
+
209
+ def default_snippets_path
210
+ Core::Configuration.instance.get :default_snippets_path
211
+ end
183
212
  end
184
213
  end
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Synvert
4
- VERSION = "0.5.3"
4
+ VERSION = "0.9.0"
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.5.3
4
+ version: 0.9.0
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-09-01 00:00:00.000000000 Z
11
+ date: 2015-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: synvert-core
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  version: '0'
125
125
  requirements: []
126
126
  rubyforge_project:
127
- rubygems_version: 2.2.2
127
+ rubygems_version: 2.4.5.1
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: synvert = syntax + convert.