item_list 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Rakefile +3 -3
- data/bin/console +3 -3
- data/item_list.gemspec +19 -16
- data/lib/item_list/version.rb +1 -1
- data/lib/item_list_printer.rb +8 -7
- data/lib/item_printer.rb +5 -7
- data/lib/list.rb +4 -3
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee2c24c2b427582794c42d3c0a784ef61c572248
|
4
|
+
data.tar.gz: 945f1a5d0f7999b9e20a7bf76e521dc031e99253
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4ba181c737e0b37528635db1667a24b071dc11c94f6bf4ec7a2b6bd6f692dae3c41e5579a1f327107efc7f97d9f776247dc25f6d7ac6ffa050a59bf38e468e0
|
7
|
+
data.tar.gz: 65c2a501e3e517c64e990c09c8201b2e6604deb71646f3872c10b0f1c92d084d5aa7461dc81b595a0fcabcfbc7e65931197f15f85054c08a9d594b27be98d2b1
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
3
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in item_list.gemspec
|
6
6
|
gemspec
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'item_list'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "item_list"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
data/item_list.gemspec
CHANGED
@@ -1,29 +1,32 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
|
3
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
6
|
+
require 'item_list/version'
|
5
7
|
|
6
8
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
9
|
+
spec.name = 'item_list'
|
8
10
|
spec.version = ItemList::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
+
spec.authors = ['Austin Rowsell']
|
12
|
+
spec.email = ['andyrow123@hotmail.co.uk']
|
11
13
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
14
|
+
spec.summary = 'Create an item list form an array of objects'
|
15
|
+
spec.description = 'Create an item list form an array of objects'
|
16
|
+
spec.homepage = 'https://github.com/andyrow123/item_list'
|
17
|
+
spec.license = 'MIT'
|
16
18
|
|
17
19
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
20
|
f.match(%r{^(test|spec|features)/})
|
19
21
|
end
|
20
|
-
spec.bindir =
|
22
|
+
spec.bindir = 'exe'
|
21
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = [
|
24
|
+
spec.require_paths = ['lib']
|
23
25
|
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
spec.add_development_dependency 'rubocop', '~> 0.48.1'
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
30
|
+
spec.add_development_dependency 'simplecov', '~> 0.14.1'
|
31
|
+
spec.add_development_dependency 'simplecov-console', '~> 0.4.1'
|
29
32
|
end
|
data/lib/item_list/version.rb
CHANGED
data/lib/item_list_printer.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
require 'item_printer'
|
2
2
|
|
3
|
+
# ItemListPrinter
|
3
4
|
module ItemListPrinter
|
4
5
|
def self.to_string(items, item_printer = ItemPrinter)
|
5
|
-
items.each_with_index
|
6
|
-
|
7
|
-
|
6
|
+
items.each_with_index
|
7
|
+
.map { |item, index| item_printer.to_string(item, index + 1) }
|
8
|
+
.join("\n")
|
8
9
|
end
|
9
10
|
|
10
11
|
def self.to_summary(items, keys, item_printer = ItemPrinter)
|
11
|
-
items.each_with_index
|
12
|
-
|
13
|
-
|
12
|
+
items.each_with_index
|
13
|
+
.map { |item, index| item_printer.to_summary(item, keys, index + 1) }
|
14
|
+
.join("\n")
|
14
15
|
end
|
15
|
-
end
|
16
|
+
end
|
data/lib/item_printer.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
+
##
|
2
|
+
# This module takes in an item and returns a string.
|
1
3
|
module ItemPrinter
|
2
4
|
def self.to_string(item, index)
|
3
5
|
str = "#{index}. "
|
4
|
-
str << item.keys.map { |key|
|
5
|
-
"#{item[key]} "
|
6
|
-
}.join
|
6
|
+
str << item.keys.map { |key| item[key].to_s }.join(' ')
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.to_summary(item, keys, index)
|
10
10
|
str = "#{index}. "
|
11
|
-
str << keys.map { |key|
|
12
|
-
"#{item[key]} "
|
13
|
-
}.join
|
11
|
+
str << keys.map { |key| item[key].to_s }.join(' ')
|
14
12
|
end
|
15
|
-
end
|
13
|
+
end
|
data/lib/list.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'item_list_printer'
|
2
2
|
|
3
|
+
# List
|
3
4
|
class List
|
4
5
|
attr_reader :items
|
5
6
|
|
@@ -8,13 +9,13 @@ class List
|
|
8
9
|
end
|
9
10
|
|
10
11
|
def add(item)
|
11
|
-
|
12
|
+
raise 'Already exists in list' if found?(item)
|
12
13
|
@items << item
|
13
14
|
'Success'
|
14
15
|
end
|
15
16
|
|
16
17
|
def remove(item)
|
17
|
-
|
18
|
+
raise 'Not found in list' unless found?(item)
|
18
19
|
@items.delete(item)
|
19
20
|
'Success'
|
20
21
|
end
|
@@ -32,7 +33,7 @@ class List
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def find(item)
|
35
|
-
all.
|
36
|
+
all.detect { |arr| arr == item }
|
36
37
|
end
|
37
38
|
|
38
39
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: item_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin Rowsell
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.48.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.48.1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|