thefox-ext 1.4.1 → 1.5.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: 05c9ab324e8e059c18d462f92ec460b1a199963f
4
- data.tar.gz: 35c5a477858d7c6acd9f293605106b1ea420ffc9
3
+ metadata.gz: a51b7381080d2423b214e5abdd4d3065b211a9ab
4
+ data.tar.gz: bb698781dbba108db0348770caaacd9e1a61a1ab
5
5
  SHA512:
6
- metadata.gz: c99fe019c4277c64c723e706503ece8ade2cb25b8420ef16137d9656b374a284f9fce0ad02599e9d4aa7f34c877f62c5f23d87261fd1d5ed9c320dad41be8471
7
- data.tar.gz: 16fadd3276e3cb8164ee74346f381ff82e1245f383a80238ee3c95f60a50039a99afe3c2ff98f0f6564aeb26b3b7168eebcb4f5981864fe162956099e630573e
6
+ metadata.gz: e5ebf340108b286b0fecb2038b789e1259b3925196088b0e7dadca3478cb60d0eaf745e3eddd87b24046d3aa139da158fddd428aff18ee3bba50d0dd51d8ba7a
7
+ data.tar.gz: 44fb1336dd930c64c103928250f52e6a9f79e089b2994d79ad8786848726959fd281ed81c88aed6dc9a955274bdd038f719d4fb3af0a3898db5e081b3b2332e0
data/.editorconfig ADDED
@@ -0,0 +1,14 @@
1
+ # editorconfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ indent_style = tab
7
+ indent_size = 4
8
+ end_of_line = lf
9
+ charset = utf-8
10
+ trim_trailing_whitespace = false
11
+ insert_final_newline = true
12
+
13
+ [*.yml]
14
+ indent_style = space
data/.gitignore CHANGED
@@ -1,5 +1,7 @@
1
1
  /.bundle/
2
2
  .setup
3
3
  CHANGELOG-*.txt
4
+ /coverage/
5
+ dev
4
6
  Gemfile.lock
5
- /releases/
7
+ /releases/
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,56 @@
1
+ before_script:
2
+ - gem update --system
3
+ - gem install bundler -v '~>1.13'
4
+ - bundler --version
5
+ - make
6
+
7
+ stages:
8
+ - test
9
+ - release
10
+
11
+ test_21:
12
+ image: ruby:2.1
13
+ stage: test
14
+ environment: test
15
+ only:
16
+ - tags
17
+ script:
18
+ - make test
19
+
20
+ test_22:
21
+ image: ruby:2.2
22
+ stage: test
23
+ environment: test
24
+ only:
25
+ - tags
26
+ script:
27
+ - make test
28
+
29
+ test_23:
30
+ image: ruby:2.3
31
+ stage: test
32
+ environment: test
33
+ only:
34
+ - tags
35
+ script:
36
+ - make test
37
+
38
+ test_24:
39
+ image: ruby:2.4.0
40
+ stage: test
41
+ environment: test
42
+ only:
43
+ - tags
44
+ script:
45
+ - make test
46
+
47
+ release:
48
+ image: ruby:2.4.0
49
+ stage: release
50
+ environment: gem
51
+ only:
52
+ - tags
53
+ script:
54
+ - mkdir -p ~/.gem
55
+ - 'printf "%s\n:rubygems_api_key: %s" "---" "${RUBYGEMSORG_API_KEY}" > ~/.gem/credentials; chmod 0600 ~/.gem/credentials'
56
+ - make release
data/.travis.yml CHANGED
@@ -2,10 +2,13 @@ language: ruby
2
2
  rvm:
3
3
  - 2.1
4
4
  - 2.2
5
+ - 2.3
6
+ - 2.4.0
7
+ - ruby-head
5
8
  sudo: required
6
9
  before_install:
7
10
  - gem update --system
8
- - gem install bundler -v '~>1.11'
11
+ - gem install bundler -v '~>1.13'
9
12
  - bundler --version
10
13
  install:
11
14
  - make
@@ -13,4 +16,4 @@ install:
13
16
  - gem install thefox-ext-*.gem
14
17
  - gem list -l thefox-ext
15
18
  script:
16
- - make test
19
+ - make test
data/Makefile CHANGED
@@ -5,4 +5,4 @@ include Makefile.common
5
5
 
6
6
  .PHONY: test
7
7
  test:
8
- RUBYOPT=-w $(BUNDLER) exec ./tests/ts_all.rb
8
+ RUBYOPT=-w $(BUNDLER) exec ./test/suite_all.rb
data/Makefile.common CHANGED
@@ -1,33 +1,36 @@
1
1
 
2
- # Ruby Common Big
3
- # 2015-12-21
2
+ # Ruby Common Big 2016-11-08
4
3
 
5
4
  MV = mv -nv
6
- RM = rm -rf
5
+ RM = rm -rfd
7
6
  MKDIR = mkdir -p
8
- BUNDLER = bundle
7
+ CHMOD = chmod
8
+ BUNDLER = bundler
9
9
  BUNDLER_OPTIONS = --jobs=5 --retry=3
10
10
  GEMSPEC_FILE = $(GEM_NAME).gemspec
11
11
 
12
- .PHONY: all $(ALL_TARGETS_EXT)
13
- all: setup
12
+ .PHONY: all
13
+ all: setup $(ALL_TARGETS_EXT)
14
14
 
15
15
  .PHONY: setup
16
16
  setup: .setup
17
17
 
18
18
  .setup:
19
+ which ruby &> /dev/null
20
+ which $(BUNDLER) &> /dev/null
21
+ ruby -v
19
22
  $(BUNDLER) install $(BUNDLER_OPTIONS)
20
23
  touch $@
21
24
 
22
25
  .PHONY: install
23
26
  install:
24
- gem_file=$$(gem build $(GEMSPEC_FILE) | grep 'File:' | tail -1 | awk '{ print $$2 }'); \
25
- sudo gem install $$gem_file; \
27
+ gem_file=$$(gem build $(GEMSPEC_FILE) 2> /dev/null | grep 'File:' | tail -1 | awk '{ print $$2 }'); \
28
+ gem install $$gem_file; \
26
29
  $(RM) $$gem_file
27
30
 
28
31
  .PHONY: uninstall
29
32
  uninstall:
30
- sudo gem uninstall $(GEM_NAME)
33
+ gem uninstall $(GEM_NAME)
31
34
 
32
35
  .PHONY: update
33
36
  update:
@@ -35,9 +38,7 @@ update:
35
38
 
36
39
  .PHONY: clean
37
40
  clean:
38
- $(RM) .bundle
39
- $(RM) .setup
40
- $(RM) Gemfile.lock
41
+ $(RM) .bundle .setup Gemfile.lock
41
42
 
42
43
  .PHONY: release
43
44
  release: | releases
@@ -51,3 +52,7 @@ release: | releases
51
52
 
52
53
  releases:
53
54
  $(MKDIR) $@
55
+
56
+ tmp:
57
+ $(MKDIR) $@
58
+ $(CHMOD) u=rwx,go-rwx $@
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Extended Ruby Classes
2
2
 
3
- Extended and useful helper classes for Ruby.
3
+ This gem extents some of the basic Ruby classes by missing functionalities.
4
4
 
5
5
  ## Install
6
6
 
@@ -11,7 +11,7 @@ The preferred method of installation is via RubyGems.org:
11
11
 
12
12
  or via `Gemfile`:
13
13
 
14
- gem 'thefox-ext', '~>1.0'
14
+ gem 'thefox-ext', '~>1.5'
15
15
 
16
16
  Use it in your sources:
17
17
 
@@ -27,6 +27,8 @@ Use it in your sources:
27
27
  - Date
28
28
  - `today?`
29
29
  - Get week array for a specific date.
30
+ - Array
31
+ - Range String Resolver
30
32
  - Hash
31
33
  - Recursive Merge
32
34
 
@@ -36,7 +38,8 @@ Use it in your sources:
36
38
  - [Travis CI Repository](https://travis-ci.org/TheFox/ext.rb)
37
39
 
38
40
  ## License
39
- Copyright (C) 2015 Christian Mayer <http://fox21.at>
41
+
42
+ Copyright (C) 2015 Christian Mayer <https://fox21.at>
40
43
 
41
44
  This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
42
45
 
@@ -0,0 +1,34 @@
1
+
2
+ class Array
3
+
4
+ # Resolve a range string to an array.
5
+ # A range string can be like '1, 3..5, 9-11'.
6
+ # Which will be resolved to [1, 3, 4, 5, 9, 10, 11].
7
+ def self.resolve_range_str(s)
8
+ a = Array.new
9
+ if !s.is_a?(String)
10
+ return a
11
+ end
12
+
13
+ s.split(',').map{ |i|
14
+ s = i.strip
15
+ if /\.\./.match(s) # ( . )( . ) <--- BOOBS
16
+ b, e = s.split('..', 2).map{ |s| s.to_i }
17
+ Range.new(b, e)
18
+ elsif /-/.match(s)
19
+ b, e = s.split('-', 2).map{ |s| s.to_i }
20
+ Range.new(b, e)
21
+ else
22
+ s.to_i
23
+ end
24
+ }.each do |r|
25
+ if r.is_a?(Range)
26
+ a.push(*r.to_a)
27
+ else
28
+ a << r
29
+ end
30
+ end
31
+ a
32
+ end
33
+
34
+ end
@@ -6,6 +6,7 @@ class Date
6
6
  self == Date.today
7
7
  end
8
8
 
9
+ # Get all days (as Date objects) for the current week.
9
10
  def week
10
11
  cweek = self.cweek
11
12
  year = self.year
@@ -1,6 +1,9 @@
1
1
 
2
2
  class FalseClass
3
+
4
+ # bool.to_i
3
5
  def to_i
4
6
  0
5
7
  end
8
+
6
9
  end
@@ -2,6 +2,10 @@
2
2
  class Hash
3
3
 
4
4
  def merge_recursive(h2, level = 0, clone = true)
5
+ if !h2.is_a?(Hash)
6
+ raise ArgumentError, "Argument is not a Hash -- #{h2.class} given"
7
+ end
8
+
5
9
  has_subhashes = false
6
10
 
7
11
  h1 = self
@@ -1,15 +1,19 @@
1
1
 
2
2
  class String
3
+
4
+ # Is a String only made of numbers?
3
5
  def is_digit?
4
6
  r = '0'..'9'
5
7
  self.split('').keep_if{ |c| r.include?(c) }.count == self.length
6
8
  end
7
9
 
10
+ # Is a String only made of lower-case charaters.
8
11
  def is_lower?
9
12
  r = 'a'..'z'
10
13
  self.split('').keep_if{ |c| r.include?(c) }.count == self.length
11
14
  end
12
15
 
16
+ # Is a String only made of upper-case charaters.
13
17
  def is_upper?
14
18
  r = 'A'..'Z'
15
19
  self.split('').keep_if{ |c| r.include?(c) }.count == self.length
@@ -24,6 +28,7 @@ class String
24
28
  return true
25
29
  end
26
30
 
31
+ # Convert 'hello world' to 'Hello World'.
27
32
  def titlecase
28
33
  self
29
34
  .split(/ /)
@@ -35,6 +40,7 @@ class String
35
40
  self.split('').map{ |c| sprintf '%02x', c.ord }.join
36
41
  end
37
42
 
43
+ # Convert a String to an Integer 32-bit Array.
38
44
  def to_i32a
39
45
  len = self.length
40
46
  len_w = (len >> 2) + (len & 0x3).to_b.to_i
@@ -1,6 +1,9 @@
1
1
 
2
2
  class TrueClass
3
+
4
+ # bool.to_i
3
5
  def to_i
4
6
  1
5
7
  end
8
+
6
9
  end
@@ -1,8 +1,8 @@
1
1
 
2
2
  module TheFox
3
3
  module Ext
4
- RELEASE_ID = 10
5
- VERSION = '1.4.1'
6
- DATE = '2016-02-13'
4
+ VERSION = '1.5.0'
5
+ DATE = '2017-03-12'
6
+ HOMEPAGE = 'https://github.com/TheFox/ext.rb'
7
7
  end
8
8
  end
data/lib/thefox-ext.rb CHANGED
@@ -8,5 +8,6 @@ require 'thefox-ext/ext/integer'
8
8
  require 'thefox-ext/ext/nil'
9
9
  require 'thefox-ext/ext/string'
10
10
  require 'thefox-ext/ext/true'
11
+ require 'thefox-ext/ext/array'
11
12
 
12
13
  require 'thefox-ext/console'
data/thefox-ext.gemspec CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |spec|
13
13
  spec.email = 'christian@fox21.at'
14
14
 
15
15
  spec.summary = %q{Extended Ruby Classes}
16
- spec.description = %q{Extended and useful helper classes for Ruby.}
17
- spec.homepage = 'https://github.com/TheFox/ext.rb'
16
+ spec.description = %q{This gem extents some of the basic Ruby classes by missing functionalities.}
17
+ spec.homepage = TheFox::Ext::HOMEPAGE
18
18
  spec.license = 'GPL-3.0'
19
19
 
20
20
  spec.files = `git ls-files -z`.split("\x0").reject{ |f| f.match(%r{^(test|spec|features)/}) }
@@ -22,4 +22,6 @@ Gem::Specification.new do |spec|
22
22
  spec.required_ruby_version = '>=2.1.0'
23
23
 
24
24
  spec.add_development_dependency 'minitest', '~>5.8'
25
+ spec.add_development_dependency 'simplecov', '~>0.13'
26
+ spec.add_development_dependency 'simplecov-phpunit', '~>1.0'
25
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thefox-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Mayer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-13 00:00:00.000000000 Z
11
+ date: 2017-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -24,13 +24,43 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5.8'
27
- description: Extended and useful helper classes for Ruby.
27
+ - !ruby/object:Gem::Dependency
28
+ name: simplecov
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.13'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov-phpunit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ description: This gem extents some of the basic Ruby classes by missing functionalities.
28
56
  email: christian@fox21.at
29
57
  executables: []
30
58
  extensions: []
31
59
  extra_rdoc_files: []
32
60
  files:
61
+ - ".editorconfig"
33
62
  - ".gitignore"
63
+ - ".gitlab-ci.yml"
34
64
  - ".travis.yml"
35
65
  - Gemfile
36
66
  - Makefile
@@ -38,6 +68,7 @@ files:
38
68
  - README.md
39
69
  - lib/thefox-ext.rb
40
70
  - lib/thefox-ext/console.rb
71
+ - lib/thefox-ext/ext/array.rb
41
72
  - lib/thefox-ext/ext/date.rb
42
73
  - lib/thefox-ext/ext/false.rb
43
74
  - lib/thefox-ext/ext/hash.rb
@@ -46,14 +77,6 @@ files:
46
77
  - lib/thefox-ext/ext/string.rb
47
78
  - lib/thefox-ext/ext/true.rb
48
79
  - lib/thefox-ext/version.rb
49
- - tests/tc_date.rb
50
- - tests/tc_false.rb
51
- - tests/tc_hash.rb
52
- - tests/tc_integer.rb
53
- - tests/tc_nil.rb
54
- - tests/tc_string.rb
55
- - tests/tc_true.rb
56
- - tests/ts_all.rb
57
80
  - thefox-ext.gemspec
58
81
  - thefox-ext.sublime-project
59
82
  homepage: https://github.com/TheFox/ext.rb
@@ -76,9 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
99
  version: '0'
77
100
  requirements: []
78
101
  rubyforge_project:
79
- rubygems_version: 2.4.7
102
+ rubygems_version: 2.6.10
80
103
  signing_key:
81
104
  specification_version: 4
82
105
  summary: Extended Ruby Classes
83
106
  test_files: []
84
- has_rdoc:
data/tests/tc_date.rb DELETED
@@ -1,70 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'minitest/autorun'
4
- require 'thefox-ext'
5
-
6
-
7
- class TestDate < MiniTest::Test
8
- def test_today
9
- assert_equal(true, Date.today.today?)
10
-
11
- assert_equal(false, Date.new(2001, 2, 3).today?)
12
- assert_equal(false, Date.new(2001, 2, 4).today?)
13
-
14
- # This test may fail on 01.01.2018 ;)
15
- assert_equal(false, Date.new(2018, 1, 1).today?)
16
-
17
- assert_equal(true, Time.now.to_date.today?)
18
- end
19
-
20
- def test_week_mid
21
- e = ['2014-02-17', '2014-02-18', '2014-02-19', '2014-02-20', '2014-02-21', '2014-02-22', '2014-02-23']
22
- assert_equal(e, Date.new(2014, 2, 21).week.map{ |d| "#{d}" })
23
-
24
- e = ['2014-03-31', '2014-04-01', '2014-04-02', '2014-04-03', '2014-04-04', '2014-04-05', '2014-04-06']
25
- assert_equal(e, Date.new(2014, 4, 1).week.map{ |d| "#{d}" })
26
-
27
- e = ['2015-02-16', '2015-02-17', '2015-02-18', '2015-02-19', '2015-02-20', '2015-02-21', '2015-02-22']
28
- assert_equal(e, Date.new(2015, 2, 21).week.map{ |d| "#{d}" })
29
-
30
- e = ['2016-02-15', '2016-02-16', '2016-02-17', '2016-02-18', '2016-02-19', '2016-02-20', '2016-02-21']
31
- assert_equal(e, Date.new(2016, 2, 21).week.map{ |d| "#{d}" })
32
- end
33
-
34
- def test_week_jan
35
- e = ['2013-12-30', '2013-12-31', '2014-01-01', '2014-01-02', '2014-01-03', '2014-01-04', '2014-01-05']
36
- assert_equal(e, Date.new(2014, 1, 1).week.map{ |d| "#{d}" })
37
-
38
- e = ['2014-12-29', '2014-12-30', '2014-12-31',
39
- '2015-01-01', '2015-01-02', '2015-01-03', '2015-01-04']
40
- assert_equal(e, Date.new(2015, 1, 1).week.map{ |d| "#{d}" })
41
-
42
- e = ['2015-12-28', '2015-12-29', '2015-12-30', '2015-12-31',
43
- '2016-01-01', '2016-01-02', '2016-01-03']
44
- assert_equal(e, Date.new(2016, 1, 1).week.map{ |d| "#{d}" })
45
-
46
- e = ['2016-12-26', '2016-12-27', '2016-12-28', '2016-12-29', '2016-12-30', '2016-12-31',
47
- '2017-01-01']
48
- assert_equal(e, Date.new(2017, 1, 1).week.map{ |d| "#{d}" })
49
-
50
- e = ['2018-01-01', '2018-01-02', '2018-01-03', '2018-01-04', '2018-01-05', '2018-01-06', '2018-01-07']
51
- assert_equal(e, Date.new(2018, 1, 1).week.map{ |d| "#{d}" })
52
- end
53
-
54
- def test_week_dec
55
- e = ['2014-12-29', '2014-12-30', '2014-12-31',
56
- '2015-01-01', '2015-01-02', '2015-01-03', '2015-01-04']
57
- assert_equal(e, Date.new(2014, 12, 31).week.map{ |d| "#{d}" })
58
-
59
- e = ['2015-12-28', '2015-12-29', '2015-12-30', '2015-12-31',
60
- '2016-01-01', '2016-01-02', '2016-01-03']
61
- assert_equal(e, Date.new(2015, 12, 31).week.map{ |d| "#{d}" })
62
-
63
- e = ['2016-12-26', '2016-12-27', '2016-12-28', '2016-12-29', '2016-12-30', '2016-12-31',
64
- '2017-01-01']
65
- assert_equal(e, Date.new(2016, 12, 31).week.map{ |d| "#{d}" })
66
-
67
- e = ['2017-12-25', '2017-12-26', '2017-12-27', '2017-12-28', '2017-12-29', '2017-12-30', '2017-12-31']
68
- assert_equal(e, Date.new(2017, 12, 31).week.map{ |d| "#{d}" })
69
- end
70
- end
data/tests/tc_false.rb DELETED
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'minitest/autorun'
4
- require 'thefox-ext'
5
-
6
-
7
- class TestFalse < MiniTest::Test
8
- def test_false
9
- assert_equal(0, false.to_i)
10
- end
11
- end
data/tests/tc_hash.rb DELETED
@@ -1,135 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'minitest/autorun'
4
- require 'thefox-ext'
5
-
6
-
7
- class TestHash < MiniTest::Test
8
- def test_merge_recursive_clone1
9
- h1 = {'k1' => 1, 'k2' => 1}
10
- h2 = {'k1' => 2, 'k2' => 2}
11
-
12
- assert_equal({'k1' => 2, 'k2' => 2}, h1.merge_recursive(h2))
13
- end
14
-
15
- def test_merge_recursive_clone2
16
- h1 = {'k1' => 1, 'k2' => 1}
17
- h2 = {'k1' => 2, 'k3' => 2}
18
-
19
- assert_equal({'k1' => 2, 'k2' => 1, 'k3' => 2}, h1.merge_recursive(h2))
20
- end
21
-
22
- def test_merge_recursive_clone3
23
- h1 = {'k1' => 1, 'k2' => {'sk1' => 1}}
24
- h2 = {'k1' => 2, 'k2' => 2}
25
-
26
- assert_equal({'k1' => 2, 'k2' => 2}, h1.merge_recursive(h2))
27
- end
28
-
29
- def test_merge_recursive_clone4a
30
- h1 = {'k1' => 1, 'k2' => 1}
31
- h2 = {'k1' => 2, 'k2' => {'sk2' => 2}}
32
-
33
- assert_equal({'k1' => 2, 'k2' => {'sk2' => 2}}, h1.merge_recursive(h2))
34
- end
35
-
36
- def test_merge_recursive_clone4b
37
- h1 = {'k1' => 1, 'k2' => {'sk1' => 1}}
38
- h2 = {'k1' => 2, 'k2' => 1}
39
-
40
- assert_equal({'k1' => 2, 'k2' => 1}, h1.merge_recursive(h2))
41
- end
42
-
43
- def test_merge_recursive_clone5
44
- h1 = {'k1' => 1, 'k2' => {'sk1' => 1}}
45
- h2 = {'k1' => 2, 'k2' => {'sk2' => 2}}
46
-
47
- assert_equal({'k1' => 2, 'k2' => {'sk1' => 1, 'sk2' => 2}}, h1.merge_recursive(h2))
48
- end
49
-
50
- def test_merge_recursive_clone6
51
- h1 = {'k1' => 1, 'k2' => 1, 'k4' => {'sk1' => 1}}
52
- h2 = {'k1' => 2, 'k3' => 2, 'k4' => {'sk2' => 2}}
53
-
54
- assert_equal({'k1' => 2, 'k2' => 1, 'k3' => 2, 'k4' => {'sk1' => 1, 'sk2' => 2}}, h1.merge_recursive(h2))
55
- end
56
-
57
- def test_merge_recursive_clone7
58
- h1 = {'k1' => 1, 'k2' => {'sk1' => 1}}
59
- h2 = {'k1' => 2}
60
-
61
- assert_equal({'k1' => 2, 'k2' => {'sk1' => 1}}, h1.merge_recursive(h2))
62
- end
63
-
64
- def test_merge_recursive_self1
65
- h1 = {'k1' => 1, 'k2' => 1}
66
- h2 = {'k1' => 2, 'k2' => 2}
67
-
68
- h1.merge_recursive!(h2)
69
-
70
- assert_equal({'k1' => 2, 'k2' => 2}, h1)
71
- end
72
-
73
- def test_merge_recursive_self2
74
- h1 = {'k1' => 1, 'k2' => 1}
75
- h2 = {'k1' => 2, 'k3' => 2}
76
-
77
- h1.merge_recursive!(h2)
78
-
79
- assert_equal({'k1' => 2, 'k2' => 1, 'k3' => 2}, h1)
80
- end
81
-
82
- def test_merge_recursive_self3
83
- h1 = {'k1' => 1, 'k2' => {'sk1' => 1}}
84
- h2 = {'k1' => 2, 'k2' => 2}
85
-
86
- h1.merge_recursive!(h2)
87
-
88
- assert_equal({'k1' => 2, 'k2' => 2}, h1)
89
- end
90
-
91
- def test_merge_recursive_self4a
92
- h1 = {'k1' => 1, 'k2' => 1}
93
- h2 = {'k1' => 2, 'k2' => {'sk2' => 2}}
94
-
95
- h1.merge_recursive!(h2)
96
-
97
- assert_equal({'k1' => 2, 'k2' => {'sk2' => 2}}, h1)
98
- end
99
-
100
- def test_merge_recursive_self4b
101
- h1 = {'k1' => 1, 'k2' => {'sk2' => 1}}
102
- h2 = {'k1' => 2, 'k2' => 1}
103
-
104
- h1.merge_recursive!(h2)
105
-
106
- assert_equal({'k1' => 2, 'k2' => 1}, h1)
107
- end
108
-
109
- def test_merge_recursive_self5
110
- h1 = {'k1' => 1, 'k2' => {'sk1' => 1}}
111
- h2 = {'k1' => 2, 'k2' => {'sk2' => 2}}
112
-
113
- h1.merge_recursive!(h2)
114
-
115
- assert_equal({'k1' => 2, 'k2' => {'sk1' => 1, 'sk2' => 2}}, h1)
116
- end
117
-
118
- def test_merge_recursive_self6
119
- h1 = {'k1' => 1, 'k2' => 1, 'k4' => {'sk1' => 1}}
120
- h2 = {'k1' => 2, 'k3' => 2, 'k4' => {'sk2' => 2}}
121
-
122
- h1.merge_recursive!(h2)
123
-
124
- assert_equal({'k1' => 2, 'k2' => 1, 'k3' => 2, 'k4' => {'sk1' => 1, 'sk2' => 2}}, h1)
125
- end
126
-
127
- def test_merge_recursive_self7
128
- h1 = {'k1' => 1, 'k2' => {'sk1' => 1}}
129
- h2 = {'k1' => 2}
130
-
131
- h1.merge_recursive!(h2)
132
-
133
- assert_equal({'k1' => 2, 'k2' => {'sk1' => 1}}, h1)
134
- end
135
- end
data/tests/tc_integer.rb DELETED
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'minitest/autorun'
4
- require 'thefox-ext'
5
-
6
-
7
- class TestInteger < MiniTest::Test
8
- def test_to_b
9
- assert_equal(true, 3.to_b)
10
- assert_equal(true, 2.to_b)
11
- assert_equal(true, 1.to_b)
12
-
13
- assert_equal(false, 0.to_b)
14
-
15
- assert_equal(true, -1.to_b)
16
- assert_equal(true, -2.to_b)
17
- assert_equal(true, -3.to_b)
18
-
19
- end
20
- end
data/tests/tc_nil.rb DELETED
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'minitest/autorun'
4
- require 'thefox-ext'
5
-
6
-
7
- class TestNil < MiniTest::Test
8
- def test_to_utf8
9
- assert_equal('', nil.to_utf8)
10
- end
11
- end
data/tests/tc_string.rb DELETED
@@ -1,87 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'minitest/autorun'
4
- require 'thefox-ext'
5
-
6
-
7
- class TestString < MiniTest::Test
8
- def test_is_digit
9
- assert_equal(true, '0123456789'.is_digit?)
10
- assert_equal(true, '1'.is_digit?)
11
- assert_equal(true, '2'.is_digit?)
12
-
13
- assert_equal(false, 'ABC'.is_digit?)
14
- assert_equal(false, 'A'.is_digit?)
15
- assert_equal(false, 'A123'.is_digit?)
16
- assert_equal(false, '123B'.is_digit?)
17
-
18
- assert_equal(false, 'abc'.is_digit?)
19
- assert_equal(false, 'a'.is_digit?)
20
- assert_equal(false, 'a123'.is_digit?)
21
- assert_equal(false, '123b'.is_digit?)
22
- end
23
-
24
- def test_is_lower
25
- assert_equal(false, '0123456789'.is_lower?)
26
- assert_equal(false, '1'.is_lower?)
27
- assert_equal(false, '2'.is_lower?)
28
-
29
- assert_equal(false, 'ABC'.is_lower?)
30
- assert_equal(false, 'A'.is_lower?)
31
- assert_equal(false, 'A123'.is_lower?)
32
- assert_equal(false, '123B'.is_lower?)
33
-
34
- assert_equal(true, 'abc'.is_lower?)
35
- assert_equal(true, 'a'.is_lower?)
36
- assert_equal(false, 'a123'.is_lower?)
37
- assert_equal(false, '123b'.is_lower?)
38
- end
39
-
40
- def test_is_upper
41
- assert_equal(false, '0123456789'.is_upper?)
42
- assert_equal(false, '1'.is_upper?)
43
- assert_equal(false, '2'.is_upper?)
44
-
45
- assert_equal(true, 'ABC'.is_upper?)
46
- assert_equal(true, 'A'.is_upper?)
47
- assert_equal(false, 'A123'.is_upper?)
48
- assert_equal(false, '123B'.is_upper?)
49
-
50
- assert_equal(false, 'abc'.is_upper?)
51
- assert_equal(false, 'a'.is_upper?)
52
- assert_equal(false, 'a123'.is_upper?)
53
- assert_equal(false, '123b'.is_upper?)
54
- end
55
-
56
- def test_is_utf8
57
- assert_equal(true, 'ABC'.is_utf8?)
58
- assert_equal(true, 'üäöß'.is_utf8?)
59
- end
60
-
61
- def test_titlecase
62
- assert_equal('Abc Abc', 'ABC ABC'.titlecase)
63
- assert_equal('Abc Abc', 'ABC abc'.titlecase)
64
- assert_equal('Abc Abc', 'abc ABC'.titlecase)
65
- assert_equal('Abc Abc', 'Abc Abc'.titlecase)
66
- assert_equal('Abc Abc', 'abc abc'.titlecase)
67
- assert_equal('Abc Abc', 'aBc abc'.titlecase)
68
- assert_equal('Abc Abc', 'aBc abC'.titlecase)
69
-
70
- assert_equal('Abc1 Abc2', 'ABC1 ABC2'.titlecase)
71
-
72
- assert_equal('(abc Abc)', '(ABC ABC)'.titlecase)
73
- end
74
-
75
- def test_to_hex
76
- assert_equal('41424320414243', 'ABC ABC'.to_hex)
77
- end
78
-
79
- def test_to_i32a
80
- assert_equal({0 => 1090519040}, 'A'.to_i32a)
81
- end
82
-
83
- def test_to_utf8
84
- assert_equal('Abc', 'Abc'.to_utf8)
85
- assert_equal('AüäößE', 'AüäößE'.to_utf8)
86
- end
87
- end
data/tests/tc_true.rb DELETED
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'minitest/autorun'
4
- require 'thefox-ext'
5
-
6
-
7
- class TestTrue < MiniTest::Test
8
- def test_to_i
9
- assert_equal(1, true.to_i)
10
- end
11
- end
data/tests/ts_all.rb DELETED
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative 'tc_date'
4
- require_relative 'tc_false'
5
- require_relative 'tc_hash'
6
- require_relative 'tc_integer'
7
- require_relative 'tc_nil'
8
- require_relative 'tc_string'
9
- require_relative 'tc_true'