erhu 0.1.7 → 0.1.8

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: 5e2903daee3341d94783a9012d6d9296dbcbf7b641f6e341bfcb417eb7e2718b
4
- data.tar.gz: 2fc00515e80deb9db2fe491f585769a5bf9ef2f631d7ae22442ed011a7635590
3
+ metadata.gz: aece6b3c18dbb9b1584bc2d2adb64afe0ba93c39a724260309eb9bba98d77ce7
4
+ data.tar.gz: e8f1179dfebb0dbcb879b52f345195834be61ffa91c86ffbe476c14e1bd5c23c
5
5
  SHA512:
6
- metadata.gz: e2d647367aaf493359d3fbbbd7f3a68c15f69fa7bb17b426e71641f8039cdb812445b7ff9724a0b5b52e34d26446a5ccffe93d1c9ede0507e891e1425db97cae
7
- data.tar.gz: ec3105639a41b1409419797a505ff3f211d4d18362513425e3feee3cc9c5dc7209a5a326235d91375f8b191713b25f67f724e8cac595b233da0b4e188a8d0876
6
+ metadata.gz: 0c435ed69d9ad03f55d1d25eefd24330993a39bc1507129f26e1dbfe2bc6b1e9a67154eaa5aa8d822d25aff97e4bcfdfba6b4abe0cf025d6276326ca7b68c7a0
7
+ data.tar.gz: 01224f69ceeb3ceb76ce7b959e5e57568b56dea97184e4980016c447ddd12ae7cb1f98892e7e6dcdf2b7cfcd56fd86f801d4d5099917692ced6bcc2e519a3e41
data/ErhuFile ADDED
@@ -0,0 +1,3 @@
1
+ target "./thirdparty"
2
+ # git "https://github.com/Tencent/rapidjson", tag: "v1.1.0"
3
+ package "https://github.com/DaveGamble/cJSON/archive/refs/tags/v1.7.15.zip", name: "cjson"
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- erhu (0.1.4)
5
- faraday (~> 2.7, >= 2.7.4)
6
- faraday-follow_redirects (~> 0.3.0)
4
+ erhu (0.1.7)
5
+ down (~> 5.0)
7
6
  git (~> 1.18)
7
+ http (~> 5.0)
8
8
  pastel (~> 0.8.0)
9
9
  rubyzip (~> 2.3, >= 2.3.2)
10
10
  tty-command (~> 0.10.1)
@@ -17,26 +17,33 @@ GEM
17
17
  specs:
18
18
  addressable (2.8.1)
19
19
  public_suffix (>= 2.0.2, < 6.0)
20
- coderay (1.1.3)
21
- faraday (2.7.4)
22
- faraday-net_http (>= 2.0, < 3.1)
23
- ruby2_keywords (>= 0.0.4)
24
- faraday-follow_redirects (0.3.0)
25
- faraday (>= 1, < 3)
26
- faraday-net_http (3.0.2)
20
+ domain_name (0.5.20190701)
21
+ unf (>= 0.0.5, < 1.0.0)
22
+ down (5.4.0)
23
+ addressable (~> 2.8)
24
+ ffi (1.15.5)
25
+ ffi-compiler (1.0.1)
26
+ ffi (>= 1.0.0)
27
+ rake
27
28
  git (1.18.0)
28
29
  addressable (~> 2.8)
29
30
  rchardet (~> 1.8)
30
- method_source (1.0.0)
31
+ http (5.1.1)
32
+ addressable (~> 2.8)
33
+ http-cookie (~> 1.0)
34
+ http-form_data (~> 2.2)
35
+ llhttp-ffi (~> 0.4.0)
36
+ http-cookie (1.0.5)
37
+ domain_name (~> 0.5)
38
+ http-form_data (2.3.0)
39
+ llhttp-ffi (0.4.0)
40
+ ffi-compiler (~> 1.0)
41
+ rake (~> 13.0)
31
42
  pastel (0.8.0)
32
43
  tty-color (~> 0.5)
33
- pry (0.14.2)
34
- coderay (~> 1.1)
35
- method_source (~> 1.0)
36
44
  public_suffix (5.0.1)
37
45
  rake (13.0.6)
38
46
  rchardet (1.8.0)
39
- ruby2_keywords (0.0.5)
40
47
  rubyzip (2.3.2)
41
48
  strings-ansi (0.2.0)
42
49
  tty-color (0.6.0)
@@ -52,6 +59,9 @@ GEM
52
59
  tty-screen (0.8.1)
53
60
  tty-spinner (0.9.3)
54
61
  tty-cursor (~> 0.7)
62
+ unf (0.1.4)
63
+ unf_ext
64
+ unf_ext (0.0.8.2)
55
65
  unicode-display_width (2.4.2)
56
66
 
57
67
  PLATFORMS
@@ -61,7 +71,6 @@ PLATFORMS
61
71
 
62
72
  DEPENDENCIES
63
73
  erhu!
64
- pry
65
74
  rake (~> 13.0)
66
75
 
67
76
  BUNDLED WITH
data/erhu.gemspec CHANGED
@@ -36,8 +36,8 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency 'tty-spinner', '~> 0.9.3'
37
37
  spec.add_dependency 'pastel', '~> 0.8.0'
38
38
  spec.add_dependency 'git', '~> 1.18'
39
- spec.add_dependency 'faraday', '~> 2.7', '>= 2.7.4'
40
- spec.add_dependency 'faraday-follow_redirects', '~> 0.3.0'
39
+ spec.add_dependency "down", "~> 5.0"
40
+ spec.add_dependency "http", "~> 5.0"
41
41
  spec.add_dependency 'rubyzip', '~> 2.3', '>= 2.3.2'
42
42
 
43
43
  # Uncomment to register a new dependency of your gem
data/lib/erhu/app.rb CHANGED
@@ -2,17 +2,17 @@ module Erhu
2
2
  class App
3
3
  attr_accessor :erhufile
4
4
  def initialize(erhufile_path=nil)
5
- @erhufile = erhufile_path || File.join(Dir.pwd, "erhuFile")
5
+ @erhufile = erhufile_path || File.join(Dir.pwd, "ErhuFile")
6
6
 
7
7
  @erhu_path = File.join(Dir.pwd, ".erhu")
8
8
  unless Dir.exist?(@erhu_path)
9
9
  FileUtils.mkdir_p(@erhu_path)
10
10
  puts "Created #{@erhu_path}"
11
- end
11
+ end
12
12
  @database_path = File.join(@erhu_path, "database.yml")
13
13
  end
14
14
 
15
- def database
15
+ def database
16
16
  if File.exist?(@database_path)
17
17
  @database ||= YAML.load_file(@database_path) || {}
18
18
  else
@@ -77,25 +77,19 @@ module Erhu
77
77
  return
78
78
  end
79
79
 
80
- conn = Faraday.new do |faraday|
81
- faraday.use Faraday::FollowRedirects::Middleware
82
- faraday.adapter Faraday.default_adapter
83
- end
84
-
85
- bar = TTY::ProgressBar.new("Downloading #{package_name} [:bar] :percent", total: 50, interval: 0.1)
86
-
87
- streamed = []
88
- response = conn.get(package_url) do |req|
89
- req.options.on_data = Proc.new do |chunk, overall_received_bytes, env|
90
- content_length = env.response_headers["content-length"]&.to_f
91
- bar.ratio = overall_received_bytes / content_length if !content_length.blank? && content_length > 0
92
- streamed << chunk
93
- end
94
- end
95
-
96
- File.open(package_file_path, 'w') do |f|
97
- f.write(streamed.join)
98
- end
80
+ bar = TTY::ProgressBar.new("downloading #{package_name} :percent [:bar]", total: 50)
81
+ total_size = 0
82
+
83
+ http.download package_url, destination: package_file_path,
84
+ content_length_proc: -> (content_length) {
85
+ total_size = content_length
86
+ },
87
+ progress_proc: -> (progress) {
88
+ if total_size > 0
89
+ bar.ratio = progress / total_size.to_f
90
+ end
91
+ }
92
+ bar.finish
99
93
 
100
94
  unless block.blank?
101
95
  block.call(package_file_path, self)
data/lib/erhu/init.rb CHANGED
@@ -6,12 +6,11 @@ require "pastel"
6
6
  require 'fileutils'
7
7
  require "uri"
8
8
  require 'yaml'
9
- require 'faraday'
10
- require 'faraday/follow_redirects'
11
9
  require 'tempfile'
12
10
  require 'zip'
13
11
  require 'git'
14
12
  require 'optparse'
13
+ require "down/http"
15
14
 
16
15
  class Object
17
16
  def blank?
@@ -52,6 +51,10 @@ def unzip(zip_file_path, target_directory)
52
51
  spinner.stop("Done!")
53
52
  end
54
53
 
54
+ def http
55
+ http = Down::Http.new
56
+ end
57
+
55
58
  class Cmd
56
59
  def initialize(pty: true, uuid: false, color: true, printer: :pretty)
57
60
  @cmd = TTY::Command.new(pty: pty, uuid: uuid, color: color, pretty: printer)
data/lib/erhu/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Erhu
4
- VERSION = "0.1.7"
4
+ VERSION = "0.1.8"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erhu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - MJ
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-28 00:00:00.000000000 Z
11
+ date: 2023-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-platform
@@ -95,39 +95,33 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.18'
97
97
  - !ruby/object:Gem::Dependency
98
- name: faraday
98
+ name: down
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '2.7'
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- version: 2.7.4
103
+ version: '5.0'
107
104
  type: :runtime
108
105
  prerelease: false
109
106
  version_requirements: !ruby/object:Gem::Requirement
110
107
  requirements:
111
108
  - - "~>"
112
109
  - !ruby/object:Gem::Version
113
- version: '2.7'
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: 2.7.4
110
+ version: '5.0'
117
111
  - !ruby/object:Gem::Dependency
118
- name: faraday-follow_redirects
112
+ name: http
119
113
  requirement: !ruby/object:Gem::Requirement
120
114
  requirements:
121
115
  - - "~>"
122
116
  - !ruby/object:Gem::Version
123
- version: 0.3.0
117
+ version: '5.0'
124
118
  type: :runtime
125
119
  prerelease: false
126
120
  version_requirements: !ruby/object:Gem::Requirement
127
121
  requirements:
128
122
  - - "~>"
129
123
  - !ruby/object:Gem::Version
130
- version: 0.3.0
124
+ version: '5.0'
131
125
  - !ruby/object:Gem::Dependency
132
126
  name: rubyzip
133
127
  requirement: !ruby/object:Gem::Requirement
@@ -156,6 +150,7 @@ executables:
156
150
  extensions: []
157
151
  extra_rdoc_files: []
158
152
  files:
153
+ - ErhuFile
159
154
  - Gemfile
160
155
  - Gemfile.lock
161
156
  - README.md