youyouaidi 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9bc980217243ad4ab182d95a4bc4e1c32ca04dc9
4
- data.tar.gz: 6bad0870b6e0cf45e6fc8f3d783c0253d9e072d0
3
+ metadata.gz: 5dc034244f89c5e008ac157a3623fee8c410506a
4
+ data.tar.gz: df6894a97327c5a0947d143a9c367e0901ab5261
5
5
  SHA512:
6
- metadata.gz: 1715bbde2ec432104c9d3012940fa4e9f51bd5e930171885136b288507de1b76f80905a15973158d7b30e978ade65e06221a55028cfd0f2b539659ad49a3a2a2
7
- data.tar.gz: 11a1b217560ebfb1142b9405df2d186a8a60131161802530145dbbf86b534ff53804a99672dcc117a3ffa3104458bd551da586b2ff0dc2bc9ddbbb774ac15242
6
+ metadata.gz: 8dddadf28922905d8c8a1797add44e48971e046354fc74031ccacecdacec9ab785e97c9703eee06579474a454770d12b25e4b31ad374c905958acbd194a0d02d
7
+ data.tar.gz: 7afcc05faff44845fd8a5b844660dd4f714ddfd475153d7e47de3643c5d31388f896e248e710f0f155e173b3efc19a88576aca17eb254d1ffff8c0e0d898f567
data/README.md CHANGED
@@ -14,12 +14,11 @@ For UUID generation, the `SecureRandom.uuid` method is used which generates vali
14
14
 
15
15
  This is what a valid, random (version 4) UUID looks like:
16
16
  ```
17
- # chars in group: 8 | 4 | 4 | 4 | 12
18
- ▼ ▼ ▼ ▼ ▼
19
- caed3f49-b0ca-454b-adf8-5ee2a1764759
20
- ▲ ▲
21
17
  version either 8, 9
22
- number a, or b
18
+ number a, or b
19
+ ▼ ▼
20
+ caed3f49-b0ca-454b-adf8-5ee2a1764759
21
+ # chars in group: 8 | 4 | 4 | 4 | 12
23
22
  ```
24
23
  As shown, the first digit of the third group indicates the UUID version.
25
24
  The first digit of the fourth group always has to be one of either `8`, `9`, `a`, or `b`.
@@ -43,6 +42,9 @@ Or install it yourself as:
43
42
 
44
43
  ## Usage
45
44
 
45
+ For usability, `UUID(...)` is patched into the kernel as a shorthand call to `Youyouaidi::UUID.parse(...)`.
46
+ Also, `UUID` is patched as a reference for the class `Youyouid::UUID`.
47
+
46
48
  ### Initializing UUIDs
47
49
 
48
50
  ```ruby
@@ -64,11 +66,15 @@ new_uuid = UUID() # generates a random UUID version 4 using the SecureRa
64
66
 
65
67
  ### Validity check and conversions
66
68
 
69
+ The validity check `UUID.valid? uuid_string` checks, if UUID contains exactly 32 hexadecimal characters which are divided by four dashes ('-') into five groups of sizes 8, 4, 4, 4, and 12.
70
+ Also, it validates that the first character of the fourth group is either a `8`, `9`, an `a`, or a `b`.
71
+
67
72
  ```ruby
68
73
  uuid_string = '550e8400-e29b-41d4-a716-446655440000' # A valid UUID in string format
69
74
  uuid = UUID uuid_string
70
75
 
71
- Youyouaidi::UUID.valid? uuid_string # => true
76
+ UUID.valid? uuid_string # Checks if `uuid_string' is a valid UUID, same as Youyouaidi::UUID.valid? uuid_string
77
+ # => true
72
78
 
73
79
  uuid.to_s # Returns the string representation of the UUID object
74
80
  # => '550e8400-e29b-41d4-a716-446655440000'
@@ -1,6 +1,8 @@
1
- require 'youyouaidi'
1
+ require 'youyouaidi/uuid'
2
2
 
3
3
  module Kernel
4
+ UUID = Youyouaidi::UUID
5
+
4
6
  def UUID(uuid_param = nil)
5
7
  Youyouaidi::UUID.parse uuid_param
6
8
  end
@@ -1,3 +1,3 @@
1
1
  module Youyouaidi
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -35,4 +35,18 @@ describe Kernel do
35
35
  it { should raise_error Youyouaidi::InvalidUUIDError }
36
36
  end
37
37
  end
38
+
39
+ describe 'UUID class behaves as an alias for Youyouaidi::UUID' do
40
+ describe '.new' do
41
+ let(:param) { '' }
42
+ let(:action) { UUID.new param }
43
+ subject { action }
44
+
45
+ context 'without a param' do
46
+ let(:action) { UUID.new }
47
+ subject { action }
48
+ it { should be_a Youyouaidi::UUID }
49
+ end
50
+ end
51
+ end
38
52
  end
@@ -4,8 +4,11 @@ require 'bundler'
4
4
  Bundler.require
5
5
 
6
6
  # Code coverage statistics at coveralls.io: https://coveralls.io/r/nicolas-fricke/youyouaidi
7
- require 'coveralls'
8
- Coveralls.wear!
7
+ # Generate coverage reports only when using MRI, see: https://github.com/lemurheavy/coveralls-public/issues/144
8
+ if ENV['TRAVIS'] && ENV['COVERALLS'] && RUBY_ENGINE == 'ruby'
9
+ require 'coveralls'
10
+ Coveralls.wear!
11
+ end
9
12
 
10
13
  require 'youyouaidi'
11
14
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youyouaidi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Fricke