logworm 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ v0.7.4
2
+ Eliminated default host for database. Must be specified in the configuration environment.
3
+
1
4
  v0.7.3
2
5
  Cleaner way to compose the URL for the DB (now logworm://key:secret@host/token/token_secret/)
3
6
 
data/Manifest CHANGED
@@ -6,4 +6,5 @@ lib/base/config.rb
6
6
  lib/base/db.rb
7
7
  lib/base/query_builder.rb
8
8
  lib/logworm.rb
9
+ spec/base_spec.rb
9
10
  tests/builder_test.rb
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'echoe'
2
- Echoe.new('logworm', '0.7.3') do |p|
2
+ Echoe.new('logworm', '0.7.4') do |p|
3
3
  p.description = "logworm logging tool"
4
4
  p.url = "http://www.logworm.com"
5
5
  p.author = "Pomelo, LLC"
data/lib/base/db.rb CHANGED
@@ -8,24 +8,23 @@ module Logworm
8
8
 
9
9
  class DB
10
10
 
11
- DEFAULT_HOST = "db.logworm.com"
12
11
  URL_FORMAT = /logworm:\/\/([^:]+):([^@]+)@([^\/]+)\/([^\/]+)\/([^\/]+)\//
13
12
  # URI: logworm://<consumer_key>:<consumer_secret>@db.logworm.com/<access_token>/<access_token_secret>/
13
+
14
+ attr_reader :host, :consumer_key, :consumer_secret, :token, :token_secret
14
15
 
15
16
  def initialize(url)
16
17
  match = DB.parse_url(url)
17
- raise ForbiddenAccessException.new("Incorrect URL Format #{url}") unless match and match.size == 6
18
-
18
+ raise ForbiddenAccessException.new("Incorrect URL Format #{url}") unless match and match.size == 6
19
19
  @consumer_key, @consumer_secret, @host, @token, @token_secret = match[1..5]
20
- raise ForbiddenAccessException.new("Missing consumer keys") if @consumer_key.nil? or @consumer_secret.nil?
21
- raise ForbiddenAccessException.new("Missing tokens") if @token.nil? or @token_secret.nil?
22
20
  @connection = OAuth::AccessToken.new(OAuth::Consumer.new(@consumer_key, @consumer_secret), @token, @token_secret)
23
21
  end
24
22
 
25
23
  def self.with_tokens(token, token_secret)
26
24
  consumer_key = ENV["#{ENV['APP_ID']}_APPS_KEY"]
27
25
  consumer_secret = ENV["#{ENV['APP_ID']}_APPS_SECRET"]
28
- DB.new(DB.url(consumer_key, consumer_secret, token, token_secret))
26
+ host = ENV["#{ENV['APP_ID']}_DB_HOST"]
27
+ DB.new(DB.make_url(host, consumer_key, consumer_secret, token, token_secret))
29
28
  end
30
29
 
31
30
  def self.from_config
@@ -50,16 +49,16 @@ module Logworm
50
49
  db
51
50
  end
52
51
 
53
- def self.url(consumer_key, consumer_secret, token, token_secret, host = DEFAULT_HOST)
52
+ def self.make_url(host, consumer_key, consumer_secret, token, token_secret)
54
53
  "logworm://#{consumer_key}:#{consumer_secret}@#{host}/#{token}/#{token_secret}/"
55
54
  end
56
55
 
57
56
  def url()
58
- DB.url(@consumer_key, @consumer_secret, @token, @token_secret, @host)
57
+ DB.make_url(@host, @consumer_key, @consumer_secret, @token, @token_secret)
59
58
  end
60
59
 
61
60
  def self.example_url
62
- self.url("Ub5sOstT9w", "GZi0HciTVcoFHEoIZ7", "OzO71hEvWYDmncbf3C", "J7wq4X06MihhZgqDeB")
61
+ self.make_url("db.logworm.com", "Ub5sOstT9w", "GZi0HciTVcoFHEoIZ7", "OzO71hEvWYDmncbf3C", "J7wq4X06MihhZgqDeB")
63
62
  end
64
63
 
65
64
  def tables()
data/logworm.gemspec CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{logworm}
5
- s.version = "0.7.3"
5
+ s.version = "0.7.4"
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-04-01}
9
+ s.date = %q{2010-04-06}
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"]
13
- s.files = ["CHANGELOG", "Manifest", "README", "Rakefile", "lib/base/config.rb", "lib/base/db.rb", "lib/base/query_builder.rb", "lib/logworm.rb", "tests/builder_test.rb", "logworm.gemspec"]
13
+ s.files = ["CHANGELOG", "Manifest", "README", "Rakefile", "lib/base/config.rb", "lib/base/db.rb", "lib/base/query_builder.rb", "lib/logworm.rb", "spec/base_spec.rb", "tests/builder_test.rb", "logworm.gemspec"]
14
14
  s.homepage = %q{http://www.logworm.com}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Logworm", "--main", "README"]
16
16
  s.require_paths = ["lib"]
data/spec/base_spec.rb ADDED
@@ -0,0 +1,52 @@
1
+ $: << File.dirname(__FILE__) + '/../lib'
2
+ require 'logworm.rb'
3
+
4
+ describe Logworm::DB, " initialization" do
5
+ it "should only accept proper URLs" do
6
+ lambda {Logworm::DB.new('')}.should raise_exception(Logworm::ForbiddenAccessException)
7
+ lambda {Logworm::DB.new('http://www.test.com')}.should raise_exception(Logworm::ForbiddenAccessException)
8
+ lambda {Logworm::DB.new('logworm://a:b@xxx/c/d')}.should raise_exception(Logworm::ForbiddenAccessException)
9
+ lambda {Logworm::DB.new('logworm://a:b@/c/d/')}.should raise_exception(Logworm::ForbiddenAccessException)
10
+ lambda {Logworm::DB.new('logworm://a:b@sda//d/')}.should raise_exception(Logworm::ForbiddenAccessException)
11
+ lambda {Logworm::DB.new('logworm://:b@sda//d/')}.should raise_exception(Logworm::ForbiddenAccessException)
12
+ lambda {Logworm::DB.new('logworm://a:b@xxx/c/d/')}.should_not raise_exception(Logworm::ForbiddenAccessException)
13
+ end
14
+
15
+ it "should be able to parse a proper logworm URL" do
16
+ db = Logworm::DB.new('logworm://a:b@localhost:9401/c/d/')
17
+ db.host.should == "localhost:9401"
18
+ db.consumer_key.should == "a"
19
+ db.consumer_secret.should == "b"
20
+ db.token.should == "c"
21
+ db.token_secret.should == "d"
22
+ end
23
+
24
+ it "should be able to read its configuration from a file"
25
+ it "should be able to read its configuration from the current Heroku application"
26
+
27
+ end
28
+
29
+ describe Logworm::DB, " functioning" do
30
+
31
+ before(:all) do
32
+ @db = Logworm::DB.new('logworm://a:b@localhost:9401/c/d/')
33
+ end
34
+
35
+ it "should support a call to get the list of tables" do
36
+ @db.should have(0).tables
37
+ log_details = {:value => 10, :_ts => Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ"), :_ts_utc => (Time.now.utc.to_f * 1000).to_i}
38
+ @db.batch_log([["log", log_details]])
39
+ @db.should have(1).tables
40
+ end
41
+
42
+ it "should support a call to start a query"
43
+
44
+ it "should support a call to get the results of a query"
45
+
46
+ it "should raise DFGD if 404"
47
+
48
+ it "should raise DFGD if 403"
49
+
50
+ it "should raise DFGD if 400"
51
+
52
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 3
9
- version: 0.7.3
8
+ - 4
9
+ version: 0.7.4
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-04-01 00:00:00 -04:00
17
+ date: 2010-04-06 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -135,6 +135,7 @@ files:
135
135
  - lib/base/db.rb
136
136
  - lib/base/query_builder.rb
137
137
  - lib/logworm.rb
138
+ - spec/base_spec.rb
138
139
  - tests/builder_test.rb
139
140
  - logworm.gemspec
140
141
  has_rdoc: true