synvert 0.10.1 → 0.11.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
  SHA256:
3
- metadata.gz: 61ccc2f378bbcddf7fe052b577b594bd832672b7cca486786ee0e07611d07d87
4
- data.tar.gz: 5ba5f7e67f79dc322e73034f699d76a3c3020bbe7090991d23e947ca25278353
3
+ metadata.gz: 1a6497202b00d143ebee65b85a45fb0fa0e1130d44984955f817799c16376424
4
+ data.tar.gz: e0befd502bd9414ef93ad6368044983a5f5d9a677a86d2ff63de637ab1740ece
5
5
  SHA512:
6
- metadata.gz: 6ad3896b92637a657e5b453a492d6620b108a33d98470eecc71850de266bfb9cf544c82780bb90f1556fcd0fe9a01ee362f953a186e1b50bc437dd8263558b83
7
- data.tar.gz: d84667fea189b0d4c0f249e2889b87946612baa103a007fb7bbcddecb88af6cb7308b0efbc2ebc63997675b5f698400230e1209b1bcf7d225f5ce00f5ff380fb
6
+ metadata.gz: cfa2c293ba1330dcccb3cd2ee43bd1ac47d45a8e0ce011615fcef575842405f27fec6b070061d6567461046a2d7c445ee0440b903baca3ca3c2c47bd00399577
7
+ data.tar.gz: 79d690b0576dc8083bfc451003ef50d8f3ab968908b774a10f6613a77172751979d93b9746b0e80617998ca0efc84a29ec4b5a61af907b17835c07af440dceaf
data/CHANGELOG.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
- ## 0.10.1 (2021-02-09)
3
+ ## 0.11.0 (2021-02-15)
4
4
 
5
+ * Add `--list-all` option
5
6
  * Add post install message
7
+ * Fix `Synvert::Snippet.fetch_core_version`
6
8
 
7
9
  ## 0.10.0 (2021-02-07)
8
10
 
data/lib/synvert/cli.rb CHANGED
@@ -28,6 +28,9 @@ module Synvert
28
28
  when 'list'
29
29
  load_rewriters
30
30
  list_available_rewriters
31
+ when 'list-all'
32
+ load_rewriters
33
+ list_all_rewriters_in_json
31
34
  when 'open'
32
35
  open_rewriter
33
36
  when 'query'
@@ -77,6 +80,9 @@ module Synvert
77
80
  'load custom snippets, snippet paths can be local file path or remote http url' do |snippet_paths|
78
81
  @options[:custom_snippet_paths] = snippet_paths.split(',').map(&:strip)
79
82
  end
83
+ opts.on '--list-all', 'list all available snippets name and description in json format' do
84
+ @options[:command] = 'list-all'
85
+ end
80
86
  opts.on '-l', '--list', 'list all available snippets' do
81
87
  @options[:command] = 'list'
82
88
  end
@@ -155,6 +161,28 @@ module Synvert
155
161
  end
156
162
  end
157
163
 
164
+ def list_all_rewriters_in_json
165
+ if Core::Rewriter.availables.empty?
166
+ puts 'There is no snippet under ~/.synvert, please run `synvert --sync` to fetch snippets.'
167
+ return
168
+ end
169
+
170
+ output = []
171
+ Core::Rewriter.availables.each do |group, rewriters|
172
+ rewriters.each do |name, rewriter|
173
+ rewriter.process_with_sandbox
174
+ output << {
175
+ group: group,
176
+ name: name,
177
+ description: rewriter.description,
178
+ sub_snippets: rewriter.sub_snippets.map(&:name)
179
+ }
180
+ end
181
+ end
182
+
183
+ puts JSON.generate(output)
184
+ end
185
+
158
186
  # Open one rewriter.
159
187
  def open_rewriter
160
188
  editor = [ENV['SYNVERT_EDITOR'], ENV['EDITOR']].find { |e| !e.nil? && !e.empty? }
@@ -6,6 +6,11 @@ require 'json'
6
6
  module Synvert
7
7
  # Manage synvert snippets.
8
8
  class Snippet
9
+ def self.fetch_core_version
10
+ content = URI.open('https://rubygems.org/api/v1/versions/synvert-core.json').read
11
+ JSON.parse(content).first['number']
12
+ end
13
+
9
14
  def initialize(snippets_path)
10
15
  @snippets_path = snippets_path
11
16
  end
@@ -19,10 +24,5 @@ module Synvert
19
24
  Kernel.system("git clone https://github.com/xinminlabs/synvert-snippets.git #{@snippets_path}")
20
25
  end
21
26
  end
22
-
23
- def fetch_core_version
24
- content = URI.open('https://rubygems.org/api/v1/versions/synvert-core.json').read
25
- JSON.parse(content).first['number']
26
- end
27
27
  end
28
28
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Synvert
4
- VERSION = '0.10.1'
4
+ VERSION = '0.11.0'
5
5
  end
data/synvert.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ['lib']
21
21
  spec.post_install_message = 'Please run `synvert --sync` first to sync snippets remotely.'
22
22
 
23
- spec.add_runtime_dependency 'synvert-core', '>= 0.19.0'
23
+ spec.add_runtime_dependency 'synvert-core', '>= 0.20.0'
24
24
 
25
25
  spec.add_development_dependency 'bundler'
26
26
  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.10.1
4
+ version: 0.11.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: 2021-02-09 00:00:00.000000000 Z
11
+ date: 2021-02-15 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.0
19
+ version: 0.20.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.19.0
26
+ version: 0.20.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement