hotbits 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.guardrc +1 -0
- data/.irbrc +1 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +13 -0
- data/Guardfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +42 -0
- data/Rakefile +1 -0
- data/hotbits.gemspec +23 -0
- data/lib/hotbits.rb +23 -0
- data/lib/hotbits/version.rb +3 -0
- data/spec/hotbits_spec.rb +39 -0
- data/spec/spec_helper.rb +14 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5707a8ef4b5eb945bd44018301907372964eb8ce
|
4
|
+
data.tar.gz: aa9a331ebe0f871b3ab8e452ba5972d4431eeeae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0de8d7eba0ab9fdc18a35972dde119c18838a1723c7c683262733cfdb7a7d938ec84c955de8e97a6c54bbd19f9c710bf02370bd2b98357e6235d922ae2ec70a4
|
7
|
+
data.tar.gz: 2b988a99608c559585cf368f69f3e03681a83134f3079d6230815939efb2161496cbfc73c4bd57927c512fe85532a0610be4881fec8001baa48269045c229aeb
|
data/.gitignore
ADDED
data/.guardrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'lib', 'hotbits.rb')
|
data/.irbrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'lib', 'hotbits.rb')
|
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
hotbits
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.0-preview1
|
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 max thom stahl
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Hotbits
|
2
|
+
|
3
|
+
Use this gem to connect to the Hotbits web service
|
4
|
+
(http://www.fourmilab.ch/hotbits/). Though I'm a fan and a user of Hotbits,
|
5
|
+
this gem isn't "official" in any sense of the word. If Hotbits changes their
|
6
|
+
API in the future, this gem will break. If you're a user of this gem and that
|
7
|
+
happens to you, please either fork this and fix it yourself or submit an issue.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'hotbits'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install hotbits
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
The easiest way to get a series of random bytes through Hotbits is to use the
|
26
|
+
`bytes` method:
|
27
|
+
|
28
|
+
irb(main):002:0> Hotbits.bytes
|
29
|
+
=> [104, 61, 58, 158]
|
30
|
+
|
31
|
+
...or if you want more than four bytes, just say so:
|
32
|
+
|
33
|
+
irb(main):002:0> Hotbits.bytes(7)
|
34
|
+
=> [104, 61, 58, 158, 17, 191, 4]
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
1. Fork it
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/hotbits.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hotbits/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hotbits"
|
8
|
+
spec.version = Hotbits::VERSION
|
9
|
+
spec.authors = ["max thom stahl"]
|
10
|
+
spec.email = ["max@villainousindustries.com"]
|
11
|
+
spec.description = %q{Ruby interface to the Hotbits random number generation service.}
|
12
|
+
spec.summary = %q{Ruby interface to the Hotbits random number generation service.}
|
13
|
+
spec.homepage = "https://github.com/mstahl/hotbits"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
data/lib/hotbits.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
Dir[File.join(File.dirname(__FILE__), 'lib', '**', '*.rb')].each {|f| require f}
|
5
|
+
|
6
|
+
module Hotbits
|
7
|
+
BASE_URI = "https://www.fourmilab.ch/cgi-bin/Hotbits?fmt=xml&"
|
8
|
+
|
9
|
+
def self.ascii(count = 4)
|
10
|
+
doc = Nokogiri::XML.parse(raw(count))
|
11
|
+
doc.css('random-data')[0].content.strip
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.bytes(count = 4)
|
15
|
+
ascii(count).split.map{|s| s.to_i(16)}
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def self.raw(count = 4)
|
21
|
+
open(BASE_URI + "nbytes=#{count}").read
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
EXAMPLE_RESPONSE=<<__END_EXAMPLE_RESPONSE__
|
4
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
5
|
+
<!DOCTYPE hotbits SYSTEM
|
6
|
+
"http://www.fourmilab.ch/hotbits/hotbits.dtd">
|
7
|
+
<hotbits version="1.0">
|
8
|
+
<status version="1.0" result="200">OK</status>
|
9
|
+
<request-information version="1.0">
|
10
|
+
<server-version>Release 3.2, June 2008</server-version>
|
11
|
+
<generation-time>2013-11-07T00:47:24Z</generation-time>
|
12
|
+
<bytes-requested>4</bytes-requested>
|
13
|
+
<bytes-returned>4</bytes-returned>
|
14
|
+
<quota-requests-remaining>119</quota-requests-remaining>
|
15
|
+
<quota-bytes-remaining>12284</quota-bytes-remaining>
|
16
|
+
</request-information>
|
17
|
+
<random-data version="1.0">
|
18
|
+
E2 FF 00 B2
|
19
|
+
</random-data>
|
20
|
+
</hotbits>
|
21
|
+
__END_EXAMPLE_RESPONSE__
|
22
|
+
|
23
|
+
describe Hotbits do
|
24
|
+
before do
|
25
|
+
Hotbits.stub(:raw).with(4).and_return(EXAMPLE_RESPONSE)
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#ascii' do
|
29
|
+
it 'should return just the random bytes, separated by spaces' do
|
30
|
+
Hotbits.ascii(4).should == 'E2 FF 00 B2'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#bytes' do
|
35
|
+
it 'should return the four random bytes above' do
|
36
|
+
Hotbits.bytes(4).should == [0xE2, 0xFF, 0x00, 0xB2]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
RSpec.configure do |config|
|
2
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
3
|
+
config.run_all_when_everything_filtered = true
|
4
|
+
config.filter_run :focus
|
5
|
+
|
6
|
+
# Run specs in random order to surface order dependencies. If you find an
|
7
|
+
# order dependency and want to debug it, you can fix the order by providing
|
8
|
+
# the seed, which is printed after each run.
|
9
|
+
# --seed 1234
|
10
|
+
config.order = 'random'
|
11
|
+
end
|
12
|
+
|
13
|
+
Dir[File.join(File.dirname(__FILE__), 'spec', 'support', '**', '*.rb')].each {|f| require f}
|
14
|
+
Dir[File.join(File.dirname(__FILE__), '..', 'lib', '**', '*.rb')].each {|f| require f}
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hotbits
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- max thom stahl
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-07 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Ruby interface to the Hotbits random number generation service.
|
42
|
+
email:
|
43
|
+
- max@villainousindustries.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".guardrc"
|
50
|
+
- ".irbrc"
|
51
|
+
- ".rspec"
|
52
|
+
- ".ruby-gemset"
|
53
|
+
- ".ruby-version"
|
54
|
+
- Gemfile
|
55
|
+
- Guardfile
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- hotbits.gemspec
|
60
|
+
- lib/hotbits.rb
|
61
|
+
- lib/hotbits/version.rb
|
62
|
+
- spec/hotbits_spec.rb
|
63
|
+
- spec/spec_helper.rb
|
64
|
+
homepage: https://github.com/mstahl/hotbits
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.1.10
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Ruby interface to the Hotbits random number generation service.
|
88
|
+
test_files:
|
89
|
+
- spec/hotbits_spec.rb
|
90
|
+
- spec/spec_helper.rb
|