googleplus-reader 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b7bafbe0f5e029e2ce170e6e02cbf191f1fa6f8
4
- data.tar.gz: dd06beb0865017d290f282bd1b40d64dccf5434b
3
+ metadata.gz: 50eeb4fc675c4ede7d46f9e480745bc1913da460
4
+ data.tar.gz: e401e69d7dc5e650dc0de14b2ca9f179389843f4
5
5
  SHA512:
6
- metadata.gz: 140d495bec389d85b61e3e0d25c200cca3a2360eaa9ea6122cb9ea9dbe6a7bfc050733467a4269886dd6376eaaf048e4ad937a818d1fc3d38b056c62084b643b
7
- data.tar.gz: 1e2c0028b36dd6ef4563dc5aa577dfa798ccb2ef003146adbf9a1549032a55923c1ed84239bbb8c8d41c8f099e597c614f422bf9b950856b485447971f2e2217
6
+ metadata.gz: f95cfea62a921aed6e9c7d4e5ae4711ec36d12428c27657b78f90c6e03df82ea5dbf614080f3b4157c9f3e1624ef1a12de0ad6106864f7815e186788d6a8dda3
7
+ data.tar.gz: 1d93e2ed023f68e28a235771d394afbb25487de0e0445f44412c5ce78e170dc0177fefdb8bce29009d697f8699d7ba9c54b105c4f45c708183cd3e3351d54272
data/README.md CHANGED
@@ -1,13 +1,16 @@
1
- # GooglePlus Reader
1
+ # GooglePlus Reader [![Gem Version](https://badge.fury.io/rb/googleplus-reader.svg)](http://badge.fury.io/rb/googleplus-reader)
2
2
 
3
- A [jQuery](http://jquery.com)-based library for reading public posts
4
- of a [Google+](https://plus.google.com) user. An example can be found
5
- [here](http://ivanukhov.com). Best enjoyed responsibly.
3
+ A [jQuery](http://jquery.com)-based library for reading public posts of a
4
+ [Google+](https://plus.google.com) user. A life demo can be found
5
+ [here](http://ivanukhov.com) and its source code
6
+ [here](https://github.com/IvanUkhov/photography). Best enjoyed responsibly.
6
7
 
7
8
  ## Installation
8
9
 
9
- $ echo "gem 'googleplus-reader'" >> Gemfile
10
- $ bundle install
10
+ ```bash
11
+ $ echo "gem 'googleplus-reader'" >> Gemfile
12
+ $ bundle install
13
+ ```
11
14
 
12
15
  The code is written in [CoffeeScript](http://coffeescript.org); however,
13
16
  any dependencies in this regard are purposely omitted. So make sure you
@@ -18,17 +21,21 @@ have CoffeeScript installed.
18
21
  Here is an example in the context of a [Rails](http://rubyonrails.org)
19
22
  application. First, we need CoffeeScript as it was noted earlier:
20
23
 
21
- $ echo "gem 'coffee-rails'" >> Gemfile
22
- $ bundle install
24
+ ```bash
25
+ $ echo "gem 'coffee-rails'" >> Gemfile
26
+ $ bundle install
27
+ ```
23
28
 
24
29
  In your `app/views/layouts/application.html.haml`:
25
- ``` rails
30
+
31
+ ```haml
26
32
  = javascript_include_tag '//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js'
27
33
  = javascript_include_tag :application
28
34
  ```
29
35
 
30
36
  In your `app/assets/javascripts/application.js.coffee`:
31
- ``` coffee
37
+
38
+ ```coffee
32
39
  //= require googleplus.reader
33
40
 
34
41
  reader = new GooglePlus.Reader \
@@ -37,6 +44,7 @@ reader = new GooglePlus.Reader \
37
44
  reader.next 5, (posts) ->
38
45
  console.log post for post in posts
39
46
  ```
47
+
40
48
  Here `user_id` is the identifier of a Google+ user, and `api_key` is your
41
49
  [Google+ API key](https://developers.google.com/+/api/oauth).
42
50
  `post` is exactly what Google has to say about each post without any
@@ -44,7 +52,8 @@ additional preprocessing. You might want to inspect it and fetch what is
44
52
  needed for your application.
45
53
 
46
54
  A more interesting example with photos that a user publishes:
47
- ``` coffee
55
+
56
+ ```coffee
48
57
  //= require googleplus.photoreader
49
58
 
50
59
  reader = new GooglePlus.PhotoReader \
@@ -53,11 +62,13 @@ reader = new GooglePlus.PhotoReader \
53
62
  reader.next 5, (photos) ->
54
63
  console.log photo.attributes for photo in photos
55
64
  ```
65
+
56
66
  `photo` is an instance of `GooglePlus.Photo`. Right now, `attributes`
57
67
  contain only `url`, `date`, and `width` (if available), but other parameters
58
68
  can be easily added via a pull request >:)~ The only method that `photo`
59
69
  has is `load`, which can be used as follows:
60
- ``` coffee
70
+
71
+ ```coffee
61
72
  photo.load {}, (element) ->
62
73
  $('#original').append element
63
74
 
@@ -71,15 +82,17 @@ element = photo.load width: 2000
71
82
  console.log element.attr('href')
72
83
  $('#huge').append element
73
84
  ```
85
+
74
86
  `load` constructs an URL referencing the photo of the desired size and
75
87
  preloads it using an `img` element, which it returns right away and also
76
88
  passes to the callback function once the photo has been loaded.
77
89
 
78
-
79
90
  ## Contributing
80
91
 
81
- 1. Fork it (https://github.com/IvanUkhov/googleplus-reader/fork)
82
- 2. Create your feature branch (`git checkout -b my-new-feature`)
83
- 3. Commit your changes (`git commit -am 'Add some feature'`)
84
- 4. Push to the branch (`git push origin my-new-feature`)
85
- 5. Create a new Pull Request
92
+ 1. [Fork](https://help.github.com/articles/fork-a-repo) the project.
93
+ 2. Create a branch for your feature (`git checkout -b awesome-feature`).
94
+ 3. Implement your feature (`vim`).
95
+ 4. Commit your changes (`git commit -am 'Implemented an awesome feature'`).
96
+ 5. Push to the branch (`git push origin awesome-feature`).
97
+ 6. [Create](https://help.github.com/articles/creating-a-pull-request)
98
+ a new Pull Request.
data/Rakefile CHANGED
@@ -1 +1,5 @@
1
1
  require 'bundler/gem_tasks'
2
+
3
+ task :default do
4
+ # nothing
5
+ end
@@ -20,9 +20,10 @@ class Photo
20
20
 
21
21
  element = $('<img/>')
22
22
 
23
- element.on 'load', ->
24
- element.off 'load'
25
- callback element if callback?
23
+ if callback?
24
+ element.on 'load', ->
25
+ element.off 'load'
26
+ callback element
26
27
 
27
28
  element.attr src: url
28
29
 
@@ -7,8 +7,7 @@ class PhotoReader extends GooglePlus.Reader
7
7
  continue unless item.verb?
8
8
  continue unless item.verb is 'post'
9
9
 
10
- date = null
11
- date = new Date item.published if item.published?
10
+ date = if item.published? then new Date(item.published) else null
12
11
 
13
12
  continue unless item.object?
14
13
 
@@ -18,6 +18,7 @@ class Reader
18
18
  nextPosition = Math.min nextPosition, @collection.length
19
19
  callback @collection.slice(@position, nextPosition) if callback?
20
20
  @position = nextPosition
21
+ return
21
22
 
22
23
  return
23
24
 
@@ -29,9 +30,13 @@ class Reader
29
30
  @append result.items
30
31
  @token = result.nextPageToken
31
32
  callback() if callback?
33
+ return
34
+
35
+ return
32
36
 
33
37
  append: (items) ->
34
38
  @collection.push item for item in items
39
+ return
35
40
 
36
41
  window.GooglePlus ||= {}
37
42
  window.GooglePlus.Reader = Reader
@@ -1,5 +1,5 @@
1
1
  module GooglePlus
2
2
  module Reader
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googleplus-reader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Ukhov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-10 00:00:00.000000000 Z
11
+ date: 2014-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  version: '0'
77
77
  requirements: []
78
78
  rubyforge_project:
79
- rubygems_version: 2.2.0
79
+ rubygems_version: 2.2.2
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: A jQuery-based library for reading public posts of a Google+ user