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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +17 -0
- data/Makefile +2 -12
- data/Makefile.common +50 -0
- data/README.md +10 -0
- data/lib/thefox-ext/ext/false.rb +6 -0
- data/lib/thefox-ext/ext/integer.rb +6 -0
- data/lib/thefox-ext/ext/nil.rb +6 -0
- data/lib/thefox-ext/ext/string.rb +35 -5
- data/lib/thefox-ext/ext/true.rb +6 -0
- data/lib/thefox-ext/version.rb +2 -2
- data/lib/thefox-ext.rb +5 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1b6504880a7a35c953cfec40f51426fe2b0e0cc
|
4
|
+
data.tar.gz: 8c02a3732da102ce197b52af5658c11f7f83429e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 258fa61735ef85f3583d808e6611080908ec9b2fe1f4dc337b6f5efe464a24d115015b26417c8274eecad5ce59b3a188b3e26a606004d8cbc6033cdd27994a90
|
7
|
+
data.tar.gz: f60a8b14ec67b8107ae33d644c9b280a32b53fdbdc303b3203997d4733340933b8dcfc2a84f2b1fe97b0e25b1fdcc2e6d62329768009e6cfca8e9153076dad01
|
data/.gitignore
CHANGED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/Makefile
CHANGED
@@ -1,14 +1,4 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
GEM_NAME = thefox-ext
|
3
3
|
|
4
|
-
.
|
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)
|
@@ -1,10 +1,18 @@
|
|
1
1
|
|
2
2
|
class String
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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')
|
data/lib/thefox-ext/version.rb
CHANGED
data/lib/thefox-ext.rb
CHANGED
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
|
+
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-
|
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
|