logworm 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/Rakefile +3 -3
- data/lib/base/config.rb +12 -5
- data/lib/base/db.rb +46 -24
- data/logworm.gemspec +8 -2
- metadata +32 -8
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'echoe'
|
2
|
-
Echoe.new('logworm', '0.
|
2
|
+
Echoe.new('logworm', '0.7.0') do |p|
|
3
3
|
p.description = "logworm logging tool"
|
4
4
|
p.url = "http://www.logworm.com"
|
5
5
|
p.author = "Pomelo, LLC"
|
6
6
|
p.email = "schapira@pomelollc.com"
|
7
7
|
p.ignore_pattern = ["tmp/*", "script/*"]
|
8
|
-
p.development_dependencies = ["memcache-client", "hpricot", "oauth"]
|
9
|
-
p.runtime_dependencies = ["memcache-client", "hpricot", "oauth"]
|
8
|
+
p.development_dependencies = ["memcache-client", "hpricot", "oauth", "heroku"]
|
9
|
+
p.runtime_dependencies = ["memcache-client", "hpricot", "oauth", "heroku"]
|
10
10
|
end
|
data/lib/base/config.rb
CHANGED
@@ -11,21 +11,28 @@ module Logworm
|
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
@file_found = false
|
14
|
-
@
|
14
|
+
@url = nil
|
15
15
|
begin
|
16
16
|
f = File.new(FILENAME, 'r')
|
17
|
-
@
|
17
|
+
@url = f.readline.strip
|
18
18
|
@file_found = true
|
19
19
|
rescue Errno::ENOENT => e
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
|
23
|
+
def url
|
24
|
+
@url
|
25
25
|
end
|
26
26
|
|
27
27
|
def file_found?
|
28
|
-
@file_found and @
|
28
|
+
@file_found and @url
|
29
|
+
end
|
30
|
+
|
31
|
+
def save(url)
|
32
|
+
File.open(FILENAME, 'w') do |f|
|
33
|
+
f.puts url
|
34
|
+
end rescue Exception
|
35
|
+
%x[echo '.logworm' >> .gitignore]
|
29
36
|
end
|
30
37
|
|
31
38
|
end
|
data/lib/base/db.rb
CHANGED
@@ -8,36 +8,53 @@ module Logworm
|
|
8
8
|
|
9
9
|
class DB
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
raise "Could not find .logworm file in current directory." if keys.is_a? FalseClass
|
26
|
-
@consumer_key, @consumer_secret = [ENV['LW_CONSUMER_KEY'], ENV['LW_CONSUMER_SECRET']]
|
27
|
-
@token, @token_secret = [ENV['LW_PROJECT_KEY'], ENV['LW_PROJECT_SECRET']]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
raise ForbiddenAccessException.new("Missing keys") if @consumer_key.nil? or @consumer_secret.nil?
|
31
|
-
raise ForbiddenAccessException.new("Missing keys") if @token.nil? or @token_secret.nil?
|
11
|
+
DEFAULT_HOST = "db.logworm.com"
|
12
|
+
URL_FORMAT = /lw:\/\/([^:]+):([^!]+)!([^:]+):([^@]+)@([^\/]+)\//
|
13
|
+
# URI: lw://<consumer_key>:<consumer_secret>!<access_token>:<access_token_secret>@db.logworm.com/
|
14
|
+
|
15
|
+
|
16
|
+
def initialize(url)
|
17
|
+
match = DB.parse_url(url)
|
18
|
+
raise ForbiddenAccessException.new("Incorrect URL Format #{url}") unless match and match.size == 6
|
19
|
+
|
20
|
+
keys = match[1..4]
|
21
|
+
raise ForbiddenAccessException.new("Incorrect Keys") unless keys.is_a? Array and keys.size == 4
|
22
|
+
@consumer_key, @consumer_secret, @token, @token_secret = keys
|
23
|
+
raise ForbiddenAccessException.new("Missing consumer keys") if @consumer_key.nil? or @consumer_secret.nil?
|
24
|
+
raise ForbiddenAccessException.new("Missing tokens") if @token.nil? or @token_secret.nil?
|
32
25
|
@connection = OAuth::AccessToken.new(OAuth::Consumer.new(@consumer_key, @consumer_secret), @token, @token_secret)
|
26
|
+
|
27
|
+
@host = "http://" + match[5]
|
33
28
|
end
|
34
29
|
|
30
|
+
def self.with_tokens(token, token_secret)
|
31
|
+
consumer_key = ENV["#{ENV['APP_ID']}_APPS_KEY"]
|
32
|
+
consumer_secret = ENV["#{ENV['APP_ID']}_APPS_SECRET"]
|
33
|
+
DB.new("lw://#{consumer_key}:#{consumer_secret}!#{token}:#{token_secret}@#{DEFAULT_HOST}/")
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.from_config
|
37
|
+
# Try with URL from the environment
|
38
|
+
return DB.new(ENV['LOGWORM_URL']) if ENV['LOGWORM_URL'] and DB.parse_url(ENV['LOGWORM_URL'])
|
39
|
+
|
40
|
+
# Try with configuration file
|
41
|
+
config = Logworm::Config.instance
|
42
|
+
return DB.new(config.url) if config.file_found? and DB.parse_url(config.url)
|
43
|
+
|
44
|
+
# Try with Heroku configuration otherwise
|
45
|
+
config_vars = %x[heroku config --long] || ""
|
46
|
+
m = config_vars.match(Regexp.new("LOGWORM_URL\\s+=>\\s+([^\\n]+)"))
|
47
|
+
config.save(m[1]) and return DB.new(m[1]) if m and DB.parse_url(m[1])
|
48
|
+
|
49
|
+
nil
|
50
|
+
end
|
51
|
+
|
35
52
|
def tables()
|
36
|
-
res = db_call(:get, "#{
|
53
|
+
res = db_call(:get, "#{@host}/")
|
37
54
|
end
|
38
55
|
|
39
56
|
def query(table, cond)
|
40
|
-
res = db_call(:post, "#{
|
57
|
+
res = db_call(:post, "#{@host}/queries", {:table => table, :query => cond})
|
41
58
|
end
|
42
59
|
|
43
60
|
def results(uri)
|
@@ -48,7 +65,7 @@ module Logworm
|
|
48
65
|
end
|
49
66
|
|
50
67
|
def batch_log(entries)
|
51
|
-
db_call(:post, "#{
|
68
|
+
db_call(:post, "#{@host}/log", {:entries => $lr_queue.to_json})
|
52
69
|
end
|
53
70
|
|
54
71
|
private
|
@@ -68,6 +85,11 @@ module Logworm
|
|
68
85
|
raise DatabaseException.new("Database reponse cannot be parsed: #{e}")
|
69
86
|
end
|
70
87
|
end
|
88
|
+
|
89
|
+
def self.parse_url(url)
|
90
|
+
url.match(URL_FORMAT)
|
91
|
+
end
|
92
|
+
|
71
93
|
end
|
72
94
|
|
73
95
|
end
|
data/logworm.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{logworm}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.7.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Pomelo, LLC"]
|
9
|
-
s.date = %q{2010-03-
|
9
|
+
s.date = %q{2010-03-31}
|
10
10
|
s.description = %q{logworm logging tool}
|
11
11
|
s.email = %q{schapira@pomelollc.com}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "README", "lib/base/config.rb", "lib/base/db.rb", "lib/base/query_builder.rb", "lib/logworm.rb"]
|
@@ -26,23 +26,29 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_runtime_dependency(%q<memcache-client>, [">= 0"])
|
27
27
|
s.add_runtime_dependency(%q<hpricot>, [">= 0"])
|
28
28
|
s.add_runtime_dependency(%q<oauth>, [">= 0"])
|
29
|
+
s.add_runtime_dependency(%q<heroku>, [">= 0"])
|
29
30
|
s.add_development_dependency(%q<memcache-client>, [">= 0"])
|
30
31
|
s.add_development_dependency(%q<hpricot>, [">= 0"])
|
31
32
|
s.add_development_dependency(%q<oauth>, [">= 0"])
|
33
|
+
s.add_development_dependency(%q<heroku>, [">= 0"])
|
32
34
|
else
|
33
35
|
s.add_dependency(%q<memcache-client>, [">= 0"])
|
34
36
|
s.add_dependency(%q<hpricot>, [">= 0"])
|
35
37
|
s.add_dependency(%q<oauth>, [">= 0"])
|
38
|
+
s.add_dependency(%q<heroku>, [">= 0"])
|
36
39
|
s.add_dependency(%q<memcache-client>, [">= 0"])
|
37
40
|
s.add_dependency(%q<hpricot>, [">= 0"])
|
38
41
|
s.add_dependency(%q<oauth>, [">= 0"])
|
42
|
+
s.add_dependency(%q<heroku>, [">= 0"])
|
39
43
|
end
|
40
44
|
else
|
41
45
|
s.add_dependency(%q<memcache-client>, [">= 0"])
|
42
46
|
s.add_dependency(%q<hpricot>, [">= 0"])
|
43
47
|
s.add_dependency(%q<oauth>, [">= 0"])
|
48
|
+
s.add_dependency(%q<heroku>, [">= 0"])
|
44
49
|
s.add_dependency(%q<memcache-client>, [">= 0"])
|
45
50
|
s.add_dependency(%q<hpricot>, [">= 0"])
|
46
51
|
s.add_dependency(%q<oauth>, [">= 0"])
|
52
|
+
s.add_dependency(%q<heroku>, [">= 0"])
|
47
53
|
end
|
48
54
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 7
|
8
|
+
- 0
|
9
|
+
version: 0.7.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Pomelo, LLC
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-31 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
type: :runtime
|
55
55
|
version_requirements: *id003
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: heroku
|
58
58
|
prerelease: false
|
59
59
|
requirement: &id004 !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
@@ -63,10 +63,10 @@ dependencies:
|
|
63
63
|
segments:
|
64
64
|
- 0
|
65
65
|
version: "0"
|
66
|
-
type: :
|
66
|
+
type: :runtime
|
67
67
|
version_requirements: *id004
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
|
-
name:
|
69
|
+
name: memcache-client
|
70
70
|
prerelease: false
|
71
71
|
requirement: &id005 !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
@@ -78,7 +78,7 @@ dependencies:
|
|
78
78
|
type: :development
|
79
79
|
version_requirements: *id005
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
|
-
name:
|
81
|
+
name: hpricot
|
82
82
|
prerelease: false
|
83
83
|
requirement: &id006 !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
@@ -89,6 +89,30 @@ dependencies:
|
|
89
89
|
version: "0"
|
90
90
|
type: :development
|
91
91
|
version_requirements: *id006
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
name: oauth
|
94
|
+
prerelease: false
|
95
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
102
|
+
type: :development
|
103
|
+
version_requirements: *id007
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: heroku
|
106
|
+
prerelease: false
|
107
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
version: "0"
|
114
|
+
type: :development
|
115
|
+
version_requirements: *id008
|
92
116
|
description: logworm logging tool
|
93
117
|
email: schapira@pomelollc.com
|
94
118
|
executables: []
|