plus 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ .rvmrc
1
2
  *.gem
2
3
  .bundle
3
4
  Gemfile.lock
@@ -0,0 +1,54 @@
1
+ # Plus
2
+
3
+ A simple gem for using the Google+ API. See documentation here: https://developers.google.com/+/api/
4
+
5
+ ## Pre-requisites
6
+
7
+ You'll need an API key from Google. You can apply from one here: https://code.google.com/apis/console
8
+
9
+ _Note: Plus does not currently support OAuth authentication._
10
+
11
+ ## Usage
12
+
13
+ First, tell Plus about your API key:
14
+
15
+ Plus.options[:api_key] = '12345abcde'
16
+
17
+ Now start getting data. Plus provies the same methods as the API and are named the same, so when
18
+ in doubt just check out the official docs. Each API call simply returns a Ruby hash mirroring the
19
+ JSON sent back from the API. If in doubt as to how to access something just `.inspect` the code
20
+ returned by the call.
21
+
22
+ ### Activities.list
23
+
24
+ Lists recent posts for a given user:
25
+
26
+ result = Plus::Activities.list(12345)
27
+
28
+ Where `12345` is a valid Google+ user id (a very large integer). To get the text of the first
29
+ activity returned from the previous call:
30
+
31
+ result['items'].first['object']['content']
32
+
33
+ ### Activities.get
34
+
35
+ Retrieves data about the given activity:
36
+
37
+ result = Plus::Activities.get('12345abcde')
38
+
39
+ Where `12345abcde` is a big string, the `id` of the activity you care about.
40
+
41
+ ### Activities.search
42
+
43
+ Returns recent activity that matches the given search term:
44
+
45
+ result = Plus::Activities.search('woodworking')
46
+
47
+ ## Future
48
+
49
+ I'm thinking of abstracting the data returned from the API into nice Ruby objects so next time
50
+ you could get the data with a much simpler call (and what feels like method calls rather than
51
+ hash key access):
52
+
53
+ result.items.first.content
54
+
@@ -1,5 +1,17 @@
1
- require "plus/version"
1
+ require 'rubygems'
2
+ require 'httparty'
3
+ require 'plus/activities'
4
+ require 'plus/comments'
5
+ require 'plus/people'
2
6
 
3
7
  module Plus
4
- # Your code goes here...
8
+
9
+ ENDPOINT = 'https://www.googleapis.com/plus/v1/'
10
+
11
+ @options = { :api_key => nil }
12
+
13
+ attr_accessor :options
14
+
15
+ extend self
16
+
5
17
  end
@@ -0,0 +1,38 @@
1
+ module Plus
2
+ class Activities
3
+
4
+ # Retrieves the recent posts for a given user.
5
+ def self.list(user_id, options={})
6
+ endpoint_prefix = 'people'
7
+
8
+ default_options = { :collection => :public, :alt => :json }
9
+ options = default_options.merge(options)
10
+ url = Plus::ENDPOINT + endpoint_prefix + '/' + user_id.to_s + '/activities/' + options.delete(:collection).to_s
11
+
12
+ HTTParty.get(url, :query => options.merge(:key => Plus.options[:api_key]))
13
+ end
14
+
15
+ # Retrieves the detail for a given activity.
16
+ def self.get(activity_id, options={})
17
+ endpoint_prefix = 'activities'
18
+
19
+ default_options = { :alt => :json }
20
+ options = default_options.merge(options)
21
+ url = Plus::ENDPOINT + endpoint_prefix + '/' + activity_id
22
+
23
+ HTTParty.get(url, :query => options.merge(:key => Plus.options[:api_key]))
24
+ end
25
+
26
+ # Searches public activities for the given search term
27
+ def self.search(query, options={})
28
+ endpoint_prefix = 'activities'
29
+
30
+ default_options = { :alt => :json }
31
+ options = default_options.merge(options)
32
+ url = Plus::ENDPOINT + endpoint_prefix
33
+
34
+ HTTParty.get(url, :query => options.merge(:key => Plus.options[:api_key], :query => query))
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,5 @@
1
+ module Plus
2
+ class Comments
3
+
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Plus
2
+ class People
3
+
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Plus
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-08 00:00:00.000000000 Z
12
+ date: 2012-01-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &70135092236640 !ruby/object:Gem::Requirement
16
+ requirement: &70144571398020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70135092236640
24
+ version_requirements: *70144571398020
25
25
  description: This gem provides programmatic access to the Google+ API without making
26
26
  HTTP calls manually.
27
27
  email:
@@ -31,10 +31,15 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
33
  - .gitignore
34
+ - .rvmrc
34
35
  - Gemfile
35
- - README
36
+ - Gemfile.lock
37
+ - README.md
36
38
  - Rakefile
37
39
  - lib/plus.rb
40
+ - lib/plus/activities.rb
41
+ - lib/plus/comments.rb
42
+ - lib/plus/people.rb
38
43
  - lib/plus/version.rb
39
44
  - plus.gemspec
40
45
  homepage: ''
data/README DELETED
File without changes