mention-api 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: 9e4467d498d2f233ca786a5b5f6ae695c4c10d1d
4
- data.tar.gz: 5c60bed83709587b5ae6523fd6a2e5db9f8ad7be
3
+ metadata.gz: 6226673f31f397a98b6241289d9a770672f6fc83
4
+ data.tar.gz: 71149341a56e2c3e02ebb68b7c8b6e1fc8b4c925
5
5
  SHA512:
6
- metadata.gz: 27a4e81b80e926f14b570326ee2a669134a0daba55f12c3ac597cadaee174bd46ef9b04f61773642c005b6686a179888a015dff467f7f94734692fe222158034
7
- data.tar.gz: f770415997967a97ce8c9fc37a5d070086360bb1b693c6b6c8f949382ccc40236529d1507ab530d54ffd2568db6506294e88ad535a8f7f22f164495b32e8b320
6
+ metadata.gz: 38d8ad612317a38ff6e2c680c5bc7295b98dfa3b9b30ab9b63165dfeecec9797a69eed4ff423f6240cba00c45843d8c65affcbdad6e21baecf2d2890c7d1f5a6
7
+ data.tar.gz: 79f194f03ab66bd58ac63f497504ea7fc8aee1162bce12a8e1ad65bb3646820ee82675730c8ec931fdf7f0f9a23b82d11378331018d0160aef3914688f395324
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - jruby
6
+ - rbx-19mode
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
+ [![Version](http://allthebadges.io/hqmq/mention-api/badge_fury.png)](http://allthebadges.io/hqmq/mention-api/badge_fury)
2
+ [![Dependencies](http://allthebadges.io/hqmq/mention-api/gemnasium.png)](http://allthebadges.io/hqmq/mention-api/gemnasium)
3
+ [![Build Status](http://allthebadges.io/hqmq/mention-api/travis.png)](http://allthebadges.io/hqmq/mention-api/travis)
4
+ [![Code Climate](http://allthebadges.io/hqmq/mention-api/code_climate.png)](http://allthebadges.io/hqmq/mention-api/code_climate)
5
+
1
6
  # Mention::Api
2
7
 
3
- A nice ruby interface to wrap the [Mention.net](mention.net) API.
8
+ A nice ruby interface to wrap the [Mention.net](http://mention.net/) API.
4
9
 
5
10
  ## Installation
6
11
 
data/Rakefile CHANGED
@@ -1 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec_unit) do |t, task_args|
5
+ t.rspec_opts = "--tag ~acceptance"
6
+ end
7
+
8
+ task :default => :spec_unit
data/lib/mention-api.rb CHANGED
@@ -7,6 +7,8 @@ require 'virtus'
7
7
  require 'mention/account'
8
8
  require 'mention/share'
9
9
  require 'mention/alert'
10
+ require 'mention/mention'
11
+ require 'mention/mention_list'
10
12
 
11
13
  # utility classes
12
14
  require 'mention/error'
@@ -9,7 +9,7 @@ module Mention
9
9
  @alerts ||= begin
10
10
  raw_data = JSON.parse(resource['alerts'].get)
11
11
  raw_data['alerts'].map do |hash|
12
- Mention::Alert.new(hash)
12
+ Alert.new(hash)
13
13
  end
14
14
  end
15
15
  end
@@ -36,10 +36,15 @@ module Mention
36
36
  creator.created_alert
37
37
  end
38
38
 
39
- def remove(alert, share)
39
+ def remove_alert(alert, share)
40
40
  resource["/alerts/#{alert.id}/shares/#{share.id}"].delete
41
41
  end
42
42
 
43
+ def fetch_mentions(alert, params = {})
44
+ raw_data = JSON.parse(resource["/alerts/#{alert.id}/mentions"].get params: params)
45
+ MentionList.new(raw_data)
46
+ end
47
+
43
48
  private
44
49
  attr_reader :account_id, :access_token
45
50
 
data/lib/mention/alert.rb CHANGED
@@ -16,7 +16,11 @@ module Mention
16
16
 
17
17
  def remove_from(account)
18
18
  share = share_for(account)
19
- account.remove(self, share)
19
+ account.remove_alert(self, share)
20
+ end
21
+
22
+ def mentions(account, params = {})
23
+ account.fetch_mentions(self, params)
20
24
  end
21
25
 
22
26
  private
@@ -5,7 +5,7 @@ module Mention
5
5
  end
6
6
 
7
7
  def created_alert
8
- @created_alert ||= Mention::Alert.new(response['alert'])
8
+ @created_alert ||= Alert.new(response['alert'])
9
9
  end
10
10
 
11
11
  def valid?
@@ -27,7 +27,9 @@ module Mention
27
27
  end
28
28
 
29
29
  def request_params
30
- alert.attributes.reject{|k,v| k == :id}
30
+ alert.attributes
31
+ .reject{|k,v| k == :id}
32
+ .reject{|k,v| k == :shares}
31
33
  end
32
34
 
33
35
  def validate_response!
@@ -1,5 +1,5 @@
1
1
  module Mention
2
2
  module Api
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -0,0 +1,13 @@
1
+ module Mention
2
+ class Mention
3
+ include Virtus.value_object(strict: true)
4
+
5
+ values do
6
+ attribute :id, Integer
7
+ attribute :title, String
8
+ attribute :description, String
9
+ attribute :url, String
10
+ attribute :published_at, Time
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module Mention
2
+ class MentionList
3
+ include Virtus.value_object(strict: true)
4
+ values do
5
+ attribute :mentions, Array[Mention]
6
+ end
7
+
8
+ extend Forwardable
9
+ def_delegator :mentions, :each
10
+ include Enumerable
11
+ end
12
+ end
data/mention-api.gemspec CHANGED
@@ -23,5 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rspec", "~> 2.14"
24
24
  spec.add_development_dependency "webmock", "~> 1.14"
25
25
  spec.add_runtime_dependency "rest-client", "~> 1.6.7"
26
- spec.add_runtime_dependency "virtus", "~> 1.0.0.rc1"
26
+ spec.add_runtime_dependency "virtus", "~> 1.0"
27
27
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper_acceptance'
2
2
 
3
- describe "Managing Alerts" do
3
+ describe "Managing Alerts", :acceptance => true do
4
4
  include_context "credentials"
5
5
 
6
6
  it "returns a list of alerts" do
@@ -0,0 +1 @@
1
+ {"mentions":[{"id":"3253260762","alert_id":461518,"title":"SPRUG: SPB Ruby User Group - Community - Google+","description":"Got even more excited about Ruby Object Mapper after listening to RubyRogues Ep. 123 with @solnic. #twt http:\/\/rubyrogues.com\/123-rr-rom-with-piotr-solnica\/.","url":"https:\/\/plus.google.com\/communities\/117927540789820622012","unique_id":"https:\/\/plus.google.com\/communities\/117927540789820622012","published_at":"2013-10-18T21:57:08.40799100+00:00","created_at":"2013-10-18T21:57:09.0+00:00","updated_at":"2013-10-18T21:57:09.0+00:00","favorite":false,"trashed":false,"trashed_set_by_user":false,"read":true,"tone":1,"tone_score":0.99686,"relevance_score":0,"source_type":"web","source_name":"google.com","source_url":"https:\/\/plus.google.com","language_code":"en","tasks":[],"logs":[],"children":[],"important":false,"offsets":{"title":[11,11,4,4],"description":[28,28,4,4,33,33,6,6,40,40,6,6,66,66,4,4,113,113,4,4,135,135,3,3],"url":[],"source_name":[],"source_url":[]},"permissions":{"favorite":true,"trash":true,"create_task":false}},{"id":"3259883082","alert_id":461518,"title":"127 RR Erik Michaels-Ober - Ruby Rogues","description":"ERIK: Yeah, so I was actually listening to a Ruby Rogues episode a few weeks ago with Piotr Solnica and he mentioned a bunch of gems that came out of the ROM project, the Ruby Object Mapper. And I tried just using them. I looked them up ...","url":"http:\/\/rubyrogues.com\/127-rr-erik-michaels-ober\/","unique_id":"http:\/\/rubyrogues.com\/127-rr-erik-michaels-ober\/","published_at":"2013-10-16T13:00:42.84034500+00:00","created_at":"2013-10-19T11:55:40.0+00:00","updated_at":"2013-10-22T04:33:43.0+00:00","favorite":true,"trashed":false,"trashed_set_by_user":false,"read":true,"tone":0,"tone_score":0.13167,"relevance_score":0,"source_type":"blogs","source_name":"Charles Max Wood","source_url":"http:\/\/rubyrogues.com\/","language_code":"en","tasks":[],"logs":[{"id":"18854292","type":"favorited","author":{"id":"209170_64b8a6q53wkks8k0k80c04o8osskc8w0scs8gsk4gco8kg8csw","name":"Michael Ries","email":"michael@riesd.com","language_code":"en","registration_client":"web","inviter_id":"209170_44yhohlf","created_at":"2013-10-06T22:09:48.0+00:00","updated_at":"2013-10-22T04:28:34.0+00:00","avatar_url":"https:\/\/web.mention.net\/avatars\/e5b3508d3d0178000d994ad8e4b50e2f-b36057eb7794d441.jpg"},"created_at":"2013-10-22T04:33:43.0+00:00"}],"children":[],"important":false,"offsets":{"title":[28,28,4,4],"description":[45,45,4,4,154,154,3,3,171,171,4,4,176,176,6,6,183,183,6,6],"url":[7,7,4,4],"source_name":[],"source_url":[7,7,4,4]},"permissions":{"favorite":true,"trash":true,"create_task":false}},{"id":"3199497112","alert_id":461518,"title":"#rom-rb on 2013-10-14 \u2014 irc logs at whitequark.org","description":"2013-06-04 15:26 solnic changed the topic of #rom-rb to: Ruby Object Mapper | Mailing List: https:\/\/groups.google.com\/forum\/?fromgroups#!forum\/rom-rb | Logs: \u00a0...","url":"http:\/\/irclog.whitequark.org\/rom-rb\/","unique_id":"http:\/\/irclog.whitequark.org\/rom-rb\/","published_at":"2013-10-15T06:02:29.54474800+00:00","created_at":"2013-10-15T06:02:30.0+00:00","updated_at":"2013-10-15T06:02:31.0+00:00","favorite":false,"trashed":false,"trashed_set_by_user":false,"read":true,"tone":1,"tone_score":0.89703,"relevance_score":0,"source_type":"web","source_name":"whitequark.org","source_url":"http:\/\/irclog.whitequark.org","language_code":"en","tasks":[],"logs":[],"children":[],"important":false,"offsets":{"title":[1,1,3,3],"description":[46,46,3,3,57,57,4,4,62,62,6,6,69,69,6,6,145,145,3,3],"url":[29,29,3,3],"source_name":[],"source_url":[]},"permissions":{"favorite":true,"trash":true,"create_task":false}},{"id":"3199497192","alert_id":461518,"title":"rom-rb (Ruby Object Mapper) \u00b7 GitHub","description":"Ruby Object Mapper rom-rb. http:\/\/rom-rb.org; Joined on Jun 01, 2013 ... Ruby Object Mapper - vagrant vm setup with environment prepared for ROM\u00a0...","url":"https:\/\/github.com\/rom-rb","unique_id":"https:\/\/github.com\/rom-rb","published_at":"2013-10-15T06:02:29.54465700+00:00","created_at":"2013-10-15T06:02:31.0+00:00","updated_at":"2013-10-22T04:33:35.0+00:00","favorite":true,"trashed":false,"trashed_set_by_user":false,"read":true,"tone":0,"tone_score":0.23322,"relevance_score":0,"source_type":"web","source_name":"github.com","source_url":"https:\/\/github.com","language_code":"en","tasks":[],"logs":[{"id":"18854282","type":"favorited","author":{"id":"209170_64b8a6q53wkks8k0k80c04o8osskc8w0scs8gsk4gco8kg8csw","name":"Michael Ries","email":"michael@riesd.com","language_code":"en","registration_client":"web","inviter_id":"209170_44yhohlf","created_at":"2013-10-06T22:09:48.0+00:00","updated_at":"2013-10-22T04:28:34.0+00:00","avatar_url":"https:\/\/web.mention.net\/avatars\/e5b3508d3d0178000d994ad8e4b50e2f-b36057eb7794d441.jpg"},"created_at":"2013-10-22T04:33:35.0+00:00"}],"children":[],"important":false,"offsets":{"title":[0,0,3,3,8,8,4,4,13,13,6,6,20,20,6,6],"description":[0,0,4,4,5,5,6,6,12,12,6,6,19,19,3,3,34,34,3,3,73,73,4,4,80,80,6,6,87,87,6,6,143,143,3,3],"url":[19,19,3,3],"source_name":[],"source_url":[]},"permissions":{"favorite":true,"trash":true,"create_task":false}},{"id":"3170907802","alert_id":461518,"title":"Joining Relations with Ruby Object Mapper - JJask.com","description":"Does anyone know of a good example of doing reads and write with joined data from Ruby Object Mapper? -- EDIT to include more details --. My ROM schema\u00a0...","url":"http:\/\/www.jjask.com\/417722\/joining-relations-with-ruby-object-mapper","unique_id":"http:\/\/www.jjask.com\/417722\/joining-relations-with-ruby-object-mapper","published_at":"2013-10-13T03:13:01.23992800+00:00","created_at":"2013-10-13T03:13:01.0+00:00","updated_at":"2013-10-13T03:13:01.0+00:00","favorite":false,"trashed":false,"trashed_set_by_user":false,"read":true,"tone":1,"tone_score":0.99723,"relevance_score":0,"source_type":"web","source_name":"jjask.com","source_url":"http:\/\/www.jjask.com","language_code":"en","tasks":[],"logs":[],"children":[],"important":false,"offsets":{"title":[23,23,4,4,28,28,6,6,35,35,6,6],"description":[84,84,4,4,89,89,6,6,96,96,6,6,143,143,3,3],"url":[51,51,4,4,56,56,6,6,63,63,6,6],"source_name":[],"source_url":[]},"permissions":{"favorite":true,"trash":true,"create_task":false}},{"id":"3133336282","alert_id":461518,"title":"Wikipedia:Requested articles\/Applied arts and sciences\/Computer ...","description":"\"Potion is an object- and mixin-oriented (traits) language. ... Macronix is a manufacturer of rom memory. www.macronix.com ..... Geoffrey Grosenbach - founder of PeepCode Screencasts and Ruby on Rails podcast; [125]]; George .... Wilhelm Oddo Ml \u2026","url":"http:\/\/en.wikipedia.org\/wiki\/Wikipedia:Requested_articles\/Applied_arts_and_sciences\/Computer_science,_computing,_and_Internet","unique_id":"http:\/\/en.wikipedia.org\/wiki\/Wikipedia:Requested_articles\/Applied_arts_and_sciences\/Computer_science,_computing,_and_Internet","published_at":"2013-10-10T12:45:25.18839700+00:00","created_at":"2013-10-10T12:45:25.0+00:00","updated_at":"2013-10-10T12:45:25.0+00:00","favorite":false,"trashed":false,"trashed_set_by_user":false,"read":true,"tone":0,"tone_score":1,"relevance_score":0,"source_type":"web","source_name":"wikipedia.org","source_url":"http:\/\/en.wikipedia.org","language_code":"en","tasks":[],"logs":[],"children":[],"important":false,"offsets":{"title":[],"description":[14,14,6,6,94,94,3,3,187,187,4,4],"url":[],"source_name":[],"source_url":[]},"permissions":{"favorite":true,"trash":true,"create_task":false}},{"id":"3133336402","alert_id":461518,"title":"Ruby Rogues","description":"Confident Ruby by Avdi Grimm! ... 123 RR ROM with Piotr Solnica ... Rails Ramp Up) Discussion 01:24 \u2013 Piotr Solnica Introduction Ruby Object Mapper 06:08\u00a0...","url":"http:\/\/rubyrogues.com\/","unique_id":"http:\/\/rubyrogues.com\/","published_at":"2013-10-10T12:45:25.18828500+00:00","created_at":"2013-10-10T12:45:25.0+00:00","updated_at":"2013-10-10T12:45:26.0+00:00","favorite":false,"trashed":false,"trashed_set_by_user":false,"read":true,"tone":1,"tone_score":0.97604,"relevance_score":0,"source_type":"web","source_name":"rubyrogues.com","source_url":"http:\/\/rubyrogues.com","language_code":"en","tasks":[],"logs":[],"children":[],"important":false,"offsets":{"title":[0,0,4,4],"description":[10,10,4,4,41,41,3,3,129,129,4,4,134,134,6,6,141,141,6,6],"url":[7,7,4,4],"source_name":[0,0,4,4],"source_url":[7,7,4,4]},"permissions":{"favorite":true,"trash":true,"create_task":false}},{"id":"3109778052","alert_id":461518,"title":"Buddenbaum.de - Heise","description":"Maker Faire Rom: Heimspiel f\u00fcr Arduino ... Ruby-Implementierung Rubinius in der Gegenwart angekommen .... Landsat Enhanced Thematic Mapper Plus (ETM +) data are used to generate finer ...... Bayesian object-based estimation of LAI and chlorophyll from \u2026","url":"http:\/\/buddenbaum.de\/index.php?inhalt=heise.ct&layout=layout16.ph&submenu=8","unique_id":"http:\/\/buddenbaum.de\/index.php?inhalt=heise.ct&layout=layout16.ph&submenu=8","published_at":"2013-10-08T20:35:28.46928600+00:00","created_at":"2013-10-08T20:35:28.0+00:00","updated_at":"2013-10-08T20:35:28.0+00:00","favorite":false,"trashed":false,"trashed_set_by_user":false,"read":true,"tone":0,"tone_score":1,"relevance_score":0,"source_type":"web","source_name":"buddenbaum.de","source_url":"http:\/\/buddenbaum.de","language_code":"en","tasks":[],"logs":[],"children":[],"important":false,"offsets":{"title":[],"description":[12,12,3,3,43,43,4,4,132,132,6,6,200,200,6,6],"url":[],"source_name":[],"source_url":[]},"permissions":{"favorite":true,"trash":true,"create_task":false}},{"id":"3098889462","alert_id":461518,"title":"Joining Relations","description":"Michael Ries ... rom-rb Hi - I opened a question on stackoverflow about how to join relations in ruby object mapper.","url":"http:\/\/groups.google.com\/g\/4f27c98a\/t\/b2ea5a96ce5377a5\/d\/a06559b71ac8626b","unique_id":"http:\/\/groups.google.com\/g\/4f27c98a\/t\/b2ea5a96ce5377a5\/d\/a06559b71ac8626b","published_at":"2013-10-08T03:56:36.91432700+00:00","created_at":"2013-10-08T03:56:36.0+00:00","updated_at":"2013-10-08T03:56:36.0+00:00","favorite":false,"trashed":false,"trashed_set_by_user":false,"read":true,"tone":1,"tone_score":0.97152,"relevance_score":0,"source_type":"forums","source_name":"google.com","source_url":"http:\/\/groups.google.com","language_code":"en","tasks":[],"logs":[],"children":[],"important":false,"offsets":{"title":[],"description":[17,17,3,3,97,97,4,4,102,102,6,6,109,109,6,6],"url":[],"source_name":[],"source_url":[]},"permissions":{"favorite":true,"trash":true,"create_task":false}}],"_links":{"pull":{"href":"\/api\/accounts\/209170_64b8a6q53wkks8k0k80c04o8osskc8w0scs8gsk4gco8kg8csw\/alerts\/461518\/mentions?limit=20&since_id=3285351912","params":{"limit":20,"since_id":"3285351912"}}},"recently_reenabled":false}
@@ -0,0 +1 @@
1
+ {"mentions":[{"id":"3199497192","alert_id":461518,"title":"rom-rb (Ruby Object Mapper) \u00b7 GitHub","description":"Ruby Object Mapper rom-rb. http:\/\/rom-rb.org; Joined on Jun 01, 2013 ... Ruby Object Mapper - vagrant vm setup with environment prepared for ROM\u00a0...","url":"https:\/\/github.com\/rom-rb","unique_id":"https:\/\/github.com\/rom-rb","published_at":"2013-10-15T06:02:29.54465700+00:00","created_at":"2013-10-15T06:02:31.0+00:00","updated_at":"2013-10-22T04:33:35.0+00:00","favorite":true,"trashed":false,"trashed_set_by_user":false,"read":true,"tone":0,"tone_score":0.23322,"relevance_score":0,"source_type":"web","source_name":"github.com","source_url":"https:\/\/github.com","language_code":"en","tasks":[],"logs":[{"id":"18854282","type":"favorited","author":{"id":"209170_64b8a6q53wkks8k0k80c04o8osskc8w0scs8gsk4gco8kg8csw","name":"Michael Ries","email":"michael@riesd.com","language_code":"en","registration_client":"web","inviter_id":"209170_44yhohlf","created_at":"2013-10-06T22:09:48.0+00:00","updated_at":"2013-10-22T04:28:34.0+00:00","avatar_url":"https:\/\/web.mention.net\/avatars\/e5b3508d3d0178000d994ad8e4b50e2f-b36057eb7794d441.jpg"},"created_at":"2013-10-22T04:33:35.0+00:00"}],"children":[],"important":false,"offsets":{"title":[0,0,3,3,8,8,4,4,13,13,6,6,20,20,6,6],"description":[0,0,4,4,5,5,6,6,12,12,6,6,19,19,3,3,34,34,3,3,73,73,4,4,80,80,6,6,87,87,6,6,143,143,3,3],"url":[19,19,3,3],"source_name":[],"source_url":[]},"permissions":{"favorite":true,"trash":true,"create_task":false}},{"id":"3253260762","alert_id":461518,"title":"SPRUG: SPB Ruby User Group - Community - Google+","description":"Got even more excited about Ruby Object Mapper after listening to RubyRogues Ep. 123 with @solnic. #twt http:\/\/rubyrogues.com\/123-rr-rom-with-piotr-solnica\/.","url":"https:\/\/plus.google.com\/communities\/117927540789820622012","unique_id":"https:\/\/plus.google.com\/communities\/117927540789820622012","published_at":"2013-10-18T21:57:08.40799100+00:00","created_at":"2013-10-18T21:57:09.0+00:00","updated_at":"2013-10-18T21:57:09.0+00:00","favorite":false,"trashed":false,"trashed_set_by_user":false,"read":true,"tone":1,"tone_score":0.99686,"relevance_score":0,"source_type":"web","source_name":"google.com","source_url":"https:\/\/plus.google.com","language_code":"en","tasks":[],"logs":[],"children":[],"important":false,"offsets":{"title":[11,11,4,4],"description":[28,28,4,4,33,33,6,6,40,40,6,6,66,66,4,4,113,113,4,4,135,135,3,3],"url":[],"source_name":[],"source_url":[]},"permissions":{"favorite":true,"trash":true,"create_task":false}},{"id":"3259883082","alert_id":461518,"title":"127 RR Erik Michaels-Ober - Ruby Rogues","description":"ERIK: Yeah, so I was actually listening to a Ruby Rogues episode a few weeks ago with Piotr Solnica and he mentioned a bunch of gems that came out of the ROM project, the Ruby Object Mapper. And I tried just using them. I looked them up ...","url":"http:\/\/rubyrogues.com\/127-rr-erik-michaels-ober\/","unique_id":"http:\/\/rubyrogues.com\/127-rr-erik-michaels-ober\/","published_at":"2013-10-16T13:00:42.84034500+00:00","created_at":"2013-10-19T11:55:40.0+00:00","updated_at":"2013-10-22T04:33:43.0+00:00","favorite":true,"trashed":false,"trashed_set_by_user":false,"read":true,"tone":0,"tone_score":0.13167,"relevance_score":0,"source_type":"blogs","source_name":"Charles Max Wood","source_url":"http:\/\/rubyrogues.com\/","language_code":"en","tasks":[],"logs":[{"id":"18854292","type":"favorited","author":{"id":"209170_64b8a6q53wkks8k0k80c04o8osskc8w0scs8gsk4gco8kg8csw","name":"Michael Ries","email":"michael@riesd.com","language_code":"en","registration_client":"web","inviter_id":"209170_44yhohlf","created_at":"2013-10-06T22:09:48.0+00:00","updated_at":"2013-10-22T04:28:34.0+00:00","avatar_url":"https:\/\/web.mention.net\/avatars\/e5b3508d3d0178000d994ad8e4b50e2f-b36057eb7794d441.jpg"},"created_at":"2013-10-22T04:33:43.0+00:00"}],"children":[],"important":false,"offsets":{"title":[28,28,4,4],"description":[45,45,4,4,154,154,3,3,171,171,4,4,176,176,6,6,183,183,6,6],"url":[7,7,4,4],"source_name":[],"source_url":[7,7,4,4]},"permissions":{"favorite":true,"trash":true,"create_task":false}}],"_links":{"pull":{"href":"\/api\/accounts\/209170_64b8a6q53wkks8k0k80c04o8osskc8w0scs8gsk4gco8kg8csw\/alerts\/461518\/mentions?limit=20&since_id=3259883082","params":{"limit":20,"since_id":"3259883082"}}},"recently_reenabled":false}
@@ -0,0 +1,29 @@
1
+ require 'spec_helper_unit'
2
+
3
+ describe Mention::Alert do
4
+ let(:account){ Mention::Account.new(account_id: 'abc', access_token: 'def') }
5
+ let(:json){ File.read('spec/fixtures/get_account_alerts.json') }
6
+ let(:alert_params){ JSON.parse(json)['alerts'].first }
7
+ let(:alert){ Mention::Alert.new(alert_params) }
8
+ let(:base_url){ "https://api.mention.net/api/accounts/abc/alerts/#{alert.id}/mentions" }
9
+
10
+ it "fetches a list of mentions" do
11
+ stub_request(:get, base_url).
12
+ with(:headers => {'Accept'=>'application/json', 'Authorization'=>'Bearer def'}).
13
+ to_return(:status => 200, :body => File.read("spec/fixtures/mention_list_default.json"))
14
+
15
+ mentions = alert.mentions(account)
16
+ mentions.should be_a(Mention::MentionList)
17
+ mentions.count.should == 9
18
+ end
19
+
20
+ it "fetches a list of mentions since a given id" do
21
+ stub_request(:get, "#{base_url}?since_id=3199497112").
22
+ with(:headers => {'Accept'=>'application/json', 'Authorization'=>'Bearer def'}).
23
+ to_return(:status => 200, :body => File.read("spec/fixtures/mention_list_since.json"))
24
+
25
+ mentions = alert.mentions(account, since_id: "3199497112")
26
+ mentions.should be_a(Mention::MentionList)
27
+ mentions.count.should == 3
28
+ end
29
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper_unit'
2
+
3
+ describe Mention::Mention do
4
+ let(:json){ File.read('spec/fixtures/mention_list_default.json') }
5
+ let(:mention_params){ JSON.parse(json)['mentions'].first }
6
+ let(:mention){ Mention::Mention.new(mention_params) }
7
+
8
+ it "has some basic information" do
9
+ mention.id.should == 3253260762
10
+ mention.title.should start_with('SPRUG')
11
+ mention.description.should start_with('Got even more excited about')
12
+ mention.url.should == "https://plus.google.com/communities/117927540789820622012"
13
+ mention.published_at.to_i.should == Time.parse('2013-10-18 15:57:08').to_i
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mention-api
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
  - Michael Ries
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-14 00:00:00.000000000 Z
11
+ date: 2013-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - ~>
88
88
  - !ruby/object:Gem::Version
89
- version: 1.0.0.rc1
89
+ version: '1.0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ~>
95
95
  - !ruby/object:Gem::Version
96
- version: 1.0.0.rc1
96
+ version: '1.0'
97
97
  description: A wrapper for the mention.net API
98
98
  email:
99
99
  - michael@riesd.com
@@ -102,6 +102,7 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - .gitignore
105
+ - .travis.yml
105
106
  - Gemfile
106
107
  - LICENSE.txt
107
108
  - README.md
@@ -113,15 +114,21 @@ files:
113
114
  - lib/mention/api.rb
114
115
  - lib/mention/api/version.rb
115
116
  - lib/mention/error.rb
117
+ - lib/mention/mention.rb
118
+ - lib/mention/mention_list.rb
116
119
  - lib/mention/share.rb
117
120
  - lib/mention/validation_error.rb
118
121
  - mention-api.gemspec
119
122
  - spec/acceptance/alert_management_spec.rb
120
123
  - spec/fixtures/get_account.json
121
124
  - spec/fixtures/get_account_alerts.json
125
+ - spec/fixtures/mention_list_default.json
126
+ - spec/fixtures/mention_list_since.json
122
127
  - spec/fixtures/post_account_alerts.json
123
128
  - spec/fixtures/post_account_alerts_failed.json
124
129
  - spec/lib/mention/account_spec.rb
130
+ - spec/lib/mention/alert_spec.rb
131
+ - spec/lib/mention/mention_spec.rb
125
132
  - spec/spec_helper.rb
126
133
  - spec/spec_helper_acceptance.rb
127
134
  - spec/spec_helper_unit.rb
@@ -154,9 +161,13 @@ test_files:
154
161
  - spec/acceptance/alert_management_spec.rb
155
162
  - spec/fixtures/get_account.json
156
163
  - spec/fixtures/get_account_alerts.json
164
+ - spec/fixtures/mention_list_default.json
165
+ - spec/fixtures/mention_list_since.json
157
166
  - spec/fixtures/post_account_alerts.json
158
167
  - spec/fixtures/post_account_alerts_failed.json
159
168
  - spec/lib/mention/account_spec.rb
169
+ - spec/lib/mention/alert_spec.rb
170
+ - spec/lib/mention/mention_spec.rb
160
171
  - spec/spec_helper.rb
161
172
  - spec/spec_helper_acceptance.rb
162
173
  - spec/spec_helper_unit.rb