cio_proto_cat 0.1.1
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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +41 -0
- data/Rakefile +10 -0
- data/bin/cio_proto_cat +7 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/cio_proto_cat.gemspec +39 -0
- data/lib/cio_proto_cat.rb +54 -0
- data/lib/cio_proto_cat/protobuffs/cat_pb.rb +34 -0
- data/lib/cio_proto_cat/protobuffs/cat_services_pb.rb +25 -0
- data/lib/cio_proto_cat/version.rb +3 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 53156dde98e0e071e5fb50f1ec3349dd64fb8a8c
|
4
|
+
data.tar.gz: f4b40b34d98c0ca12b3997401727ad690fd057e0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a764f7eadde539741acdd7b3eaae059b95a2541d9bc39949ae6eacd48db94bb5c7532f8a7ae6829e42cc5d33b86c995e015c5c6e0664dad710aeb8d953ac8ef7
|
7
|
+
data.tar.gz: 6bdd82b58471640c60cefbc1f2b84ee64f7c3e4109562194f44c2800975eb1d324274611084da94f1c5725c1f6ff43a27b5527805d92c7b363e77e97a186a88e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# CioProtoCat
|
2
|
+
## Installation
|
3
|
+
|
4
|
+
Add this line to your application's Gemfile:
|
5
|
+
|
6
|
+
```ruby
|
7
|
+
gem 'cio_proto_cat'
|
8
|
+
```
|
9
|
+
|
10
|
+
And then execute:
|
11
|
+
|
12
|
+
$ bundle
|
13
|
+
|
14
|
+
Or install it yourself as:
|
15
|
+
|
16
|
+
$ gem install cio_proto_cat
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
This gem has two main uses.
|
21
|
+
|
22
|
+
First is as a command line interface to the Cat server.
|
23
|
+
|
24
|
+
```
|
25
|
+
$ gem install cio_proto_cat
|
26
|
+
|
27
|
+
$ cio_proto_cat --method=list
|
28
|
+
>[<Cat: id: 1, name: "Kumo", color: "Gray">, <Cat: id: 2, name: "Meowzers", color: "Tortoise">]
|
29
|
+
```
|
30
|
+
|
31
|
+
Secondly to be used in a Ruby script or Rails app.
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
gem 'cio_proto_cat'
|
35
|
+
|
36
|
+
proto = CioProtoCat::Proto.new
|
37
|
+
|
38
|
+
proto.list_cats
|
39
|
+
[<Cat: id: 1, name: "Kumo", color: "Gray">, <Cat: id: 2, name: "Meowzers", color: "Tortoise">]
|
40
|
+
```
|
41
|
+
|
data/Rakefile
ADDED
data/bin/cio_proto_cat
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "cio_proto_cat"
|
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 "pry"
|
14
|
+
Pry.start
|
data/bin/setup
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cio_proto_cat/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cio_proto_cat"
|
8
|
+
spec.version = CioProtoCat::VERSION
|
9
|
+
spec.authors = ["Dane Carmichael"]
|
10
|
+
spec.email = ["carmichaeldane@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{CIO proto test}
|
13
|
+
spec.description = %q{CIO Proto test}
|
14
|
+
spec.homepage = "https://github.com/contextio"
|
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
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
"public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = "bin"
|
29
|
+
spec.executables = ["cio_proto_cat"]
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
35
|
+
spec.add_development_dependency "pry"
|
36
|
+
|
37
|
+
spec.add_dependency "grpc"
|
38
|
+
spec.add_dependency "google"
|
39
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "cio_proto_cat/version"
|
2
|
+
require_relative "./cio_proto_cat/protobuffs/cat_services_pb.rb"
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
module CioProtoCat
|
6
|
+
class Proto
|
7
|
+
STUB = CatService::Stub.new("cats.codes-sandbox.com:50051", :this_channel_is_insecure)
|
8
|
+
|
9
|
+
def boop_snoots
|
10
|
+
options = {}
|
11
|
+
OptionParser.new do |opt|
|
12
|
+
opt.on('--method METHOD') { |o| options[:method] = o }
|
13
|
+
opt.on('--name NAME') { |o| options[:name] = o }
|
14
|
+
opt.on('--color COLOR') { |o| options[:color] = o }
|
15
|
+
end.parse!
|
16
|
+
|
17
|
+
case options.fetch(:method, "").downcase
|
18
|
+
when "get"
|
19
|
+
fetch_cat(command_line: true, name: options[:name])
|
20
|
+
when "list"
|
21
|
+
list_cats(command_line: true)
|
22
|
+
when "new"
|
23
|
+
create_cat(command_line: true,
|
24
|
+
name: options[:name],
|
25
|
+
color: options[:color])
|
26
|
+
else
|
27
|
+
puts "Invalid method"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def fetch_cat(command_line: false, name:)
|
32
|
+
cat_request = GetCatRequest.new(name: name)
|
33
|
+
cat = STUB.get_cat(cat_request)
|
34
|
+
command_line ? inspect_for_command_line(cat): cat
|
35
|
+
end
|
36
|
+
|
37
|
+
def list_cats(command_line: false)
|
38
|
+
list_request = CatListRequest.new
|
39
|
+
cats = STUB.get_cat_list(list_request).cats
|
40
|
+
command_line ? inspect_for_command_line(cats): cats
|
41
|
+
end
|
42
|
+
|
43
|
+
def create_cat(command_line: false, name:, color:)
|
44
|
+
new_cat = NewCatRequest.new(name: name, color: color)
|
45
|
+
cat = STUB.new_cat(new_cat)
|
46
|
+
command_line ? inspect_for_command_line(cat): cat
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def inspect_for_command_line(obj)
|
51
|
+
puts obj.inspect
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: cat.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
7
|
+
add_message "Cat" do
|
8
|
+
optional :id, :int32, 1
|
9
|
+
optional :name, :string, 2
|
10
|
+
optional :color, :string, 3
|
11
|
+
end
|
12
|
+
add_message "CatList" do
|
13
|
+
repeated :cats, :message, 1, "Cat"
|
14
|
+
end
|
15
|
+
add_message "NewCatRequest" do
|
16
|
+
optional :name, :string, 1
|
17
|
+
optional :color, :string, 2
|
18
|
+
end
|
19
|
+
add_message "GetCatRequest" do
|
20
|
+
optional :name, :string, 1
|
21
|
+
end
|
22
|
+
add_message "DeleteCatRequest" do
|
23
|
+
optional :name, :string, 1
|
24
|
+
end
|
25
|
+
add_message "CatListRequest" do
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Cat = Google::Protobuf::DescriptorPool.generated_pool.lookup("Cat").msgclass
|
30
|
+
CatList = Google::Protobuf::DescriptorPool.generated_pool.lookup("CatList").msgclass
|
31
|
+
NewCatRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("NewCatRequest").msgclass
|
32
|
+
GetCatRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("GetCatRequest").msgclass
|
33
|
+
DeleteCatRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("DeleteCatRequest").msgclass
|
34
|
+
CatListRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("CatListRequest").msgclass
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# Source: cat.proto for package ''
|
3
|
+
|
4
|
+
require 'grpc'
|
5
|
+
require_relative 'cat_pb'
|
6
|
+
|
7
|
+
module CioProtoCat
|
8
|
+
module CatService
|
9
|
+
class Service
|
10
|
+
|
11
|
+
include GRPC::GenericService
|
12
|
+
|
13
|
+
self.marshal_class_method = :encode
|
14
|
+
self.unmarshal_class_method = :decode
|
15
|
+
self.service_name = 'CatService'
|
16
|
+
|
17
|
+
rpc :NewCat, NewCatRequest, Cat
|
18
|
+
rpc :GetCat, GetCatRequest, Cat
|
19
|
+
rpc :DeleteCat, DeleteCatRequest, Cat
|
20
|
+
rpc :GetCatList, CatListRequest, CatList
|
21
|
+
end
|
22
|
+
|
23
|
+
Stub = Service.rpc_stub_class
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cio_proto_cat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dane Carmichael
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: grpc
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: google
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: CIO Proto test
|
98
|
+
email:
|
99
|
+
- carmichaeldane@gmail.com
|
100
|
+
executables:
|
101
|
+
- cio_proto_cat
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".travis.yml"
|
108
|
+
- Gemfile
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/cio_proto_cat
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
114
|
+
- cio_proto_cat.gemspec
|
115
|
+
- lib/cio_proto_cat.rb
|
116
|
+
- lib/cio_proto_cat/protobuffs/cat_pb.rb
|
117
|
+
- lib/cio_proto_cat/protobuffs/cat_services_pb.rb
|
118
|
+
- lib/cio_proto_cat/version.rb
|
119
|
+
homepage: https://github.com/contextio
|
120
|
+
licenses: []
|
121
|
+
metadata:
|
122
|
+
allowed_push_host: https://rubygems.org
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.5.1
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: CIO proto test
|
143
|
+
test_files: []
|