typesafe_enum 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +11 -5
- data/LICENSE.md +1 -1
- data/README.md +10 -5
- data/lib/typesafe_enum/base.rb +1 -1
- data/lib/typesafe_enum/module_info.rb +2 -2
- data/spec/unit/typesafe_enum/base_spec.rb +1 -1
- data/typesafe_enum.gemspec +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4528ca4b1564d3a5ec9d24574a01347e3c722a64
|
4
|
+
data.tar.gz: cb8329c1159be1527dae44c527a4137887cdd9e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 096ca0c3cac38232d29392d42648bd23d28e68faa18ecceaaa249601132f975185bd1fb2e5c9237d1729b2f889fa8087c851785cd035ab2ddb5829c7f9166f11
|
7
|
+
data.tar.gz: 6706fe40b8e449bef7061281691dc0cfe18f92df421f866baf2e59db093410d0f5cb197b1d6af993fc2fa6105a03e06331127007b9547e997c6da63d1520cd17
|
data/CHANGES.md
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
## 0.1.
|
1
|
+
## 0.1.5 (27 Jan 2016)
|
2
|
+
|
3
|
+
- Include the original call site in the warning message for duplicate instances to help
|
4
|
+
with debugging.
|
5
|
+
- Modified gemspec to take into account SSH checkouts when determining the homepage URL.
|
6
|
+
|
7
|
+
## 0.1.4 (18 Dec 2015))
|
2
8
|
|
3
9
|
- Exact duplicate instances (e.g. due to multiple `requires`) are now ignored with a warning,
|
4
10
|
instead of causing a `NameError`. Duplicate keys with different values, and duplicate values
|
@@ -6,19 +12,19 @@
|
|
6
12
|
- `NameErrors` due to invalid keys or values no longer cause the enum class to be undefined.
|
7
13
|
However, the invalid instances will still not be registered and no constants created for them.
|
8
14
|
|
9
|
-
## 0.1.3
|
15
|
+
## 0.1.3 (17 Dec 2015)
|
10
16
|
|
11
17
|
- Fixed issue where invalid classes weren't properly removed after duplicate name declarations,
|
12
18
|
polluting the namespace and causing duplicate declration error messages to be lost.
|
13
19
|
|
14
|
-
## 0.1.2
|
20
|
+
## 0.1.2 (19 Nov 2015)
|
15
21
|
|
16
22
|
- Fixed issue where `::find_by_value_str` failed to return `nil` for bad values
|
17
23
|
|
18
|
-
## 0.1.1
|
24
|
+
## 0.1.1 (19 Nov 2015)
|
19
25
|
|
20
26
|
- Added `::find_by_value_str`
|
21
27
|
|
22
|
-
## 0.1.0
|
28
|
+
## 0.1.0 (18 Nov 2015)
|
23
29
|
|
24
30
|
- Initial release
|
data/LICENSE.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2016 The Regents of the University of California
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
6
6
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -116,7 +116,7 @@ end
|
|
116
116
|
```
|
117
117
|
|
118
118
|
However, declaring an identical key/value pair will be ignored with a warning, to avoid unnecessary errors
|
119
|
-
when, e.g., a declaration file is accidentally
|
119
|
+
when, e.g., a declaration file is accidentally loaded twice.
|
120
120
|
|
121
121
|
```ruby
|
122
122
|
class Tarot < TypesafeEnum::Base
|
@@ -133,12 +133,17 @@ class Tarot < TypesafeEnum::Base
|
|
133
133
|
new :SWORDS, 'Swords'
|
134
134
|
end
|
135
135
|
|
136
|
-
# => ignoring redeclaration of Tarot::CUPS with value:
|
137
|
-
# => ignoring redeclaration of Tarot::COINS with value:
|
138
|
-
# => ignoring redeclaration of Tarot::WANDS with value:
|
139
|
-
# => ignoring redeclaration of Tarot::SWORDS with value:
|
136
|
+
# => ignoring redeclaration of Tarot::CUPS with value Cups (source: /tmp/duplicate_enum.rb:13:in `new')
|
137
|
+
# => ignoring redeclaration of Tarot::COINS with value Coins (source: /tmp/duplicate_enum.rb:14:in `new')
|
138
|
+
# => ignoring redeclaration of Tarot::WANDS with value Wands (source: /tmp/duplicate_enum.rb:15:in `new')
|
139
|
+
# => ignoring redeclaration of Tarot::SWORDS with value Swords (source: /tmp/duplicate_enum.rb:16:in `new')
|
140
140
|
```
|
141
141
|
|
142
|
+
**Note:** If do you see these warnings, it probably means there's something wrong with your `$LOAD_PATH` (e.g.,
|
143
|
+
the same directory present both via its real path and via a symlink). This can cause all sorts of problems,
|
144
|
+
and Ruby's `require` statement is [known to be not smart enough to deal with it](https://bugs.ruby-lang.org/issues/4403),
|
145
|
+
so it's worth tracking down and fixing the root cause.
|
146
|
+
|
142
147
|
## Ordering
|
143
148
|
|
144
149
|
Enum instances have an ordinal value corresponding to their declaration
|
data/lib/typesafe_enum/base.rb
CHANGED
@@ -76,7 +76,7 @@ module TypesafeEnum
|
|
76
76
|
value = instance.value
|
77
77
|
if (found = find_by_key(key))
|
78
78
|
fail NameError, "#{name}::#{key} already exists" unless value == found.value
|
79
|
-
warn("ignoring redeclaration of #{name}::#{key} with value
|
79
|
+
warn("ignoring redeclaration of #{name}::#{key} with value #{value} (source: #{caller[4]})")
|
80
80
|
nil
|
81
81
|
else
|
82
82
|
fail NameError, "A #{name} instance with value '#{value}' already exists" if find_by_value(value)
|
@@ -3,8 +3,8 @@ module TypesafeEnum
|
|
3
3
|
NAME = 'typesafe_enum'
|
4
4
|
|
5
5
|
# The version of this gem
|
6
|
-
VERSION = '0.1.
|
6
|
+
VERSION = '0.1.5'
|
7
7
|
|
8
8
|
# The copyright notice for this gem
|
9
|
-
COPYRIGHT = 'Copyright (c)
|
9
|
+
COPYRIGHT = 'Copyright (c) 2016 The Regents of the University of California'
|
10
10
|
end
|
@@ -92,7 +92,7 @@ module TypesafeEnum
|
|
92
92
|
class ::IdenticalInstances < Base
|
93
93
|
new :SPADES, 'spades'
|
94
94
|
end
|
95
|
-
expect(::IdenticalInstances).to receive(:warn).with(
|
95
|
+
expect(::IdenticalInstances).to receive(:warn).with(a_string_matching(/ignoring redeclaration of IdenticalInstances::SPADES with value spades/))
|
96
96
|
class ::IdenticalInstances < Base
|
97
97
|
new :SPADES, 'spades'
|
98
98
|
end
|
data/typesafe_enum.gemspec
CHANGED
@@ -14,7 +14,8 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.description = 'A gem that implements the typesafe enum pattern in Ruby'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
|
-
|
17
|
+
origin = `git config --get remote.origin.url`.chomp
|
18
|
+
origin_uri = origin.start_with?('http') ? URI(origin) : URI(origin.sub('git@github.com:', 'https://github.com/'))
|
18
19
|
spec.homepage = URI::HTTP.build(host: origin_uri.host, path: origin_uri.path.chomp('.git')).to_s
|
19
20
|
|
20
21
|
spec.files = `git ls-files -z`.split("\x0")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typesafe_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Moles
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|