erhu 0.1.6 → 0.1.7

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: 67f03be8e9f501c9c5aeabb72e8c1c02b8af4071ae7202650b8eb613e7ef9d89
4
- data.tar.gz: 0b1e04f538c108856d3cce11f841bcf65e291a8f4ba27aa805717cf63ccdb0b0
3
+ metadata.gz: 5e2903daee3341d94783a9012d6d9296dbcbf7b641f6e341bfcb417eb7e2718b
4
+ data.tar.gz: 2fc00515e80deb9db2fe491f585769a5bf9ef2f631d7ae22442ed011a7635590
5
5
  SHA512:
6
- metadata.gz: d64097dfa0d355254252925da1d7353807a5e356662f99bf4152ecc80bfac2197c52f11bde20e603cb41244ace8aebb20465c7543ed2b6d885af94d77fb63a90
7
- data.tar.gz: 3ed530e799f073492f0f007a982a0e202a10f59356f798949633f8d7946514c6260da6e928d605026508c4a7eca18f3abfcba132d93822e7778cdd5e75d07b50
6
+ metadata.gz: e2d647367aaf493359d3fbbbd7f3a68c15f69fa7bb17b426e71641f8039cdb812445b7ff9724a0b5b52e34d26446a5ccffe93d1c9ede0507e891e1425db97cae
7
+ data.tar.gz: ec3105639a41b1409419797a505ff3f211d4d18362513425e3feee3cc9c5dc7209a5a326235d91375f8b191713b25f67f724e8cac595b233da0b4e188a8d0876
data/README.md CHANGED
@@ -7,8 +7,6 @@
7
7
  gem install erhu
8
8
  ```
9
9
 
10
- 注意:你的系统必须有cmake和pkg-config,mac用户可以用homebrew安装
11
-
12
10
  ## 如何使用
13
11
 
14
12
  在根目录里面建立`ErhuFile`, 当前也可以使用`erhu init`用于拉取依赖
@@ -24,4 +22,57 @@ package "https://github.com/DaveGamble/cJSON/archive/refs/tags/v1.7.15.zip", nam
24
22
 
25
23
  然后就在项目目录中使用 erhu 命令即可拉取对应的代码
26
24
 
27
- 示例项目可以看 example 目录
25
+ 示例项目可以看 demo 目录
26
+
27
+ ## 注意事项
28
+ 1. 请不要随便用git来做依赖管理
29
+ 2. package只支持zip压缩包,暂时没有计划做其他
30
+ 3. ErhuFile着色采用ruby编程语言即可,同时整个文件均可执行ruby脚本
31
+ 4. 判断系统安装对应的包,请看高级用法的系统判断
32
+ 5. 下载后可以有高级使用办法,比如进入里面继续cmake等等,具体请看高级用法的安装后处理
33
+
34
+ ## 高级用法
35
+
36
+ ### 系统判断
37
+
38
+ ```ruby
39
+ # platform.windows? # => false
40
+ # platform.unix? # => true
41
+ # platform.linux? # => false
42
+ # platform.mac? # => true
43
+ if platform.windows?
44
+ package "https://github.com/DaveGamble/cJSON/archive/refs/tags/v1.7.15.zip", name: "cjson"
45
+ end
46
+ ```
47
+
48
+ ### 安装后处理
49
+ > 警告一般不建议这么做,而是采用Rakefile的方式来做处理
50
+
51
+ ```ruby
52
+ # 方法定义 git(repository_url, branch: nil, name: nil, tag: nil, &block)
53
+ git "https://github.com/Tencent/rapidjson", tag: "v1.1.0" do |repo, env|
54
+ # repo 的接口请看 https://rubydoc.info/gems/git/Git/Base
55
+ # env 的接口请看 https://github.com/mjason/erhu/blob/main/lib/erhu/app.rb
56
+ # 还有一些高级接口 https://github.com/mjason/erhu/blob/main/lib/erhu/init.rb
57
+ end
58
+
59
+ # 方法定义 package(package_url, name: nil, &block)
60
+ package "https://github.com/DaveGamble/cJSON/archive/refs/tags/v1.7.15.zip", name: "cjson" do |package_file_path, env|
61
+ # package_file_path 下载包的地址,String类型,你得自己解压
62
+ # env 同上
63
+
64
+ # 解压示例
65
+ #
66
+ # zip_file_path: String类型,包含要解压缩的zip文件的路径
67
+ # target_directory: String类型,包含要提取zip文件的位置
68
+ #
69
+ # 该方法使用TTY::Spinner库来显示进度条,并通过调用Zip::File库中的方法来解压缩zip文件。
70
+ # 它迭代zip文件中的每个条目,并使用条目名称中的信息来构造目标路径。
71
+ unzip(package_file_path, "./libs/cjson")
72
+ end
73
+ ```
74
+
75
+ 具体使用案例,可以查看项目里的 demo 目录
76
+
77
+ ## 总结
78
+ 这是一个很灵活的包管理,希望你用的开心,开源协议MIT
@@ -0,0 +1,10 @@
1
+ cmake_minimum_required(VERSION 3.15)
2
+
3
+ project(Erhu)
4
+
5
+ add_executable(${PROJECT_NAME} main.cpp)
6
+
7
+ # 设置编译产物的输出目录
8
+ set_target_properties(${PROJECT_NAME} PROPERTIES
9
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/target"
10
+ )
data/demo/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/demo/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # gem "rails"
6
+ gem 'tty-platform'
7
+ gem "tty-command"
8
+ gem "tty-progressbar"
9
+ gem "tty-spinner"
10
+ gem "pry"
11
+
12
+ gem "pastel"
13
+ gem "rugged"
14
+
15
+ gem 'faraday'
16
+ gem 'faraday-follow_redirects'
17
+ gem 'rubyzip'
data/demo/Gemfile.lock ADDED
@@ -0,0 +1,52 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ coderay (1.1.3)
5
+ faraday (2.7.4)
6
+ faraday-net_http (>= 2.0, < 3.1)
7
+ ruby2_keywords (>= 0.0.4)
8
+ faraday-follow_redirects (0.3.0)
9
+ faraday (>= 1, < 3)
10
+ faraday-net_http (3.0.2)
11
+ method_source (1.0.0)
12
+ pastel (0.8.0)
13
+ tty-color (~> 0.5)
14
+ pry (0.14.2)
15
+ coderay (~> 1.1)
16
+ method_source (~> 1.0)
17
+ ruby2_keywords (0.0.5)
18
+ rubyzip (2.3.2)
19
+ rugged (1.6.2)
20
+ strings-ansi (0.2.0)
21
+ tty-color (0.6.0)
22
+ tty-command (0.10.1)
23
+ pastel (~> 0.8)
24
+ tty-cursor (0.7.1)
25
+ tty-platform (0.3.0)
26
+ tty-progressbar (0.18.2)
27
+ strings-ansi (~> 0.2)
28
+ tty-cursor (~> 0.7)
29
+ tty-screen (~> 0.8)
30
+ unicode-display_width (>= 1.6, < 3.0)
31
+ tty-screen (0.8.1)
32
+ tty-spinner (0.9.3)
33
+ tty-cursor (~> 0.7)
34
+ unicode-display_width (2.4.2)
35
+
36
+ PLATFORMS
37
+ arm64-darwin-22
38
+
39
+ DEPENDENCIES
40
+ faraday
41
+ faraday-follow_redirects
42
+ pastel
43
+ pry
44
+ rubyzip
45
+ rugged
46
+ tty-command
47
+ tty-platform
48
+ tty-progressbar
49
+ tty-spinner
50
+
51
+ BUNDLED WITH
52
+ 2.4.6
data/demo/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "erhu"
2
+
3
+ task :build do |t|
4
+ Cmd.new().chdir("./build")
5
+ .run("cmake", "..")
6
+ .run("make")
7
+ end
8
+
9
+ task run: [:build] do |t|
10
+ Cmd.new().chdir("./target").run("./Erhu")
11
+ end
data/demo/main.cpp ADDED
@@ -0,0 +1,8 @@
1
+ #include <iostream>
2
+
3
+ using namespace std;
4
+
5
+ int main(int argc, char* argv[]) {
6
+ cout << "使用erhu来做包管理是你的第一选择" << endl;
7
+ return 0;
8
+ }
data/lib/erhu/app.rb CHANGED
@@ -106,18 +106,7 @@ module Erhu
106
106
  end
107
107
 
108
108
  def zip(package_file_path, package_name)
109
- spinner = TTY::Spinner.new("[:spinner] extracted :title ...")
110
- spinner.auto_spin
111
-
112
- Zip::File.open(package_file_path) do |zip_file|
113
- zip_file.each do |entry|
114
- dest_path = File.join(@target, package_name, entry.name.split('/')[1..-1].join('/'))
115
- entry.extract(dest_path)
116
- spinner.update title: entry.name
117
- end
118
- end
119
- spinner.update title: "ALL"
120
- spinner.stop("Done!")
109
+ unzip(package_file_path, File.join(@target, package_name))
121
110
  end
122
111
 
123
112
  def run
data/lib/erhu/init.rb CHANGED
@@ -37,6 +37,21 @@ def warn!(*args)
37
37
  puts "Warning: #{warning.(*args)}"
38
38
  end
39
39
 
40
+ def unzip(zip_file_path, target_directory)
41
+ spinner = TTY::Spinner.new("[:spinner] extracted :title ...")
42
+ spinner.auto_spin
43
+
44
+ Zip::File.open(zip_file_path) do |zip_file|
45
+ zip_file.each do |entry|
46
+ dest_path = File.join(target_directory, entry.name.split('/')[1..-1].join('/'))
47
+ entry.extract(dest_path)
48
+ spinner.update title: entry.name
49
+ end
50
+ end
51
+ spinner.update title: "ALL"
52
+ spinner.stop("Done!")
53
+ end
54
+
40
55
  class Cmd
41
56
  def initialize(pty: true, uuid: false, color: true, printer: :pretty)
42
57
  @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.6"
4
+ VERSION = "0.1.7"
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.6
4
+ version: 0.1.7
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-25 00:00:00.000000000 Z
11
+ date: 2023-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-platform
@@ -160,6 +160,12 @@ files:
160
160
  - Gemfile.lock
161
161
  - README.md
162
162
  - Rakefile
163
+ - demo/CMakeLists.txt
164
+ - demo/ErhuFile
165
+ - demo/Gemfile
166
+ - demo/Gemfile.lock
167
+ - demo/Rakefile
168
+ - demo/main.cpp
163
169
  - erhu.gemspec
164
170
  - exe/erhu
165
171
  - lib/erhu.rb