pocket-console 0.1.2 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65c06e806cd4e4aeac76308e1b6d07eea8e76e73
4
- data.tar.gz: 5cea7ac4f6698f08d120eb74adc2e5ef7c204004
3
+ metadata.gz: 77bb64cbb0e25495054b4a4c072784ac89751741
4
+ data.tar.gz: 6a743f070da60692ce6c50695f02928e5b4ff7d9
5
5
  SHA512:
6
- metadata.gz: de946cfddc39e65af2fca0991b951f38d533381b01d7ad4a3d96eee524014fdd5f5d29e76704bffad5148536348529d6110cfbe2900b219fa70da7a9e383d2a0
7
- data.tar.gz: 99be703c72c783ab7912f6d21e7ab41ca9b08b8af0d46af9e2477a12b3d7f27d8ebe7b029869f47ed20c50874d35a00dd9936951bae071227b268e68cb1f1e2e
6
+ metadata.gz: f5e753dba239a54814afa4183b71767e46cf91be727779f6c50c54e1766ccc9334aa2ac862b5c870a7b37784a9d602a4b5802c3539dd23e9858b97654d4571b9
7
+ data.tar.gz: 7198c40430d9ce9050203853099cd5feb656055d4bba9c5d73d905b641fedcb38afffc135f8ae5e04a90f0aa9e16210f48d99cee125137d82d48e696d6abe8c0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 0.1.4
2
+
3
+ * Adds Stats for specific terms
4
+
5
+ # 0.1.3
6
+
7
+ * Refactors Stats Print methods
8
+
1
9
  # 0.1.2
2
10
 
3
11
  * Added 'Less Unread'. Tags that are associated to the lowest amount of unread items.
data/lib/pocketConsole.rb CHANGED
@@ -29,6 +29,11 @@ class PocketConsole
29
29
  tagStats.print
30
30
  end
31
31
 
32
+ def printSpecificTermsStats(terms)
33
+ tagStats = TagStats.new(@tagCollection)
34
+ tagStats.printSpecificTerms(terms)
35
+ end
36
+
32
37
  def printItems
33
38
  items = @taggedItems + @untaggedItems
34
39
  itemsPrinter = ItemsPrinter.new(items)
data/lib/tagStats.rb CHANGED
@@ -15,179 +15,152 @@ class TagStats
15
15
  end
16
16
 
17
17
  def printMostUsed
18
- @tags = @tags.sort_by{|_key, stats| stats['count']}.reverse!
19
- puts '================================='
20
- puts ' Tag Stats - Most Used '
21
- puts '---------------------------------'
18
+ @tags = @tags.sort_by{|_key, stats| stats['total']}.reverse!
19
+ printTitle(' Tag Stats - Most Used ')
22
20
  printMostUsedUntilChange(10)
23
- puts '================================='
21
+ printSeparator
24
22
  end
25
23
 
26
24
  def printLessUsed
27
- @tags = @tags.sort_by{|_key, stats| stats['count']}
28
- puts '================================='
29
- puts ' Tag Stats - Less Used '
30
- puts '---------------------------------'
25
+ @tags = @tags.sort_by{|_key, stats| stats['total']}
26
+ printTitle(' Tag Stats - Less Used ')
31
27
  printLessUsedUntilChange(3)
32
- puts '================================='
28
+ printSeparator
33
29
  end
34
30
 
35
31
  def printMostUnread
36
32
  @tags = @tags.sort_by{|_key, stats| stats['unread']}.reverse!
37
- puts '================================='
38
- puts ' Tag Stats - Most Unread '
39
- puts '---------------------------------'
33
+ printTitle(' Tag Stats - Most Unread ')
40
34
  printMostUnreadUntilChange(10)
41
- puts '================================='
35
+ printSeparator
42
36
  end
43
37
 
44
38
  def printLessUnread
45
39
  @tags = @tags.sort_by{|_key, stats| stats['unread']}
46
- puts '================================='
47
- puts ' Tag Stats - Less Unread '
48
- puts '---------------------------------'
40
+ printTitle(' Tag Stats - Less Unread ')
49
41
  printLessUnreadUntilChange(3)
50
- puts '================================='
42
+ printSeparator
51
43
  end
52
44
 
53
45
 
54
- def printMostUsedUntilChange(changes)
46
+ def printSpecificTerms(terms)
47
+
48
+ specificTags = Hash.new
49
+ terms.each do |term|
50
+ if (@tags.has_key?(term))
51
+ specificTags[term] = @tags[term]
52
+ end
53
+ end
55
54
 
56
- puts sprintf "%-13s | %6s | %7s", 'tag', 'total', 'unread'
57
- puts '---------------------------------'
55
+ if (!specificTags.empty?)
56
+ aux = @tags
57
+ @tags = specificTags
58
+ printMostUnread
59
+ puts ''
60
+ @tags = aux
61
+ end
58
62
 
59
- changeCount = 0
60
- firstLoop = true
61
- prevCount = 0
63
+ end
62
64
 
63
- @tags.each do |tag, stats|
64
65
 
65
- if (firstLoop)
66
- prevCount = stats['count']
67
- firstLoop = false
68
- end
66
+ def printMostUsedUntilChange(changes)
67
+ printTableHeaderTotalUnread
68
+ printMostTableBody('total', 'unread',changes)
69
+ end
69
70
 
70
- count = stats['count']
71
- if (count < prevCount)
72
- changeCount += 1
73
- if (changeCount == changes)
74
- break
75
- end
76
- end
77
- prevCount = stats['count']
71
+ def printLessUsedUntilChange(changes)
72
+ printTableHeaderTotalUnread
73
+ printLessTableBody('total', 'unread', changes)
74
+ end
78
75
 
79
- unread = stats['unread']
80
- puts sprintf "%-13s | %6d | %7d", tag, count, unread
76
+ def printMostUnreadUntilChange(changes)
77
+ printTableHeaderUnreadTotal
78
+ printMostTableBody('unread', 'total', changes)
79
+ end
81
80
 
82
- end
81
+ def printLessUnreadUntilChange(changes)
82
+ printTableHeaderUnreadTotal
83
+ printLessTableBody('unread', 'total', changes)
84
+ end
83
85
 
86
+ def printTableHeaderTotalUnread
87
+ printTableHeader('total', 'unread')
84
88
  end
85
89
 
90
+ def printTableHeaderUnreadTotal
91
+ printTableHeader('unread', 'total')
92
+ end
86
93
 
87
- def printLessUsedUntilChange(changes)
88
94
 
89
- puts sprintf "%-13s | %6s | %7s", 'tag', 'total', 'unread'
95
+ def printTableHeader(firstColumn, secondColumn)
96
+ puts sprintf "%-13s | %6s | %7s", 'tag', firstColumn, secondColumn
90
97
  puts '---------------------------------'
98
+ end
91
99
 
92
- changeCount = 0
93
- prevCount = 0
94
-
95
- @tags.each do |tag, stats|
96
-
97
- count = stats['count']
98
- if (count > prevCount)
99
- changeCount += 1
100
- if (changeCount == changes)
101
- break
102
- end
103
- end
104
- prevCount = stats['count']
100
+ def printTitle(title)
101
+ puts '================================='
102
+ puts title
103
+ puts '---------------------------------'
104
+ end
105
105
 
106
- unread = stats['unread']
107
- puts sprintf "%-13s | %6d | %7d", tag, count, unread
106
+ def printSeparator
107
+ puts '================================='
108
+ end
108
109
 
109
- end
110
110
 
111
+ def printRow(tag, firstColumnValue, secondColumnValue)
112
+ puts sprintf "%-13s | %6d | %7d", tag, firstColumnValue, secondColumnValue
111
113
  end
112
114
 
113
115
 
114
- def printMostUnreadUntilChange(changes)
115
-
116
- puts sprintf "%-13s | %6s | %7s", 'tag', 'unread', 'total'
117
- puts '---------------------------------'
116
+ def printMostTableBody(firstColumn, secondColumn, changes)
118
117
 
119
118
  changeCount = 0
120
119
  firstLoop = true
121
- prevCount = 0
120
+ prevValue = 0
122
121
 
123
122
  @tags.each do |tag, stats|
124
123
 
125
124
  if (firstLoop)
126
- prevCount = stats['unread']
125
+ prevCount = stats[firstColumn]
127
126
  firstLoop = false
128
127
  end
129
128
 
130
- unread = stats['unread']
131
- if (unread < prevCount)
129
+ firstColumnValue = stats[firstColumn]
130
+ if (firstColumnValue < prevValue)
132
131
  changeCount += 1
133
132
  if (changeCount == changes)
134
133
  break
135
134
  end
136
135
  end
137
- prevCount = stats['unread']
136
+ prevValue = firstColumnValue
138
137
 
139
- count = stats['count']
140
- puts sprintf "%-13s | %6d | %7d", tag, unread, count
138
+ secondColumnValue = stats[secondColumn]
139
+ printRow(tag, firstColumnValue, secondColumnValue)
141
140
 
142
141
  end
143
142
 
144
143
  end
145
144
 
146
145
 
147
- def printLessUnreadUntilChange(changes)
148
-
149
- puts sprintf "%-13s | %6s | %7s", 'tag', 'unread', 'total'
150
- puts '---------------------------------'
146
+ def printLessTableBody(firstColumn, secondColumn, changes)
151
147
 
152
148
  changeCount = 0
153
149
  prevCount = 0
154
150
 
155
151
  @tags.each do |tag, stats|
156
-
157
- unread = stats['unread']
158
- if (unread > prevCount)
152
+
153
+ firstColumnValue = stats[firstColumn]
154
+ if (firstColumnValue > prevCount)
159
155
  changeCount += 1
160
156
  if (changeCount == changes)
161
157
  break
162
158
  end
163
159
  end
164
- prevCount = stats['unread']
165
-
166
- count = stats['count']
167
- puts sprintf "%-13s | %6d | %7d", tag, unread, count
168
-
169
- end
170
-
171
- end
172
-
173
-
174
- def printTopTable
175
-
176
- puts sprintf "%-13s | %6s | %7s", 'tag', 'total', 'unread'
177
- puts '---------------------------------'
178
- top_count = 0
160
+ prevCount = stats[firstColumn]
179
161
 
180
- @tags.each do |tag, stats|
181
-
182
- count = stats['count']
183
- unread = stats['unread']
184
- puts sprintf "%-13s | %6d | %7d", tag, count, unread
185
-
186
- top_count += 1
187
-
188
- if (top_count == 10)
189
- break
190
- end
162
+ secondColumnValue = stats[secondColumn]
163
+ printRow(tag, firstColumnValue, secondColumnValue)
191
164
 
192
165
  end
193
166
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pocket-console
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Cedillo
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.1
19
+ version: 0.0.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.1
26
+ version: 0.0.3
27
27
  description: Stats about Pocket tags, on your console.
28
28
  email: franco.cedillo@gmail.com
29
29
  executables: []