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 +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +2 -1
- data/bin/pickpocket +4 -1
- data/lib/pickpocket/articles/library.rb +19 -8
- data/lib/pickpocket/version.rb +1 -1
- data/pickpocket.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47da4d86e70428b9f6b6b2e5fb3e33a3f46f2ae8
|
4
|
+
data.tar.gz: 936ef80f55449d4a17548908f6161d5fefe40a8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22571a063d59d6d834eb6cc38b264050e0b1aafdfe1b13868eb92217dc07de913bda6c0e8170b923b41bc25ad67eaa2bdd16ecee4e4f38845acba3842dcdd1f5
|
7
|
+
data.tar.gz: c4208564d467b7ce8ea31196a3573085a086027750f8be2432e254c6dd19b52709fda0998f124d22756c41491c642881b45fa17e9f24eb2b332d3d8ce21b17b7
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.4.0
|
data/.travis.yml
CHANGED
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
|
-
|
29
|
+
# @param [Integer] quantity. Quantity of articles to open.
|
30
|
+
def pick(quantity = 1)
|
30
31
|
guarantee_inventory
|
31
32
|
store.transaction do
|
32
|
-
|
33
|
-
|
33
|
+
quantity.times do
|
34
|
+
unread = store[:unread]
|
35
|
+
random_key = random_hash_key(unread)
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
data/lib/pickpocket/version.rb
CHANGED
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.
|
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.
|
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:
|
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.
|
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.
|
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.
|
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)'
|