pocket-console 0.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: efd026097239a27b37f2b9c61de4d7585c442820
4
+ data.tar.gz: c6b565b8916ffdec3e579d3935778b9289eabdfe
5
+ SHA512:
6
+ metadata.gz: 0cf180512c9fe497418da054c305d6de42fefe24fcfd3170d2dd0fdc2834b7f40e120d1943d7c0cd220b3835968fdb52cfaca1857058832e168f237f53deb1b6
7
+ data.tar.gz: 0c3e8bb839dd24f924d528a05d5196e3fd0ac170d8334373e12ce4bf650fd5935c8f5bcc8c8e0b03c86625a42cb2b2ab814e07bb12a8afb320d9738d2327006b
data/lib/itemStats.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'item'
2
+
3
+ class ItemStats
4
+
5
+ def initialize(taggedItems, untaggedItems)
6
+ @taggedItems = taggedItems
7
+ @untaggedItems = untaggedItems
8
+ end
9
+
10
+ def print
11
+ printGeneralStats
12
+ end
13
+
14
+ def printGeneralStats
15
+ tagged = @taggedItems.length
16
+ untagged = @untaggedItems.length
17
+ puts '===================='
18
+ puts ' General Stats '
19
+ puts '--------------------'
20
+ puts sprintf "%-15s %2d", 'Tagged items:', tagged
21
+ puts sprintf "%-15s %2d", 'Untagged items:', untagged
22
+ puts '--------------------'
23
+ end
24
+
25
+ end
@@ -0,0 +1,29 @@
1
+ require 'item'
2
+
3
+ class ItemsPrinter
4
+
5
+ def initialize(items)
6
+ @items = items
7
+ end
8
+
9
+ def printItems
10
+ puts ''
11
+ puts '==========='
12
+ puts ' Items '
13
+ puts '-----------'
14
+ puts 'status | title'
15
+ for item in @items
16
+ given_title = item.getGivenTitle
17
+ status = item.getStatus
18
+ tags = item.getTags
19
+ if !tags.empty?
20
+ puts "#{status} | #{tags} #{given_title}"
21
+ else
22
+ puts "#{status} | #{given_title}"
23
+ end
24
+ end
25
+ puts '==========='
26
+ puts ''
27
+ end
28
+
29
+ end
@@ -0,0 +1,38 @@
1
+ class PocketConsole
2
+
3
+ def initialize(taggedItems, untaggedItems)
4
+ @taggedItems = taggedItems
5
+ @untaggedItems = untaggedItems
6
+ @tagCollection = TagCollection.new(taggedItems)
7
+ end
8
+
9
+ def printStats
10
+ puts ''
11
+ printGeneralStats
12
+ puts ''
13
+ printTagStats
14
+ puts ''
15
+ end
16
+
17
+ def printGeneralStats
18
+ itemStats = ItemStats.new(@taggedItems, @untaggedItems)
19
+ itemStats.print
20
+ end
21
+
22
+ def printTagStats
23
+ tagStats = TagStats.new(@tagCollection)
24
+ tagStats.print
25
+ end
26
+
27
+ def printItems
28
+ items = @taggedItems + @untaggedItems
29
+ itemsPrinter = ItemsPrinter.new(items)
30
+ end
31
+
32
+ end
33
+
34
+ require 'tagCollection'
35
+
36
+ require 'itemStats.rb'
37
+ require 'tagStats.rb'
38
+ require 'itemsPrinter.rb'
data/lib/tagStats.rb ADDED
@@ -0,0 +1,47 @@
1
+ class TagStats
2
+
3
+ def initialize(tagCollection)
4
+ @tags = tagCollection.getTags
5
+ end
6
+
7
+ def print
8
+ printMostUsed
9
+ puts ''
10
+ printMostUnread
11
+ end
12
+
13
+ def printMostUsed
14
+ @tags = @tags.sort_by{|_key, stats| stats['count']}.reverse!
15
+ puts '================================'
16
+ puts ' Tag Stats - Most Used '
17
+ puts '--------------------------------'
18
+ puts sprintf "%-12s | %6s | %7s", 'tag', 'total', 'unread'
19
+ @tags.each do |tag, stats|
20
+ count = stats['count']
21
+ if count == 1
22
+ break
23
+ end
24
+ unread = stats['unread']
25
+ puts sprintf "%-12s | %6d | %7d", tag, count, unread
26
+ end
27
+ puts '================================'
28
+ end
29
+
30
+ def printMostUnread
31
+ @tags = @tags.sort_by{|_key, stats| stats['unread']}.reverse!
32
+ puts '================================'
33
+ puts ' Tag Stats - Most Unread '
34
+ puts '--------------------------------'
35
+ puts sprintf "%-12s | %7s | %6s", 'tag', 'unread', 'total'
36
+ @tags.each do |tag, stats|
37
+ unread = stats['unread']
38
+ if unread == 1
39
+ break
40
+ end
41
+ count = stats['count']
42
+ puts sprintf "%-12s | %7d | %6d", tag, unread, count
43
+ end
44
+ puts '================================'
45
+ end
46
+
47
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pocket-console
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Franco Cedillo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-25 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |+
14
+ This gem provides methods to output stats about Pocket tags.
15
+
16
+ 1. General Stats
17
+ 2. Most Used tags
18
+ 3. Most Unread. Tags that were assigned to the most large amount of items.
19
+
20
+ Stats are presented in tables, formatted as you can see below:
21
+
22
+ ====================
23
+ General Stats
24
+ --------------------
25
+ Tagged items: 50
26
+ Untagged items: 30
27
+ --------------------
28
+
29
+ ================================
30
+ Tag Stats - Most Used
31
+ --------------------------------
32
+ tag | total | unread
33
+ pocket | 16 | 3
34
+ dev | 7 | 5
35
+ ux | 4 | 1
36
+ techonomics | 4 | 0
37
+ rails | 2 | 2
38
+ things | 2 | 2
39
+ history | 2 | 1
40
+ ifttt | 2 | 1
41
+ ios | 2 | 2
42
+ node.js | 2 | 2
43
+ ================================
44
+
45
+ ================================
46
+ Tag Stats - Most Unread
47
+ --------------------------------
48
+ tag | unread | total
49
+ dev | 5 | 7
50
+ pocket | 3 | 16
51
+ rails | 2 | 2
52
+ things | 2 | 2
53
+ ios | 2 | 2
54
+ node.js | 2 | 2
55
+ ================================
56
+
57
+ email: franco.cedillo@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/itemStats.rb
63
+ - lib/itemsPrinter.rb
64
+ - lib/pocketConsole.rb
65
+ - lib/tagStats.rb
66
+ homepage: http://rubygems.org/gems/pocket-console
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.4.2
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Stats from Pocket on your console
90
+ test_files: []
91
+ has_rdoc: