synvert-core 1.35.2 → 1.35.4

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: 51a30c5d53520076a6b19d8b37b3e731c8ac8c6b37f1ccea72a2290710d8dedb
4
- data.tar.gz: 544b1b22736424d6383c9213e9aa1cea20738bf3c099977a9ad18c91fdbb0a70
3
+ metadata.gz: 241e9b40114c50b1dec1b86784fde026ed03ac64f2e38e314f00ed1f35a010c5
4
+ data.tar.gz: 521fee14550bd2eebb9e26d9aa1928bd4ae51cc43a88692c5337dad7ab32cc11
5
5
  SHA512:
6
- metadata.gz: c92691509ab9373752de66a4461499f19217ae9eac07a8f655b67b433679719623cdd56febfc90a310c9fcee4b3914a513811e0115e46133a194980a7fb3cf04
7
- data.tar.gz: bda965c4cc14f93c2e1fe87c36b3390512fad4827d9c7f6ea80ace198e2f0f72826a66950ab743737d610b461d9cb24eaccf47db2961498a79d56e008d81e232
6
+ metadata.gz: 206b4e331e89760a0f47376401a48986b0ce2ec7e72d29cc566a93ae9b2341d7298a9738da3b9434c38a66d81b32bd6e109c9f52a0804d2575dcc0a8f46b2254
7
+ data.tar.gz: e42ec5540b5b3dab9688ef43d9872132ea8e78c33073aa8567e10dcfb3152e7c50b8d1d639b16d3a0bacd9bc088966fb32c915dfccb045c412b79552e37a3eec
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.35.4 (2024-04-25)
4
+
5
+ * Eval snippet on gist.github.com
6
+
7
+ ## 1.35.3 (2024-04-18)
8
+
9
+ * Update `prism_ext` to 0.3.2
10
+ * Update `syntax_tree_ext` to 0.8.2
11
+ * Update `parser_node_ext` to 1.3.2
12
+ * Remove `reject_keys_from_hash` helper method
13
+
3
14
  ## 1.35.2 (2024-04-16)
4
15
 
5
16
  * Explicitly read file as UTF-8 encoding
data/Gemfile.lock CHANGED
@@ -1,17 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- synvert-core (1.35.2)
4
+ synvert-core (1.35.4)
5
5
  activesupport (< 7.0.0)
6
6
  node_mutation (>= 1.24.4)
7
7
  node_query (>= 1.15.2)
8
8
  parallel
9
9
  parser
10
- parser_node_ext (>= 1.3.0)
10
+ parser_node_ext (>= 1.3.2)
11
11
  prism
12
- prism_ext (>= 0.3.1)
12
+ prism_ext (>= 0.3.2)
13
13
  syntax_tree
14
- syntax_tree_ext (>= 0.8.1)
14
+ syntax_tree_ext (>= 0.8.2)
15
15
 
16
16
  GEM
17
17
  remote: https://rubygems.org/
@@ -61,11 +61,11 @@ GEM
61
61
  parser (3.3.0.5)
62
62
  ast (~> 2.4.1)
63
63
  racc
64
- parser_node_ext (1.3.0)
64
+ parser_node_ext (1.3.2)
65
65
  parser
66
66
  prettier_print (1.2.1)
67
- prism (0.25.0)
68
- prism_ext (0.3.1)
67
+ prism (0.27.0)
68
+ prism_ext (0.3.2)
69
69
  prism
70
70
  pry (0.14.1)
71
71
  coderay (~> 1.1)
@@ -91,7 +91,7 @@ GEM
91
91
  shellany (0.0.1)
92
92
  syntax_tree (6.2.0)
93
93
  prettier_print (>= 1.2.0)
94
- syntax_tree_ext (0.8.1)
94
+ syntax_tree_ext (0.8.2)
95
95
  syntax_tree
96
96
  thor (1.2.1)
97
97
  tzinfo (2.0.6)
@@ -71,20 +71,5 @@ module Synvert::Core
71
71
  Regexp.last_match(1).strip
72
72
  }
73
73
  end
74
-
75
- # Reject some keys from hash node.
76
- #
77
- # @param hash_node [Parser::AST::Node]
78
- # @param keys [Array<String, Symbol>] keys should be rejected from the hash.
79
- # @return [String] source of of the hash node after rejecting some keys.
80
- #
81
- # @example
82
- #
83
- # hash_node = Parser::CurrentRuby.parse("{ key1: 'value1', key2: 'value2' }")
84
- # reject_keys_from_hash(hash_node, :key1) => "key2: 'value2'"
85
- def reject_keys_from_hash(hash_node, *keys)
86
- hash_node.children.reject { |pair_node| keys.include?(pair_node.key.to_value) }
87
- .map(&:to_source).join(', ')
88
- end
89
74
  end
90
75
  end
@@ -88,9 +88,15 @@ module Synvert::Core
88
88
  end
89
89
 
90
90
  def convert_to_github_raw_url(url)
91
- return url unless url.include?('//github.com/')
91
+ if url.starts_with?('https://github.com')
92
+ return url.sub('//github.com/', '//raw.githubusercontent.com/').sub('/blob/', '/')
93
+ end
94
+
95
+ if url.starts_with?('https://gist.github.com')
96
+ return url.sub('gist.github.com/', 'gist.githubusercontent.com/') + '/raw'
97
+ end
92
98
 
93
- url.sub('//github.com/', '//raw.githubusercontent.com/').sub('/blob/', '/')
99
+ url
94
100
  end
95
101
 
96
102
  # Filter only paths with `Configuration.only_paths`.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '1.35.2'
5
+ VERSION = '1.35.4'
6
6
  end
7
7
  end
@@ -83,17 +83,5 @@ module Synvert::Core
83
83
  expect(dummy_instance.strip_brackets('(123]')).to eq '(123]'
84
84
  end
85
85
  end
86
-
87
- describe '#reject_keys_from_hash' do
88
- it 'rejects single key' do
89
- hash_node = Parser::CurrentRuby.parse("{ key1: 'value1', key2: 'value2' }")
90
- expect(dummy_instance.reject_keys_from_hash(hash_node, :key1)).to eq "key2: 'value2'"
91
- end
92
-
93
- it 'rejects multi keys' do
94
- hash_node = Parser::CurrentRuby.parse("{ key1: 'value1', key2: 'value2', key3: 'value3', key4: 'value4' }")
95
- expect(dummy_instance.reject_keys_from_hash(hash_node, :key1, :key3)).to eq "key2: 'value2', key4: 'value4'"
96
- end
97
- end
98
86
  end
99
87
  end
@@ -12,6 +12,22 @@ module Synvert::Core
12
12
  expect(rewriter.name).to eq 'name'
13
13
  end
14
14
 
15
+ it 'evals github url' do
16
+ expect(described_class).to receive(:remote_snippet_exists?).with(URI.parse('https://raw.githubusercontent.com/synvert-hq/synvert-snippets-ruby/main/lib/bundler/use_shortcut_git_source.rb')).and_return(true)
17
+ expect_any_instance_of(URI::HTTP).to receive(:open).and_return(StringIO.new("Rewriter.new 'group', 'name' do\nend"))
18
+ rewriter = described_class.eval_snippet('https://github.com/synvert-hq/synvert-snippets-ruby/blob/main/lib/bundler/use_shortcut_git_source.rb')
19
+ expect(rewriter.group).to eq 'group'
20
+ expect(rewriter.name).to eq 'name'
21
+ end
22
+
23
+ it 'evals gist url' do
24
+ expect(described_class).to receive(:remote_snippet_exists?).with(URI.parse('https://gist.githubusercontent.com/flyerhzm/6b868cf6cceba0e2fa253f1936acf1f6/raw')).and_return(true)
25
+ expect_any_instance_of(URI::HTTP).to receive(:open).and_return(StringIO.new("Rewriter.new 'group', 'name' do\nend"))
26
+ rewriter = described_class.eval_snippet('https://gist.github.com/flyerhzm/6b868cf6cceba0e2fa253f1936acf1f6')
27
+ expect(rewriter.group).to eq 'group'
28
+ expect(rewriter.name).to eq 'name'
29
+ end
30
+
15
31
  it 'raises error' do
16
32
  expect(described_class).to receive(:remote_snippet_exists?).and_return(false)
17
33
  expect do
@@ -23,10 +23,10 @@ Gem::Specification.new do |spec|
23
23
  spec.add_runtime_dependency "node_query", ">= 1.15.2"
24
24
  spec.add_runtime_dependency "node_mutation", ">= 1.24.4"
25
25
  spec.add_runtime_dependency "parser"
26
- spec.add_runtime_dependency "parser_node_ext", ">= 1.3.0"
26
+ spec.add_runtime_dependency "parser_node_ext", ">= 1.3.2"
27
27
  spec.add_runtime_dependency "syntax_tree"
28
- spec.add_runtime_dependency "syntax_tree_ext", ">= 0.8.1"
28
+ spec.add_runtime_dependency "syntax_tree_ext", ">= 0.8.2"
29
29
  spec.add_runtime_dependency "prism"
30
- spec.add_runtime_dependency "prism_ext", ">= 0.3.1"
30
+ spec.add_runtime_dependency "prism_ext", ">= 0.3.2"
31
31
  spec.add_runtime_dependency "parallel"
32
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synvert-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.35.2
4
+ version: 1.35.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-16 00:00:00.000000000 Z
11
+ date: 2024-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 1.3.0
75
+ version: 1.3.2
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 1.3.0
82
+ version: 1.3.2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: syntax_tree
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: 0.8.1
103
+ version: 0.8.2
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 0.8.1
110
+ version: 0.8.2
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: prism
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: 0.3.1
131
+ version: 0.3.2
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: 0.3.1
138
+ version: 0.3.2
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: parallel
141
141
  requirement: !ruby/object:Gem::Requirement