synvert 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 430688d602830d6cbccecf277a580969288b875e992dc1447eb108a7ebd0726c
4
- data.tar.gz: 6ea78cce8187cea7470bbc043978b318a4f0bd608bf13124cb9ec5f75917fe37
3
+ metadata.gz: 61ccc2f378bbcddf7fe052b577b594bd832672b7cca486786ee0e07611d07d87
4
+ data.tar.gz: 5ba5f7e67f79dc322e73034f699d76a3c3020bbe7090991d23e947ca25278353
5
5
  SHA512:
6
- metadata.gz: dad3de4c88092bba08138b0b64d70e92fa33ca2d8d4d7acea22d7b5e468e48fb2b08b8531832c985b03f5a4b6c2e0fda5f5aa415aae204c414fc5d14d18646c1
7
- data.tar.gz: e500c57544648cb230f43e52658d58c36bde8a13f052c5e66441fc3471c43e867c8693a0b4fde23a9a9c6c69eae28c0d174ef5ddedec499ff6594a676b0beece
6
+ metadata.gz: 6ad3896b92637a657e5b453a492d6620b108a33d98470eecc71850de266bfb9cf544c82780bb90f1556fcd0fe9a01ee362f953a186e1b50bc437dd8263558b83
7
+ data.tar.gz: d84667fea189b0d4c0f249e2889b87946612baa103a007fb7bbcddecb88af6cb7308b0efbc2ebc63997675b5f698400230e1209b1bcf7d225f5ce00f5ff380fb
data/.travis.yml CHANGED
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1
4
- - 2.2
5
3
  - 2.3
6
4
  - 2.4
5
+ - 2.5
6
+ - 2.6
7
+ - 2.7
8
+ - 3.0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.10.1 (2021-02-09)
4
+
5
+ * Add post install message
6
+
3
7
  ## 0.10.0 (2021-02-07)
4
8
 
5
9
  * Use new `Core::Confiruation`
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in synvert.gemspec
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
data/bin/synvert CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- # coding: utf-8
2
+ # frozen_string_literal: true
3
3
 
4
- $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
4
+ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
5
5
  require 'synvert'
6
6
 
7
7
  result = Synvert::CLI.run
data/lib/synvert.rb CHANGED
@@ -1,4 +1,5 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'synvert/version'
3
4
  require 'bundler'
4
5
  require 'synvert/core'
data/lib/synvert/cli.rb CHANGED
@@ -1,4 +1,5 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'optparse'
3
4
 
4
5
  module Synvert
@@ -14,7 +15,7 @@ module Synvert
14
15
 
15
16
  # Initialize a CLI.
16
17
  def initialize
17
- @options = {command: 'run', custom_snippet_paths: [], snippet_names: []}
18
+ @options = { command: 'run', custom_snippet_paths: [], snippet_names: [] }
18
19
  end
19
20
 
20
21
  # Run the CLI.
@@ -37,7 +38,8 @@ module Synvert
37
38
  show_rewriter
38
39
  when 'sync'
39
40
  sync_snippets
40
- else # run
41
+ else
42
+ # run
41
43
  load_rewriters
42
44
  @options[:snippet_names].each do |snippet_name|
43
45
  puts "===== #{snippet_name} started ====="
@@ -67,47 +69,56 @@ module Synvert
67
69
 
68
70
  # Run OptionParser to parse arguments.
69
71
  def run_option_parser(args)
70
- optparse = OptionParser.new do |opts|
71
- opts.banner = 'Usage: synvert [project_path]'
72
- opts.on '-d', '--load SNIPPET_PATHS', 'load custom snippets, snippet paths can be local file path or remote http url' do |snippet_paths|
73
- @options[:custom_snippet_paths] = snippet_paths.split(',').map(&:strip)
74
- end
75
- opts.on '-l', '--list', 'list all available snippets' do
76
- @options[:command] = 'list'
77
- end
78
- opts.on '-o', '--open SNIPPET_NAME', 'Open a snippet' do |snippet_name|
79
- @options[:command] = 'open'
80
- @options[:snippet_name] = snippet_name
81
- end
82
- opts.on '-q', '--query QUERY', 'query specified snippets' do |query|
83
- @options[:command] = 'query'
84
- @options[:query] = query
85
- end
86
- 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|
87
- @options[:skip_file_patterns] = file_patterns.split(',')
88
- end
89
- 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|
90
- @options[:command] = 'show'
91
- @options[:snippet_name] = snippet_name
92
- end
93
- opts.on '--sync', 'sync snippets' do
94
- @options[:command] = 'sync'
95
- end
96
- 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|
97
- @options[:snippet_names] = snippet_names.split(',').map(&:strip)
98
- end
99
- opts.on '-v', '--version', 'show this version' do
100
- puts Core::VERSION
101
- exit
72
+ optparse =
73
+ OptionParser.new do |opts|
74
+ opts.banner = 'Usage: synvert [project_path]'
75
+ opts.on '-d',
76
+ '--load SNIPPET_PATHS',
77
+ 'load custom snippets, snippet paths can be local file path or remote http url' do |snippet_paths|
78
+ @options[:custom_snippet_paths] = snippet_paths.split(',').map(&:strip)
79
+ end
80
+ opts.on '-l', '--list', 'list all available snippets' do
81
+ @options[:command] = 'list'
82
+ end
83
+ opts.on '-o', '--open SNIPPET_NAME', 'Open a snippet' do |snippet_name|
84
+ @options[:command] = 'open'
85
+ @options[:snippet_name] = snippet_name
86
+ end
87
+ opts.on '-q', '--query QUERY', 'query specified snippets' do |query|
88
+ @options[:command] = 'query'
89
+ @options[:query] = query
90
+ end
91
+ opts.on '--skip FILE_PATTERNS',
92
+ 'skip specified files or directories, separated by comma, e.g. app/models/post.rb,vendor/plugins/**/*.rb' do |file_patterns|
93
+ @options[:skip_file_patterns] = file_patterns.split(',')
94
+ end
95
+ opts.on '-s',
96
+ '--show SNIPPET_NAME',
97
+ 'show specified snippet description, SNIPPET_NAME is combined by group and name, e.g. ruby/new_hash_syntax' do |snippet_name|
98
+ @options[:command] = 'show'
99
+ @options[:snippet_name] = snippet_name
100
+ end
101
+ opts.on '--sync', 'sync snippets' do
102
+ @options[:command] = 'sync'
103
+ end
104
+ opts.on '-r',
105
+ '--run SNIPPET_NAMES',
106
+ '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|
107
+ @options[:snippet_names] = snippet_names.split(',').map(&:strip)
108
+ end
109
+ opts.on '-v', '--version', 'show this version' do
110
+ puts Core::VERSION
111
+ exit
112
+ end
102
113
  end
103
- end
104
114
  paths = optparse.parse(args)
105
115
  Core::Configuration.path = paths.first || Dir.pwd
106
116
  if @options[:skip_file_patterns] && !@options[:skip_file_patterns].empty?
107
- skip_files = @options[:skip_file_patterns].map do |file_pattern|
108
- full_file_pattern = File.join(Core::Configuration.path, file_pattern)
109
- Dir.glob(full_file_pattern)
110
- end.flatten
117
+ skip_files =
118
+ @options[:skip_file_patterns].map do |file_pattern|
119
+ full_file_pattern = File.join(Core::Configuration.path, file_pattern)
120
+ Dir.glob(full_file_pattern)
121
+ end.flatten
111
122
  Core::Configuration.skip_files = skip_files
112
123
  end
113
124
  end
@@ -117,14 +128,14 @@ module Synvert
117
128
  Dir.glob(File.join(default_snippets_path, 'lib/**/*.rb')).each { |file| require file }
118
129
 
119
130
  @options[:custom_snippet_paths].each do |snippet_path|
120
- if snippet_path =~ /^http/
131
+ if /^http/.match?(snippet_path)
121
132
  uri = URI.parse snippet_path
122
133
  eval(uri.read)
123
134
  else
124
135
  require snippet_path
125
136
  end
126
137
  end
127
- rescue
138
+ rescue StandardError
128
139
  FileUtils.rm_rf default_snippets_path
129
140
  retry
130
141
  end
@@ -136,7 +147,7 @@ module Synvert
136
147
  else
137
148
  Core::Rewriter.availables.each do |group, rewriters|
138
149
  puts group
139
- rewriters.each do |name, rewriter|
150
+ rewriters.each do |name, _rewriter|
140
151
  puts ' ' + name
141
152
  end
142
153
  end
@@ -162,12 +173,12 @@ module Synvert
162
173
  Core::Rewriter.availables.each do |group, rewriters|
163
174
  if group.include? @options[:query]
164
175
  puts group
165
- rewriters.each do |name, rewriter|
176
+ rewriters.each do |name, _rewriter|
166
177
  puts ' ' + name
167
178
  end
168
179
  elsif rewriters.keys.any? { |name| name.include? @options[:query] }
169
180
  puts group
170
- rewriters.each do |name, rewriter|
181
+ rewriters.each do |name, _rewriter|
171
182
  puts ' ' + name if name.include?(@options[:query])
172
183
  end
173
184
  end
@@ -1,4 +1,5 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'open-uri'
3
4
  require 'json'
4
5
 
@@ -1,5 +1,5 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Synvert
4
- VERSION = '0.10.0'
4
+ VERSION = '0.10.1'
5
5
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
4
 
3
5
  require 'synvert'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Synvert
@@ -8,7 +10,9 @@ module Synvert
8
10
 
9
11
  describe 'sync' do
10
12
  it 'git clones snippets' do
11
- expect(Kernel).to receive(:system).with("git clone https://github.com/xinminlabs/synvert-snippets.git #{snippets_path}")
13
+ expect(Kernel).to receive(:system).with(
14
+ "git clone https://github.com/xinminlabs/synvert-snippets.git #{snippets_path}"
15
+ )
12
16
  snippet.sync
13
17
  end
14
18
 
@@ -22,8 +26,9 @@ module Synvert
22
26
 
23
27
  describe 'fetch_core_version' do
24
28
  it 'gets remote version' do
25
- stub_request(:get, 'https://rubygems.org/api/v1/versions/synvert-core.json').
26
- to_return(:body => '[{"number":"0.4.2"}]')
29
+ stub_request(:get, 'https://rubygems.org/api/v1/versions/synvert-core.json').to_return(
30
+ body: '[{"number":"0.4.2"}]'
31
+ )
27
32
  expect(snippet.fetch_core_version).to eq '0.4.2'
28
33
  end
29
34
  end
data/synvert.gemspec CHANGED
@@ -1,5 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'synvert/version'
5
6
 
@@ -17,6 +18,7 @@ Gem::Specification.new do |spec|
17
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
20
  spec.require_paths = ['lib']
21
+ spec.post_install_message = 'Please run `synvert --sync` first to sync snippets remotely.'
20
22
 
21
23
  spec.add_runtime_dependency 'synvert-core', '>= 0.19.0'
22
24
 
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.0
4
+ version: 0.10.1
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-07 00:00:00.000000000 Z
11
+ date: 2021-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: synvert-core
@@ -108,7 +108,7 @@ homepage: https://github.com/xinminlabs/synvert
108
108
  licenses:
109
109
  - MIT
110
110
  metadata: {}
111
- post_install_message:
111
+ post_install_message: Please run `synvert --sync` first to sync snippets remotely.
112
112
  rdoc_options: []
113
113
  require_paths:
114
114
  - lib