list-tool 1.0.0 → 1.0.1
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 +31 -16
- data/lib/list_tool/item.rb +7 -3
- data/lib/list_tool/list.rb +4 -4
- data/lib/list_tool/version.rb +1 -1
- data/spec/list_tool/item_spec.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34ece5f2e12c07abd8d89e3487fd5b2a38aedb36
|
4
|
+
data.tar.gz: 32586be177d6ff874d2a70d5110f5253ec1c8d6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c82e5dd20dbf585787b50d88b306bfc8dc6a4f265b225624e1f7e94e19515d67c74bbb4fb40f9f7d8dbfd6b738561698adcd52502394f90475e97690f6c8c218
|
7
|
+
data.tar.gz: 5e975d2ddf492cdbdd531d3feae2167462790764b12c61c7ba833a894ddd788c5dca3591437ba4c47d1f46351aa0d854fcd7b993acb67d829a2cab70d85d85f0
|
data/README.md
CHANGED
@@ -1,29 +1,44 @@
|
|
1
1
|
# ListTool
|
2
2
|
|
3
|
-
|
3
|
+
This gem may be used to manage lists of text strings (todos, for example) in your app or in console
|
4
4
|
|
5
|
-
##
|
5
|
+
## In app
|
6
6
|
|
7
|
-
|
7
|
+
In your app do this:
|
8
8
|
|
9
|
-
|
9
|
+
require 'list-tool'
|
10
10
|
|
11
|
-
|
11
|
+
...
|
12
12
|
|
13
|
-
|
13
|
+
lister = Lister.new
|
14
14
|
|
15
|
-
|
15
|
+
I'll describe later how to work with it
|
16
16
|
|
17
|
-
|
17
|
+
## In console
|
18
18
|
|
19
|
-
|
19
|
+
Also gem provides console tool named 'clt' ('console list tool'), which allows you to manage lists in console.
|
20
20
|
|
21
|
-
|
21
|
+
USAGE: clt COMMAND [OPTIONS]
|
22
22
|
|
23
|
-
|
23
|
+
COMMANDS:
|
24
|
+
a, add-item TEXT [LIST] Add item with TEXT to given or default list
|
25
|
+
r, replace-item ITEM, TEXT Set ITEM text to TEXT
|
26
|
+
d, del-item ITEM [LIST] Delete ITEM from given or default list
|
27
|
+
s, show-items [LIST] Print contents of default or given list
|
28
|
+
al, add-list NAME Create list with NAME
|
29
|
+
rl, rename-list LIST, NAME Set LIST name to NAME
|
30
|
+
dl, del-list LIST Delete given LIST
|
31
|
+
sl, show-lists Print list of existing lists
|
32
|
+
u, use LIST Set default list
|
33
|
+
-h, --help Print this message
|
34
|
+
-v, --version Print version
|
24
35
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
36
|
+
clt keeps it's data file in ~/.clt
|
37
|
+
|
38
|
+
## Notes
|
39
|
+
|
40
|
+
Note that this is my first gem and also my first rspec experiance.
|
41
|
+
|
42
|
+
## Contacts
|
43
|
+
|
44
|
+
You can contact me via email: vizvamitra@gmail.com
|
data/lib/list_tool/item.rb
CHANGED
@@ -1,19 +1,23 @@
|
|
1
1
|
module ListTool
|
2
2
|
|
3
3
|
class Item
|
4
|
-
|
4
|
+
attr_reader :text
|
5
5
|
|
6
6
|
def initialize arg
|
7
7
|
if arg.is_a?(String)
|
8
|
-
@text = arg
|
8
|
+
@text = arg.gsub('"', "'")
|
9
9
|
elsif arg.is_a?(Hash)
|
10
10
|
raise(ArgumentError, "item text not found in given hash") unless arg['text'].is_a?(String)
|
11
|
-
@text = arg["text"]
|
11
|
+
@text = arg["text"].gsub('"', "'")
|
12
12
|
else
|
13
13
|
raise(ArgumentError, "argument expected to be Hash or String, #{arg.class} given")
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
def text= new_text
|
18
|
+
@text = new_text.gsub('"', "'")
|
19
|
+
end
|
20
|
+
|
17
21
|
def to_json
|
18
22
|
"{\"text\":\"#{@text}\"}"
|
19
23
|
end
|
data/lib/list_tool/list.rb
CHANGED
@@ -3,16 +3,16 @@ module ListTool
|
|
3
3
|
class List
|
4
4
|
include Enumerable
|
5
5
|
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :items, :name
|
7
7
|
|
8
8
|
def initialize(arg=nil)
|
9
9
|
if arg.respond_to?(:to_str)
|
10
|
-
@name = arg
|
10
|
+
@name = arg.gsub('"', "'")
|
11
11
|
@items = []
|
12
12
|
elsif arg.is_a?(Hash)
|
13
13
|
prepare_data(arg)
|
14
14
|
|
15
|
-
@name = arg['name']
|
15
|
+
@name = arg['name'].gsub('"', "'")
|
16
16
|
|
17
17
|
@items = []
|
18
18
|
arg['items'].each do |item|
|
@@ -30,7 +30,7 @@ module ListTool
|
|
30
30
|
def rename str
|
31
31
|
raise ArgumentError, 'string expected' unless str.is_a?(String)
|
32
32
|
old_name = @name
|
33
|
-
@name = str
|
33
|
+
@name = str.gsub('"', "'")
|
34
34
|
old_name
|
35
35
|
end
|
36
36
|
|
data/lib/list_tool/version.rb
CHANGED
data/spec/list_tool/item_spec.rb
CHANGED
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitrii Krasnov
|
@@ -184,7 +184,7 @@ 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.1
|
188
188
|
test_files:
|
189
189
|
- spec/fixtures/data.json
|
190
190
|
- spec/list_tool/app/commands/add_item_command_spec.rb
|