pick-pocket 0.1.2 → 0.2.0

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: acb1ff4bf46b57855872d3e81f2b079d14b3d06b
4
- data.tar.gz: 79c0a01ad96651b84ccd45854290428ad49f873f
3
+ metadata.gz: 47da4d86e70428b9f6b6b2e5fb3e33a3f46f2ae8
4
+ data.tar.gz: 936ef80f55449d4a17548908f6161d5fefe40a8a
5
5
  SHA512:
6
- metadata.gz: b7c6b4f7baa490d815276c759914995393128a606eb9d12939ba5d323448b2f52d204dc608ab554ef8655baeb7631df3311865885aa5413d9ed9b86277aef4d1
7
- data.tar.gz: 6e7b973232acda4032e2bb453e76d32ea29bf6c0da9cc2932bb9ffaa0f56e81ca846692844ae8526c640a975abea694d739d8ae86065dc226931cd4be18693f8
6
+ metadata.gz: 22571a063d59d6d834eb6cc38b264050e0b1aafdfe1b13868eb92217dc07de913bda6c0e8170b923b41bc25ad67eaa2bdd16ecee4e4f38845acba3842dcdd1f5
7
+ data.tar.gz: c4208564d467b7ce8ea31196a3573085a086027750f8be2432e254c6dd19b52709fda0998f124d22756c41491c642881b45fa17e9f24eb2b332d3d8ce21b17b7
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.4.0
data/.travis.yml CHANGED
@@ -4,7 +4,8 @@ sudo: false
4
4
  language: ruby
5
5
  cache: bundler
6
6
  rvm:
7
- - 2.3.1
7
+ - 2.4.0
8
+ - 2.3.3
8
9
  - 2.2.5
9
10
  - 2.1.10
10
11
  before_install: gem install bundler -v 1.13.1
data/bin/pickpocket CHANGED
@@ -20,9 +20,12 @@ class PickpocketCLI < Thor
20
20
  end
21
21
 
22
22
  desc 'pick', 'Picks a random article from your library (marking it as read)'
23
+ method_option :quantity, aliases: '-q', banner: '1', desc: 'Quantity of articles to open', type: :numeric, default: 1
23
24
  def pick
25
+ quantity = options[:quantity].to_i
26
+
24
27
  library = Pickpocket::Articles::Library.new
25
- library.pick
28
+ library.pick(quantity)
26
29
  end
27
30
 
28
31
  desc 'renew', 'Syncs your local library with your Pocket. It will delete read articles and download new articles from your library'
@@ -26,17 +26,20 @@ module Pickpocket
26
26
  end
27
27
 
28
28
  # Select an unread article, put it to the read collection and return this article
29
- def pick
29
+ # @param [Integer] quantity. Quantity of articles to open.
30
+ def pick(quantity = 1)
30
31
  guarantee_inventory
31
32
  store.transaction do
32
- unread = store[:unread]
33
- random_key = unread.keys.sample
33
+ quantity.times do
34
+ unread = store[:unread]
35
+ random_key = random_hash_key(unread)
34
36
 
35
- if (random_article = unread.delete(random_key))
36
- store[:read].update({ random_key => random_article })
37
- Launchy.open(random_article['resolved_url'])
38
- else
39
- logger.info 'You have read all articles!'
37
+ if (random_article = unread.delete(random_key))
38
+ store[:read].update({ random_key => random_article })
39
+ Launchy.open(random_article['resolved_url'])
40
+ else
41
+ logger.info 'You have read all articles!'
42
+ end
40
43
  end
41
44
  end
42
45
  end
@@ -65,6 +68,14 @@ module Pickpocket
65
68
  logger.info %Q{You have #{unread_count} unread articles}
66
69
  end
67
70
  end
71
+
72
+ private
73
+
74
+ # @param [Hash] unread_articles
75
+ # @return [String, NilClass]
76
+ def random_hash_key(unread_articles)
77
+ unread_articles.keys.sample
78
+ end
68
79
  end
69
80
  end
70
81
  end
@@ -1,3 +1,3 @@
1
1
  module Pickpocket
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.0'
3
3
  end
data/pickpocket.gemspec CHANGED
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'rspec', '~> 3.0'
28
28
  spec.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.3'
29
29
  spec.add_development_dependency 'codeclimate-test-reporter', "~> 0.6.0"
30
- spec.add_development_dependency 'webmock', '~> 2.1', '>= 2.1.0'
30
+ spec.add_development_dependency 'webmock', '~> 2.3', '>= 2.1.0'
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pick-pocket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Amaro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-16 00:00:00.000000000 Z
11
+ date: 2017-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: launchy
@@ -126,7 +126,7 @@ dependencies:
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '2.1'
129
+ version: '2.3'
130
130
  - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: 2.1.0
@@ -136,7 +136,7 @@ dependencies:
136
136
  requirements:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: '2.1'
139
+ version: '2.3'
140
140
  - - ">="
141
141
  - !ruby/object:Gem::Version
142
142
  version: 2.1.0
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  version: '0'
192
192
  requirements: []
193
193
  rubyforge_project:
194
- rubygems_version: 2.5.1
194
+ rubygems_version: 2.6.8
195
195
  signing_key:
196
196
  specification_version: 4
197
197
  summary: 'Pickpocket: selects a random article from your Pocket (former Read It Later)'