thefox-ext 1.0.0 → 1.1.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: ed21df13d8eec335d281b280f5967f375eb9b46c
4
- data.tar.gz: 9e9190942cccc50480d8ab2441e5d8346c38ec8a
3
+ metadata.gz: a1b6504880a7a35c953cfec40f51426fe2b0e0cc
4
+ data.tar.gz: 8c02a3732da102ce197b52af5658c11f7f83429e
5
5
  SHA512:
6
- metadata.gz: 8d7820a07fd851511cdeea64e053e3624777dc05794af09d0545bf94ef0bb606c147746f4d0a2bf071a78db3151c4e581404d9353e9f28915336dbc758641224
7
- data.tar.gz: d30a2b3e130c1746e788849ea2719669b2e8d796b683c479781867e4f6fe4a367bfe12756fe14686e653746a05e71a389b686daf12da45d2392e716f5a87f5a2
6
+ metadata.gz: 258fa61735ef85f3583d808e6611080908ec9b2fe1f4dc337b6f5efe464a24d115015b26417c8274eecad5ce59b3a188b3e26a606004d8cbc6033cdd27994a90
7
+ data.tar.gz: f60a8b14ec67b8107ae33d644c9b280a32b53fdbdc303b3203997d4733340933b8dcfc2a84f2b1fe97b0e25b1fdcc2e6d62329768009e6cfca8e9153076dad01
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
+ .setup
1
2
  CHANGELOG-*.txt
2
3
  /releases/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+
2
+ source 'https://rubygems.org'
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,17 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ thefox-ext (1.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ thefox-ext!
15
+
16
+ BUNDLED WITH
17
+ 1.10.2
data/Makefile CHANGED
@@ -1,14 +1,4 @@
1
1
 
2
- MV = mv -nv
2
+ GEM_NAME = thefox-ext
3
3
 
4
- .PHONY: all
5
- all:
6
-
7
- release:
8
- set -e; \
9
- gem_file=$$(gem build thefox-ext.gemspec | grep 'File:' | tail -1 | awk '{ print $$2 }'); \
10
- dst="releases/$$gem_file"; \
11
- [ ! -f $$dst ]; \
12
- $(MV) $$gem_file releases; \
13
- gem push $$dst; \
14
- echo 'done'
4
+ include Makefile.common
data/Makefile.common ADDED
@@ -0,0 +1,50 @@
1
+
2
+ # Ruby Common Big
3
+ # 2015-12-07
4
+
5
+ MV = mv -nv
6
+ RM = rm -rf
7
+ MKDIR = mkdir -p
8
+ BUNDLER = bundle
9
+ GEMSPEC_FILE = $(GEM_NAME).gemspec
10
+
11
+ .PHONY: all
12
+ all: setup
13
+
14
+ .PHONY: setup
15
+ setup: .setup
16
+
17
+ .setup:
18
+ $(BUNDLER) install
19
+ touch $@
20
+
21
+ .PHONY: install
22
+ install:
23
+ gem_file=$$(gem build $(GEMSPEC_FILE) | grep 'File:' | tail -1 | awk '{ print $$2 }'); \
24
+ sudo gem install $$gem_file; \
25
+ $(RM) $$gem_file
26
+
27
+ .PHONY: uninstall
28
+ uninstall:
29
+ sudo gem uninstall $(GEM_NAME)
30
+
31
+ .PHONY: update
32
+ update:
33
+ $(BUNDLER) update
34
+
35
+ .PHONY: clean
36
+ clean:
37
+ $(RM) .setup
38
+
39
+ .PHONY: release
40
+ release: | releases
41
+ set -e; \
42
+ gem_file=$$(gem build $(GEMSPEC_FILE) | grep 'File:' | tail -1 | awk '{ print $$2 }'); \
43
+ dst="releases/$$gem_file"; \
44
+ [ ! -f $$dst ]; \
45
+ $(MV) $$gem_file releases; \
46
+ gem push $$dst; \
47
+ echo 'done'
48
+
49
+ releases:
50
+ $(MKDIR) $@
data/README.md CHANGED
@@ -7,6 +7,16 @@ Extended and useful helper classes for Ruby.
7
7
  The preferred method of installation is via RubyGems.org:
8
8
  <https://rubygems.org/gems/thefox-ext>
9
9
 
10
+ gem install thefox-ext
11
+
12
+ or via `Gemfile`:
13
+
14
+ gem 'thefox-ext', '~>1.0'
15
+
16
+ Use it in your sources:
17
+
18
+ require 'thefox-ext'
19
+
10
20
  ## Features
11
21
 
12
22
  - [String Manipulation](lib/thefox-ext/ext/string.rb)
@@ -0,0 +1,6 @@
1
+
2
+ class FalseClass
3
+ def to_i
4
+ 0
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+
2
+ class Integer
3
+ def to_b
4
+ !self.zero?
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+
2
+ class Nil
3
+ def to_utf8
4
+ ''
5
+ end
6
+ end
@@ -1,10 +1,18 @@
1
1
 
2
2
  class String
3
- def titlecase
4
- self
5
- .split(/ /)
6
- .map{ |word| word.capitalize }
7
- .join(' ')
3
+ def is_digit?
4
+ r = '0'..'9'
5
+ self.split('').keep_if{ |c| r.include?(c) }.count == self.length
6
+ end
7
+
8
+ def is_lower?
9
+ r = 'a'..'z'
10
+ self.split('').keep_if{ |c| r.include?(c) }.count == self.length
11
+ end
12
+
13
+ def is_upper?
14
+ r = 'A'..'Z'
15
+ self.split('').keep_if{ |c| r.include?(c) }.count == self.length
8
16
  end
9
17
 
10
18
  def is_utf8?
@@ -16,6 +24,28 @@ class String
16
24
  return true
17
25
  end
18
26
 
27
+ def titlecase
28
+ self
29
+ .split(/ /)
30
+ .map{ |word| word.capitalize }
31
+ .join(' ')
32
+ end
33
+
34
+ def to_i32a
35
+ len = self.length
36
+ len_w = (len >> 2) + (len & 0x3).to_b.to_i
37
+
38
+ out = (0..(len_w - 1)).map{ |n| [n, 0] }.to_h
39
+
40
+ i = 0
41
+ self.split('').each do |s|
42
+ out[i >> 2] |= (s.ord << ((3 - (i & 0x3)) << 3))
43
+ i += 1
44
+ end
45
+
46
+ out
47
+ end
48
+
19
49
  def to_utf8
20
50
  if is_utf8?
21
51
  self.force_encoding('UTF-8')
@@ -0,0 +1,6 @@
1
+
2
+ class TrueClass
3
+ def to_i
4
+ 1
5
+ end
6
+ end
@@ -1,7 +1,7 @@
1
1
 
2
2
  module TheFox
3
3
  module Ext
4
- VERSION = '1.0.0'
5
- DATE = '2015-12-06'
4
+ VERSION = '1.1.0'
5
+ DATE = '2015-12-07'
6
6
  end
7
7
  end
data/lib/thefox-ext.rb CHANGED
@@ -1,3 +1,8 @@
1
1
 
2
2
  require 'thefox-ext/version'
3
+
4
+ require 'thefox-ext/ext/false'
5
+ require 'thefox-ext/ext/integer'
6
+ require 'thefox-ext/ext/nil'
3
7
  require 'thefox-ext/ext/string'
8
+ require 'thefox-ext/ext/true'
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.0.0
4
+ version: 1.1.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-06 00:00:00.000000000 Z
11
+ date: 2015-12-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Extended and useful helper classes for Ruby.
14
14
  email: christian@fox21.at
@@ -17,10 +17,17 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - ".gitignore"
20
+ - Gemfile
21
+ - Gemfile.lock
20
22
  - Makefile
23
+ - Makefile.common
21
24
  - README.md
22
25
  - lib/thefox-ext.rb
26
+ - lib/thefox-ext/ext/false.rb
27
+ - lib/thefox-ext/ext/integer.rb
28
+ - lib/thefox-ext/ext/nil.rb
23
29
  - lib/thefox-ext/ext/string.rb
30
+ - lib/thefox-ext/ext/true.rb
24
31
  - lib/thefox-ext/version.rb
25
32
  - thefox-ext.gemspec
26
33
  - thefox-ext.sublime-project