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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +2 -1
- data/lib/synvert/cli.rb +36 -7
- data/lib/synvert/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8941e003bae93eb24a188ff2dbcb48dbad8cc2b6
|
4
|
+
data.tar.gz: e796edccc2f96ff9ea1f3303c51360ffdbdf90a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77e919724aa7ec0508621a38a7a5cea5d85ec05925bf8b0bdacb9e6509cb5ce5593ebc5b96110d90d771d7ef936891e5a6c48de8303e427602d7d11ff350da32
|
7
|
+
data.tar.gz: 7ec460303474e7f5116983c6e6097cb9338e9f8c40eb93dad50d9978e0a1fa1beda9cd86fa6937588a99e68d17b3769206ef69b08004a3835d758ec26c334b2a
|
data/CHANGELOG.md
CHANGED
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
|
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
|
data/lib/synvert/cli.rb
CHANGED
@@ -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'
|
31
|
-
|
32
|
-
|
33
|
-
when '
|
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
|
-
|
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
|
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.
|
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:
|
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.
|
127
|
+
rubygems_version: 2.4.5.1
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: synvert = syntax + convert.
|