logtime 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/Gemfile.lock +2 -4
- data/README.md +14 -12
- data/VERSION +1 -1
- data/bin/lt +3 -0
- data/config/application.rb +4 -2
- data/config/database.rb +1 -1
- data/config/initialisation.rb +1 -2
- data/config/schema.rb +1 -1
- data/lib/commands/add.rb +2 -3
- data/lib/commands/list.rb +22 -15
- data/lib/commands/start.rb +13 -8
- data/lib/commands/stop.rb +19 -10
- data/lib/helpers/time_display.rb +2 -2
- data/lib/models/log.rb +79 -6
- data/lib/models/series.rb +5 -6
- data/lib/subcommands/series.rb +15 -14
- data/lib/subcommands/tags.rb +3 -3
- data.tar.gz.sig +0 -0
- metadata +3 -17
- metadata.gz.sig +0 -0
- data/lib/app/commands/add.rb +0 -41
- data/lib/app/commands/list.rb +0 -56
- data/lib/app/commands/start.rb +0 -28
- data/lib/app/commands/stop.rb +0 -29
- data/lib/app/helpers/estimate.rb +0 -13
- data/lib/app/helpers/statistics.rb +0 -45
- data/lib/app/helpers/time_to_words.rb +0 -33
- data/lib/app/logtime.rb +0 -67
- data/lib/app/models/log.rb +0 -42
- data/lib/app/models/series.rb +0 -35
- data/lib/app/models/tag.rb +0 -9
- data/lib/app/subcommands/keyword.rb +0 -214
- data/lib/app/subcommands/series.rb +0 -58
- data/lib/app/subcommands/tags.rb +0 -79
- data/lib/helpers/estimate.rb +0 -13
- data/lib/subcommands/keyword.rb +0 -214
data/lib/app/subcommands/tags.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
module SubCommands
|
2
|
-
class Tags < Thor
|
3
|
-
desc "add", "create new tag"
|
4
|
-
def add(tag)
|
5
|
-
tag = ::Tag.new(tag: tag.strip)
|
6
|
-
|
7
|
-
if !tag.save
|
8
|
-
tag.errors.full_messages.each do |error|
|
9
|
-
say error, :red
|
10
|
-
end
|
11
|
-
exit 1
|
12
|
-
end
|
13
|
-
|
14
|
-
say tag.tag + " added!", :green
|
15
|
-
end
|
16
|
-
|
17
|
-
desc "rm", "remove tag"
|
18
|
-
# option :prune, :type => :boolean, :alias => '-p', :default => false not implemented yet
|
19
|
-
def rm(tag)
|
20
|
-
tag = ::Tag.where(tag: tag)
|
21
|
-
p tag.inspect
|
22
|
-
end
|
23
|
-
|
24
|
-
desc "ls", "list tags"
|
25
|
-
option :order, :type => :string, :default => "created_at"
|
26
|
-
def ls
|
27
|
-
tags = ::Tag.order(options[:order].to_sym => :desc)
|
28
|
-
|
29
|
-
table = [['#', '']] # header
|
30
|
-
tags.each do |tag|
|
31
|
-
table << [tag.id, tag.tag] # row
|
32
|
-
end
|
33
|
-
print_table table
|
34
|
-
end
|
35
|
-
|
36
|
-
# desc "add <name> <domain>", "Adds an account that owns a <domain>"
|
37
|
-
# def add(name, domain)
|
38
|
-
# account = Account.new({
|
39
|
-
# :name => name,
|
40
|
-
# :domain => domain
|
41
|
-
# })
|
42
|
-
|
43
|
-
# if account.save
|
44
|
-
# say name + ' added', :green
|
45
|
-
# else
|
46
|
-
# say 'could not add account!', :red
|
47
|
-
# error account.errors.first[0].to_s + ' ' + account.errors.first[1]
|
48
|
-
# end
|
49
|
-
# end
|
50
|
-
|
51
|
-
# desc "delete <account>", "Deletes <account>"
|
52
|
-
# #option :force, :type => :boolean, :alias => '-f', :default => false
|
53
|
-
# def delete(account)
|
54
|
-
# account = Account.search(account)
|
55
|
-
|
56
|
-
# if account.blank?
|
57
|
-
# say 'no account found', :red
|
58
|
-
# else
|
59
|
-
# say 'WARNING ', :red, false
|
60
|
-
# should_destroy = ask "Are you sure you want to delete " + account.name + "?", :limited_to => ["y", "n"]
|
61
|
-
# account.destroy and say account.name + ' destroyed!', :red if should_destroy == 'y'
|
62
|
-
# say 'no action was taken', :green if should_destroy == 'n'
|
63
|
-
# end
|
64
|
-
# end
|
65
|
-
|
66
|
-
# desc "list", "Lists all accounts"
|
67
|
-
# def list
|
68
|
-
# accounts = Account.all
|
69
|
-
|
70
|
-
# table = [['# Name', '# Domain', '# Keywords']] # header
|
71
|
-
# accounts.each do |a|
|
72
|
-
# table << [a.name, a.domain, a.keywords.size] # row
|
73
|
-
# end
|
74
|
-
# say ''
|
75
|
-
# print_table table
|
76
|
-
# say ''
|
77
|
-
# end
|
78
|
-
end
|
79
|
-
end
|
data/lib/helpers/estimate.rb
DELETED
data/lib/subcommands/keyword.rb
DELETED
@@ -1,214 +0,0 @@
|
|
1
|
-
class Keywords < Thor
|
2
|
-
# desc "add <account> <keyword>", "Add a new <keyword> to an <account>"
|
3
|
-
# option :interactive, :type => :boolean, :alias => :i
|
4
|
-
# def add(account, keyword=nil)
|
5
|
-
# account = Account.find_by(:name => account)
|
6
|
-
|
7
|
-
# if account.blank?
|
8
|
-
# say 'no account found', :red
|
9
|
-
# else
|
10
|
-
# if options[:interactive]
|
11
|
-
# say "To stop adding keywords type exit", :cyan
|
12
|
-
# while true
|
13
|
-
# keyword = ask ':'
|
14
|
-
# break if keyword == 'exit'
|
15
|
-
# if Keyword.new(:keyword => keyword, :account_id => account.id).save
|
16
|
-
# say 'added', :green
|
17
|
-
# else
|
18
|
-
# say 'failed', :red
|
19
|
-
# end
|
20
|
-
# end
|
21
|
-
# else
|
22
|
-
# keyword.split(',').each do |k|
|
23
|
-
# k = Keyword.new(:keyword => k, :account_id => account.id)
|
24
|
-
|
25
|
-
# if k.save
|
26
|
-
# say k.keyword + ' keyword added', :green
|
27
|
-
# else
|
28
|
-
# say 'could not add keyword!', :red
|
29
|
-
# error k.errors.first[0].to_s + ' ' + k.errors.first[1]
|
30
|
-
# end
|
31
|
-
# end
|
32
|
-
# end
|
33
|
-
# end
|
34
|
-
# end
|
35
|
-
|
36
|
-
# desc "delete <account> <keyword>", "Removes <keyword> on an <account>"
|
37
|
-
# def delete(account, keyword)
|
38
|
-
# account = Account.search(account)
|
39
|
-
|
40
|
-
# if account.blank?
|
41
|
-
# say 'no account found', :red
|
42
|
-
# else
|
43
|
-
# keyword.split(',').each do |k|
|
44
|
-
# k = Keyword.search(k)
|
45
|
-
|
46
|
-
# if k.blank?
|
47
|
-
# say 'could not find keyword!', :red
|
48
|
-
# else
|
49
|
-
# say k.keyword + ' removed', :green if k.destroy
|
50
|
-
# end
|
51
|
-
# end
|
52
|
-
# end
|
53
|
-
# end
|
54
|
-
|
55
|
-
# desc "list", "Lists keywords belonging to an <account>"
|
56
|
-
# option :account
|
57
|
-
# def list(account=nil)
|
58
|
-
# if account.nil?
|
59
|
-
# keywords = Keyword.all
|
60
|
-
|
61
|
-
# table = [['# Keyword', '# Position', '']] # header
|
62
|
-
# keywords.each do |k|
|
63
|
-
# stat = k.keyword_statistics.last unless k.keyword_statistics.empty?
|
64
|
-
# table << [k.keyword, stat.position || '', stat.created_at.pretty ] # row
|
65
|
-
# end
|
66
|
-
|
67
|
-
# say ''
|
68
|
-
# print_table table
|
69
|
-
# say ''
|
70
|
-
# else
|
71
|
-
# account = Account.search(account)
|
72
|
-
# if account.blank?
|
73
|
-
# say 'no account found', :red
|
74
|
-
# elsif account.keywords.empty?
|
75
|
-
# say 'no keywords exist for that account yet', :red
|
76
|
-
# else
|
77
|
-
# table = [['# Keyword', '# Position', '']] # header
|
78
|
-
# account.keywords.each do |k|
|
79
|
-
# stat = k.keyword_statistics.last unless k.keyword_statistics.empty?
|
80
|
-
# table << [k.keyword, stat.position || '', stat.created_at.pretty] # row
|
81
|
-
# end
|
82
|
-
|
83
|
-
# say ''
|
84
|
-
# print_table table
|
85
|
-
# say ''
|
86
|
-
# end
|
87
|
-
# end
|
88
|
-
# end
|
89
|
-
|
90
|
-
# desc "stats", "Compare keywords over time"
|
91
|
-
# option :search, :default => 'year', :banner => 'year,month,week,day'
|
92
|
-
# option :length, :type => :numeric, :default => 1
|
93
|
-
# option :engine, :default => :google
|
94
|
-
# def stats(account)
|
95
|
-
# account = Account.search(account)
|
96
|
-
|
97
|
-
# if account.blank?
|
98
|
-
# say 'no account found', :red
|
99
|
-
# elsif account.keywords.empty?
|
100
|
-
# say 'no keywords exist for that account yet', :red
|
101
|
-
# else
|
102
|
-
|
103
|
-
# table = [['# Keyword', 'n', 'High', 'Low', 'Current', 'Delta']] # header
|
104
|
-
# searched = 0;
|
105
|
-
# account.keywords.each do |k|
|
106
|
-
# stats = KeywordStatistic.send options[:search], k.id, options[:length], options[:engine]
|
107
|
-
# stats.order(:position)
|
108
|
-
|
109
|
-
# if !stats.empty?
|
110
|
-
# delta = stats.last.position - stats.first.position
|
111
|
-
# delta = '' if delta == 0
|
112
|
-
# table << [k.keyword, stats.size, stats.last.position, stats.first.position, stats.last.position, delta] # row
|
113
|
-
# searched = searched + stats.size
|
114
|
-
# end
|
115
|
-
# end
|
116
|
-
|
117
|
-
# if searched == 0
|
118
|
-
# say 'these keywords have not been indexed yet', :red
|
119
|
-
# else
|
120
|
-
# say ''
|
121
|
-
# say account.name + ' has ' + searched.to_s + ' recorded positions for ' + account.keywords.size.to_s + ' keywords', :green
|
122
|
-
# say ''
|
123
|
-
# print_table table
|
124
|
-
# say ''
|
125
|
-
# end
|
126
|
-
# end
|
127
|
-
# end
|
128
|
-
|
129
|
-
# #desc "import", "imports csv file"
|
130
|
-
# #options :file
|
131
|
-
# #def import(file)
|
132
|
-
|
133
|
-
# #end
|
134
|
-
|
135
|
-
# desc "index", "gets keyword position and saves it for later use"
|
136
|
-
# def index(account)
|
137
|
-
# account = Account.search(account)
|
138
|
-
# if account.blank?
|
139
|
-
# say 'no account found', :red
|
140
|
-
# else
|
141
|
-
# table = [['# Keyword', '# Google', '# GoogleUS']] # header
|
142
|
-
# account.keywords.each do |k|
|
143
|
-
# # Google
|
144
|
-
# google = ::Ranking.new(:keyword => k.keyword, :url => account.domain, :limit =>100).from_googleAU
|
145
|
-
# if !google.blank?
|
146
|
-
# KeywordStatistic.new(:keyword_id => k.id, :engine => :google, :position => google).save
|
147
|
-
# say '.', :green, false
|
148
|
-
# else
|
149
|
-
# say '.', :red, false
|
150
|
-
# end
|
151
|
-
|
152
|
-
# # GoogleUS
|
153
|
-
# googleUS = ::Ranking.new(:keyword => k.keyword, :url => account.domain, :limit =>100).from_googleUS
|
154
|
-
# if !googleUS.blank?
|
155
|
-
# KeywordStatistic.new(:keyword_id => k.id, :engine => :googleUS, :position => googleUS).save
|
156
|
-
# say '.', :green, false
|
157
|
-
# else
|
158
|
-
# say '.', :red, false
|
159
|
-
# end
|
160
|
-
|
161
|
-
# # Bing
|
162
|
-
# # bing = ::Ranking.new(:keyword => k.keyword, :url => account.domain, :limit =>100).from_bingAU
|
163
|
-
# # if !bing.blank?
|
164
|
-
# # KeywordStatistic.new(:keyword_id => k.id, :engine => :bing, :position => bing).save
|
165
|
-
# # say '.', :green, false
|
166
|
-
# # else
|
167
|
-
# # say '.', :red, false
|
168
|
-
# # end
|
169
|
-
|
170
|
-
|
171
|
-
# # Yahoo
|
172
|
-
# # yahoo = ::Ranking.new(:keyword => k.keyword, :url => account.domain, :limit =>100).from_yahooAU
|
173
|
-
# # if !yahoo.blank?
|
174
|
-
# # KeywordStatistic.new(:keyword_id => k.id, :engine => :yahoo, :position => yahoo).save
|
175
|
-
# # say '.', :green, false
|
176
|
-
# # else
|
177
|
-
# # say '.', :red, false
|
178
|
-
# # end
|
179
|
-
|
180
|
-
# table << [k.keyword, google, googleUS]
|
181
|
-
# end
|
182
|
-
|
183
|
-
# say ''
|
184
|
-
# print_table table
|
185
|
-
# say ''
|
186
|
-
# end
|
187
|
-
# end
|
188
|
-
|
189
|
-
# desc "export", "export keywords with positions"
|
190
|
-
# option :file
|
191
|
-
# def export(account)
|
192
|
-
# account = Account.search(account)
|
193
|
-
# if account.blank?
|
194
|
-
# say 'no account found', :red
|
195
|
-
# else
|
196
|
-
# table = [['# Date', '# Keyword', '# Position']] # header
|
197
|
-
|
198
|
-
# options[:file] = 'export.csv' unless options.includes? :file
|
199
|
-
# CSV.open(options[:file], 'w') do |csv|
|
200
|
-
# account.keywords.each do |keyword|
|
201
|
-
# keyword.keyword_statistics.each do |stat|
|
202
|
-
# row = [stat.created_at, keyword.keyword, stat.position]
|
203
|
-
# table << row
|
204
|
-
# csv << row
|
205
|
-
# end
|
206
|
-
# end
|
207
|
-
# end
|
208
|
-
|
209
|
-
# say ''
|
210
|
-
# print_table table
|
211
|
-
# say ''
|
212
|
-
# end
|
213
|
-
# end
|
214
|
-
end
|