keen 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source "https://rubygems.org"
2
2
 
3
3
  group :development, :test do
4
4
  gem 'rake'
5
- gem 'rspec'
5
+ gem 'rspec', '~>2'
6
6
  gem 'em-http-request'
7
7
  gem 'em-synchrony', :require => false
8
8
  gem 'webmock'
data/README.md CHANGED
@@ -297,8 +297,11 @@ EventMachine itself won't do this because it runs in a different thread. Here's
297
297
 
298
298
  ### Changelog
299
299
 
300
+ ##### 0.8.4
301
+ + Add support for getting [project details](https://keen.io/docs/api/reference/#project-row-resource)
302
+
300
303
  ##### 0.8.3
301
- + Add support for getting a list of a projects collections
304
+ + Add support for getting a list of a [project's collections](https://keen.io/docs/api/reference/#event-resource)
302
305
 
303
306
  ##### 0.8.2
304
307
  + Add support for `median` and `percentile` analysis
@@ -48,7 +48,8 @@ module Keen
48
48
 
49
49
  def_delegators :default_client,
50
50
  :delete,
51
- :event_collections
51
+ :event_collections,
52
+ :project_info
52
53
 
53
54
  attr_writer :logger
54
55
 
@@ -27,7 +27,7 @@ module Keen
27
27
  process_response(response.code, response_body)
28
28
  end
29
29
 
30
- # Runs an events query.
30
+ # Return list of collections for the configured project
31
31
  # See detailed documentation here:
32
32
  # https://keen.io/docs/api/reference/#event-resource
33
33
  def event_collections
@@ -46,6 +46,25 @@ module Keen
46
46
  process_response(response.code, response_body)
47
47
  end
48
48
 
49
+ # Return details for the current project
50
+ # See detailed documentation here:
51
+ # https://keen.io/docs/api/reference/#project-resource
52
+ def project_info
53
+ ensure_project_id!
54
+ ensure_master_key!
55
+
56
+ begin
57
+ response = Keen::HTTP::Sync.new(self.api_url, self.proxy_url).get(
58
+ :path => "/#{api_version}/projects/#{project_id}",
59
+ :headers => api_headers(self.master_key, "sync"))
60
+ rescue Exception => http_error
61
+ raise HttpError.new("Couldn't perform project info on Keen IO: #{http_error.message}", http_error)
62
+ end
63
+
64
+ response_body = response.body ? response.body.chomp : ''
65
+ process_response(response.code, response_body)
66
+ end
67
+
49
68
  end
50
69
  end
51
70
  end
@@ -1,3 +1,3 @@
1
1
  module Keen
2
- VERSION = "0.8.3"
2
+ VERSION = "0.8.4"
3
3
  end
@@ -266,4 +266,21 @@ describe "Keen IO API" do
266
266
  results.first["delete"].should == "you"
267
267
  end
268
268
  end
269
+
270
+ describe "project methods" do
271
+ describe "event_collection" do
272
+ # requires a project with at least 1 collection
273
+ it "should return the project's collections as JSON" do
274
+ first_collection = Keen.event_collections.first
275
+ first_collection["properties"]["keen.timestamp"].should == "datetime"
276
+ end
277
+ end
278
+
279
+ describe "project_info" do
280
+ it "should return the project info as JSON" do
281
+ Keen.project_info["url"].should =~ Regexp.new(project_id)
282
+
283
+ end
284
+ end
285
+ end
269
286
  end
@@ -39,10 +39,20 @@ describe Keen::Client do
39
39
  describe '#event_collections' do
40
40
  let(:events_url) { "#{api_url}/#{api_version}/projects/#{project_id}/events" }
41
41
 
42
- it "should not require params" do
42
+ it "should fetch the project's event resource" do
43
43
  stub_keen_get(events_url, 200, [{ "a" => 1 }, { "b" => 2 }] )
44
44
  client.event_collections.should == [{ "a" => 1 }, { "b" => 2 }]
45
45
  expect_keen_get(events_url, "sync", master_key)
46
46
  end
47
47
  end
48
+
49
+ describe '#event_collections' do
50
+ let(:project_url) { "#{api_url}/#{api_version}/projects/#{project_id}" }
51
+
52
+ it "should fetch the project resource" do
53
+ stub_keen_get(project_url, 200, [{ "a" => 1 }, { "b" => 2 }] )
54
+ client.project_info.should == [{ "a" => 1 }, { "b" => 2 }]
55
+ expect_keen_get(project_url, "sync", master_key)
56
+ end
57
+ end
48
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.8.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-06-28 00:00:00.000000000 Z
14
+ date: 2014-07-03 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: multi_json