synvert 1.1.1 → 1.1.2
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/Gemfile.lock +1 -1
- data/lib/synvert/cli.rb +1 -1
- data/lib/synvert/utils.rb +18 -0
- data/lib/synvert/version.rb +1 -1
- data/lib/synvert.rb +1 -0
- data/spec/synvert/snippet_spec.rb +1 -1
- data/spec/synvert/utils_spec.rb +15 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d1c0fbeb63275ae605f0b709a33ee2b0cae147e503d775316f4aac6fb613d98
|
4
|
+
data.tar.gz: d971eaab50b37a77e7b2949bd65e764a1011424da5ecd7b6cae9f74a1e27c7d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b7f15432a9f4e5da206c155df3129d1b583c23098b506cd34b3ba82f6aab96504671600a2c64510e199ddd67a5a00c060f3b774bd4b24b3eec8335c86128c78
|
7
|
+
data.tar.gz: 294a5b5ee299a9e7702a4f0b17d883ddc253d5a8978c609f12d2246ae67489ab7442d1536d34961aec586c58e540537f2c9750d2cb01884c781841d4893ceb1a
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/synvert/cli.rb
CHANGED
@@ -238,7 +238,7 @@ module Synvert
|
|
238
238
|
# or from local path or http url.
|
239
239
|
def eval_snippet(snippet_name)
|
240
240
|
if /^http/.match?(snippet_name)
|
241
|
-
uri = URI.parse(snippet_name)
|
241
|
+
uri = URI.parse(Utils.format_url(snippet_name))
|
242
242
|
eval(uri.open.read)
|
243
243
|
elsif File.exists?(snippet_name)
|
244
244
|
eval(File.read(snippet_name))
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Synvert
|
2
|
+
module Utils
|
3
|
+
class << self
|
4
|
+
def format_url(url)
|
5
|
+
convert_to_github_raw_url(url)
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def convert_to_github_raw_url(url)
|
11
|
+
if url.include?('//github.com/')
|
12
|
+
url = url.sub('//github.com/', '//raw.githubusercontent.com/').sub('/blob/', '/')
|
13
|
+
end
|
14
|
+
url
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/synvert/version.rb
CHANGED
data/lib/synvert.rb
CHANGED
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
module Synvert
|
6
6
|
describe Snippet do
|
7
|
-
let(:snippets_path) { File.join(File.dirname(__FILE__), '.synvert') }
|
7
|
+
let(:snippets_path) { File.join(File.dirname(__FILE__), '.synvert-ruby') }
|
8
8
|
let(:snippet) { Snippet.new(snippets_path) }
|
9
9
|
after { FileUtils.rmdir(snippets_path) if File.exist?(snippets_path) }
|
10
10
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module Synvert
|
6
|
+
RSpec.describe Utils do
|
7
|
+
describe '.format_url' do
|
8
|
+
it 'converts github url to github raw url' do
|
9
|
+
url = 'https://github.com/xinminlabs/synvert-snippets-ruby/blob/main/lib/ruby/map_and_flatten_to_flat_map.rb'
|
10
|
+
raw_url = 'https://raw.githubusercontent.com/xinminlabs/synvert-snippets-ruby/main/lib/ruby/map_and_flatten_to_flat_map.rb'
|
11
|
+
expect(described_class.format_url(url)).to eq raw_url
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
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: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: synvert-core
|
@@ -103,9 +103,11 @@ files:
|
|
103
103
|
- lib/synvert.rb
|
104
104
|
- lib/synvert/cli.rb
|
105
105
|
- lib/synvert/snippet.rb
|
106
|
+
- lib/synvert/utils.rb
|
106
107
|
- lib/synvert/version.rb
|
107
108
|
- spec/spec_helper.rb
|
108
109
|
- spec/synvert/snippet_spec.rb
|
110
|
+
- spec/synvert/utils_spec.rb
|
109
111
|
- synvert-ruby.gemspec
|
110
112
|
homepage: https://github.com/xinminlabs/synvert-ruby
|
111
113
|
licenses:
|
@@ -133,3 +135,4 @@ summary: synvert = syntax + convert.
|
|
133
135
|
test_files:
|
134
136
|
- spec/spec_helper.rb
|
135
137
|
- spec/synvert/snippet_spec.rb
|
138
|
+
- spec/synvert/utils_spec.rb
|