sro 0.0.1

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: 4426845faa068b5bcbd11a3747ec30f15997f392
4
+ data.tar.gz: 8da16793a98649bcb68dca18dc146ff186070899
5
+ SHA512:
6
+ metadata.gz: 0333308a728a9e922adfe109fc6d3bc1e3121d6f0ba8588771ae967d37ef3621f0ea78f6ad0d746bfdf4190044e8ffa36655bf893cc6f0c33f3ff6d01065af26
7
+ data.tar.gz: da08e460f4a3a49633735462ce898d52f097e7c579844819590aa626d80664e4ba84cf145ed8f47a3477be4bbeb59fab62472d17ac456de75aad3448456a4e9f
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ # ignores bundler files
2
+ /.bundle
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ 0.0.0 / 2014-02-21
2
+
3
+ Enhancements:
4
+
5
+ Add version 5 UUID (Michael Pope)
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://www.rubygems.org"
2
+
3
+ gem "uuidtools", "~> 2.1.4"
4
+
5
+ group :development, :test do
6
+ gem "pry", "~> 0.9.12.6"
7
+ gem "rspec", "~> 2.14.1"
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,28 @@
1
+ GEM
2
+ remote: https://www.rubygems.org/
3
+ specs:
4
+ coderay (1.1.0)
5
+ diff-lcs (1.2.5)
6
+ method_source (0.8.2)
7
+ pry (0.9.12.6)
8
+ coderay (~> 1.0)
9
+ method_source (~> 0.8)
10
+ slop (~> 3.4)
11
+ rspec (2.14.1)
12
+ rspec-core (~> 2.14.0)
13
+ rspec-expectations (~> 2.14.0)
14
+ rspec-mocks (~> 2.14.0)
15
+ rspec-core (2.14.7)
16
+ rspec-expectations (2.14.5)
17
+ diff-lcs (>= 1.1.3, < 2.0)
18
+ rspec-mocks (2.14.6)
19
+ slop (3.4.7)
20
+ uuidtools (2.1.4)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ pry (= 0.9.12.6)
27
+ rspec (= 2.14.1)
28
+ uuidtools (= 2.1.4)
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Michael Pope
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,31 @@
1
+ # Sro
2
+
3
+ Some Ruby Objects
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'sro'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install sro
18
+
19
+ ## Usage
20
+
21
+ Sro::Uuid.version5
22
+ * generates a Version 5 UUID
23
+ * Wikpedia link => http://bit.ly/Olq2MQ
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( http://github.com/<my-github-username>/sro/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ module Sro::Uuid
2
+ class Version5
3
+ def mac_address
4
+ mac_address = UUIDTools::UUID.mac_address
5
+ end
6
+
7
+ def run
8
+ version5.to_s
9
+ end
10
+
11
+ def timestamp
12
+ UUIDTools::UUID.timestamp_create
13
+ end
14
+
15
+ def version5
16
+ UUIDTools::UUID.sha1_create(timestamp, mac_address)
17
+ end
18
+ end
19
+ end
data/lib/sro/uuid.rb ADDED
@@ -0,0 +1,9 @@
1
+ module Sro::Uuid
2
+ def self.pattern
3
+ /([a-z]|\d){8}-([a-z]|\d){4}-([a-z]|\d){4}-([a-z]|\d){4}-([a-z]|\d){12}/
4
+ end
5
+
6
+ def self.version5
7
+ Version5.new.run
8
+ end
9
+ end
data/lib/sro.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "uuidtools"
2
+
3
+ module Sro
4
+ end
5
+
6
+ require "./lib/sro/uuid"
7
+ require "./lib/sro/uuid/version5"
@@ -0,0 +1,19 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require "./lib/sro"
8
+
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+ end
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ describe Sro::Uuid do
4
+ subject { Sro::Uuid }
5
+
6
+ context "#pattern" do
7
+ it "matches the pattern" do
8
+ pattern = subject.pattern
9
+ uuid = SecureRandom.uuid
10
+ expect(pattern).to match(uuid)
11
+ end
12
+ end
13
+
14
+ context "#version5" do
15
+ it "matches the pattern" do
16
+ uuid = subject.version5
17
+ pattern = subject.pattern
18
+ expect(uuid).to match(pattern)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+
3
+ describe Sro::Uuid::Version5 do
4
+ subject { Sro::Uuid::Version5.new }
5
+
6
+ context "#mac_address" do
7
+ it "retrieves computers mac address" do
8
+ mac_address = subject.mac_address
9
+ pattern = /((\d|[a-f]){2}:){5}(\d|[a-f]){2}/
10
+ expect(mac_address).to match(pattern)
11
+ end
12
+ end
13
+
14
+ context "#run" do
15
+ it "returns a uuid" do
16
+ pattern = Sro::Uuid.pattern
17
+ uuid = subject.run
18
+ expect(uuid).to match(pattern)
19
+ end
20
+ end
21
+
22
+ context "#timestamp" do
23
+ it "returns a UUIDTools::UUID object" do
24
+ object = subject.timestamp
25
+ expect(object).to be_instance_of(UUIDTools::UUID)
26
+ end
27
+ end
28
+
29
+ context "#version5" do
30
+ it "generates a Version 5 UUID" do
31
+ object = subject.version5
32
+ expect(object).to be_instance_of(UUIDTools::UUID)
33
+ end
34
+ end
35
+ end
data/sro.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "sro"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Michael Pope"]
9
+ spec.email = ["amorphid@captaincoder.io"]
10
+ spec.summary = %q{Some Ruby Objects}
11
+ spec.description = %q{ Checkout README.md }
12
+ spec.homepage = "https://github.com/amorphid/sro"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency("uuidtools", "~> 2.1.4")
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.5"
23
+ spec.add_development_dependency "pry", "~> 0.9.12.6"
24
+ spec.add_development_dependency "rspec", "~> 2.14.1"
25
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sro
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Michael Pope
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: uuidtools
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.1.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.4
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.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.9.12.6
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.12.6
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.14.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.14.1
69
+ description: " Checkout README.md "
70
+ email:
71
+ - amorphid@captaincoder.io
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - CHANGELOG.md
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - lib/sro.rb
85
+ - lib/sro/uuid.rb
86
+ - lib/sro/uuid/version5.rb
87
+ - spec/spec_helper.rb
88
+ - spec/sro/uuic_spec.rb
89
+ - spec/sro/uuid/version5_spec.rb
90
+ - sro.gemspec
91
+ homepage: https://github.com/amorphid/sro
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.2.2
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Some Ruby Objects
115
+ test_files:
116
+ - spec/spec_helper.rb
117
+ - spec/sro/uuic_spec.rb
118
+ - spec/sro/uuid/version5_spec.rb