googleplus-reader 0.0.4 → 0.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e6464b486318c333d4c7cc2d89cf54473eef50e
4
- data.tar.gz: 0cbc58dfa6382b1f909deefbba0451472f1745b4
3
+ metadata.gz: 7be44f0159805b65d7933c87b18f492cf3def380
4
+ data.tar.gz: 858d27889d93276aff2dbb0261e5fb61ba8fee17
5
5
  SHA512:
6
- metadata.gz: 4d852aacdb87788bb02ef12b4f6d2ce3dc7f4bdfc86ffdd6d6d96f87f8021e5a7f681f59124134f0c5c1bd414eeffca1e88916c9c69e661e142319fb9a7274b8
7
- data.tar.gz: ef4541183a576fc8e48755b5f76eb54bf2bcaa6c40b1d529daf8a29e75f3beb6c648cbd728534e84c7457ba5d1bc018c48bdf7e2d36cc30c372d3bb015917484
6
+ metadata.gz: 7de3bce12c30b1694edfa0687cbfde4e85ac227a2ddb0374ecff6a2dcfc1936053b8f07e264e8ecc1168946b1edb6989f725d8a33058011856d074a3b3ae6449
7
+ data.tar.gz: 206f17d40101ee0f35bf813ce05fe12ef5108095d42721a69c3a9ebf3eeb2fc973937d6ce086f412413d8ef510e9302f09a423c3ba272afcf900269a706e757a
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
+ ## GooglePlus Reader 0.0.5 (August 4, 2014)
2
+
3
+ * Added support for [RequireJS](http://requirejs.org/).
4
+
1
5
  ## GooglePlus Reader 0.0.4 (August 2, 2014)
2
6
 
3
- * Changed the API to rely on deferreds instead of callbacks.
7
+ * Changed the API to rely on promises instead of callbacks.
4
8
 
5
9
  ## GooglePlus Reader 0.0.3 (August 1, 2014)
6
10
 
@@ -8,7 +12,7 @@
8
12
 
9
13
  ## GooglePlus Reader 0.0.2 (July 15, 2014)
10
14
 
11
- * Adjusted README to make YARD happy.
15
+ * Adjusted README to make [YARD](http://yardoc.org/) happy.
12
16
 
13
17
  ## GooglePlus Reader 0.0.1 (May 10, 2014)
14
18
 
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
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 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.
3
+ A library for reading public posts of a [Google+](https://plus.google.com)
4
+ user. A life demo can be found [here](http://photography.ivanukhov.com) and
5
+ its source code [here](https://github.com/IvanUkhov/photography). Best enjoyed
6
+ responsibly.
7
7
 
8
8
  ## Installation
9
9
 
@@ -13,9 +13,15 @@ In `Gemfile`:
13
13
  gem 'googleplus-reader'
14
14
  ```
15
15
 
16
- The code is written in [CoffeeScript](http://coffeescript.org); however,
17
- any dependencies in this regard are purposely omitted. So make sure you
18
- have CoffeeScript installed.
16
+ In terminal:
17
+
18
+ ```bash
19
+ $ bundle
20
+ ```
21
+
22
+ The code is written in [CoffeeScript](http://coffeescript.org) and relies on
23
+ [jQuery](http://jquery.com); however, all dependencies in this regard are
24
+ purposely omitted. So make sure you have a proper setup (see below).
19
25
 
20
26
  ## Usage
21
27
 
@@ -28,6 +34,12 @@ In `Gemfile`:
28
34
  gem 'coffee-rails'
29
35
  ```
30
36
 
37
+ In terminal:
38
+
39
+ ```bash
40
+ $ bundle
41
+ ```
42
+
31
43
  In `app/views/layouts/application.html.haml`:
32
44
 
33
45
  ```haml
@@ -55,6 +67,8 @@ needed for your application.
55
67
  A more interesting example with photos that a user publishes:
56
68
 
57
69
  ```coffee
70
+ //= require googleplus.photo
71
+ //= require googleplus.reader
58
72
  //= require googleplus.photoreader
59
73
 
60
74
  reader = new GooglePlus.PhotoReader(id: 'user_id', key: 'api_key')
@@ -1,40 +1,42 @@
1
- class Photo
2
- constructor: (@attributes) ->
3
- @$ = jQuery
1
+ unless typeof define is 'function' and define.amd
2
+ module = @GooglePlus ||= {}
3
+ @define = (name, deps, callback) ->
4
+ module.Photo = callback(jQuery)
4
5
 
5
- load: (options = {}) ->
6
- deferred = @$.Deferred()
6
+ define 'googleplus.photo', ['jquery'], ($) ->
7
+ class
8
+ constructor: (@attributes) ->
7
9
 
8
- width = options.width if options.width?
10
+ load: (options = {}) ->
11
+ deferred = $.Deferred()
9
12
 
10
- if @attributes.width?
11
- if width?
12
- width = Math.min(width, @attributes.width)
13
- else
14
- width = @attributes.width
13
+ width = options.width if options.width?
15
14
 
16
- if width?
17
- width = Math.round(width)
18
- url = @attributes.url.replace(/w\d+-h\d+(-p)?/, "w#{width}")
19
- else
20
- url = @attributes.url
15
+ if @attributes.width?
16
+ if width?
17
+ width = Math.min(width, @attributes.width)
18
+ else
19
+ width = @attributes.width
21
20
 
22
- element = @$('<img/>')
21
+ if width?
22
+ width = Math.round(width)
23
+ url = @attributes.url.replace(/w\d+-h\d+(-p)?/, "w#{width}")
24
+ else
25
+ url = @attributes.url
23
26
 
24
- element
25
- .on 'load', ->
26
- element.off('load error')
27
- deferred.resolve(element)
28
- return
27
+ element = $('<img/>')
29
28
 
30
- .on 'error', (details...) ->
31
- element.off('load error')
32
- deferred.reject(details...)
33
- return
29
+ element
30
+ .on 'load', ->
31
+ element.off('load error')
32
+ deferred.resolve(element)
33
+ return
34
34
 
35
- element.attr(src: url)
35
+ .on 'error', (details...) ->
36
+ element.off('load error')
37
+ deferred.reject(details...)
38
+ return
36
39
 
37
- deferred.promise()
40
+ element.attr(src: url)
38
41
 
39
- window.GooglePlus ||= {}
40
- window.GooglePlus.Photo = Photo
42
+ deferred.promise()
@@ -1,49 +1,49 @@
1
- #= require googleplus.reader
2
- #= require googleplus.photo
1
+ unless typeof define is 'function' and define.amd
2
+ module = @GooglePlus ||= {}
3
+ @define = (name, deps, callback) ->
4
+ module.PhotoReader = callback(module.Reader, module.Photo)
3
5
 
4
- class PhotoReader extends GooglePlus.Reader
5
- append: (items) ->
6
- for item in items
7
- continue unless item.verb?
8
- continue unless item.verb is 'post'
6
+ define 'googleplus.photoreader', ['googleplus.reader', 'googleplus.photo'], (Reader, Photo) ->
7
+ class extends Reader
8
+ append: (items) ->
9
+ for item in items
10
+ continue unless item.verb?
11
+ continue unless item.verb is 'post'
9
12
 
10
- date = if item.published? then new Date(item.published) else null
13
+ date = if item.published? then new Date(item.published) else null
11
14
 
12
- continue unless item.object?
15
+ continue unless item.object?
13
16
 
14
- post = item.object
17
+ post = item.object
15
18
 
16
- continue unless post.attachments?
19
+ continue unless post.attachments?
17
20
 
18
- for attachment in post.attachments
19
- continue unless attachment.objectType?
21
+ for attachment in post.attachments
22
+ continue unless attachment.objectType?
20
23
 
21
- if attachment.objectType is 'photo'
22
- continue unless attachment.image?
24
+ if attachment.objectType is 'photo'
25
+ continue unless attachment.image?
23
26
 
24
- if attachment.fullImage?
25
- @collection.push new GooglePlus.Photo \
26
- url: attachment.image.url,
27
- width: attachment.fullImage.width,
28
- date: date
29
- else
30
- @collection.push new GooglePlus.Photo \
31
- url: attachment.image.url,
32
- width: null,
33
- date: date
27
+ if attachment.fullImage?
28
+ @collection.push new Photo
29
+ url: attachment.image.url,
30
+ width: attachment.fullImage.width,
31
+ date: date
32
+ else
33
+ @collection.push new Photo
34
+ url: attachment.image.url,
35
+ width: null,
36
+ date: date
34
37
 
35
- else if attachment.objectType is 'album'
36
- continue unless attachment.thumbnails?
38
+ else if attachment.objectType is 'album'
39
+ continue unless attachment.thumbnails?
37
40
 
38
- for thumbnail in attachment.thumbnails
39
- continue unless thumbnail.image?
41
+ for thumbnail in attachment.thumbnails
42
+ continue unless thumbnail.image?
40
43
 
41
- @collection.push new GooglePlus.Photo \
42
- url: thumbnail.image.url,
43
- width: null,
44
- date: date
44
+ @collection.push new Photo
45
+ url: thumbnail.image.url,
46
+ width: null,
47
+ date: date
45
48
 
46
- return
47
-
48
- window.GooglePlus ||= {}
49
- window.GooglePlus.PhotoReader = PhotoReader
49
+ return
@@ -1,50 +1,51 @@
1
- class Reader
2
- constructor: (options) ->
3
- @$ = jQuery
4
-
5
- @id = options.id
6
- @key = options.key
7
- @token = null
8
- @collection = []
9
- @position = 0
10
-
11
- next: (count) ->
12
- deferred = @$.Deferred()
13
-
14
- nextPosition = @position + count
15
-
16
- if nextPosition <= @collection.length
17
- elements = @collection.slice(@position, nextPosition)
18
- @position = nextPosition
19
- deferred.resolve(elements)
20
-
21
- else
22
- @load()
23
- .done =>
24
- nextPosition = Math.min(nextPosition, @collection.length)
25
- elements = @collection.slice(@position, nextPosition)
26
- @position = nextPosition
27
- deferred.resolve(elements)
28
- return
29
-
30
- .fail (details...) =>
31
- deferred.reject(details...)
32
- return
33
-
34
- deferred.promise()
35
-
36
- load: ->
37
- url = "https://www.googleapis.com/plus/v1/people/#{@id}/activities/public?key=#{@key}"
38
- url = "#{url}&pageToken=#{@token}" if @token
39
-
40
- @$.ajax(url: url, crossDomain: true, dataType: 'jsonp').done (result) =>
41
- @append(result.items)
42
- @token = result.nextPageToken
1
+ unless typeof define is 'function' and define.amd
2
+ module = @GooglePlus ||= {}
3
+ @define = (name, deps, callback) ->
4
+ module.Reader = callback(jQuery)
5
+
6
+ define 'googleplus.reader', ['jquery'], ($) ->
7
+ class
8
+ constructor: (options) ->
9
+ @id = options.id
10
+ @key = options.key
11
+ @token = null
12
+ @collection = []
13
+ @position = 0
14
+
15
+ next: (count) ->
16
+ deferred = $.Deferred()
17
+
18
+ nextPosition = @position + count
19
+
20
+ if nextPosition <= @collection.length
21
+ elements = @collection.slice(@position, nextPosition)
22
+ @position = nextPosition
23
+ deferred.resolve(elements)
24
+
25
+ else
26
+ @load()
27
+ .done =>
28
+ nextPosition = Math.min(nextPosition, @collection.length)
29
+ elements = @collection.slice(@position, nextPosition)
30
+ @position = nextPosition
31
+ deferred.resolve(elements)
32
+ return
33
+
34
+ .fail (details...) =>
35
+ deferred.reject(details...)
36
+ return
37
+
38
+ deferred.promise()
39
+
40
+ load: ->
41
+ url = "https://www.googleapis.com/plus/v1/people/#{@id}/activities/public?key=#{@key}"
42
+ url = "#{url}&pageToken=#{@token}" if @token
43
+
44
+ $.ajax(url: url, crossDomain: true, dataType: 'jsonp').done (result) =>
45
+ @append(result.items)
46
+ @token = result.nextPageToken
47
+ return
48
+
49
+ append: (items) ->
50
+ @collection.push(item) for item in items
43
51
  return
44
-
45
- append: (items) ->
46
- @collection.push(item) for item in items
47
- return
48
-
49
- window.GooglePlus ||= {}
50
- window.GooglePlus.Reader = Reader
@@ -1,5 +1,5 @@
1
1
  module GooglePlus
2
2
  module Reader
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
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.4
4
+ version: 0.0.5
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-08-02 00:00:00.000000000 Z
11
+ date: 2014-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,3 +82,4 @@ signing_key:
82
82
  specification_version: 4
83
83
  summary: A jQuery-based library for reading public posts of a Google+ user
84
84
  test_files: []
85
+ has_rdoc: