degu 0.5.0 → 0.6.0

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: 6d11ad3d30e696815259b126d84c4b22fcc34972
4
- data.tar.gz: 429c99d88ae9bd7d151064ff80a031846fc4ca61
3
+ metadata.gz: 02a36ad5dbf090d463a5bcb6663647276524efbb
4
+ data.tar.gz: a708d7d3b15edb9fb5d91b7efebf17598467ad1e
5
5
  SHA512:
6
- metadata.gz: 49a820e95b6e154a83ba14c35bac7121ed83cba626fecd7e704c8b34ad21b80fa521b134a4b6c349ecfedc2c53524d1940fb715f2bd70c806d95abf038678c71
7
- data.tar.gz: c0bf803c5398e823312fd83996ff4b51d4f396e41c6a0831e1922abcdc868a929bdfcef38c01e183d616aa8303112de7c055ed54c8a4339841e298d6965d3cac
6
+ metadata.gz: 3ab2d609d9206f6b59125c371b21121edaa394f39abc20356bb8b762e55c214c0453b4a82170e90ba080b4b870f04eb43162a4a29037239d3ddd72d3fae306fa
7
+ data.tar.gz: 6490e1a508f3b904cc429f37e268a3658f5021aa80b61678530f4eb4f7ceb2e4255726dfeec9f692bfb3c7e07b720f4df0111212154681f6d8d59c4d419aa7a9
data/.travis.yml CHANGED
@@ -3,9 +3,9 @@ bundler_args: --binstubs
3
3
 
4
4
  # Specify which ruby versions you wish to run your tests on, each version will be used
5
5
  rvm:
6
- - 1.9.3
7
- - 2.0.0
8
- - 2.1.2
6
+ - 2.0
7
+ - 2.1
8
+ - 2.2
9
9
  - rbx-19mode
10
10
  - jruby-19mode
11
11
  - ruby-head
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0
data/degu.gemspec CHANGED
@@ -1,21 +1,21 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: degu 0.5.0 ruby lib
2
+ # stub: degu 0.6.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "degu"
6
- s.version = "0.5.0"
6
+ s.version = "0.6.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
10
10
  s.authors = ["Florian Frank"]
11
- s.date = "2014-06-10"
11
+ s.date = "2015-04-24"
12
12
  s.description = "Library that includes enums, and rails support for enums and bitfield sets."
13
13
  s.email = "dev@pkw.de"
14
14
  s.extra_rdoc_files = ["README.md", "lib/degu.rb", "lib/degu/has_enum.rb", "lib/degu/has_set.rb", "lib/degu/polite.rb", "lib/degu/renum.rb", "lib/degu/renum/enumerated_value.rb", "lib/degu/renum/enumerated_value_type_factory.rb", "lib/degu/rude.rb", "lib/degu/version.rb"]
15
15
  s.files = [".gitignore", ".travis.yml", "COPYING", "Gemfile", "README.md", "Rakefile", "VERSION", "degu.gemspec", "lib/degu.rb", "lib/degu/has_enum.rb", "lib/degu/has_set.rb", "lib/degu/polite.rb", "lib/degu/renum.rb", "lib/degu/renum/enumerated_value.rb", "lib/degu/renum/enumerated_value_type_factory.rb", "lib/degu/rude.rb", "lib/degu/version.rb", "spec/renum_spec.rb", "spec/spec_helper.rb", "test/has_enum_test.rb", "test/has_set_test.rb", "test/test_helper.rb", "test_helper.rb"]
16
16
  s.homepage = "https://github.com/tuskenraiders/degu"
17
17
  s.rdoc_options = ["--title", "Degu - Library for enums and bitfield sets.", "--main", "README.md"]
18
- s.rubygems_version = "2.2.1"
18
+ s.rubygems_version = "2.4.6"
19
19
  s.summary = "Library for enums and bitfield sets."
20
20
  s.test_files = ["test/has_enum_test.rb", "test/has_set_test.rb"]
21
21
 
@@ -23,14 +23,14 @@ Gem::Specification.new do |s|
23
23
  s.specification_version = 4
24
24
 
25
25
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- s.add_development_dependency(%q<gem_hadar>, ["~> 1.0.0"])
26
+ s.add_development_dependency(%q<gem_hadar>, ["~> 1.2.0"])
27
27
  s.add_development_dependency(%q<test-unit>, [">= 0"])
28
28
  s.add_development_dependency(%q<mocha>, [">= 0"])
29
29
  s.add_development_dependency(%q<sqlite3>, [">= 0"])
30
30
  s.add_development_dependency(%q<rspec>, [">= 0"])
31
31
  s.add_runtime_dependency(%q<activerecord>, ["< 5.0", ">= 3.0"])
32
32
  else
33
- s.add_dependency(%q<gem_hadar>, ["~> 1.0.0"])
33
+ s.add_dependency(%q<gem_hadar>, ["~> 1.2.0"])
34
34
  s.add_dependency(%q<test-unit>, [">= 0"])
35
35
  s.add_dependency(%q<mocha>, [">= 0"])
36
36
  s.add_dependency(%q<sqlite3>, [">= 0"])
@@ -38,7 +38,7 @@ Gem::Specification.new do |s|
38
38
  s.add_dependency(%q<activerecord>, ["< 5.0", ">= 3.0"])
39
39
  end
40
40
  else
41
- s.add_dependency(%q<gem_hadar>, ["~> 1.0.0"])
41
+ s.add_dependency(%q<gem_hadar>, ["~> 1.2.0"])
42
42
  s.add_dependency(%q<test-unit>, [">= 0"])
43
43
  s.add_dependency(%q<mocha>, [">= 0"])
44
44
  s.add_dependency(%q<sqlite3>, [">= 0"])
@@ -212,7 +212,11 @@ module Degu
212
212
 
213
213
  # Sorts enumerated values into the order in which they're declared.
214
214
  def <=> other
215
- index <=> other.index
215
+ if self.class === other
216
+ index <=> other.index
217
+ elsif other_value = self.class[other]
218
+ self <=> other_value
219
+ end
216
220
  end
217
221
 
218
222
  # Returns a marshalled string for this enum instance.
data/lib/degu/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Degu
2
2
  # Degu version
3
- VERSION = '0.5.0'
3
+ VERSION = '0.6.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/spec/renum_spec.rb CHANGED
@@ -49,7 +49,6 @@ describe "basic enum" do
49
49
  expect(Color::GREEN.id).to eq 1
50
50
  end
51
51
 
52
-
53
52
  it "provides name lookup on values" do
54
53
  expect(Status.with_name('IN_PROGRESS')).to eq Status::IN_PROGRESS
55
54
  expect(Color.with_name('GREEN')).to eq Color::GREEN
@@ -317,3 +316,36 @@ describe "definition extensions included as models and block to use inside of th
317
316
  expect(Foo3::Bang.set_per_extension).to eq 'c_set_via_extension'
318
317
  end
319
318
  end
319
+
320
+
321
+ enum :LogLevel, %i[ DEBUG INFO WARN ERROR FATAL UNKNOWN ]
322
+
323
+ enum :Nix, %i[ FOO BAR ]
324
+
325
+ describe 'comparing renums' do
326
+ it 'can compare to other enums of the same type' do
327
+ expect(LogLevel::WARN).to be < LogLevel::ERROR
328
+ expect(LogLevel::WARN).not_to be < LogLevel::WARN
329
+ end
330
+
331
+ it 'cannot compare to enums of other types' do
332
+ expect(LogLevel::DEBUG <=> Nix::BAR).to be_nil
333
+ end
334
+
335
+ it 'can compare to indexes' do
336
+ expect(LogLevel::WARN).to be < 3
337
+ end
338
+
339
+ it 'cannot compare to unknown indexes' do
340
+ expect(LogLevel::DEBUG <=> 666).to be_nil
341
+ end
342
+
343
+ it 'can compare to names' do
344
+ expect(LogLevel::WARN).to be < :ERROR
345
+ expect(LogLevel::WARN).not_to be < :WARN
346
+ end
347
+
348
+ it 'cannot compare to unknown names' do
349
+ expect(LogLevel::DEBUG <=> :foo).to be_nil
350
+ end
351
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: degu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-10 00:00:00.000000000 Z
11
+ date: 2015-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0
19
+ version: 1.2.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.0
26
+ version: 1.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: test-unit
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  version: '0'
164
164
  requirements: []
165
165
  rubyforge_project:
166
- rubygems_version: 2.2.1
166
+ rubygems_version: 2.4.6
167
167
  signing_key:
168
168
  specification_version: 4
169
169
  summary: Library for enums and bitfield sets.