geostats 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +13 -0
- data/README.md +58 -0
- data/bin/geostats +33 -0
- data/lib/geostats.rb +36 -0
- data/lib/geostats/commands/base.rb +73 -0
- data/lib/geostats/commands/console.rb +17 -0
- data/lib/geostats/commands/generate.rb +21 -0
- data/lib/geostats/commands/help.rb +20 -0
- data/lib/geostats/commands/init.rb +31 -0
- data/lib/geostats/commands/migrate.rb +21 -0
- data/lib/geostats/commands/push.rb +41 -0
- data/lib/geostats/commands/set.rb +35 -0
- data/lib/geostats/commands/update.rb +175 -0
- data/lib/geostats/console.rb +2 -0
- data/lib/geostats/core_ext.rb +5 -0
- data/lib/geostats/database.rb +15 -0
- data/lib/geostats/generator.rb +43 -0
- data/lib/geostats/grabber/cache.rb +95 -0
- data/lib/geostats/grabber/log.rb +27 -0
- data/lib/geostats/grabber/logs.rb +37 -0
- data/lib/geostats/grabber/user.rb +15 -0
- data/lib/geostats/http.rb +97 -0
- data/lib/geostats/migrations/001_create_caches.rb +27 -0
- data/lib/geostats/migrations/002_create_cache_types.rb +16 -0
- data/lib/geostats/migrations/003_create_logs.rb +13 -0
- data/lib/geostats/migrations/004_create_log_types.rb +15 -0
- data/lib/geostats/migrations/005_create_settings.rb +9 -0
- data/lib/geostats/migrations/006_add_cito_cache_type.rb +5 -0
- data/lib/geostats/models/cache.rb +47 -0
- data/lib/geostats/models/cache_type.rb +9 -0
- data/lib/geostats/models/log.rb +33 -0
- data/lib/geostats/models/log_type.rb +9 -0
- data/lib/geostats/models/setting.rb +16 -0
- data/lib/geostats/stats.rb +220 -0
- data/lib/geostats/templates/default.mustache +10 -0
- data/lib/geostats/templates/difficulty_terrain_matrix.mustache +40 -0
- data/lib/geostats/templates/founds_by_cache_type.mustache +17 -0
- data/lib/geostats/templates/milestones.mustache +19 -0
- data/lib/geostats/templates/monthly_founds.mustache +18 -0
- data/lib/geostats/templates/stylesheet.css +160 -0
- data/lib/geostats/utils.rb +42 -0
- data/lib/geostats/version.rb +3 -0
- data/lib/geostats/views/base.rb +19 -0
- data/lib/geostats/views/default.rb +13 -0
- data/lib/geostats/views/difficulty_terrain_matrix.rb +34 -0
- data/lib/geostats/views/founds_by_cache_type.rb +24 -0
- data/lib/geostats/views/milestones.rb +23 -0
- data/lib/geostats/views/monthly_founds.rb +24 -0
- metadata +165 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
module Geostats
|
2
|
+
module Utils
|
3
|
+
SMILIES_URLS = %w(
|
4
|
+
http://www.geocaching.com/images/icons/icon_smile.gif
|
5
|
+
http://www.geocaching.com/images/icons/icon_smile_big.gif
|
6
|
+
http://www.geocaching.com/images/icons/icon_smile_cool.gif
|
7
|
+
http://www.geocaching.com/images/icons/icon_smile_blush.gif
|
8
|
+
http://www.geocaching.com/images/icons/icon_smile_tongue.gif
|
9
|
+
http://www.geocaching.com/images/icons/icon_smile_evil.gif
|
10
|
+
http://www.geocaching.com/images/icons/icon_smile_wink.gif
|
11
|
+
http://www.geocaching.com/images/icons/icon_smile_clown.gif
|
12
|
+
http://www.geocaching.com/images/icons/icon_smile_blackeye.gif
|
13
|
+
http://www.geocaching.com/images/icons/icon_smile_8ball.gif
|
14
|
+
http://www.geocaching.com/images/icons/icon_smile_sad.gif
|
15
|
+
http://www.geocaching.com/images/icons/icon_smile_shy.gif
|
16
|
+
http://www.geocaching.com/images/icons/icon_smile_shock.gif
|
17
|
+
http://www.geocaching.com/images/icons/icon_smile_angry.gif
|
18
|
+
http://www.geocaching.com/images/icons/icon_smile_dead.gif
|
19
|
+
http://www.geocaching.com/images/icons/icon_smile_sleepy.gif
|
20
|
+
http://www.geocaching.com/images/icons/icon_smile_kisses.gif
|
21
|
+
http://www.geocaching.com/images/icons/icon_smile_approve.gif
|
22
|
+
http://www.geocaching.com/images/icons/icon_smile_dissapprove.gif
|
23
|
+
http://www.geocaching.com/images/icons/icon_smile_question.gif
|
24
|
+
)
|
25
|
+
|
26
|
+
SMILIES_TEXT = ["[:)]", "[:D]", "[8D]", "[:I]", "[:P]", "[}:)]", "[;)]",
|
27
|
+
"[:O)]", "[B)]", "[8]", "[:(]", "[8)]", "[:O]", "[:(!]", "[xx(]",
|
28
|
+
"[|)]", "[:*]", "[^]", "[V]", "[?]"]
|
29
|
+
|
30
|
+
def self.unescape(str)
|
31
|
+
CGI.unescapeHTML(str.gsub(/&#(\d{3});/) { [$1.to_i].pack("U") })
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.replace_smilie_img_tags(str)
|
35
|
+
str.gsub(/<img src='(.*?)' border=0 align=middle>/) do |match|
|
36
|
+
if index = SMILIES_URLS.index($1)
|
37
|
+
SMILIES_TEXT[index]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "mustache"
|
2
|
+
|
3
|
+
module Geostats
|
4
|
+
module Views
|
5
|
+
class Base < Mustache
|
6
|
+
self.template_path = File.join(File.dirname(__FILE__), "..", "templates")
|
7
|
+
|
8
|
+
protected
|
9
|
+
|
10
|
+
def url_for_cache(cache)
|
11
|
+
"http://coord.info/#{cache.code}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def url_for_log(log)
|
15
|
+
"http://www.geocaching.com/seek/log.aspx?LUID=#{log.uuid}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Geostats
|
2
|
+
module Views
|
3
|
+
class DifficultyTerrainMatrix < Base
|
4
|
+
STEPS = [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5]
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@matrix = Stats.difficulty_terrain_matrix
|
8
|
+
end
|
9
|
+
|
10
|
+
def matrix
|
11
|
+
difficulties = STEPS.reverse
|
12
|
+
|
13
|
+
@matrix.map do |row|
|
14
|
+
hash = {
|
15
|
+
:difficulty => difficulties.pop,
|
16
|
+
:dsum => row.sum,
|
17
|
+
}
|
18
|
+
|
19
|
+
STEPS.length.times do |i|
|
20
|
+
hash["t#{STEPS[i].to_s.gsub(".", "")}"] = row[i] > 0 ? row[i] : nil
|
21
|
+
end
|
22
|
+
|
23
|
+
hash
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def tsums
|
28
|
+
STEPS.length.times.to_a.map do |i|
|
29
|
+
{ :sum => STEPS.length.times.to_a.map { |j| @matrix[j][i] }.sum }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Geostats
|
2
|
+
module Views
|
3
|
+
class FoundsByCacheType < Base
|
4
|
+
HEIGHT = 400
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@founds = Stats.founds_by_cache_type
|
8
|
+
.select { |a| a[1] > 0 }
|
9
|
+
.sort { |a, b| b[1] <=> a[1] }
|
10
|
+
@factor = HEIGHT.to_f / @founds.first[1].to_f
|
11
|
+
end
|
12
|
+
|
13
|
+
def founds_by_cache_type
|
14
|
+
@founds.map do |type, count|
|
15
|
+
{
|
16
|
+
:height => [1, count * @factor].max,
|
17
|
+
:founds => count,
|
18
|
+
:name => type.name
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Geostats
|
2
|
+
module Views
|
3
|
+
class Milestones < Base
|
4
|
+
def initialize
|
5
|
+
@milestones = Stats.milestones
|
6
|
+
end
|
7
|
+
|
8
|
+
def milestones
|
9
|
+
@milestones.map do |milestone|
|
10
|
+
{
|
11
|
+
:milestone => milestone[:milestone],
|
12
|
+
:name => milestone[:log].cache.name,
|
13
|
+
:type => milestone[:log].cache.cache_type.name,
|
14
|
+
:cache_url => url_for_cache(milestone[:log].cache),
|
15
|
+
:log_url => url_for_log(milestone[:log]),
|
16
|
+
:date => milestone[:log].logged_at.strftime("%F"),
|
17
|
+
:distance => milestone[:distance] ? milestone[:distance].to_i : nil
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Geostats
|
2
|
+
module Views
|
3
|
+
class MonthlyFounds < Base
|
4
|
+
HEIGHT = 140
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@founds = Stats.monthly_founds(12).reverse
|
8
|
+
@max = @founds.map { |a| a[1] }.max
|
9
|
+
@factor = HEIGHT.to_f / @max.to_f
|
10
|
+
end
|
11
|
+
|
12
|
+
def monthly_founds
|
13
|
+
@founds.map do |date, count|
|
14
|
+
{
|
15
|
+
:height => [1, count * @factor].max,
|
16
|
+
:founds => count,
|
17
|
+
:month => date.strftime("%b"),
|
18
|
+
:year => date.strftime("%Y")
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: geostats
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Thomas Cyron
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-05-16 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: activerecord
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 3
|
29
|
+
- 0
|
30
|
+
- 0
|
31
|
+
- beta3
|
32
|
+
version: 3.0.0.beta3
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: css_parser
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 1
|
44
|
+
- 0
|
45
|
+
- 1
|
46
|
+
version: 1.0.1
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: mustache
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
- 11
|
59
|
+
- 0
|
60
|
+
version: 0.11.0
|
61
|
+
type: :runtime
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: hpricot
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
- 8
|
73
|
+
- 2
|
74
|
+
version: 0.8.2
|
75
|
+
type: :runtime
|
76
|
+
version_requirements: *id004
|
77
|
+
description: Tool to generate statistics about your geocaching.com account
|
78
|
+
email: thomas@thcyron.de
|
79
|
+
executables:
|
80
|
+
- geostats
|
81
|
+
extensions: []
|
82
|
+
|
83
|
+
extra_rdoc_files: []
|
84
|
+
|
85
|
+
files:
|
86
|
+
- README.md
|
87
|
+
- LICENSE
|
88
|
+
- lib/geostats/commands/base.rb
|
89
|
+
- lib/geostats/commands/console.rb
|
90
|
+
- lib/geostats/commands/generate.rb
|
91
|
+
- lib/geostats/commands/help.rb
|
92
|
+
- lib/geostats/commands/init.rb
|
93
|
+
- lib/geostats/commands/migrate.rb
|
94
|
+
- lib/geostats/commands/push.rb
|
95
|
+
- lib/geostats/commands/set.rb
|
96
|
+
- lib/geostats/commands/update.rb
|
97
|
+
- lib/geostats/console.rb
|
98
|
+
- lib/geostats/core_ext.rb
|
99
|
+
- lib/geostats/database.rb
|
100
|
+
- lib/geostats/generator.rb
|
101
|
+
- lib/geostats/grabber/cache.rb
|
102
|
+
- lib/geostats/grabber/log.rb
|
103
|
+
- lib/geostats/grabber/logs.rb
|
104
|
+
- lib/geostats/grabber/user.rb
|
105
|
+
- lib/geostats/http.rb
|
106
|
+
- lib/geostats/migrations/001_create_caches.rb
|
107
|
+
- lib/geostats/migrations/002_create_cache_types.rb
|
108
|
+
- lib/geostats/migrations/003_create_logs.rb
|
109
|
+
- lib/geostats/migrations/004_create_log_types.rb
|
110
|
+
- lib/geostats/migrations/005_create_settings.rb
|
111
|
+
- lib/geostats/migrations/006_add_cito_cache_type.rb
|
112
|
+
- lib/geostats/models/cache.rb
|
113
|
+
- lib/geostats/models/cache_type.rb
|
114
|
+
- lib/geostats/models/log.rb
|
115
|
+
- lib/geostats/models/log_type.rb
|
116
|
+
- lib/geostats/models/setting.rb
|
117
|
+
- lib/geostats/stats.rb
|
118
|
+
- lib/geostats/templates/default.mustache
|
119
|
+
- lib/geostats/templates/difficulty_terrain_matrix.mustache
|
120
|
+
- lib/geostats/templates/founds_by_cache_type.mustache
|
121
|
+
- lib/geostats/templates/milestones.mustache
|
122
|
+
- lib/geostats/templates/monthly_founds.mustache
|
123
|
+
- lib/geostats/templates/stylesheet.css
|
124
|
+
- lib/geostats/utils.rb
|
125
|
+
- lib/geostats/version.rb
|
126
|
+
- lib/geostats/views/base.rb
|
127
|
+
- lib/geostats/views/default.rb
|
128
|
+
- lib/geostats/views/difficulty_terrain_matrix.rb
|
129
|
+
- lib/geostats/views/founds_by_cache_type.rb
|
130
|
+
- lib/geostats/views/milestones.rb
|
131
|
+
- lib/geostats/views/monthly_founds.rb
|
132
|
+
- lib/geostats.rb
|
133
|
+
- bin/geostats
|
134
|
+
has_rdoc: true
|
135
|
+
homepage: http://nano.github.com/geostats
|
136
|
+
licenses: []
|
137
|
+
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
segments:
|
148
|
+
- 0
|
149
|
+
version: "0"
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
segments:
|
155
|
+
- 0
|
156
|
+
version: "0"
|
157
|
+
requirements: []
|
158
|
+
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 1.3.6
|
161
|
+
signing_key:
|
162
|
+
specification_version: 3
|
163
|
+
summary: Geocaching.com statistics generation
|
164
|
+
test_files: []
|
165
|
+
|