multichain 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0234d57073bac6f7b3f58e32f9a0364d1e1cb798
4
+ data.tar.gz: 912d714a79d55990883c25e14ba43165779e1e2d
5
+ SHA512:
6
+ metadata.gz: 757d4f3b949ab4b16280bd0d10995c6e8ef419e816eb6c1c519957b3e7bdabfb3e3f562d762ae235cabf7aae23b15fdf3b3e1f4c42bcb04b7d617495ccb5bd05
7
+ data.tar.gz: c208a76215fc824a1400284f3a7435abf028581f37f5e090c665bf6c5a4335b971e678b5e03a03aeeb2958c7395adaed4d178d2d938066c0edb0c09c839d8613
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ 2.3.0
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ cache: bundler
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in multichain.gemspec
4
+ gemspec
@@ -0,0 +1,23 @@
1
+ guard :rspec, cmd: 'bundle exec rspec' do
2
+ require 'guard/rspec/dsl'
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ # RSpec files
6
+ rspec = dsl.rspec
7
+ watch(rspec.spec_helper) { rspec.spec_dir }
8
+ watch(rspec.spec_support) { rspec.spec_dir }
9
+ watch(rspec.spec_files)
10
+
11
+ # Ruby files
12
+ ruby = dsl.ruby
13
+ dsl.watch_spec_files_for(ruby.lib_files)
14
+ end
15
+
16
+ guard 'cucumber' do
17
+ watch(%r{^features/.+\.feature$})
18
+ watch(%r{^features/support/.+$}) { 'features' }
19
+
20
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
21
+ Dir[File.join("**/#{m[1]}.feature")][0] || 'features'
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 pikesley
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,6 @@
1
+ [![Build Status](http://img.shields.io/travis/theodi/multichain-client.svg?style=flat-square)](https://travis-ci.org/theodi/multichain-client)
2
+ [![Dependency Status](http://img.shields.io/gemnasium/theodi/multichain-client.svg?style=flat-square)](https://gemnasium.com/theodi/multichain-client)
3
+ [![Coverage Status](http://img.shields.io/coveralls/theodi/multichain-client.svg?style=flat-square)](https://coveralls.io/r/theodi/multichain-client)
4
+ [![Code Climate](http://img.shields.io/codeclimate/github/theodi/multichain-client.svg?style=flat-square)](https://codeclimate.com/github/theodi/multichain-client)
5
+ [![Gem Version](http://img.shields.io/gem/v/multichain.svg?style=flat-square)](https://rubygems.org/gems/multichain)
6
+ [![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://theodi.mit-license.org)
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'coveralls/rake/task'
4
+ require 'cucumber/rake/task'
5
+
6
+ Coveralls::RakeTask.new
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ Cucumber::Rake::Task.new
9
+
10
+ task :default => [:spec, :cucumber, 'coveralls:push']
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "multichain"
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
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'multichain/cli'
4
+ Multichain::CLI.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,6 @@
1
+ require 'httparty'
2
+ require 'thor'
3
+
4
+ require 'multichain/cli'
5
+ require 'multichain/encoder'
6
+ require 'multichain/version'
@@ -0,0 +1,39 @@
1
+ require 'multichain'
2
+
3
+ module Multichain
4
+ class CLI < Thor
5
+ desc 'version', 'Print multichain version'
6
+ def version
7
+ puts "multichain version #{VERSION}"
8
+ end
9
+ map %w(-v --version) => :version
10
+
11
+ desc 'hexify URL', 'Prepare a hexified string for a URL'
12
+ def hexify url
13
+ puts Encoder.hexify url
14
+ end
15
+ map %w(--encode) => :hexify
16
+
17
+ desc 'dehexify hex', 'Dehexify a hexified string'
18
+ def dehexify hex
19
+ puts Encoder.dehexify hex
20
+ end
21
+ map %w(--decode) => :dehexify
22
+
23
+ desc 'verify hex', 'Verify that a hexified string still represents the same URL content'
24
+ def verify hex
25
+ url = Encoder.extract(Encoder.dehexify(hex))[:url]
26
+ v = Encoder.verify hex
27
+
28
+ case v
29
+ when true
30
+ puts "'#{url}' is verified"
31
+ exit 0
32
+
33
+ when false
34
+ puts "'#{url}' is not verified"
35
+ exit 1
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,65 @@
1
+ module Multichain
2
+ class Encoder
3
+ def self.headers
4
+ {
5
+ 'Accept' => 'application/json'
6
+ }
7
+ end
8
+
9
+ def self.sha256 url, headers = self.headers
10
+ body = Digest::SHA256.hexdigest(HTTParty.get(url, headers: headers).body)
11
+ end
12
+
13
+ def self.hash url, headers = self.headers
14
+ sha256 url, headers = self.headers
15
+ end
16
+
17
+ def self.input_string url, headers = self.headers
18
+ a = []
19
+ a.push Time.new.to_i
20
+ a.push url
21
+ a.push headers.to_json
22
+ a.push sha256(url)
23
+
24
+ a.join '|'
25
+ end
26
+
27
+ def self.extract input_string
28
+ parts = input_string.split '|'
29
+ keys = [
30
+ :timestamp,
31
+ :url,
32
+ :headers,
33
+ :hash
34
+ ]
35
+ h = {}
36
+
37
+ keys.each_with_index do |k, i|
38
+ h[k] = parts[i]
39
+ end
40
+
41
+ h
42
+ end
43
+
44
+ def self.hexify url, headers = self.headers
45
+ input_string(url).each_byte.map { |b| b.to_s(16) }.join
46
+ end
47
+
48
+ def self.encode url, headers = self.headers
49
+ hexify url, headers = self.headers
50
+ end
51
+
52
+ def self.dehexify hexified
53
+ hexified.scan(/../).map { |x| x.hex.chr }.join
54
+ end
55
+
56
+ def self.decode hexified
57
+ dehexify hexified
58
+ end
59
+
60
+ def self.verify hexified
61
+ parts = extract dehexify hexified
62
+ parts[:hash] == sha256(parts[:url])
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,3 @@
1
+ module Multichain
2
+ VERSION = "0.1.1"
3
+ end
@@ -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 'multichain/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'multichain'
8
+ spec.version = Multichain::VERSION
9
+ spec.authors = ['pikesley']
10
+ spec.email = ['ops@theodi.org']
11
+
12
+ spec.summary = 'multichain client'
13
+ spec.description = 'multichain client'
14
+ spec.homepage = 'http://github.com/theodi'
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
+
22
+ spec.add_dependency 'httparty', '~> 0.13'
23
+ spec.add_dependency 'thor', '~> 0.19'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.10'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'rspec', '~> 3.4'
28
+ spec.add_development_dependency 'vcr', '~> 3.0'
29
+ spec.add_development_dependency 'webmock', '~> 1.22'
30
+ spec.add_development_dependency 'coveralls', '~> 0.8'
31
+ spec.add_development_dependency 'timecop', '~> 0.8'
32
+ spec.add_development_dependency 'guard-rspec', '~> 4.6'
33
+ spec.add_development_dependency 'cucumber', '~> 2.1'
34
+ spec.add_development_dependency 'aruba', '~> 0.12'
35
+ spec.add_development_dependency 'guard', '~> 2.13'
36
+ spec.add_development_dependency 'guard-cucumber', '~> 2.0'
37
+ spec.add_development_dependency 'terminal-notifier-guard', '~> 1.6'
38
+ spec.add_development_dependency 'pry'
39
+ end
metadata ADDED
@@ -0,0 +1,285 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: multichain
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - pikesley
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.13'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.19'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.19'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.22'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.22'
111
+ - !ruby/object:Gem::Dependency
112
+ name: coveralls
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.8'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.8'
125
+ - !ruby/object:Gem::Dependency
126
+ name: timecop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.8'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.8'
139
+ - !ruby/object:Gem::Dependency
140
+ name: guard-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '4.6'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '4.6'
153
+ - !ruby/object:Gem::Dependency
154
+ name: cucumber
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '2.1'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '2.1'
167
+ - !ruby/object:Gem::Dependency
168
+ name: aruba
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.12'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0.12'
181
+ - !ruby/object:Gem::Dependency
182
+ name: guard
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '2.13'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '2.13'
195
+ - !ruby/object:Gem::Dependency
196
+ name: guard-cucumber
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '2.0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '2.0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: terminal-notifier-guard
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '1.6'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '1.6'
223
+ - !ruby/object:Gem::Dependency
224
+ name: pry
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ description: multichain client
238
+ email:
239
+ - ops@theodi.org
240
+ executables: []
241
+ extensions: []
242
+ extra_rdoc_files: []
243
+ files:
244
+ - ".gitignore"
245
+ - ".rspec"
246
+ - ".ruby-version"
247
+ - ".travis.yml"
248
+ - Gemfile
249
+ - Guardfile
250
+ - LICENSE.md
251
+ - README.md
252
+ - Rakefile
253
+ - bin/console
254
+ - bin/multichain
255
+ - bin/setup
256
+ - lib/multichain.rb
257
+ - lib/multichain/cli.rb
258
+ - lib/multichain/encoder.rb
259
+ - lib/multichain/version.rb
260
+ - multichain.gemspec
261
+ homepage: http://github.com/theodi
262
+ licenses:
263
+ - MIT
264
+ metadata: {}
265
+ post_install_message:
266
+ rdoc_options: []
267
+ require_paths:
268
+ - lib
269
+ required_ruby_version: !ruby/object:Gem::Requirement
270
+ requirements:
271
+ - - ">="
272
+ - !ruby/object:Gem::Version
273
+ version: '0'
274
+ required_rubygems_version: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - ">="
277
+ - !ruby/object:Gem::Version
278
+ version: '0'
279
+ requirements: []
280
+ rubyforge_project:
281
+ rubygems_version: 2.5.1
282
+ signing_key:
283
+ specification_version: 4
284
+ summary: multichain client
285
+ test_files: []