thefox-ext 1.4.0 → 1.6.3.pre.rc.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +15 -0
- data/.env.example +2 -0
- data/.github/workflows/ci.yml +39 -0
- data/.github/workflows/release.yml +38 -0
- data/.gitignore +3 -4
- data/CHANGELOG-v1.md +68 -0
- data/LICENSE +21 -0
- data/README.md +20 -13
- data/bin/.gitignore +1 -0
- data/bin/install.sh +51 -0
- data/bin/release.sh +37 -0
- data/bin/setup.sh +17 -0
- data/bin/test.sh +13 -0
- data/bin/uninstall.sh +24 -0
- data/lib/thefox-ext.rb +1 -0
- data/lib/thefox-ext/console.rb +47 -47
- data/lib/thefox-ext/ext/array.rb +38 -0
- data/lib/thefox-ext/ext/date.rb +42 -41
- data/lib/thefox-ext/ext/false.rb +6 -3
- data/lib/thefox-ext/ext/hash.rb +62 -55
- data/lib/thefox-ext/ext/integer.rb +3 -3
- data/lib/thefox-ext/ext/nil.rb +3 -3
- data/lib/thefox-ext/ext/string.rb +63 -57
- data/lib/thefox-ext/ext/true.rb +6 -3
- data/lib/thefox-ext/version.rb +5 -4
- data/thefox-ext.code-workspace +32 -0
- data/thefox-ext.gemspec +9 -7
- metadata +53 -21
- data/.travis.yml +0 -16
- data/Makefile +0 -8
- data/Makefile.common +0 -53
- data/tests/tc_date.rb +0 -70
- data/tests/tc_false.rb +0 -11
- data/tests/tc_hash.rb +0 -103
- data/tests/tc_integer.rb +0 -20
- data/tests/tc_nil.rb +0 -11
- data/tests/tc_string.rb +0 -87
- data/tests/tc_true.rb +0 -11
- data/tests/ts_all.rb +0 -9
- data/thefox-ext.sublime-project +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb29dbe2b611a1e90870883e49ed7f76ae04e5c7
|
4
|
+
data.tar.gz: 116453f66db3968ee85a1580640ce0bfaba857f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36a74d9e537ff7719d1f55c8c29bc4d885271d273b437b63f1dd3611f45607a017a5a264ca4faaa5613282d5c26e71de60518f342b170af5c358cc8fc62aa21c
|
7
|
+
data.tar.gz: ec59119bc45373620c74a7e13c856a4c4f8c9bc482a091395a73b302707c0967ac22ae6089611f73ebf58cf479f6d3e87c5e6b74be0569adeb3044a4427dc9fb
|
data/.editorconfig
ADDED
data/.env.example
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
|
2
|
+
name: CI
|
3
|
+
|
4
|
+
env:
|
5
|
+
LANG: C.UTF-8
|
6
|
+
GEM_NAME: thefox-ext
|
7
|
+
GEMSPEC_FILE: thefox-ext.gemspec
|
8
|
+
|
9
|
+
on:
|
10
|
+
push:
|
11
|
+
branches:
|
12
|
+
- master
|
13
|
+
tags:
|
14
|
+
- v*
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
runs-on: ubuntu-latest
|
19
|
+
strategy:
|
20
|
+
matrix:
|
21
|
+
ruby-version:
|
22
|
+
- '2.3'
|
23
|
+
- '2.4'
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v2
|
26
|
+
- name: Set up Ruby
|
27
|
+
uses: ruby/setup-ruby@v1
|
28
|
+
#uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
29
|
+
with:
|
30
|
+
ruby-version: ${{ matrix.ruby-version }}
|
31
|
+
bundler-cache: true
|
32
|
+
- name: Setup Rubygems
|
33
|
+
run: |
|
34
|
+
mkdir -p ~/.gem
|
35
|
+
printf "%s\n:rubygems_api_key: %s" "---" "${RUBYGEMSORG_API_KEY}" > ~/.gem/credentials; chmod 0600 ~/.gem/credentials
|
36
|
+
- name: Install
|
37
|
+
run: ./bin/install.sh
|
38
|
+
- name: Run tests
|
39
|
+
run: ./bin/test.sh
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
name: Release
|
3
|
+
|
4
|
+
env:
|
5
|
+
LANG: C.UTF-8
|
6
|
+
GEM_NAME: thefox-ext
|
7
|
+
GEMSPEC_FILE: thefox-ext.gemspec
|
8
|
+
|
9
|
+
on:
|
10
|
+
push:
|
11
|
+
tags:
|
12
|
+
- v*
|
13
|
+
|
14
|
+
jobs:
|
15
|
+
release:
|
16
|
+
runs-on: ubuntu-latest
|
17
|
+
strategy:
|
18
|
+
matrix:
|
19
|
+
ruby-version:
|
20
|
+
- '2.4'
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
- name: Set up Ruby
|
24
|
+
uses: ruby/setup-ruby@v1
|
25
|
+
#uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
26
|
+
with:
|
27
|
+
ruby-version: ${{ matrix.ruby-version }}
|
28
|
+
bundler-cache: true
|
29
|
+
- name: Setup Rubygems
|
30
|
+
env:
|
31
|
+
RUBYGEMSORG_API_KEY: ${{ secrets.RUBYGEMSORG_API_KEY }}
|
32
|
+
run: |
|
33
|
+
mkdir -p ~/.gem
|
34
|
+
printf "%s\n:rubygems_api_key: %s" "---" "${RUBYGEMSORG_API_KEY}" > ~/.gem/credentials; chmod 0600 ~/.gem/credentials
|
35
|
+
- name: Install
|
36
|
+
run: ./bin/install.sh
|
37
|
+
- name: Release
|
38
|
+
run: ./bin/release.sh
|
data/.gitignore
CHANGED
data/CHANGELOG-v1.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Release Notes for Extended Ruby Classes v1.x
|
2
|
+
|
3
|
+
## v1.7.0 [unreleased]
|
4
|
+
|
5
|
+
## v1.6.0
|
6
|
+
|
7
|
+
- MIT License
|
8
|
+
- Remove Travis CI support.
|
9
|
+
- Range++
|
10
|
+
|
11
|
+
## v1.5.1
|
12
|
+
|
13
|
+
- Local variable shadowing fix.
|
14
|
+
|
15
|
+
## v1.5.0
|
16
|
+
|
17
|
+
- Array: Range String Resolver added.
|
18
|
+
- Test and release using Ruby 2.4.
|
19
|
+
|
20
|
+
## v1.4.2
|
21
|
+
|
22
|
+
- Hash, merge_recursive() - check h2 class.
|
23
|
+
|
24
|
+
## v1.4.1
|
25
|
+
|
26
|
+
- Hash Bugfix: do nothing when the key of Hash 2 doesn't exist.
|
27
|
+
|
28
|
+
## v1.4.0
|
29
|
+
|
30
|
+
- Hash extension added.
|
31
|
+
- Date: get week array for a specific date.
|
32
|
+
- Hash: don't make a clone; modify the source hash.
|
33
|
+
|
34
|
+
## v1.3.0
|
35
|
+
|
36
|
+
- `Date.today?` function added.
|
37
|
+
|
38
|
+
## v1.2.1
|
39
|
+
|
40
|
+
- Dependency fixes.
|
41
|
+
|
42
|
+
## v1.2.0
|
43
|
+
|
44
|
+
- String: to_hex function added.
|
45
|
+
- Console support class added.
|
46
|
+
- NilClass fix.
|
47
|
+
- Tests added.
|
48
|
+
|
49
|
+
## v1.1.1
|
50
|
+
|
51
|
+
- Version date fix.
|
52
|
+
|
53
|
+
## v1.1.0
|
54
|
+
|
55
|
+
- 'install' target added.
|
56
|
+
- Nil extension added.
|
57
|
+
- Common Makefile added.
|
58
|
+
- True extension added.
|
59
|
+
- False extension added.
|
60
|
+
- Integer extension added.
|
61
|
+
- String: to_i32a function added.
|
62
|
+
- String: is_digit, is_lower and is_upper function added.
|
63
|
+
|
64
|
+
## v1.0.0
|
65
|
+
|
66
|
+
- String Manipulation
|
67
|
+
- Title Case
|
68
|
+
- UTF-8 Encoding
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2015 Christian Mayer
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,21 +1,34 @@
|
|
1
1
|
# Extended Ruby Classes
|
2
2
|
|
3
|
-
|
3
|
+
This gem extents some of the basic Ruby classes by missing functionalities.
|
4
|
+
|
5
|
+
## Project Outlines
|
6
|
+
|
7
|
+
The project outlines as described in my blog post about [Open Source Software Collaboration](https://blog.fox21.at/2019/02/21/open-source-software-collaboration.html).
|
8
|
+
|
9
|
+
- The main purpose of this collection is to provide common single functions or classes, which are too small for a separate project.
|
10
|
+
- This list is open. Feel free to request features.
|
4
11
|
|
5
12
|
## Install
|
6
13
|
|
7
|
-
The preferred method of installation is via RubyGems.org:
|
14
|
+
The preferred method of installation is via RubyGems.org:
|
8
15
|
<https://rubygems.org/gems/thefox-ext>
|
9
16
|
|
10
|
-
|
17
|
+
```bash
|
18
|
+
gem install thefox-ext
|
19
|
+
```
|
11
20
|
|
12
21
|
or via `Gemfile`:
|
13
22
|
|
14
|
-
|
23
|
+
```ruby
|
24
|
+
gem 'thefox-ext', '~>1.5'
|
25
|
+
```
|
15
26
|
|
16
27
|
Use it in your sources:
|
17
28
|
|
18
|
-
|
29
|
+
```ruby
|
30
|
+
require 'thefox-ext'
|
31
|
+
```
|
19
32
|
|
20
33
|
## Features
|
21
34
|
|
@@ -27,17 +40,11 @@ Use it in your sources:
|
|
27
40
|
- Date
|
28
41
|
- `today?`
|
29
42
|
- Get week array for a specific date.
|
43
|
+
- Array
|
44
|
+
- Range String Resolver
|
30
45
|
- Hash
|
31
46
|
- Recursive Merge
|
32
47
|
|
33
48
|
## Project Links
|
34
49
|
|
35
50
|
- [Gem](https://rubygems.org/gems/thefox-ext)
|
36
|
-
- [Travis CI Repository](https://travis-ci.org/TheFox/ext.rb)
|
37
|
-
|
38
|
-
## License
|
39
|
-
Copyright (C) 2015 Christian Mayer <http://fox21.at>
|
40
|
-
|
41
|
-
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
|
-
|
43
|
-
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
data/bin/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
dev
|
data/bin/install.sh
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# Install Gem local.
|
4
|
+
|
5
|
+
SCRIPT_BASEDIR=$(dirname "$0")
|
6
|
+
|
7
|
+
|
8
|
+
option=$1
|
9
|
+
set -e
|
10
|
+
which mkdir &> /dev/null || { echo 'ERROR: mkdir not found in PATH'; exit 1; }
|
11
|
+
which mv &> /dev/null || { echo 'ERROR: mv not found in PATH'; exit 1; }
|
12
|
+
which chmod &> /dev/null || { echo 'ERROR: chmod not found in PATH'; exit 1; }
|
13
|
+
which gem &> /dev/null || { echo 'ERROR: gem not found in PATH'; exit 1; }
|
14
|
+
which bundler &> /dev/null || { echo 'ERROR: bundler not found in PATH'; exit 1; }
|
15
|
+
|
16
|
+
cd "${SCRIPT_BASEDIR}/.."
|
17
|
+
|
18
|
+
# Load Environment Variables
|
19
|
+
[[ -f .env ]] && source .env
|
20
|
+
|
21
|
+
if [[ -z "${GEMSPEC_FILE}" ]] ; then
|
22
|
+
echo 'ERROR: one of the environment variables is missing'
|
23
|
+
|
24
|
+
echo "GEMSPEC_FILE: '${GEMSPEC_FILE}'"
|
25
|
+
|
26
|
+
exit 1
|
27
|
+
fi
|
28
|
+
|
29
|
+
gem_file=$(gem build "${GEMSPEC_FILE}" 2> /dev/null | grep 'File:' | tail -1 | awk '{ print $2 }')
|
30
|
+
|
31
|
+
if [[ -z "$gem_file" ]] ; then
|
32
|
+
echo 'ERROR: gem_file variable not set'
|
33
|
+
exit 1
|
34
|
+
fi
|
35
|
+
|
36
|
+
echo "install gem file '$gem_file'"
|
37
|
+
gem install "$gem_file"
|
38
|
+
|
39
|
+
# Create tmp directory.
|
40
|
+
if [[ ! -d tmp/releases ]]; then
|
41
|
+
mkdir -p tmp/releases
|
42
|
+
|
43
|
+
chmod u=rwx,go-rwx tmp
|
44
|
+
chmod u=rwx,go-rwx tmp/releases
|
45
|
+
fi
|
46
|
+
|
47
|
+
if [[ "$option" = "-f" ]]; then
|
48
|
+
mv -v "$gem_file" tmp/releases
|
49
|
+
else
|
50
|
+
mv -v -i "$gem_file" tmp/releases
|
51
|
+
fi
|
data/bin/release.sh
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# Release gem to https://rubygems.org.
|
4
|
+
|
5
|
+
SCRIPT_BASEDIR=$(dirname "$0")
|
6
|
+
|
7
|
+
which mv &> /dev/null || { echo 'ERROR: mv not found in PATH'; exit 1; }
|
8
|
+
which gem &> /dev/null || { echo 'ERROR: gem not found in PATH'; exit 1; }
|
9
|
+
|
10
|
+
cd "${SCRIPT_BASEDIR}/.."
|
11
|
+
|
12
|
+
# Load Environment Variables
|
13
|
+
if [[ -f .env ]] ; then
|
14
|
+
source .env
|
15
|
+
fi
|
16
|
+
|
17
|
+
if [[ -z "${GEMSPEC_FILE}" ]] ; then
|
18
|
+
echo 'ERROR: one of the environment variables is missing'
|
19
|
+
|
20
|
+
echo "GEMSPEC_FILE: '${GEMSPEC_FILE}'"
|
21
|
+
|
22
|
+
exit 1
|
23
|
+
fi
|
24
|
+
|
25
|
+
gem_file=$(gem build "${GEMSPEC_FILE}" 2> /dev/null | grep 'File:' | tail -1 | awk '{ print $2 }')
|
26
|
+
|
27
|
+
echo "push gem file '$gem_file'"
|
28
|
+
gem push "$gem_file"
|
29
|
+
|
30
|
+
# Create tmp directory.
|
31
|
+
if [[ ! -d tmp/releases ]]; then
|
32
|
+
mkdir -p tmp/releases
|
33
|
+
|
34
|
+
chmod u=rwx,go-rwx tmp
|
35
|
+
chmod u=rwx,go-rwx tmp/releases
|
36
|
+
fi
|
37
|
+
mv -v -i "$gem_file" tmp/releases
|
data/bin/setup.sh
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# Development setup.
|
4
|
+
|
5
|
+
SCRIPT_BASEDIR=$(dirname "$0")
|
6
|
+
|
7
|
+
which cp &> /dev/null || { echo 'ERROR: cp not found in PATH'; exit 1; }
|
8
|
+
which bundler &> /dev/null || { echo 'ERROR: bundler not found in PATH'; exit 1; }
|
9
|
+
|
10
|
+
cd "${SCRIPT_BASEDIR}/.."
|
11
|
+
|
12
|
+
# Create .env file.
|
13
|
+
if [[ ! -f .env ]]; then
|
14
|
+
cp .env.example .env
|
15
|
+
fi
|
16
|
+
|
17
|
+
bundler install
|
data/bin/test.sh
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# Run Tests.
|
4
|
+
|
5
|
+
SCRIPT_BASEDIR=$(dirname "$0")
|
6
|
+
RUBYOPT=-w
|
7
|
+
TZ=Europe/Vienna
|
8
|
+
|
9
|
+
which bundler &> /dev/null || { echo 'ERROR: bundler not found in PATH'; exit 1; }
|
10
|
+
|
11
|
+
cd "${SCRIPT_BASEDIR}/.."
|
12
|
+
|
13
|
+
bundler exec ./test/suite_all.rb $*
|
data/bin/uninstall.sh
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# Uninstall gem.
|
4
|
+
|
5
|
+
SCRIPT_BASEDIR=$(dirname "$0")
|
6
|
+
|
7
|
+
|
8
|
+
set -e
|
9
|
+
which gem &> /dev/null || { echo 'ERROR: gem not found in PATH'; exit 1; }
|
10
|
+
|
11
|
+
cd "${SCRIPT_BASEDIR}/.."
|
12
|
+
|
13
|
+
# Load Environment Variables
|
14
|
+
[[ -f .env ]] && source .env
|
15
|
+
|
16
|
+
if [[ -z "${GEM_NAME}" ]] ; then
|
17
|
+
echo 'ERROR: one of the environment variables is missing'
|
18
|
+
|
19
|
+
echo "GEM_NAME: '${GEM_NAME}'"
|
20
|
+
|
21
|
+
exit 1
|
22
|
+
fi
|
23
|
+
|
24
|
+
gem uninstall "${GEM_NAME}" --all --executables
|
data/lib/thefox-ext.rb
CHANGED
data/lib/thefox-ext/console.rb
CHANGED
@@ -1,50 +1,50 @@
|
|
1
1
|
|
2
2
|
class Console
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
50
|
end
|