stampery 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +62 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/example.rb +21 -0
- data/lib/stampery.rb +71 -0
- data/lib/stampery/version.rb +3 -0
- data/stampery.gemspec +30 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1d6d7fb6dab761a2e8ef8a1a93485454d89983f7
|
4
|
+
data.tar.gz: 4bf70d933b25fb4c2bd9ca481b72f7db4aefa6cd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8301150d83b42c6c292d14f4daf3d8dd3debc6fd53fb9a5797ef10200b06f508c67df051d1ce24226005287ad6121e4c6c80488c0bec3b8308dd6974c2917bff
|
7
|
+
data.tar.gz: 5a640db7edb6826ad7d0c1a34ed825e95e7ba0529584bc6e9d539d65383ffdd3d617f7995263ffe52c7c1a98d281fb1691ee354fbe33f7aa0f10996b2aa2bd5f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Stampery
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Stampery
|
2
|
+
Stampery API for Ruby. Notarize all your data using the blockchain!
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'stampery'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install stampery
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
require 'stampery'
|
23
|
+
|
24
|
+
stampery = Client.new '2d4cdee7-38b0-4a66-da87-c1ab05b43768', 'prod'
|
25
|
+
|
26
|
+
stampery.on :proof do |hash, proof|
|
27
|
+
puts 'Received proof for'
|
28
|
+
puts hash
|
29
|
+
puts 'Proof'
|
30
|
+
puts proof.to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
stampery.on :error do |err|
|
34
|
+
puts "Woot: #{err}"
|
35
|
+
end
|
36
|
+
|
37
|
+
stampery.on :ready do
|
38
|
+
digest = stampery.hash 'Hello, blockchain!'
|
39
|
+
stampery.stamp digest
|
40
|
+
end
|
41
|
+
|
42
|
+
stampery.start
|
43
|
+
|
44
|
+
|
45
|
+
# Official implementations
|
46
|
+
- [NodeJS](https://github.com/stampery/node)
|
47
|
+
- [PHP](https://github.com/stampery/php)
|
48
|
+
- [Ruby](https://github.com/stampery/ruby)
|
49
|
+
- [Python](https://github.com/stampery/python)
|
50
|
+
- [Elixir](https://github.com/stampery/elixir)
|
51
|
+
|
52
|
+
# Feedback
|
53
|
+
|
54
|
+
Ping us at support@stampery.com and we’ll help you! 😃
|
55
|
+
|
56
|
+
|
57
|
+
## License
|
58
|
+
|
59
|
+
Code released under
|
60
|
+
[the MIT license](https://github.com/stampery/js/blob/master/LICENSE).
|
61
|
+
|
62
|
+
Copyright 2016 Stampery
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "stampery"
|
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
|
data/bin/setup
ADDED
data/lib/example.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'stampery'
|
2
|
+
|
3
|
+
stampery = Client.new '2d4cdee7-38b0-4a66-da87-c1ab05b43768', 'prod'
|
4
|
+
|
5
|
+
stampery.on :proof do |hash, proof|
|
6
|
+
puts 'Received proof for'
|
7
|
+
puts hash
|
8
|
+
puts 'Proof'
|
9
|
+
puts proof.to_s
|
10
|
+
end
|
11
|
+
|
12
|
+
stampery.on :error do |err|
|
13
|
+
puts "Woot: #{err}"
|
14
|
+
end
|
15
|
+
|
16
|
+
stampery.on :ready do
|
17
|
+
digest = stampery.hash 'Hello, blockchain!'
|
18
|
+
stampery.stamp digest
|
19
|
+
end
|
20
|
+
|
21
|
+
stampery.start
|
data/lib/stampery.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'stampery/version'
|
2
|
+
require 'bunny'
|
3
|
+
require 'digest/md5'
|
4
|
+
require 'sha3'
|
5
|
+
require 'msgpack/rpc'
|
6
|
+
require 'event_emitter'
|
7
|
+
|
8
|
+
class Client
|
9
|
+
include EventEmitter
|
10
|
+
@@api_end_points = { 'prod' => ['api.stampery.com', 4000],
|
11
|
+
'beta' => ['api-beta.stampery.com', 4000] }
|
12
|
+
@@amqp_end_points = { 'prod' => ['young-squirrel.rmq.cloudamqp.com', 5672, 'consumer', '9FBln3UxOgwgLZtYvResNXE7', 'ukgmnhoi'],
|
13
|
+
'beta' => ['young-squirrel.rmq.cloudamqp.com', 5672, 'consumer', '9FBln3UxOgwgLZtYvResNXE7', 'beta'] }
|
14
|
+
|
15
|
+
def initialize secret, branch = 'prod'
|
16
|
+
@client_secret = secret
|
17
|
+
@client_id = Digest::MD5.hexdigest(secret)[0, 15]
|
18
|
+
@api_end_point = @@api_end_points[branch] || @@api_end_points['prod']
|
19
|
+
@amqp_end_point = @@amqp_end_points[branch] || @@amqp_end_points['prod']
|
20
|
+
end
|
21
|
+
|
22
|
+
def start
|
23
|
+
api_login @api_end_point
|
24
|
+
amqp_login @amqp_end_point
|
25
|
+
end
|
26
|
+
|
27
|
+
def stamp data
|
28
|
+
puts "Stamping \n#{data}"
|
29
|
+
begin
|
30
|
+
@api_client.call 'stamp', data.upcase
|
31
|
+
rescue Exception => e
|
32
|
+
emit :error, e
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def hash data
|
37
|
+
SHA3::Digest.hexdigest(:sha512, data).upcase
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def api_login end_point
|
43
|
+
@api_client = MessagePack::RPC::Client.new(end_point[0], end_point[1])
|
44
|
+
req = @api_client.call_async('stampery.3.auth', @client_id, @client_secret)
|
45
|
+
req.join
|
46
|
+
@auth = req.result
|
47
|
+
puts "logged #{@client_id}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def amqp_login end_point
|
51
|
+
amqp_conn = Bunny.new(automatically_recover: true, host: end_point[0],
|
52
|
+
port: end_point[1], user: end_point[2],
|
53
|
+
pass: end_point[3], vhost: end_point[4])
|
54
|
+
amqp_conn.start
|
55
|
+
puts '[QUEUE] Connected to Rabbit!'
|
56
|
+
emit :ready
|
57
|
+
|
58
|
+
amqp_channel = amqp_conn.create_channel
|
59
|
+
|
60
|
+
queue = amqp_channel.queue(@client_id + '-clnt', no_declare: true)
|
61
|
+
begin
|
62
|
+
queue.subscribe(block: true) do |delivery_info, _metadata, queueMsg|
|
63
|
+
hash = delivery_info.routing_key
|
64
|
+
proof = MessagePack.unpack queueMsg
|
65
|
+
emit :proof, hash, proof
|
66
|
+
end
|
67
|
+
rescue Exception => _
|
68
|
+
puts "\n\nClosing the client"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/stampery.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'stampery/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "stampery"
|
8
|
+
spec.version = "0.1.0"
|
9
|
+
spec.authors = ["Johann Ortiz"]
|
10
|
+
spec.email = ["johann@stampery.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Stampery API for Ruby}
|
13
|
+
spec.description = %q{Notarize all your data using the blockchain!.}
|
14
|
+
spec.homepage = "https://github.com/stampery/ruby"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
spec.required_ruby_version = ">= 2.0"
|
22
|
+
|
23
|
+
spec.add_dependency "sha3", "~> 1.0", ">= 1.0.1"
|
24
|
+
spec.add_dependency "msgpack-rpc", "~> 0.5.4"
|
25
|
+
spec.add_dependency "bunny", ">= 2.2.2"
|
26
|
+
spec.add_dependency "event_emitter", "~> 0.2.5"
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stampery
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Johann Ortiz
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sha3
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: msgpack-rpc
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.5.4
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.5.4
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bunny
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.2.2
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 2.2.2
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: event_emitter
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.2.5
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.2.5
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: bundler
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.12'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.12'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rake
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '10.0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '10.0'
|
103
|
+
description: Notarize all your data using the blockchain!.
|
104
|
+
email:
|
105
|
+
- johann@stampery.com
|
106
|
+
executables: []
|
107
|
+
extensions: []
|
108
|
+
extra_rdoc_files: []
|
109
|
+
files:
|
110
|
+
- ".gitignore"
|
111
|
+
- Gemfile
|
112
|
+
- LICENSE.txt
|
113
|
+
- README.md
|
114
|
+
- Rakefile
|
115
|
+
- bin/console
|
116
|
+
- bin/setup
|
117
|
+
- lib/example.rb
|
118
|
+
- lib/stampery.rb
|
119
|
+
- lib/stampery/version.rb
|
120
|
+
- stampery.gemspec
|
121
|
+
homepage: https://github.com/stampery/ruby
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '2.0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.5.1
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: Stampery API for Ruby
|
145
|
+
test_files: []
|