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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02b3b401bb917dd37c09651ea107c8331d9d20dd
4
- data.tar.gz: 214817e634ce79d29ea58f413fa5ff07f017c849
3
+ metadata.gz: 34ece5f2e12c07abd8d89e3487fd5b2a38aedb36
4
+ data.tar.gz: 32586be177d6ff874d2a70d5110f5253ec1c8d6c
5
5
  SHA512:
6
- metadata.gz: 1eae4a8fdc49fea6567d963e69e3cdf77bb95f17d8529303700f161fbfb03c6cd86563aa525d988313bd504b1b7b62b54dbbd2d3280980111c3e50918a7b06b1
7
- data.tar.gz: d717f15417c6851f289d5d8a9c1ff975b94c06f6f751e4d6e85c52550e3633d3d5a1b260c873ffb40b4da323ba55139f53f1f7a73bf62c732c8120ab3ad91ce2
6
+ metadata.gz: c82e5dd20dbf585787b50d88b306bfc8dc6a4f265b225624e1f7e94e19515d67c74bbb4fb40f9f7d8dbfd6b738561698adcd52502394f90475e97690f6c8c218
7
+ data.tar.gz: 5e975d2ddf492cdbdd531d3feae2167462790764b12c61c7ba833a894ddd788c5dca3591437ba4c47d1f46351aa0d854fcd7b993acb67d829a2cab70d85d85f0
data/README.md CHANGED
@@ -1,29 +1,44 @@
1
1
  # ListTool
2
2
 
3
- TODO: Write a gem description
3
+ This gem may be used to manage lists of text strings (todos, for example) in your app or in console
4
4
 
5
- ## Installation
5
+ ## In app
6
6
 
7
- Add this line to your application's Gemfile:
7
+ In your app do this:
8
8
 
9
- gem 'list_tool'
9
+ require 'list-tool'
10
10
 
11
- And then execute:
11
+ ...
12
12
 
13
- $ bundle
13
+ lister = Lister.new
14
14
 
15
- Or install it yourself as:
15
+ I'll describe later how to work with it
16
16
 
17
- $ gem install list_tool
17
+ ## In console
18
18
 
19
- ## Usage
19
+ Also gem provides console tool named 'clt' ('console list tool'), which allows you to manage lists in console.
20
20
 
21
- TODO: Write usage instructions here
21
+ USAGE: clt COMMAND [OPTIONS]
22
22
 
23
- ## Contributing
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
- 1. Fork it ( http://github.com/<my-github-username>/list_tool/fork )
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
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
@@ -1,19 +1,23 @@
1
1
  module ListTool
2
2
 
3
3
  class Item
4
- attr_accessor :text
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
@@ -3,16 +3,16 @@ module ListTool
3
3
  class List
4
4
  include Enumerable
5
5
 
6
- attr_reader :name, :items
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
 
@@ -1,3 +1,3 @@
1
1
  module ListTool
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -39,4 +39,11 @@ describe ListTool::Item do
39
39
  end
40
40
  end
41
41
 
42
+ describe '#text=' do
43
+ it 'substitutes " with \'' do
44
+ item.text = 'text with ""'
45
+ expect(item.text).to eq "text with ''"
46
+ end
47
+ end
48
+
42
49
  end
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.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.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