list-tool 1.0.2 → 1.0.3
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 +4 -4
- data/README.md +19 -19
- data/lib/list_tool/app/colorizer.rb +17 -0
- data/lib/list_tool/app/commands.rb +20 -17
- data/lib/list_tool/app/printer.rb +25 -25
- data/lib/list_tool/app.rb +1 -1
- data/lib/list_tool/file_manager.rb +19 -17
- data/lib/list_tool/item.rb +1 -1
- data/lib/list_tool/list.rb +4 -8
- data/lib/list_tool/lister.rb +16 -18
- data/lib/list_tool/{data.rb → lister_data.rb} +4 -10
- data/lib/list_tool/version.rb +1 -1
- data/lib/list_tool.rb +1 -1
- data/spec/fixtures/data.json +4 -4
- data/spec/list_tool/app/colorizer_spec.rb +34 -0
- data/spec/list_tool/app/commands_spec.rb +1 -1
- data/spec/list_tool/app/printer_spec.rb +2 -2
- data/spec/list_tool/file_manager_spec.rb +1 -1
- data/spec/list_tool/{data_spec.rb → lister_data_spec.rb} +7 -13
- data/spec/list_tool/lister_spec.rb +3 -3
- metadata +8 -8
- data/lib/list_tool/app/string.rb +0 -9
- data/spec/list_tool/app/string_spec.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c69589b5f4855ec2cd106e4ca28da01ca9b1652a
|
4
|
+
data.tar.gz: f0d3bfbe5f5461158b742da2b3d78dcbee9a9b3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e42225bf98637b797789690784b886be3ad17d6ca88625b9896bfd144ec439873cdc5281882319b6dde1b0f8b36374a5c6c9ade3a53a98e1832ec2b0bea7b21
|
7
|
+
data.tar.gz: 433cec2c79327d00fb6605baedc3f03759be0f7b942a770f91d8db3a2c182840564d49f50421977825d52af86a672f43f0ec05a9d0f011d0842975ce62fcf49d
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ListTool
|
2
2
|
|
3
|
-
This gem may be used to manage lists of text strings (todos, for example) in your ruby application or in a console (
|
3
|
+
This gem may be used to manage lists of text strings (todos, for example) in your ruby application or in a console (to be honest, generally in a console).
|
4
4
|
|
5
5
|
## INSTALLATION
|
6
6
|
|
@@ -36,11 +36,11 @@ Require list-tool with `require 'list_tool'` command
|
|
36
36
|
|
37
37
|
#### General methods
|
38
38
|
|
39
|
-
lister.lists # => { 'todolist' => 3, 'wishlist' => 2 }
|
40
|
-
#
|
39
|
+
lister.lists # => { 'todolist' => 3, 'wishlist' => 2 }
|
40
|
+
# (digits for item quantitiy in a list)
|
41
41
|
lister.list(list_index=nil) # => {name: 'list_name', items: ['item1', 'item2']}
|
42
42
|
|
43
|
-
For **#list** method, if list index not specified, it will return contents of default list.
|
43
|
+
For **#list** method, if list index is not specified, it will return contents of default list.
|
44
44
|
|
45
45
|
#### List management methods
|
46
46
|
|
@@ -59,15 +59,15 @@ For **#list** method, if list index not specified, it will return contents of de
|
|
59
59
|
lister.delete_item(item_index, {list: 2})
|
60
60
|
lister.move_item(item_index, :up, {list: 2})
|
61
61
|
|
62
|
-
You can omit {list: list_index} argument
|
62
|
+
You can omit {list: list_index} argument. In this case methods will affect default list.
|
63
63
|
|
64
64
|
#### Bonus classes
|
65
65
|
|
66
|
-
You may also want to use such classes as **ListTool::List**, **ListTool::Item** and **ListTool::
|
66
|
+
You may also want to use such classes as **ListTool::List**, **ListTool::Item** and **ListTool::ListerData**.
|
67
67
|
|
68
68
|
List class responds to all item management methods (**\*\_item**) and few others, like **#clear!**, **#rename**, **#each** (returns each Item) and **#to_json**
|
69
69
|
|
70
|
-
|
70
|
+
ListerData class responds to all list management methods (**\*\_list**) and also has **#to_json** and **#each** (returns each list) methods.
|
71
71
|
|
72
72
|
#### Errors
|
73
73
|
|
@@ -83,23 +83,23 @@ This gem provides console tool named '**clt**' ('console list tool'), which allo
|
|
83
83
|
USAGE: clt COMMAND [OPTIONS]
|
84
84
|
|
85
85
|
COMMANDS:
|
86
|
-
a, add-item TEXT [LIST]
|
87
|
-
r, replace-item ITEM, TEXT
|
88
|
-
d, del-item ITEM [LIST]
|
89
|
-
s, show-items [LIST]
|
90
|
-
al, add-list NAME
|
91
|
-
rl, rename-list LIST, NAME
|
92
|
-
dl, del-list LIST
|
93
|
-
sl, show-lists
|
94
|
-
u, use LIST
|
95
|
-
-h, --help
|
96
|
-
-v, --version
|
86
|
+
a, add-item TEXT [LIST] Add item with TEXT to given or default list
|
87
|
+
r, replace-item ITEM, TEXT Set ITEM text to TEXT
|
88
|
+
d, del-item ITEM [LIST] Delete ITEM from given or default list
|
89
|
+
s, show-items [LIST] Print contents of default or given list
|
90
|
+
al, add-list NAME Create list with NAME
|
91
|
+
rl, rename-list LIST, NAME Set LIST name to NAME
|
92
|
+
dl, del-list LIST Delete given LIST
|
93
|
+
sl, show-lists Print list of existing lists
|
94
|
+
u, use LIST Set default list
|
95
|
+
-h, --help Print this message
|
96
|
+
-v, --version Print version
|
97
97
|
|
98
98
|
clt keeps it's data in **~/.clt/data.json**
|
99
99
|
|
100
100
|
## NOTES
|
101
101
|
|
102
|
-
Note that
|
102
|
+
Note that it is my first gem and also my first rspec experience.
|
103
103
|
|
104
104
|
## CONTACTS
|
105
105
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ListTool
|
2
|
+
module App
|
3
|
+
|
4
|
+
class Colorizer
|
5
|
+
class << self
|
6
|
+
def colorize(string, code)
|
7
|
+
"\x1B[#{code}m" + string + "\x1B[0m"
|
8
|
+
end
|
9
|
+
|
10
|
+
def red(string); colorize(string, 31); end
|
11
|
+
def green(string); colorize(string, 32); end
|
12
|
+
def blue(string); colorize(string, 34); end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -15,28 +15,31 @@ module ListTool
|
|
15
15
|
module App
|
16
16
|
|
17
17
|
class Commands
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
18
|
+
|
19
|
+
COMMANDS = ListTool::App.constants.map {|const| ListTool::App.const_get(const)} - [self, Printer, Runner, Colorizer]
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def process argv, lister
|
23
|
+
argv.is_a?(Array) || raise(ArgumentError, "expected first paramenter to be an Array, #{argv.class} given")
|
24
|
+
argv << 'h' if argv.empty?
|
25
|
+
param = argv.shift
|
26
|
+
|
27
|
+
begin
|
28
|
+
COMMANDS.each do |cmd|
|
29
|
+
if cmd.match? param
|
30
|
+
cmd.execute cmd.parse(argv), lister
|
31
|
+
break
|
32
|
+
end
|
30
33
|
end
|
31
34
|
end
|
32
|
-
end
|
33
35
|
|
34
|
-
|
36
|
+
end
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
+
def help
|
39
|
+
COMMANDS.inject(""){|out, cmd| out << cmd.help << "\n" }
|
40
|
+
end
|
38
41
|
end
|
39
|
-
|
42
|
+
|
40
43
|
end
|
41
44
|
|
42
45
|
end
|
@@ -2,39 +2,39 @@ module ListTool
|
|
2
2
|
module App
|
3
3
|
|
4
4
|
class Printer
|
5
|
+
class << self
|
6
|
+
def error error
|
7
|
+
puts "#{Colorizer.red("ERROR")}: #{error.message}\n"
|
8
|
+
end
|
5
9
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
list[:items].each.with_index do |item, index|
|
13
|
-
out << " %2i. %s\n" % [index+1, item]
|
10
|
+
def print_items list
|
11
|
+
out = "Printing #{Colorizer.green(list[:name])}:\n"
|
12
|
+
list[:items].each.with_index do |item, index|
|
13
|
+
out << " %2i. %s\n" % [index+1, item]
|
14
|
+
end
|
15
|
+
puts out
|
14
16
|
end
|
15
|
-
puts out
|
16
|
-
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
def print_lists lists
|
19
|
+
out = "Printing lists:\n"
|
20
|
+
lists.each.with_index do |list, index|
|
21
|
+
out << " %2i. %s (%i)\n" % [index+1, list[0], list[1]]
|
22
|
+
end
|
23
|
+
puts out
|
22
24
|
end
|
23
|
-
puts out
|
24
|
-
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
def print_usage
|
27
|
+
out = "#{Colorizer.green('USAGE')}: clt COMMAND [OPTIONS]\n\nCOMMANDS:\n"
|
28
|
+
Commands::COMMANDS.each do |cmd|
|
29
|
+
out << cmd.help << "\n"
|
30
|
+
end
|
31
|
+
puts out
|
30
32
|
end
|
31
|
-
puts out
|
32
|
-
end
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
def print_version
|
35
|
+
puts "clt version #{VERSION}"
|
36
|
+
end
|
36
37
|
end
|
37
|
-
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
data/lib/list_tool/app.rb
CHANGED
@@ -2,24 +2,26 @@ module ListTool
|
|
2
2
|
|
3
3
|
class FileManager
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
class << self
|
6
|
+
def load filename
|
7
|
+
File.read(filename)
|
8
|
+
rescue Errno::EACCES
|
9
|
+
raise FileAccessError, "can't read file '#{filename}': access denied"
|
10
|
+
rescue Errno::ENOENT
|
11
|
+
raise FileNotFoundError, "can't read file '#{filename}': file not found"
|
12
|
+
rescue
|
13
|
+
raise IOError, "can't read file '#{filename}': unknown error"
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
def save filename, data
|
17
|
+
File.open(filename, 'w') { |f| f << data.to_json }
|
18
|
+
rescue Errno::EACCES
|
19
|
+
raise FileAccessError, "can't open file '#{filename}': access denied"
|
20
|
+
rescue Errno::ENOENT
|
21
|
+
raise FileNotFoundError, "can't open file '#{filename}': file not found"
|
22
|
+
rescue
|
23
|
+
raise IOError, "can't open file '#{filename}': unknown error"
|
24
|
+
end
|
23
25
|
end
|
24
26
|
|
25
27
|
end
|
data/lib/list_tool/item.rb
CHANGED
data/lib/list_tool/list.rb
CHANGED
@@ -5,7 +5,7 @@ module ListTool
|
|
5
5
|
|
6
6
|
attr_reader :items, :name
|
7
7
|
|
8
|
-
def initialize(arg
|
8
|
+
def initialize(arg)
|
9
9
|
if arg.respond_to?(:to_str)
|
10
10
|
@name = arg
|
11
11
|
@items = []
|
@@ -34,13 +34,9 @@ module ListTool
|
|
34
34
|
old_name
|
35
35
|
end
|
36
36
|
|
37
|
-
def to_json
|
38
|
-
|
39
|
-
|
40
|
-
json += item.to_json
|
41
|
-
json += ',' unless item == @items.last
|
42
|
-
end
|
43
|
-
json += ']}'
|
37
|
+
def to_json options=nil
|
38
|
+
hash = {name: @name, items: @items}
|
39
|
+
hash.to_json
|
44
40
|
end
|
45
41
|
|
46
42
|
def each
|
data/lib/list_tool/lister.rb
CHANGED
@@ -2,27 +2,29 @@ module ListTool
|
|
2
2
|
class Lister
|
3
3
|
|
4
4
|
def initialize
|
5
|
-
@data =
|
5
|
+
@data = ListerData.new
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
class << self
|
9
|
+
def from_hash(hash)
|
10
|
+
lister = Lister.new
|
11
|
+
lister.instance_variable_set(:@data, ListerData.new(hash))
|
12
|
+
lister
|
13
|
+
end
|
11
14
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
def from_json(json)
|
16
|
+
data = JsonParser.parse(json)
|
17
|
+
from_hash(data)
|
18
|
+
end
|
16
19
|
end
|
17
20
|
|
18
|
-
def
|
19
|
-
|
20
|
-
from_hash(data)
|
21
|
+
def inspect
|
22
|
+
"#<#{self.class}:0x#{self.__id__.to_s(16)}>"
|
21
23
|
end
|
22
24
|
|
23
25
|
def load(filename)
|
24
26
|
json = FileManager.load(filename)
|
25
|
-
@data =
|
27
|
+
@data = ListerData.new( JsonParser.parse(json) )
|
26
28
|
self
|
27
29
|
end
|
28
30
|
|
@@ -31,9 +33,7 @@ module ListTool
|
|
31
33
|
end
|
32
34
|
|
33
35
|
def lists
|
34
|
-
|
35
|
-
@data.each { |list| out[list.name] = list.items.count }
|
36
|
-
out
|
36
|
+
@data.map{|list| [list.name, list.items.count] }.to_h
|
37
37
|
end
|
38
38
|
|
39
39
|
def list(index=nil)
|
@@ -45,9 +45,7 @@ module ListTool
|
|
45
45
|
@data.default_list
|
46
46
|
end
|
47
47
|
|
48
|
-
|
49
|
-
list.items.each { |item| out[:items] << item.text }
|
50
|
-
out
|
48
|
+
{ name: list.name, items: list.items.map{|item| item.text} }
|
51
49
|
end
|
52
50
|
|
53
51
|
def method_missing(name, *args, &block)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ListTool
|
2
2
|
|
3
|
-
class
|
3
|
+
class ListerData
|
4
4
|
include Enumerable
|
5
5
|
|
6
6
|
attr_reader :lists, :default_list
|
@@ -44,7 +44,6 @@ module ListTool
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def set_default_list(index)
|
47
|
-
raise ArgumentError, 'argument is not an integer' unless index.respond_to?(:to_int)
|
48
47
|
return nil if @lists[index] == nil
|
49
48
|
@default_list = @lists[index]
|
50
49
|
end
|
@@ -61,14 +60,9 @@ module ListTool
|
|
61
60
|
end
|
62
61
|
|
63
62
|
def to_json
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
@lists.each do |list|
|
68
|
-
json += list.to_json
|
69
|
-
json += ',' unless list == @lists.last
|
70
|
-
end
|
71
|
-
json += ']}'
|
63
|
+
hash = {lists: @lists}
|
64
|
+
hash.merge!(default: @lists.index(@default_list)) if @default_list
|
65
|
+
hash.to_json
|
72
66
|
end
|
73
67
|
|
74
68
|
end
|
data/lib/list_tool/version.rb
CHANGED
data/lib/list_tool.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative "./list_tool/version"
|
|
4
4
|
require_relative "./list_tool/lister"
|
5
5
|
require_relative "./list_tool/item"
|
6
6
|
require_relative "./list_tool/list"
|
7
|
-
require_relative "./list_tool/
|
7
|
+
require_relative "./list_tool/lister_data"
|
8
8
|
require_relative "./list_tool/json_parser"
|
9
9
|
require_relative "./list_tool/file_manager"
|
10
10
|
require_relative "./list_tool/app.rb"
|
data/spec/fixtures/data.json
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative '../../spec_helper.rb'
|
2
|
+
|
3
|
+
describe ListTool::App::Colorizer do
|
4
|
+
|
5
|
+
subject { ListTool::App::Colorizer }
|
6
|
+
|
7
|
+
describe '#colorize' do
|
8
|
+
it 'colorizes string using given code' do
|
9
|
+
expect(subject.colorize('test', 31)).to eq "\x1B[31mtest\x1B[0m"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '::red' do
|
14
|
+
it 'calls ::colorize with 31' do
|
15
|
+
expect(subject).to receive(:colorize).with('test', 31)
|
16
|
+
subject.red('test')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '::green' do
|
21
|
+
it 'calls ::colorize with 32' do
|
22
|
+
expect(subject).to receive(:colorize).with('test', 32)
|
23
|
+
subject.green('test')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '::blue' do
|
28
|
+
it 'calls ::colorize with 34' do
|
29
|
+
expect(subject).to receive(:colorize).with('test', 34)
|
30
|
+
subject.blue('test')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -4,7 +4,7 @@ describe ListTool::App::Commands do
|
|
4
4
|
subject { ListTool::App::Commands }
|
5
5
|
|
6
6
|
it 'stores command list' do
|
7
|
-
commands = ListTool::App.constants.map {|c| ListTool::App.const_get(c)} - [ListTool::App::Commands, ListTool::App::Printer, ListTool::App::Runner]
|
7
|
+
commands = ListTool::App.constants.map {|c| ListTool::App.const_get(c)} - [ListTool::App::Commands, ListTool::App::Printer, ListTool::App::Runner, ListTool::App::Colorizer]
|
8
8
|
expect(subject::COMMANDS).to eq commands
|
9
9
|
end
|
10
10
|
|
@@ -5,7 +5,7 @@ describe ListTool::App::Printer do
|
|
5
5
|
|
6
6
|
describe '.error' do
|
7
7
|
it 'prints error message' do
|
8
|
-
expect(subject).to receive(:puts).with( "
|
8
|
+
expect(subject).to receive(:puts).with( "\x1B[31mERROR\x1B[0m: some error\n" )
|
9
9
|
subject.error(StandardError.new('some error'))
|
10
10
|
end
|
11
11
|
end
|
@@ -13,7 +13,7 @@ describe ListTool::App::Printer do
|
|
13
13
|
|
14
14
|
describe '.print_items' do
|
15
15
|
it 'prints list of items with indexes (starting with 1)' do
|
16
|
-
expect(subject).to receive(:puts).with( "Printing
|
16
|
+
expect(subject).to receive(:puts).with( "Printing \x1B[32mtestlist\x1B[0m:\n 1. item1\n 2. item2\n" )
|
17
17
|
subject.print_items( {name: 'testlist', items: ['item1', 'item2']} )
|
18
18
|
end
|
19
19
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../spec_helper.rb'
|
2
2
|
|
3
|
-
describe
|
4
|
-
let (:data) { ListTool::
|
3
|
+
describe ListTool::ListerData do
|
4
|
+
let (:data) { ListTool::ListerData.new(Factory.data) }
|
5
5
|
|
6
6
|
describe '#initialize' do
|
7
7
|
|
@@ -22,7 +22,7 @@ describe Data do
|
|
22
22
|
|
23
23
|
context 'no arguments' do
|
24
24
|
it 'creates new Data instance with empty array of lists' do
|
25
|
-
expect(ListTool::
|
25
|
+
expect(ListTool::ListerData.new().lists).to be_empty
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -31,19 +31,19 @@ describe Data do
|
|
31
31
|
context 'failure' do
|
32
32
|
context 'argument is not a hash' do
|
33
33
|
it 'raises ArgumentError' do
|
34
|
-
expect{ListTool::
|
34
|
+
expect{ListTool::ListerData.new('not_a_hash')}.to raise_error(ArgumentError)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
context 'no "lists" key in given hash' do
|
39
39
|
it 'creates new Data instance with empty lists array' do
|
40
|
-
expect(ListTool::
|
40
|
+
expect(ListTool::ListerData.new({}).lists).to be_empty
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
context '"lists" is not an array' do
|
45
45
|
it 'raises ArgumentError' do
|
46
|
-
expect{ListTool::
|
46
|
+
expect{ListTool::ListerData.new("lists" => 'not_an_array')}.to raise_error(ArgumentError)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -141,12 +141,6 @@ describe Data do
|
|
141
141
|
|
142
142
|
context 'failure' do
|
143
143
|
|
144
|
-
context 'argument is not an integer' do
|
145
|
-
it 'raises ArgumentError' do
|
146
|
-
expect{data.set_default_list('bad_int')}.to raise_error(ArgumentError)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
144
|
context 'no list with given index' do
|
151
145
|
it 'returns nil' do
|
152
146
|
expect(data.set_default_list(2)).to be_nil
|
@@ -248,7 +242,7 @@ describe Data do
|
|
248
242
|
|
249
243
|
context 'default list not set' do
|
250
244
|
it 'returns json without "default_list" field' do
|
251
|
-
data = ListTool::
|
245
|
+
data = ListTool::ListerData.new(Factory.blank_data)
|
252
246
|
expect(data.to_json).to eq '{"lists":[]}'
|
253
247
|
end
|
254
248
|
end
|
@@ -6,7 +6,7 @@ describe ListTool::Lister do
|
|
6
6
|
describe '#initialize' do
|
7
7
|
|
8
8
|
it 'creates Lister with empty data' do
|
9
|
-
expect(ListTool::
|
9
|
+
expect(ListTool::ListerData).to receive(:new).with no_args
|
10
10
|
ListTool::Lister.new
|
11
11
|
end
|
12
12
|
|
@@ -51,7 +51,7 @@ describe ListTool::Lister do
|
|
51
51
|
it 'returns self' do
|
52
52
|
allow( ListTool::FileManager ).to receive(:load)
|
53
53
|
allow( ListTool::JsonParser ).to receive(:parse)
|
54
|
-
allow( ListTool::
|
54
|
+
allow( ListTool::ListerData ).to receive(:new).and_return( ListTool::ListerData.new() )
|
55
55
|
expect( lister.load('data_file') ).to eq lister
|
56
56
|
end
|
57
57
|
end
|
@@ -62,7 +62,7 @@ describe ListTool::Lister do
|
|
62
62
|
let(:filename){ 'test_file' }
|
63
63
|
|
64
64
|
it 'calls FileManager.save to save its data to file' do
|
65
|
-
data = ListTool::
|
65
|
+
data = ListTool::ListerData.new
|
66
66
|
lister.instance_variable_set(:@data, data)
|
67
67
|
expect( ListTool::FileManager ).to receive(:save).with(filename, data)
|
68
68
|
lister.save(filename)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: list-tool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitrii Krasnov
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- bin/clt
|
113
113
|
- lib/list_tool.rb
|
114
114
|
- lib/list_tool/app.rb
|
115
|
+
- lib/list_tool/app/colorizer.rb
|
115
116
|
- lib/list_tool/app/commands.rb
|
116
117
|
- lib/list_tool/app/commands/add_item_command.rb
|
117
118
|
- lib/list_tool/app/commands/add_list_command.rb
|
@@ -127,16 +128,16 @@ files:
|
|
127
128
|
- lib/list_tool/app/commands/version_command.rb
|
128
129
|
- lib/list_tool/app/printer.rb
|
129
130
|
- lib/list_tool/app/runner.rb
|
130
|
-
- lib/list_tool/app/string.rb
|
131
|
-
- lib/list_tool/data.rb
|
132
131
|
- lib/list_tool/file_manager.rb
|
133
132
|
- lib/list_tool/item.rb
|
134
133
|
- lib/list_tool/json_parser.rb
|
135
134
|
- lib/list_tool/list.rb
|
136
135
|
- lib/list_tool/lister.rb
|
136
|
+
- lib/list_tool/lister_data.rb
|
137
137
|
- lib/list_tool/version.rb
|
138
138
|
- list_tool.gemspec
|
139
139
|
- spec/fixtures/data.json
|
140
|
+
- spec/list_tool/app/colorizer_spec.rb
|
140
141
|
- spec/list_tool/app/commands/add_item_command_spec.rb
|
141
142
|
- spec/list_tool/app/commands/add_list_command_spec.rb
|
142
143
|
- spec/list_tool/app/commands/delete_item_command_spec.rb
|
@@ -152,12 +153,11 @@ files:
|
|
152
153
|
- spec/list_tool/app/commands_spec.rb
|
153
154
|
- spec/list_tool/app/printer_spec.rb
|
154
155
|
- spec/list_tool/app/runner_spec.rb
|
155
|
-
- spec/list_tool/app/string_spec.rb
|
156
|
-
- spec/list_tool/data_spec.rb
|
157
156
|
- spec/list_tool/file_manager_spec.rb
|
158
157
|
- spec/list_tool/item_spec.rb
|
159
158
|
- spec/list_tool/json_parser_spec.rb
|
160
159
|
- spec/list_tool/list_spec.rb
|
160
|
+
- spec/list_tool/lister_data_spec.rb
|
161
161
|
- spec/list_tool/lister_spec.rb
|
162
162
|
- spec/spec_helper.rb
|
163
163
|
- spec/support/factory.rb
|
@@ -184,9 +184,10 @@ rubyforge_project:
|
|
184
184
|
rubygems_version: 2.2.2
|
185
185
|
signing_key:
|
186
186
|
specification_version: 4
|
187
|
-
summary: list-tool-1.0.
|
187
|
+
summary: list-tool-1.0.3
|
188
188
|
test_files:
|
189
189
|
- spec/fixtures/data.json
|
190
|
+
- spec/list_tool/app/colorizer_spec.rb
|
190
191
|
- spec/list_tool/app/commands/add_item_command_spec.rb
|
191
192
|
- spec/list_tool/app/commands/add_list_command_spec.rb
|
192
193
|
- spec/list_tool/app/commands/delete_item_command_spec.rb
|
@@ -202,12 +203,11 @@ test_files:
|
|
202
203
|
- spec/list_tool/app/commands_spec.rb
|
203
204
|
- spec/list_tool/app/printer_spec.rb
|
204
205
|
- spec/list_tool/app/runner_spec.rb
|
205
|
-
- spec/list_tool/app/string_spec.rb
|
206
|
-
- spec/list_tool/data_spec.rb
|
207
206
|
- spec/list_tool/file_manager_spec.rb
|
208
207
|
- spec/list_tool/item_spec.rb
|
209
208
|
- spec/list_tool/json_parser_spec.rb
|
210
209
|
- spec/list_tool/list_spec.rb
|
210
|
+
- spec/list_tool/lister_data_spec.rb
|
211
211
|
- spec/list_tool/lister_spec.rb
|
212
212
|
- spec/spec_helper.rb
|
213
213
|
- spec/support/factory.rb
|
data/lib/list_tool/app/string.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require_relative '../../spec_helper.rb'
|
2
|
-
|
3
|
-
describe String do
|
4
|
-
|
5
|
-
describe '#colorize' do
|
6
|
-
it 'colorizes string using given code' do
|
7
|
-
expect('test'.colorize(31)).to eq "\x1B[31mtest\x1B[0m"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '#red' do
|
12
|
-
it 'calls #colorize with 31' do
|
13
|
-
expect(string = 'test').to receive(:colorize).with(31)
|
14
|
-
string.red
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '#green' do
|
19
|
-
it 'calls #colorize with 32' do
|
20
|
-
expect(string = 'test').to receive(:colorize).with(32)
|
21
|
-
string.green
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#blue' do
|
26
|
-
it 'calls #colorize with 34' do
|
27
|
-
expect(string = 'test').to receive(:colorize).with(34)
|
28
|
-
string.blue
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|