grpm 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b97c424687ed1929e1e67a1f0cc0034cbe669fa1
4
+ data.tar.gz: c7ae9be78b9d170cc0c59ee632a265f28ce3591f
5
+ SHA512:
6
+ metadata.gz: b9668b6fb20ee188e21bb8989f15f28bf9328a3673b9d83b39f880aca279fa07d55bb3ff36dce29c28c48ad8ddf0f8d6a884a59bcc321d14ba85e7723784d7d6
7
+ data.tar.gz: 79b299a3486059eb60c4830b71d667d4c3acc89ed6ba2f3840668db69447040b8d2d86b23ca60b0a3fe8ec922aa4db73e572f3d6c893334b7921bbdb24c08b5e
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in grpm.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,36 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ grpm (0.1.0)
5
+ gitlab
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ coderay (1.1.2)
11
+ gitlab (4.2.0)
12
+ httparty
13
+ terminal-table
14
+ httparty (0.15.6)
15
+ multi_xml (>= 0.5.2)
16
+ method_source (0.9.0)
17
+ multi_xml (0.6.0)
18
+ pry (0.11.3)
19
+ coderay (~> 1.1.0)
20
+ method_source (~> 0.9.0)
21
+ rake (10.5.0)
22
+ terminal-table (1.8.0)
23
+ unicode-display_width (~> 1.1, >= 1.1.1)
24
+ unicode-display_width (1.3.0)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ bundler (~> 1.16)
31
+ grpm!
32
+ pry
33
+ rake (~> 10.0)
34
+
35
+ BUNDLED WITH
36
+ 1.16.0
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Grpm
2
+
3
+ grpc proto 文件管理器, 用于管理内部的grpc版本
4
+
5
+ ## 安装
6
+
7
+ 在mac上面你需要运行以下命令进行安装, 其他系统需要先行安装ruby
8
+
9
+ ```shell
10
+ gem install grpm
11
+ ```
12
+
13
+ ## 使用
14
+
15
+ TODO: Write usage instructions here
16
+
17
+ ## Contributing
18
+
19
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mjason/grpm.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "grpm"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ deps:
2
+ - type: gitlab
3
+ url: https://git.xx.xx:xx/xx/auth.git
data/exe/grpm ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'grpm'
4
+ require 'yaml'
5
+
6
+ deps = YAML.load_file('./Grcfile.yml')['deps']
7
+
8
+ deps.each do |dep|
9
+ if dep['type'] == 'gitlab'
10
+ Grpm::Gitlab.new(dep['url']).install
11
+ end
12
+ end
data/grpm.gemspec ADDED
@@ -0,0 +1,31 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "grpm/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "grpm"
8
+ spec.version = Grpm::VERSION
9
+ spec.authors = ["mj"]
10
+ spec.email = ["tywf91@gmail.com"]
11
+
12
+ spec.summary = %q{grpc proto file manager}
13
+ spec.description = %q{grpc proto file manager}
14
+ spec.homepage = "https://github.com/mjason/grpm"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
+ f.match(%r{^(test|spec|features)/})
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+
27
+ spec.add_dependency "gitlab"
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.16"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ end
data/lib/grpm.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "grpm/version"
2
+ require "grpm/env"
3
+ require "grpm/gitlab"
4
+
5
+ module Grpm
6
+
7
+ end
data/lib/grpm/env.rb ADDED
@@ -0,0 +1,11 @@
1
+ require "yaml"
2
+
3
+ module Grpm
4
+ class Env
5
+ class << self
6
+ def info
7
+ @info ||= YAML.load_file("#{ENV['HOME']}/.grpm")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,61 @@
1
+ require 'gitlab'
2
+ require 'uri'
3
+ require 'yaml'
4
+ require 'fileutils'
5
+ require 'pathname'
6
+ require 'ostruct'
7
+
8
+ module Grpm
9
+ class Gitlab
10
+ attr_reader :project, :client
11
+
12
+ def initialize(repository, ref='master')
13
+ @info = parse_uri(repository)
14
+ @ref = ref
15
+
16
+ token = Env.info.select {|env|
17
+ env['host'] == @info.host
18
+ }.first['token']
19
+
20
+ @client = ::Gitlab.client(endpoint: @info.endpoint, private_token: token)
21
+ @project = @client.project(@info.project)
22
+ @id = @project.id
23
+ end
24
+
25
+ def parse_uri(repository)
26
+ uri = URI(repository)
27
+ path_args = uri.path.sub('.git', '').split('/')
28
+ uri.path = '/api/v4'
29
+
30
+ OpenStruct.new({
31
+ host: uri.host,
32
+ name: path_args.last,
33
+ endpoint: uri.to_s,
34
+ project: path_args.select { |e| e != "" }.join('/')
35
+ })
36
+ end
37
+
38
+ def package
39
+ @package ||= YAML.load @client.file_contents(@id, 'grpc.yml', @ref)
40
+ end
41
+
42
+ def install
43
+ package['deps'].map { |dep|
44
+ if dep[0] == '/'
45
+ dep
46
+ else
47
+ '/' + dep
48
+ end
49
+ }.each { |path|
50
+ dir = Pathname.new('./grpm').join(@info.name)
51
+ file_name = Pathname.new(path).basename.to_s
52
+ file = @client.file_contents(@id, path)
53
+
54
+ puts file_name
55
+
56
+ FileUtils.mkdir_p(dir)
57
+ File.write dir.join(file_name), file
58
+ }
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,3 @@
1
+ module Grpm
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: grpm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - mj
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-12-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gitlab
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: grpc proto file manager
56
+ email:
57
+ - tywf91@gmail.com
58
+ executables:
59
+ - grpm
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - example/Grcfile.yml
71
+ - exe/grpm
72
+ - grpm.gemspec
73
+ - lib/grpm.rb
74
+ - lib/grpm/env.rb
75
+ - lib/grpm/gitlab.rb
76
+ - lib/grpm/version.rb
77
+ homepage: https://github.com/mjason/grpm
78
+ licenses: []
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.6.14
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: grpc proto file manager
100
+ test_files: []