thefox-wallet 0.17.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.editorconfig +5 -4
- data/.env.example +4 -0
- data/.gitignore +6 -9
- data/.gitlab-ci.yml +53 -43
- data/.travis.yml +17 -15
- data/Gemfile +4 -4
- data/README.md +37 -13
- data/Vagrantfile +34 -0
- data/bin/build_coverage.sh +24 -0
- data/bin/dev +1 -1
- data/bin/dev_data.sh +18 -0
- data/bin/dev_setup.sh +21 -0
- data/bin/install.sh +51 -0
- data/bin/release.sh +37 -0
- data/bin/test.sh +16 -0
- data/bin/uninstall.sh +24 -0
- data/bin/wallet +104 -104
- data/lib/wallet/command.rb +57 -57
- data/lib/wallet/command_add.rb +113 -113
- data/lib/wallet/command_categories.rb +13 -13
- data/lib/wallet/command_clear.rb +13 -13
- data/lib/wallet/command_csv.rb +30 -30
- data/lib/wallet/command_html.rb +20 -20
- data/lib/wallet/command_list.rb +168 -173
- data/lib/wallet/entry.rb +137 -137
- data/lib/wallet/version.rb +9 -9
- data/lib/wallet/wallet.rb +1051 -1051
- data/thefox-wallet.gemspec +23 -23
- data/wallet.sublime-project +8 -8
- metadata +12 -6
- data/.ackrc +0 -7
- data/Makefile +0 -29
- data/Makefile.common +0 -58
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
|
+
sudo 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
|
+
|
8
|
+
set -e
|
9
|
+
which mv &> /dev/null || { echo 'ERROR: mv not found in PATH'; exit 1; }
|
10
|
+
which gem &> /dev/null || { echo 'ERROR: gem not found in PATH'; exit 1; }
|
11
|
+
|
12
|
+
cd "${SCRIPT_BASEDIR}/.."
|
13
|
+
|
14
|
+
# Load Environment Variables
|
15
|
+
[[ -f .env ]] && source .env
|
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/test.sh
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# Run all tests.
|
4
|
+
|
5
|
+
SCRIPT_BASEDIR=$(dirname "$0")
|
6
|
+
RUBYOPT=-w
|
7
|
+
TZ=Europe/Vienna
|
8
|
+
|
9
|
+
|
10
|
+
set -e
|
11
|
+
which bundler &> /dev/null || { echo 'ERROR: bundler not found in PATH'; exit 1; }
|
12
|
+
|
13
|
+
cd "${SCRIPT_BASEDIR}/.."
|
14
|
+
|
15
|
+
mkdir -p tmp
|
16
|
+
bundler exec ./test/suite_all.rb -v
|
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/bin/wallet
CHANGED
@@ -12,115 +12,115 @@ require 'wallet'
|
|
12
12
|
@options = Hash.new
|
13
13
|
@options[:logger] = @logger
|
14
14
|
opts = OptionParser.new do |o|
|
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
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
15
|
+
o.banner = 'Usage: wallet <command> [options]'
|
16
|
+
o.separator('')
|
17
|
+
o.separator('Commands:')
|
18
|
+
o.separator('')
|
19
|
+
o.separator(' add Add a new entry')
|
20
|
+
o.separator(' categories List categories')
|
21
|
+
o.separator(' clear Clear temp and cache files')
|
22
|
+
o.separator(' csv Import/Export CSV file')
|
23
|
+
o.separator(' html Exports a wallet as HTML')
|
24
|
+
o.separator(' list List entries')
|
25
|
+
o.separator('')
|
26
|
+
|
27
|
+
o.on('-w', '--wallet <path>', 'Path to wallet directory.') do |path|
|
28
|
+
@options[:wallet_path] = Pathname.new(path).expand_path
|
29
|
+
end
|
30
|
+
|
31
|
+
o.on('--id <id>', 'ID used for a new entry.') do |id|
|
32
|
+
@options[:entry_id] = id
|
33
|
+
end
|
34
|
+
|
35
|
+
o.on('-t', '--title <title>', 'Title used for a new entry.') do |title|
|
36
|
+
@options[:entry_title] = title
|
37
|
+
end
|
38
|
+
|
39
|
+
o.on('-d', '--date <YYYY-MM-DD>', 'Date used for a new entry.') do |date|
|
40
|
+
@options[:entry_date] = date
|
41
|
+
end
|
42
|
+
|
43
|
+
o.on('--start <YYYY-MM-DD>', 'Start-date used for a range.') do |date|
|
44
|
+
@options[:entry_date_start] = Date.parse(date)
|
45
|
+
end
|
46
|
+
|
47
|
+
o.on('--end <YYYY-MM-DD>', 'End-date used for a range.') do |date|
|
48
|
+
@options[:entry_date_end] = Date.parse(date)
|
49
|
+
end
|
50
|
+
|
51
|
+
o.on('-r', '--revenue <revenue>', 'Revenue used for a new entry.') do |revenue|
|
52
|
+
# @TODO replace with Wumber.
|
53
|
+
# @options[:entry_revenue] = revenue.to_s.sub(/,/, '.').to_f.abs
|
54
|
+
@options[:entry_revenue] = eval(revenue.to_s.to_s.gsub(/,/, '.')).to_f.round(TheFox::Wallet::NUMBER_ROUND).abs
|
55
|
+
end
|
56
|
+
|
57
|
+
o.on('-e', '--expense <expense>', 'Expense used for a new entry.') do |expense|
|
58
|
+
# @TODO replace with Wumber.
|
59
|
+
# @options[:entry_expense] = -expense.to_s.sub(/,/, '.').to_f.abs
|
60
|
+
@options[:entry_expense] = -eval(expense.to_s.gsub(/,/, '.')).to_f.round(TheFox::Wallet::NUMBER_ROUND).abs
|
61
|
+
end
|
62
|
+
|
63
|
+
o.on('-c', '--category <category>', 'Category used for a new entry.') do |category|
|
64
|
+
@options[:entry_category] = category
|
65
|
+
end
|
66
|
+
|
67
|
+
o.on('-o', '--comment <comment>', 'Comment used for a new entry.') do |comment|
|
68
|
+
@options[:entry_comment] = comment
|
69
|
+
end
|
70
|
+
|
71
|
+
o.on('--import', 'Import CSV') do
|
72
|
+
@options[:is_import] = true
|
73
|
+
end
|
74
|
+
|
75
|
+
o.on('--export', 'Export CSV') do
|
76
|
+
@options[:is_export] = true
|
77
|
+
end
|
78
|
+
|
79
|
+
o.on('-p', '--path <path>', 'Path used for csv import/export and html directory path.') do |path|
|
80
|
+
@options[:path] = path
|
81
|
+
end
|
82
|
+
|
83
|
+
o.on('-i', '--interactive', 'Use some commands interactively.') do
|
84
|
+
@options[:is_interactively] = true
|
85
|
+
end
|
86
|
+
|
87
|
+
o.on('-f', '--force', 'Force add command.') do
|
88
|
+
@options[:force] = true
|
89
|
+
end
|
90
|
+
|
91
|
+
o.on('--no-force', 'Do not force add command.') do
|
92
|
+
@options[:force] = false
|
93
|
+
end
|
94
|
+
|
95
|
+
o.on('-v', '--verbose', 'Log on debug level.') do
|
96
|
+
@logger.level = Logger::DEBUG
|
97
|
+
end
|
98
|
+
|
99
|
+
o.on_tail('-V', '--version', 'Show version.') do
|
100
|
+
puts "#{::TheFox::Wallet::NAME} #{::TheFox::Wallet::VERSION} (#{::TheFox::Wallet::DATE})"
|
101
|
+
puts TheFox::Wallet::HOMEPAGE
|
102
|
+
exit
|
103
|
+
end
|
104
|
+
|
105
|
+
o.on_tail('-h', '--help', 'Show this message.') do
|
106
|
+
puts o
|
107
|
+
puts
|
108
|
+
exit 3
|
109
|
+
end
|
110
110
|
end
|
111
111
|
ARGV << '-h' if ARGV.count == 0
|
112
112
|
commands = opts.parse(ARGV)
|
113
113
|
command_name = commands.shift
|
114
114
|
|
115
115
|
if command_name
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
116
|
+
begin
|
117
|
+
command = TheFox::Wallet::Command.create_by_name(command_name, @options)
|
118
|
+
command.run
|
119
|
+
rescue Exception => e
|
120
|
+
@logger.error(e.to_s)
|
121
|
+
exit 1
|
122
|
+
end
|
123
123
|
else
|
124
|
-
|
125
|
-
|
124
|
+
# Show help page when no argument was given.
|
125
|
+
opts.parse(['-h'])
|
126
126
|
end
|
data/lib/wallet/command.rb
CHANGED
@@ -6,61 +6,61 @@ require 'date'
|
|
6
6
|
require 'pathname'
|
7
7
|
|
8
8
|
module TheFox::Wallet
|
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
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
9
|
+
|
10
|
+
class Command
|
11
|
+
|
12
|
+
NAME = 'default'
|
13
|
+
|
14
|
+
def initialize(options = Hash.new)
|
15
|
+
# Initialize all options.
|
16
|
+
@options = options
|
17
|
+
@options[:logger] ||= Logger.new(IO::NULL)
|
18
|
+
@options[:wallet_path] ||= Pathname.new('wallet')
|
19
|
+
@options[:entry_id] ||= nil
|
20
|
+
@options[:entry_title] ||= nil
|
21
|
+
@options[:entry_date] ||= Date.today.to_s
|
22
|
+
@options[:entry_date_start] ||= Date.parse('1970-01-01')
|
23
|
+
@options[:entry_date_end] ||= Date.today
|
24
|
+
@options[:entry_revenue] ||= 0.0
|
25
|
+
@options[:entry_expense] ||= 0.0
|
26
|
+
@options[:entry_category] ||= nil
|
27
|
+
@options[:entry_comment] ||= nil
|
28
|
+
@options[:is_import] ||= false
|
29
|
+
@options[:is_export] ||= false
|
30
|
+
@options[:path] ||= nil
|
31
|
+
@options[:is_interactively] ||= false
|
32
|
+
@options[:force] ||= false
|
33
|
+
end
|
34
|
+
|
35
|
+
def run
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.create_by_name(name, options = Hash.new)
|
39
|
+
classes = [
|
40
|
+
AddCommand,
|
41
|
+
CategoriesCommand,
|
42
|
+
ClearCommand,
|
43
|
+
CsvCommand,
|
44
|
+
HtmlCommand,
|
45
|
+
ListCommand,
|
46
|
+
]
|
47
|
+
|
48
|
+
# Search class by name.
|
49
|
+
classes.each do |cclass|
|
50
|
+
if cclass.is_matching_class(name)
|
51
|
+
# Create a new Object from the found Class.
|
52
|
+
cmd = cclass.new(options)
|
53
|
+
return cmd
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
raise "Unknown command '#{name}'"
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.is_matching_class(name)
|
61
|
+
name == self::NAME
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
66
|
end
|