synvert-core 0.18.0 → 0.19.0

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: a30d3e6c2241ca3fb2d35ead568fb24dc04db2d38a8faebb99eda33b0da7a354
4
- data.tar.gz: f5d6ecdbcecbceabdf95ee474253b6e4ed0fc5cc5c52d25a7408d53ab54ccff0
3
+ metadata.gz: e1248f2c7c2721ea6135b6adb3a5d40afc95497c63d91e8b1b508febb6e7d4b1
4
+ data.tar.gz: 9e7f64e254dc25e1bf9894559c7586eb6fb96f3aea07bedd09d71a17d930e0fc
5
5
  SHA512:
6
- metadata.gz: b7a9a026022ba96e5140d3aa6976bdbc8448dffdc8539b946df41016daf5847bf2c75a1458c2b8184d73e2a50a40741be67e8c382b49b1c1df5adf9e7c2e29dd
7
- data.tar.gz: 42d7d7249ba0047709013c61a14c3428728967ff701b738eaa261683dfdf44ea899a3235cf1a2adb034034bb0bd006d7ec6ce59c415abfaef263647d15cbeb21
6
+ metadata.gz: a940b5ea3029c9cbc7b10034e3e6eca05370d4015a4c98af28a1eb8b2a825133627f1d25da20e8986d89f52da00c7056893eb9946aff5a017979bc720d097755
7
+ data.tar.gz: 37a51398a51fec8cac11b2b3aae8353f5483bfbd7e9485d1b644b8000dea5186036438f1a01b9f4c0d4ce8b940ab6b40261673eb309a663c6f61df45afcf1b45
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.19.0 (2021-02-07)
4
+
5
+ * Simplify `Configuration`
6
+
3
7
  ## 0.18.0 (2021-02-07)
4
8
 
5
9
  * Add `Rewriter.execute`
@@ -1,26 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'singleton'
4
-
5
3
  module Synvert::Core
6
4
  # Synvert global configuration.
7
- class Configuration < Hash
8
- include Singleton
5
+ class Configuration
6
+ class << self
7
+ attr_writer :path, :skip_files
9
8
 
10
- # Set the configuration.
11
- #
12
- # @param key [String] configuration key.
13
- # @param value [Object] configuration value.
14
- def set(key, value)
15
- self[key] = value
16
- end
9
+ def path
10
+ @path || '.'
11
+ end
17
12
 
18
- # Get the configuration.
19
- #
20
- # @param key [String] configuration key.
21
- # @return [Object] configuration value.
22
- def get(key)
23
- self[key]
13
+ def skip_files
14
+ @skip_files || []
15
+ end
24
16
  end
25
17
  end
26
18
  end
@@ -233,7 +233,7 @@ module Synvert::Core
233
233
  def add_file(filename, content)
234
234
  return if @sandbox
235
235
 
236
- filepath = File.join(Configuration.instance.get(:path), filename)
236
+ filepath = File.join(Configuration.path, filename)
237
237
  if File.exist?(filepath)
238
238
  puts "File #{filepath} already exists."
239
239
  return
@@ -251,7 +251,7 @@ module Synvert::Core
251
251
  def remove_file(filename)
252
252
  return if @sandbox
253
253
 
254
- file_path = File.join(Configuration.instance.get(:path), filename)
254
+ file_path = File.join(Configuration.path, filename)
255
255
  File.delete(file_path) if File.exist?(file_path)
256
256
  end
257
257
 
@@ -26,7 +26,7 @@ module Synvert::Core
26
26
  # @return [Boolean] true if matches, otherwise false.
27
27
  # @raise [Synvert::Core::GemfileLockNotFound] raise if Gemfile.lock does not exist.
28
28
  def match?
29
- gemfile_lock_path = File.join(Configuration.instance.get(:path), 'Gemfile.lock')
29
+ gemfile_lock_path = File.join(Configuration.path, 'Gemfile.lock')
30
30
 
31
31
  # if Gemfile.lock does not exist, just ignore this check
32
32
  return true unless File.exist?(gemfile_lock_path)
@@ -86,11 +86,11 @@ module Synvert::Core
86
86
  # It finds all files, for each file, it executes the block code, gets all rewrite actions,
87
87
  # and rewrite source code back to original file.
88
88
  def process
89
- file_pattern = File.join(Configuration.instance.get(:path), @file_pattern)
89
+ file_pattern = File.join(Configuration.path, @file_pattern)
90
90
  Dir
91
91
  .glob(file_pattern)
92
92
  .each do |file_path|
93
- next if Configuration.instance.get(:skip_files).include? file_path
93
+ next if Configuration.skip_files.include? file_path
94
94
 
95
95
  begin
96
96
  conflict_actions = []
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '0.18.0'
5
+ VERSION = '0.19.0'
6
6
  end
7
7
  end
data/spec/spec_helper.rb CHANGED
@@ -18,9 +18,4 @@ RSpec.configure do |config|
18
18
  config.filter_run :focus
19
19
 
20
20
  config.order = 'random'
21
-
22
- config.before do
23
- Synvert::Core::Configuration.instance.set :path, '.'
24
- Synvert::Core::Configuration.instance.set :skip_files, []
25
- end
26
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synvert-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
@@ -167,7 +167,6 @@ files:
167
167
  - lib/synvert/core/version.rb
168
168
  - spec/spec_helper.rb
169
169
  - spec/support/parser_helper.rb
170
- - spec/synvert/core/configuration_spec.rb
171
170
  - spec/synvert/core/engine/erb_spec.rb
172
171
  - spec/synvert/core/node_ext_spec.rb
173
172
  - spec/synvert/core/rewriter/action/append_action_spec.rb
@@ -216,7 +215,6 @@ summary: convert ruby code to better syntax.
216
215
  test_files:
217
216
  - spec/spec_helper.rb
218
217
  - spec/support/parser_helper.rb
219
- - spec/synvert/core/configuration_spec.rb
220
218
  - spec/synvert/core/engine/erb_spec.rb
221
219
  - spec/synvert/core/node_ext_spec.rb
222
220
  - spec/synvert/core/rewriter/action/append_action_spec.rb
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- module Synvert::Core
6
- describe Configuration do
7
- it 'sets / gets' do
8
- Configuration.instance.set :key, 'value'
9
- expect(Configuration.instance.get(:key)).to eq 'value'
10
- end
11
- end
12
- end