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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 438e2853650eeb72e42c08abe83346368e4ff33d
4
- data.tar.gz: 1575e3bb987a0b9848a92314ac2dcdd9925ac92e
3
+ metadata.gz: ee2c24c2b427582794c42d3c0a784ef61c572248
4
+ data.tar.gz: 945f1a5d0f7999b9e20a7bf76e521dc031e99253
5
5
  SHA512:
6
- metadata.gz: ca6908a7f2855a3d442525e7b00a03ca7b0480ea1e597053e7ef227e599d2fb387c0334814740d8f06561f9226c4d4153f0d11748da638951887172c605f96bb
7
- data.tar.gz: 52f371844f4e4667834eaaa51b04489305639563b9188d5bf3d4282abc1a996127f7dad61e5e64a2549182a7a97dc1789d2d1b2823147829d04f02d024cc92f5
6
+ metadata.gz: a4ba181c737e0b37528635db1667a24b071dc11c94f6bf4ec7a2b6bd6f692dae3c41e5579a1f327107efc7f97d9f776247dc25f6d7ac6ffa050a59bf38e468e0
7
+ data.tar.gz: 65c2a501e3e517c64e990c09c8201b2e6604deb71646f3872c10b0f1c92d084d5aa7461dc81b595a0fcabcfbc7e65931197f15f85054c08a9d594b27be98d2b1
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source "https://rubygems.org"
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
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "item_list"
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 "irb"
13
+ require 'irb'
14
14
  IRB.start(__FILE__)
@@ -1,29 +1,32 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "item_list/version"
6
+ require 'item_list/version'
5
7
 
6
8
  Gem::Specification.new do |spec|
7
- spec.name = "item_list"
9
+ spec.name = 'item_list'
8
10
  spec.version = ItemList::VERSION
9
- spec.authors = ["Austin Rowsell"]
10
- spec.email = ["andyrow123@hotmail.co.uk"]
11
+ spec.authors = ['Austin Rowsell']
12
+ spec.email = ['andyrow123@hotmail.co.uk']
11
13
 
12
- spec.summary = "Create an item list form an array of objects"
13
- spec.description = "Create an item list form an array of objects"
14
- spec.homepage = "https://github.com/andyrow123/item_list"
15
- spec.license = "MIT"
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 = "exe"
22
+ spec.bindir = 'exe'
21
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
24
+ spec.require_paths = ['lib']
23
25
 
24
- spec.add_development_dependency "bundler", "~> 1.15"
25
- spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rspec", "~> 3.0"
27
- spec.add_development_dependency "simplecov", "~> 0.14.1"
28
- spec.add_development_dependency "simplecov-console", "~> 0.4.1"
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
@@ -1,3 +1,3 @@
1
1
  module ItemList
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -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.map { |item, index|
6
- item_printer.to_string(item, index + 1)
7
- }.join("\n")
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.map { |item, index|
12
- item_printer.to_summary(item, keys, index + 1)
13
- }.join("\n")
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
@@ -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
@@ -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
- fail 'Already exists in list' if found?(item)
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
- fail 'Not found in list' unless found?(item)
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.select { |arr| arr == item }
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.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