thefox-ext 1.1.1 → 1.2.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: 98ab102527798b7c90f7e4eb0e4f2c6e63b9cd58
4
- data.tar.gz: 7f4ccccbfd77b66d7d7f769697d02b3f0127d7a4
3
+ metadata.gz: ee911e444424c00f4bd6a4e18f439e8121057000
4
+ data.tar.gz: 4b2a22e6b4bc4b93e9306e9930b3780bc86a64b9
5
5
  SHA512:
6
- metadata.gz: ddf600d32d7600ac1639033c401b45f637e7f6e808a743d77e9c0a0f8dbba88c7c8501798ef158f49e05b0311cd46abb96e0f74e33e611ea3707099baef40d9c
7
- data.tar.gz: 3591e74b9db8e998021c071974c962320f36dcce26ab7a4b2eac12a9e8f683699c72e1ab9284a85eb800d92b25dafdf3d888338da045a9cc8367d14f0e2083f1
6
+ metadata.gz: 10a470cfb54127d0bc24b1bc62b2d5b31e6cb1a7c2ca7d1577c956e9746d804be27b661437ee7117dc6157f4c8cda5a610feba95589de60f8cc0b5c846a2c45c
7
+ data.tar.gz: 76ca6d660005fa7d8e7564445fc1eaae37f2cb4f21821d765e0af62872d37227f85202ebaff4146f40fe1833dbf2a7f3f19a4261d7a9e5089dc627a74c063b4e
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1
4
+ - 2.2
5
+ before_install:
6
+ - ruby --version
7
+ script:
8
+ - make test
9
+ - make install
data/Gemfile.lock CHANGED
@@ -1,16 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- thefox-ext (1.1.1)
4
+ thefox-ext (1.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ minitest (5.8.3)
9
10
 
10
11
  PLATFORMS
11
12
  ruby
12
13
 
13
14
  DEPENDENCIES
15
+ bundler (~> 1.10)
16
+ minitest (~> 5.8)
14
17
  thefox-ext!
15
18
 
16
19
  BUNDLED WITH
data/Makefile CHANGED
@@ -2,3 +2,7 @@
2
2
  GEM_NAME = thefox-ext
3
3
 
4
4
  include Makefile.common
5
+
6
+ .PHONY: test
7
+ test:
8
+ RUBYOPT=-w ./tests/ts_all.rb
data/Makefile.common CHANGED
@@ -1,21 +1,22 @@
1
1
 
2
2
  # Ruby Common Big
3
- # 2015-12-07
3
+ # 2015-12-15
4
4
 
5
5
  MV = mv -nv
6
6
  RM = rm -rf
7
7
  MKDIR = mkdir -p
8
8
  BUNDLER = bundle
9
+ BUNDLER_OPTIONS = --jobs=5 --retry=3
9
10
  GEMSPEC_FILE = $(GEM_NAME).gemspec
10
11
 
11
- .PHONY: all
12
+ .PHONY: all $(ALL_TARGETS_EXT)
12
13
  all: setup
13
14
 
14
15
  .PHONY: setup
15
16
  setup: .setup
16
17
 
17
18
  .setup:
18
- $(BUNDLER) install
19
+ $(BUNDLER) install $(BUNDLER_OPTIONS)
19
20
  touch $@
20
21
 
21
22
  .PHONY: install
data/lib/thefox-ext.rb CHANGED
@@ -6,3 +6,5 @@ require 'thefox-ext/ext/integer'
6
6
  require 'thefox-ext/ext/nil'
7
7
  require 'thefox-ext/ext/string'
8
8
  require 'thefox-ext/ext/true'
9
+
10
+ require 'thefox-ext/console'
@@ -0,0 +1,50 @@
1
+
2
+ class Console
3
+
4
+ CHAR_ESCAPE = "\x1b"
5
+
6
+ def self.cursor_up(rows = 1)
7
+ print "#{CHAR_ESCAPE}[#{rows}A"
8
+ end
9
+
10
+ def self.cursor_down(rows = 1)
11
+ print "#{CHAR_ESCAPE}[#{rows}B"
12
+ end
13
+
14
+ def self.cursor_jump_to_top
15
+ print "#{CHAR_ESCAPE}[1;1f"
16
+ end
17
+
18
+ def self.cursor_jump_to_column(col = 1)
19
+ print "#{CHAR_ESCAPE}[#{col}G"
20
+ end
21
+
22
+ def self.cursor_right(offset = 1)
23
+ print "#{CHAR_ESCAPE}[#{offset}C"
24
+ end
25
+
26
+ def self.cursor_left(offset = 1)
27
+ print "#{CHAR_ESCAPE}[#{offset}D"
28
+ end
29
+
30
+ def self.line_clear
31
+ print "\r#{CHAR_ESCAPE}[K"
32
+ end
33
+
34
+ def self.line_clear_right
35
+ print "#{CHAR_ESCAPE}[0K"
36
+ end
37
+
38
+ def self.screen_clear_to_bottom
39
+ print "#{CHAR_ESCAPE}[J"
40
+ end
41
+
42
+ def self.scroll_up
43
+ print "#{CHAR_ESCAPE}[S"
44
+ end
45
+
46
+ def self.scroll_down
47
+ print "#{CHAR_ESCAPE}[T"
48
+ end
49
+
50
+ end
@@ -1,5 +1,5 @@
1
1
 
2
- class Nil
2
+ class NilClass
3
3
  def to_utf8
4
4
  ''
5
5
  end
@@ -31,6 +31,10 @@ class String
31
31
  .join(' ')
32
32
  end
33
33
 
34
+ def to_hex
35
+ self.split('').map{ |c| sprintf '%02x', c.ord }.join
36
+ end
37
+
34
38
  def to_i32a
35
39
  len = self.length
36
40
  len_w = (len >> 2) + (len & 0x3).to_b.to_i
@@ -1,7 +1,7 @@
1
1
 
2
2
  module TheFox
3
3
  module Ext
4
- VERSION = '1.1.1'
5
- DATE = '2015-12-15'
4
+ VERSION = '1.2.0'
5
+ DATE = '2015-12-17'
6
6
  end
7
7
  end
data/tests/tc_false.rb ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'minitest/autorun'
5
+ require 'thefox-ext'
6
+
7
+ class TestFalse < MiniTest::Test
8
+ def test_false
9
+ assert_equal(0, false.to_i)
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'minitest/autorun'
5
+ require 'thefox-ext'
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 ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'minitest/autorun'
5
+ require 'thefox-ext'
6
+
7
+ class TestNil < MiniTest::Test
8
+ def test_to_utf8
9
+ assert_equal('', nil.to_utf8)
10
+ end
11
+ end
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'minitest/autorun'
5
+ require 'thefox-ext'
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 ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'minitest/autorun'
5
+ require 'thefox-ext'
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 ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative 'tc_false'
4
+ require_relative 'tc_integer'
5
+ require_relative 'tc_nil'
6
+ require_relative 'tc_string'
7
+ require_relative 'tc_true'
data/thefox-ext.gemspec CHANGED
@@ -19,5 +19,8 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.files = `git ls-files -z`.split("\x0").reject{ |f| f.match(%r{^(test|spec|features)/}) }
21
21
  spec.require_paths = ['lib']
22
- spec.required_ruby_version = '>=2.2.0'
22
+ spec.required_ruby_version = '>=2.1.0'
23
+
24
+ spec.add_development_dependency 'bundler', '~>1.10'
25
+ spec.add_development_dependency 'minitest', '~>5.8'
23
26
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thefox-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.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: 2015-12-15 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2015-12-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.8'
13
41
  description: Extended and useful helper classes for Ruby.
14
42
  email: christian@fox21.at
15
43
  executables: []
@@ -17,18 +45,26 @@ extensions: []
17
45
  extra_rdoc_files: []
18
46
  files:
19
47
  - ".gitignore"
48
+ - ".travis.yml"
20
49
  - Gemfile
21
50
  - Gemfile.lock
22
51
  - Makefile
23
52
  - Makefile.common
24
53
  - README.md
25
54
  - lib/thefox-ext.rb
55
+ - lib/thefox-ext/console.rb
26
56
  - lib/thefox-ext/ext/false.rb
27
57
  - lib/thefox-ext/ext/integer.rb
28
58
  - lib/thefox-ext/ext/nil.rb
29
59
  - lib/thefox-ext/ext/string.rb
30
60
  - lib/thefox-ext/ext/true.rb
31
61
  - lib/thefox-ext/version.rb
62
+ - tests/tc_false.rb
63
+ - tests/tc_integer.rb
64
+ - tests/tc_nil.rb
65
+ - tests/tc_string.rb
66
+ - tests/tc_true.rb
67
+ - tests/ts_all.rb
32
68
  - thefox-ext.gemspec
33
69
  - thefox-ext.sublime-project
34
70
  homepage: https://github.com/TheFox/ext.rb
@@ -43,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
43
79
  requirements:
44
80
  - - ">="
45
81
  - !ruby/object:Gem::Version
46
- version: 2.2.0
82
+ version: 2.1.0
47
83
  required_rubygems_version: !ruby/object:Gem::Requirement
48
84
  requirements:
49
85
  - - ">="