rubenum 1.0.2 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40dfdc334f527dd44f5199e9160e8c62d0c13304e0d54f1e2203e0909b628eaf
4
- data.tar.gz: e841cb03f57411073b5598d1d813bb2d22e22014eef1cb238f0d8bdb9bac67eb
3
+ metadata.gz: c47d1e73f4d1583a4aa13d3fefc2f391c1d321cbe37f8b10f852c591990f7111
4
+ data.tar.gz: 8a8ce0b92aa93e1c6c2bed166b56f4277cd19b7661da6e9734480e08169d0763
5
5
  SHA512:
6
- metadata.gz: 505fad695cd0b7e33b5b9aa625fce6db83d3d7308e38e0a3fd771277bd78729f2fca8cdf278dbe37fa740deda3a2bfe594ce55ad05160faf1d093e7268d867fe
7
- data.tar.gz: 7c7bc6d24d815c6da8d48c0c88f5a782b74c75d0c79ce7b327cc2e65ff2e9e0b03fffeaee67edbde2e1566fe199bf0bd6260b5408ab8ecf27dbfb01444831011
6
+ metadata.gz: 04ec6ecfee4893f7988098fad52e7a73f4204794fb4ac633b1846d66fbb27739e83a01a7d848cc742361162a5c06b3eb069b3a7ab87e4cfb04abcae016a4629e
7
+ data.tar.gz: ab5a88ceecf6aee0bd93b373ad5a435b8ea0702d87256f43bde5f6021a797a158a55980590bb86bd41d07beda148de5ce154cf6cfce75485860948bf69104e5c
data/README.md CHANGED
@@ -14,8 +14,8 @@ By default, every element will be capitalized in order to make valid Ruby consta
14
14
 
15
15
  ### Arguments
16
16
  - elements (array of string) : array containing the elements of the enumeration
17
- - upcase (optional boolean (default:false)) : true => upcase the elements' name instead of capitalizing them
18
- - binary_values (optional boolean (default:false)) : true => use binary values (1 2 4 8 16 ...) instead of incremental values (1 2 3 4 5 ...)
17
+ - upcase (optional boolean (default : false)) : true => upcase the elements' name instead of capitalizing them
18
+ - binary_values (optional boolean (default : false)) : true => use binary values (1 2 4 8 16 ...) instead of incremental values (1 2 3 4 5 ...)
19
19
 
20
20
  ### Example
21
21
  colors = Rubenum.new(%w[red orange green])
data/Rakefile CHANGED
@@ -1,9 +1,9 @@
1
1
  require 'rake/testtask'
2
2
 
3
+ task default: :test
4
+
3
5
  Rake::TestTask.new do |t|
4
6
  t.libs << 'test'
7
+ t.test_files = FileList['test/test_*.rb']
5
8
  end
6
9
 
7
- desc "Run tests"
8
- task :default => :test
9
-
@@ -6,8 +6,8 @@ module Rubenum
6
6
  #
7
7
  # Arguments :
8
8
  # - elements (array of string) : array containing the elements of the enumeration
9
- # - upcase (optional boolean (default:false)) : true => upcase the elements' name instead of capitalizing them
10
- # - binary_values (optional boolean (default:false)) : true => use binary values (1 2 4 8 16 ...) instead of incremental values (1 2 3 4 5 ...)
9
+ # - upcase (optional boolean (default : false)) : true => upcase the elements' name instead of capitalizing them
10
+ # - binary_values (optional boolean (default : false)) : true => use binary values (1 2 4 8 16 ...) instead of incremental values (1 2 3 4 5 ...)
11
11
  #
12
12
  # Example :
13
13
  # colors = Rubenum.new(%w[red orange green])
@@ -37,7 +37,7 @@ module Rubenum
37
37
  mod.const_set(e, value)
38
38
  end
39
39
 
40
- # Freeze the module so it can't be modifed
40
+ # Freeze the module so it can't be modified
41
41
  mod.freeze
42
42
  end
43
43
  end
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rubenum'
3
- s.version = '1.0.2'
4
- s.summary = "Create simple enumerations in Ruby."
3
+ s.version = '1.0.3'
4
+ s.summary = 'Create simple enumerations in Ruby.'
5
5
  s.author = 'Jérémy Blain'
6
- s.files = Dir['lib/**/*'] + Dir['test/**/*']
6
+ s.files = Dir["{lib,test}/**/*"]
7
7
  s.files += ['LICENSE', 'README.md', 'Rakefile', 'rubenum.gemspec']
8
8
 
9
9
  s.license = 'MIT'
@@ -10,49 +10,51 @@ class TestRubenum < Minitest::Test
10
10
  assert_equal e.constants.sort, [:First, :Sec_ond, :Third_, :Fou_rth4].sort
11
11
  end
12
12
 
13
+ def test_with_a_single_char
14
+ e = Rubenum.new(%w[First x sec_ond third_ fou_rth4])
15
+ assert_equal e.constants.sort, [:First, :X, :Sec_ond, :Third_, :Fou_rth4].sort
16
+ end
17
+
18
+ def test_duplicate_elements_are_made_unique
19
+ e = Rubenum.new(%w[First first sec_ond third_ fou_rth4])
20
+ assert_equal e.constants.sort, [:First, :Sec_ond, :Third_, :Fou_rth4].sort
21
+ end
22
+
23
+ # Invalid elements
24
+
13
25
  def test_when_elements_isnt_an_array
14
26
  assert_raises ArgumentError do
15
27
  Rubenum.new(45)
16
28
  end
17
29
  end
18
30
 
19
- def test_with_wrong_type_of_elements
31
+ def test_with_empty_array
20
32
  assert_raises ArgumentError do
21
- Rubenum.new([:First, "sec_ond", ["third"], 4])
33
+ Rubenum.new([])
22
34
  end
23
35
  end
24
36
 
25
- def test_with_empty_elements
37
+ def test_with_wrong_type_of_elements
26
38
  assert_raises ArgumentError do
27
- Rubenum.new([])
39
+ Rubenum.new([:First, "sec_ond", ["third"], 4])
28
40
  end
29
41
  end
30
42
 
31
- def test_duplicate_elements_are_made_unique
32
- e = Rubenum.new(%w[First first sec_ond third_ fou_rth4])
33
- assert_equal e.constants.sort, [:First, :Sec_ond, :Third_, :Fou_rth4].sort
34
- end
35
-
36
- def test_with_a_single_char
37
- e = Rubenum.new(%w[First x sec_ond third_ fou_rth4])
38
- assert_equal e.constants.sort, [:First, :X, :Sec_ond, :Third_, :Fou_rth4].sort
39
- end
40
-
41
43
  def test_not_working_with_a_space_char
42
44
  assert_raises NameError do
43
45
  Rubenum.new(["First", "sec ond", "third_", "fou_rth4"])
44
46
  end
45
47
  end
46
48
 
47
- def test_not_working_with_a_leading_underscore
49
+ def test_not_working_with_a_special_char
48
50
  assert_raises NameError do
49
- Rubenum.new(%w[First _sec_ond third_ fou_rth4])
51
+ Rubenum.new(%w[First sec!ond third_ fou_rth4])
50
52
  end
51
53
  end
52
54
 
53
- def test_not_working_with_a_special_char
55
+ def test_not_working_with_a_leading_underscore
54
56
  assert_raises NameError do
55
- Rubenum.new(%w[First sec!ond third_ fou_rth4])
57
+ Rubenum.new(%w[First _sec_ond third_ fou_rth4])
56
58
  end
57
59
  end
58
60
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubenum
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jérémy Blain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-06 00:00:00.000000000 Z
11
+ date: 2019-05-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: blain.jeremy@gmail.com