erhu 0.1.6 → 0.1.7
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 +4 -4
 - data/README.md +54 -3
 - data/demo/CMakeLists.txt +10 -0
 - data/demo/ErhuFile +3 -0
 - data/demo/Gemfile +17 -0
 - data/demo/Gemfile.lock +52 -0
 - data/demo/Rakefile +11 -0
 - data/demo/main.cpp +8 -0
 - data/lib/erhu/app.rb +1 -12
 - data/lib/erhu/init.rb +15 -0
 - data/lib/erhu/version.rb +1 -1
 - metadata +8 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 5e2903daee3341d94783a9012d6d9296dbcbf7b641f6e341bfcb417eb7e2718b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 2fc00515e80deb9db2fe491f585769a5bf9ef2f631d7ae22442ed011a7635590
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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 
     | 
    
         
            -
            示例项目可以看  
     | 
| 
      
 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
         
     | 
    
        data/demo/CMakeLists.txt
    ADDED
    
    
    
        data/demo/ErhuFile
    ADDED
    
    
    
        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
    
    
    
        data/demo/main.cpp
    ADDED
    
    
    
        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 
     | 
    
         
            -
                   
     | 
| 
       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
    
    
    
        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. 
     | 
| 
      
 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- 
     | 
| 
      
 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
         
     |