synvert 0.4.2 → 0.5.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 +4 -0
- data/lib/synvert/cli.rb +25 -13
- data/lib/synvert/snippet.rb +2 -2
- data/lib/synvert/version.rb +1 -1
- data/spec/synvert/snippet_spec.rb +3 -3
- data/synvert.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad8467c3b26e89499b67e13b5c4441a5b9d20a69
|
4
|
+
data.tar.gz: 701ad231cea1d52fc69827ced8610bcb7a07ebce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec940d0d793d9df5183fd06a670ecd545b229db7cd69cd698120172d4d304cd5a321edb71b9693bcb021596571b8633377751898972c0fc27f65b652a50e728d
|
7
|
+
data.tar.gz: 1a3c11744001240a5545aeb77c7ad4cee4d1e82c3c6913b2d5dcb8dd256816743d36f3ae30139b6e2515d8e7c8f65ad87a4147d4863a6f4a464f3916ca5f81a0
|
data/CHANGELOG.md
CHANGED
data/lib/synvert/cli.rb
CHANGED
@@ -34,7 +34,8 @@ module Synvert
|
|
34
34
|
else
|
35
35
|
@options[:snippet_names].each do |snippet_name|
|
36
36
|
puts "===== #{snippet_name} started ====="
|
37
|
-
|
37
|
+
group, name = snippet_name.split('/')
|
38
|
+
rewriter = Core::Rewriter.call group, name
|
38
39
|
rewriter.warnings.each do |warning|
|
39
40
|
puts "[Warn] " + warning.message
|
40
41
|
end
|
@@ -50,10 +51,6 @@ module Synvert
|
|
50
51
|
puts "file #{e.diagnostic.location.source_buffer.name}"
|
51
52
|
puts "line #{e.diagnostic.location.line}"
|
52
53
|
false
|
53
|
-
rescue Exception => e
|
54
|
-
print "Error: "
|
55
|
-
p e
|
56
|
-
false
|
57
54
|
end
|
58
55
|
|
59
56
|
private
|
@@ -75,14 +72,14 @@ module Synvert
|
|
75
72
|
opts.on '--skip FILE_PATTERNS', 'skip specified files or directories, separated by comma, e.g. app/models/post.rb,vendor/plugins/**/*.rb' do |file_patterns|
|
76
73
|
@options[:skip_file_patterns] = file_patterns.split(',')
|
77
74
|
end
|
78
|
-
opts.on '-s', '--show SNIPPET_NAME', 'show specified snippet description' do |snippet_name|
|
75
|
+
opts.on '-s', '--show SNIPPET_NAME', 'show specified snippet description, SNIPPET_NAME is combined by group and name, e.g. ruby/new_hash_syntax' do |snippet_name|
|
79
76
|
@options[:command] = 'show'
|
80
77
|
@options[:snippet_name] = snippet_name
|
81
78
|
end
|
82
79
|
opts.on '--sync', 'sync snippets' do
|
83
80
|
@options[:command] = 'sync'
|
84
81
|
end
|
85
|
-
opts.on '-r', '--run SNIPPET_NAMES', 'run specified snippets' do |snippet_names|
|
82
|
+
opts.on '-r', '--run SNIPPET_NAMES', 'run specified snippets, each SNIPPET_NAME is combined by group and name, e.g. ruby/new_hash_syntax,ruby/new_lambda_syntax' do |snippet_names|
|
86
83
|
@options[:snippet_names] = snippet_names.split(',').map(&:strip)
|
87
84
|
end
|
88
85
|
opts.on '-v', '--version', 'show this version' do
|
@@ -114,6 +111,9 @@ module Synvert
|
|
114
111
|
eval(File.read(snippet_path))
|
115
112
|
end
|
116
113
|
end
|
114
|
+
rescue
|
115
|
+
FileUtils.rm_rf default_snippets_path
|
116
|
+
retry
|
117
117
|
end
|
118
118
|
|
119
119
|
# List and print all available rewriters.
|
@@ -121,8 +121,11 @@ module Synvert
|
|
121
121
|
if Core::Rewriter.availables.empty?
|
122
122
|
puts "There is no snippet under ~/.synvert, please run `synvert --sync` to fetch snippets."
|
123
123
|
else
|
124
|
-
Core::Rewriter.availables.each do |
|
125
|
-
|
124
|
+
Core::Rewriter.availables.each do |group, rewriters|
|
125
|
+
puts group
|
126
|
+
rewriters.each do |name, rewriter|
|
127
|
+
puts " " + name
|
128
|
+
end
|
126
129
|
end
|
127
130
|
puts
|
128
131
|
end
|
@@ -130,9 +133,17 @@ module Synvert
|
|
130
133
|
|
131
134
|
# Query and print available rewriters.
|
132
135
|
def query_available_rewriters
|
133
|
-
Core::Rewriter.availables.each do |
|
134
|
-
if
|
135
|
-
|
136
|
+
Core::Rewriter.availables.each do |group, rewriters|
|
137
|
+
if group.include? @options[:query]
|
138
|
+
puts group
|
139
|
+
rewriters.each do |name, rewriter|
|
140
|
+
puts " " + name
|
141
|
+
end
|
142
|
+
elsif rewriters.keys.any? { |name| name.include? @options[:query] }
|
143
|
+
puts group
|
144
|
+
rewriters.each do |name, rewriter|
|
145
|
+
puts " " + name if name.include?(@options[:query])
|
146
|
+
end
|
136
147
|
end
|
137
148
|
end
|
138
149
|
puts
|
@@ -140,7 +151,8 @@ module Synvert
|
|
140
151
|
|
141
152
|
# Show and print one rewriter.
|
142
153
|
def show_rewriter
|
143
|
-
|
154
|
+
group, name = @options[:snippet_name].split('/')
|
155
|
+
rewriter = Core::Rewriter.fetch(group, name)
|
144
156
|
if rewriter
|
145
157
|
rewriter.process_with_sandbox
|
146
158
|
puts rewriter.description
|
data/lib/synvert/snippet.rb
CHANGED
@@ -10,9 +10,9 @@ module Synvert
|
|
10
10
|
snippets_path = Core::Configuration.instance.get :default_snippets_path
|
11
11
|
if File.exist?(snippets_path)
|
12
12
|
FileUtils.cd snippets_path
|
13
|
-
|
13
|
+
system("git pull --rebase")
|
14
14
|
else
|
15
|
-
|
15
|
+
system("git clone https://github.com/xinminlabs/synvert-snippets.git #{snippets_path}")
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
data/lib/synvert/version.rb
CHANGED
@@ -8,14 +8,14 @@ module Synvert
|
|
8
8
|
after { FileUtils.rm_rf default_snippets_path }
|
9
9
|
|
10
10
|
it 'git clones snippets' do
|
11
|
+
expect(Snippet).to receive(:system).with("git clone https://github.com/xinminlabs/synvert-snippets.git #{default_snippets_path}")
|
11
12
|
Snippet.sync
|
12
|
-
expect(File.exist?(default_snippets_path)).to be_truthy
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'git pull snippets' do
|
16
|
+
FileUtils.mkdir default_snippets_path
|
17
|
+
expect(Snippet).to receive(:system).with("git pull --rebase")
|
16
18
|
Snippet.sync
|
17
|
-
Snippet.sync
|
18
|
-
expect(File.exist?(default_snippets_path)).to be_truthy
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
data/synvert.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency "synvert-core", ">= 0.
|
21
|
+
spec.add_runtime_dependency "synvert-core", ">= 0.5.0"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
24
|
spec.add_development_dependency "rake"
|
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.5.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-08-
|
11
|
+
date: 2014-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: synvert-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.5.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.5.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|