agig 0.1.5 → 0.2.0

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: c3da2fcec9b0d123aeb956eebab8e2a4dbafa454
4
- data.tar.gz: 950c9a3ffa495fc0718f42e3fd69e3c8c8f25413
3
+ metadata.gz: 47bd15707a6adb5cec6a9b81d32e20d71dc79c8e
4
+ data.tar.gz: cd14f5823712eac9f25388c63c30b69e6b58afa5
5
5
  SHA512:
6
- metadata.gz: 079b2dab6b4a2283e009a1dc3be88349fdcfd9d195dc7f603cf6bc95ac67def535a02fb8ac73604e39dfdedbf940f70468f0b495f43f75b884584f34cff6c333
7
- data.tar.gz: 660a20b981b3549ceb41ef89981066d5f0318e8ec4ac693042f82d8a1721542d5ef319e5d8292bc38ae928f8062df35ec207b6e881fbff7172e2171b0d64ad4e
6
+ metadata.gz: 49a46afddf8da734cc68b6ea2692e70e70dc98cd8d52f10a507d1c1ba722195f5501d3a567ca2302982acef59bdbc4a7c514c7cc6f5e050f69bb334f80eb9081
7
+ data.tar.gz: b8f9564df4745326e0a335dba490562e1f8f9eb453927c4612e931b7b44d888195dee7037fb1261ada72a82397492c354a08677685d36902eff4db513e41350e
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1
6
+
7
+ script: bundle exec rake spec
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in agig.gemspec
4
4
  gemspec
5
+
6
+ gem 'rspec', '~> 3.0.0.beta2'
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # Agig
1
+ # agig
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/atig.png)](https://rubygems.org/gems/atig) [![Code Climate](https://codeclimate.com/github/hsbt/agig.png)](https://codeclimate.com/github/hsbt/agig) [![Build Status](https://travis-ci.org/hsbt/agig.png)](https://travis-ci.org/hsbt/agig)
2
4
 
3
5
  Agig is another Github IRC Gateway, forked cho45's [gig.rb](https://github.com/cho45/net-irc/blob/master/examples/gig.rb)
4
6
 
@@ -12,6 +14,9 @@ Modified from original gig.rb:
12
14
  $ gem install agig
13
15
  $ agig -d
14
16
 
17
+ # setting a retrieving interval second.
18
+ $ agig -i 60
19
+
15
20
  ## Contributing
16
21
 
17
22
  1. Fork it
@@ -23,4 +28,6 @@ Modified from original gig.rb:
23
28
  ## Contributor
24
29
 
25
30
  * @morygonzalez
26
-
31
+ * @taketin
32
+ * @mizoR
33
+ * @ykzts
data/Rakefile CHANGED
@@ -1,2 +1,9 @@
1
1
  #!/usr/bin/env rake
2
+ require 'rspec/core/rake_task'
2
3
  require "bundler/gem_tasks"
4
+
5
+ RSpec::Core::RakeTask.new do |t|
6
+ t.pattern = 'spec/**/*_spec.rb'
7
+ end
8
+
9
+ task :default => [:spec]
data/agig.gemspec CHANGED
@@ -8,8 +8,6 @@ Gem::Specification.new do |gem|
8
8
  gem.summary = %q{agig is another Github IRC Gateway. agig is forked from gig.rb, and contained net-irc gems.}
9
9
  gem.homepage = "https://github.com/hsbt/agig"
10
10
 
11
- gem.required_ruby_version = Gem::Requirement.new(">= 1.9.2")
12
-
13
11
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
14
12
  gem.files = `git ls-files`.split("\n")
15
13
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -17,10 +15,15 @@ Gem::Specification.new do |gem|
17
15
  gem.require_paths = ["lib"]
18
16
  gem.version = Agig::VERSION
19
17
 
18
+ gem.required_ruby_version = Gem::Requirement.new(">= 1.9.3")
19
+
20
20
  gem.add_dependency 'net-irc'
21
- gem.add_dependency 'json'
22
- gem.add_dependency 'faraday', '~> 0.8.7'
23
- gem.add_dependency 'octokit', '~> 1.25'
21
+ gem.add_dependency 'string-irc'
22
+ gem.add_dependency 'octokit'
24
23
 
25
- gem.add_development_dependency 'rspec'
24
+ gem.add_development_dependency 'bundler'
25
+ gem.add_development_dependency 'rake'
26
+ gem.add_development_dependency 'webmock'
27
+ gem.add_development_dependency 'pry-byebug'
28
+ gem.add_development_dependency 'coveralls'
26
29
  end
data/lib/agig/optparse.rb CHANGED
@@ -3,11 +3,12 @@ require "optparse"
3
3
  module Agig::OptParser
4
4
  def self.parse!(argv)
5
5
  opts = {
6
- :port => 16705,
7
- :host => "localhost",
8
- :log => nil,
9
- :debug => false,
10
- :foreground => false,
6
+ port: 16705,
7
+ host: "localhost",
8
+ interval: 30,
9
+ log: nil,
10
+ debug: false,
11
+ foreground: false,
11
12
  }
12
13
 
13
14
  OptionParser.new do |parser|
@@ -24,6 +25,10 @@ module Agig::OptParser
24
25
  opts[:host] = host
25
26
  end
26
27
 
28
+ on("-i", "--interval [INTERVAL=#{opts[:interval]}]", "set a retrieving interval") do |interval|
29
+ opts[:interval] = interval
30
+ end
31
+
27
32
  on("-l", "--log LOG", "log file") do |log|
28
33
  opts[:log] = log
29
34
  end
@@ -42,6 +47,18 @@ module Agig::OptParser
42
47
  end
43
48
  end
44
49
 
45
- opts
50
+ self.cast opts
51
+ end
52
+
53
+ def self.cast(opts)
54
+ opts.inject({}) {|r, i|
55
+ key, value = i[0], i[1]
56
+ r.update key => case value
57
+ when nil then true
58
+ when /\A\d+\z/ then value.to_i
59
+ when /\A(?:\d+\.\d*|\.\d+)\z/ then value.to_f
60
+ else value
61
+ end
62
+ }
46
63
  end
47
64
  end
data/lib/agig/session.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'ostruct'
2
2
  require 'time'
3
3
  require 'net/irc'
4
+ require 'string-irc'
4
5
  require 'octokit'
5
6
 
6
7
  class Agig::Session < Net::IRC::Server::Session
@@ -22,11 +23,7 @@ class Agig::Session < Net::IRC::Server::Session
22
23
  end
23
24
 
24
25
  def client
25
- @client ||= if @opts.oauth_token
26
- Octokit::Client.new(oauth_token: @pass)
27
- else
28
- Octokit::Client.new(login: @nick, password: @pass)
29
- end
26
+ @client ||= Octokit::Client.new(access_token: @pass)
30
27
  end
31
28
 
32
29
  def on_disconnected
@@ -36,58 +33,56 @@ class Agig::Session < Net::IRC::Server::Session
36
33
  def on_user(m)
37
34
  super
38
35
 
39
- @real, *@opts = @real.split(/\s+/)
40
- @opts = OpenStruct.new @opts.inject({}) {|r, i|
41
- key, value = i.split("=", 2)
42
- r.update key => case value
43
- when nil then true
44
- when /\A\d+\z/ then value.to_i
45
- when /\A(?:\d+\.\d*|\.\d+)\z/ then value.to_f
46
- else value
47
- end
48
- }
49
36
  channels.each{|channel| post @nick, JOIN, channel }
50
37
 
51
38
  @retrieve_thread = Thread.start do
52
39
  loop do
53
- begin
54
- @log.info 'retrieveing feed...'
55
-
56
- entries = client.notifications(all: true)
57
- entries.sort_by(&:updated_at).reverse_each do |entry|
58
- updated_at = Time.parse(entry.updated_at).utc
59
- next if updated_at <= @notification_last_retrieved
60
-
61
- reachable_url = reachable_url_for(entry.subject.latest_comment_url)
62
-
63
- post entry.repository.owner.login, PRIVMSG, "#notification", "\0035#{entry.subject.title}\017 \00314#{reachable_url}\017"
64
- @notification_last_retrieved = updated_at
65
- end
66
-
67
- events = client.received_events(@nick)
68
- events.sort_by(&:created_at).reverse_each do |event|
69
- next if event.type != "WatchEvent"
70
-
71
- created_at = Time.parse(event.created_at).utc
72
- next if created_at <= @watch_last_retrieved
73
-
74
- post event.actor.login, PRIVMSG, "#watch", "\0035#{event.payload.action}\017 \00314http://github.com/#{event.repo.name}\017"
75
- @watch_last_retrieved = created_at
76
- end
77
-
78
- @log.info 'sleep'
79
- sleep 30
80
- rescue Exception => e
81
- @log.error e.inspect
82
- e.backtrace.each do |l|
83
- @log.error "\t#{l}"
84
- end
85
- sleep 10
86
- end
40
+ retrieve @opts.interval
87
41
  end
88
42
  end
89
43
  end
90
44
 
45
+ private
46
+
47
+ def retrieve(interval)
48
+ @log.info 'retrieveing feed...'
49
+
50
+ entries = client.notifications(all: true)
51
+ entries.sort_by(&:updated_at).each do |entry|
52
+ updated_at = Time.parse(entry.updated_at.to_s).utc
53
+ next if updated_at <= @notification_last_retrieved
54
+
55
+ title = StringIrc.new(entry.subject.title).brown.to_s
56
+ url = StringIrc.new(reachable_url_for(entry.subject.latest_comment_url)).grey.to_s
57
+
58
+ post entry.repository.owner.login, PRIVMSG, "#notification", "#{title} #{url}"
59
+ @notification_last_retrieved = updated_at
60
+ end
61
+
62
+ events = client.received_events(@nick)
63
+ events.sort_by(&:created_at).each do |event|
64
+ next if event.type != "WatchEvent"
65
+
66
+ created_at = Time.parse(event.created_at.to_s).utc
67
+ next if created_at <= @watch_last_retrieved
68
+
69
+ action = StringIrc.new(event.payload.action).brown.to_s
70
+ url = StringIrc.new("http://github.com/#{event.repo.name}").grey.to_s
71
+
72
+ post event.actor.login, PRIVMSG, "#watch", "#{action} #{url}"
73
+ @watch_last_retrieved = created_at
74
+ end
75
+
76
+ @log.info 'sleep'
77
+ sleep interval
78
+ rescue Exception => e
79
+ @log.error e.inspect
80
+ e.backtrace.each do |l|
81
+ @log.error "\t#{l}"
82
+ end
83
+ sleep 10
84
+ end
85
+
91
86
  def reachable_url_for(latest_comment_url)
92
87
  repos_owner = latest_comment_url.match(/repos\/(.+?\/.+?)\//)[1]
93
88
  if issue_match = latest_comment_url.match(/(?:issues|pulls)\/(\d+?)$/)
data/lib/agig/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Agig
2
- VERSION = "0.1.5"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,392 @@
1
+ [
2
+ {
3
+ "id": "8335854",
4
+ "unread": true,
5
+ "reason": "subscribed",
6
+ "updated_at": "2013-10-11T23:31:04Z",
7
+ "last_read_at": "2013-10-11T20:57:20Z",
8
+ "subject": {
9
+ "title": "Read events from a database?",
10
+ "url": "https://api.github.com/repos/tomykaira/clockwork/issues/25",
11
+ "latest_comment_url": "https://api.github.com/repos/tomykaira/clockwork/issues/comments/26182644",
12
+ "type": "Issue"
13
+ },
14
+ "repository": {
15
+ "id": 2555236,
16
+ "name": "clockwork",
17
+ "full_name": "tomykaira/clockwork",
18
+ "owner": {
19
+ "login": "tomykaira",
20
+ "id": 789929,
21
+ "avatar_url": "https://1.gravatar.com/avatar/196fcecb9032f580dbed8d06a3aac090?d=https%3A%2F%2Fidenticons.github.com%2Fb5d0460763b00ef426c164d1dc4e8301.png",
22
+ "gravatar_id": "196fcecb9032f580dbed8d06a3aac090",
23
+ "url": "https://api.github.com/users/tomykaira",
24
+ "html_url": "https://github.com/tomykaira",
25
+ "followers_url": "https://api.github.com/users/tomykaira/followers",
26
+ "following_url": "https://api.github.com/users/tomykaira/following{/other_user}",
27
+ "gists_url": "https://api.github.com/users/tomykaira/gists{/gist_id}",
28
+ "starred_url": "https://api.github.com/users/tomykaira/starred{/owner}{/repo}",
29
+ "subscriptions_url": "https://api.github.com/users/tomykaira/subscriptions",
30
+ "organizations_url": "https://api.github.com/users/tomykaira/orgs",
31
+ "repos_url": "https://api.github.com/users/tomykaira/repos",
32
+ "events_url": "https://api.github.com/users/tomykaira/events{/privacy}",
33
+ "received_events_url": "https://api.github.com/users/tomykaira/received_events",
34
+ "type": "User",
35
+ "site_admin": false
36
+ },
37
+ "private": false,
38
+ "html_url": "https://github.com/tomykaira/clockwork",
39
+ "description": "A scheduler process to replace cron.",
40
+ "fork": true,
41
+ "url": "https://api.github.com/repos/tomykaira/clockwork",
42
+ "forks_url": "https://api.github.com/repos/tomykaira/clockwork/forks",
43
+ "keys_url": "https://api.github.com/repos/tomykaira/clockwork/keys{/key_id}",
44
+ "collaborators_url": "https://api.github.com/repos/tomykaira/clockwork/collaborators{/collaborator}",
45
+ "teams_url": "https://api.github.com/repos/tomykaira/clockwork/teams",
46
+ "hooks_url": "https://api.github.com/repos/tomykaira/clockwork/hooks",
47
+ "issue_events_url": "https://api.github.com/repos/tomykaira/clockwork/issues/events{/number}",
48
+ "events_url": "https://api.github.com/repos/tomykaira/clockwork/events",
49
+ "assignees_url": "https://api.github.com/repos/tomykaira/clockwork/assignees{/user}",
50
+ "branches_url": "https://api.github.com/repos/tomykaira/clockwork/branches{/branch}",
51
+ "tags_url": "https://api.github.com/repos/tomykaira/clockwork/tags",
52
+ "blobs_url": "https://api.github.com/repos/tomykaira/clockwork/git/blobs{/sha}",
53
+ "git_tags_url": "https://api.github.com/repos/tomykaira/clockwork/git/tags{/sha}",
54
+ "git_refs_url": "https://api.github.com/repos/tomykaira/clockwork/git/refs{/sha}",
55
+ "trees_url": "https://api.github.com/repos/tomykaira/clockwork/git/trees{/sha}",
56
+ "statuses_url": "https://api.github.com/repos/tomykaira/clockwork/statuses/{sha}",
57
+ "languages_url": "https://api.github.com/repos/tomykaira/clockwork/languages",
58
+ "stargazers_url": "https://api.github.com/repos/tomykaira/clockwork/stargazers",
59
+ "contributors_url": "https://api.github.com/repos/tomykaira/clockwork/contributors",
60
+ "subscribers_url": "https://api.github.com/repos/tomykaira/clockwork/subscribers",
61
+ "subscription_url": "https://api.github.com/repos/tomykaira/clockwork/subscription",
62
+ "commits_url": "https://api.github.com/repos/tomykaira/clockwork/commits{/sha}",
63
+ "git_commits_url": "https://api.github.com/repos/tomykaira/clockwork/git/commits{/sha}",
64
+ "comments_url": "https://api.github.com/repos/tomykaira/clockwork/comments{/number}",
65
+ "issue_comment_url": "https://api.github.com/repos/tomykaira/clockwork/issues/comments/{number}",
66
+ "contents_url": "https://api.github.com/repos/tomykaira/clockwork/contents/{+path}",
67
+ "compare_url": "https://api.github.com/repos/tomykaira/clockwork/compare/{base}...{head}",
68
+ "merges_url": "https://api.github.com/repos/tomykaira/clockwork/merges",
69
+ "archive_url": "https://api.github.com/repos/tomykaira/clockwork/{archive_format}{/ref}",
70
+ "downloads_url": "https://api.github.com/repos/tomykaira/clockwork/downloads",
71
+ "issues_url": "https://api.github.com/repos/tomykaira/clockwork/issues{/number}",
72
+ "pulls_url": "https://api.github.com/repos/tomykaira/clockwork/pulls{/number}",
73
+ "milestones_url": "https://api.github.com/repos/tomykaira/clockwork/milestones{/number}",
74
+ "notifications_url": "https://api.github.com/repos/tomykaira/clockwork/notifications{?since,all,participating}",
75
+ "labels_url": "https://api.github.com/repos/tomykaira/clockwork/labels{/name}"
76
+ },
77
+ "url": "https://api.github.com/notifications/threads/8335854",
78
+ "subscription_url": "https://api.github.com/notifications/threads/8335854/subscription"
79
+ },
80
+ {
81
+ "id": "18296091",
82
+ "unread": true,
83
+ "reason": "subscribed",
84
+ "updated_at": "2013-10-11T23:30:39Z",
85
+ "last_read_at": null,
86
+ "subject": {
87
+ "title": "Feature/last attempt message",
88
+ "url": "https://api.github.com/repos/plataformatec/devise/pulls/2682",
89
+ "latest_comment_url": "https://api.github.com/repos/plataformatec/devise/pulls/2682",
90
+ "type": "PullRequest"
91
+ },
92
+ "repository": {
93
+ "id": 308770,
94
+ "name": "devise",
95
+ "full_name": "plataformatec/devise",
96
+ "owner": {
97
+ "login": "plataformatec",
98
+ "id": 127679,
99
+ "avatar_url": "https://2.gravatar.com/avatar/7c12adb8b5521c060ab4630360a4fa27?d=https%3A%2F%2Fidenticons.github.com%2Fa248316fb518936eeae7161fd0a823f5.png",
100
+ "gravatar_id": "7c12adb8b5521c060ab4630360a4fa27",
101
+ "url": "https://api.github.com/users/plataformatec",
102
+ "html_url": "https://github.com/plataformatec",
103
+ "followers_url": "https://api.github.com/users/plataformatec/followers",
104
+ "following_url": "https://api.github.com/users/plataformatec/following{/other_user}",
105
+ "gists_url": "https://api.github.com/users/plataformatec/gists{/gist_id}",
106
+ "starred_url": "https://api.github.com/users/plataformatec/starred{/owner}{/repo}",
107
+ "subscriptions_url": "https://api.github.com/users/plataformatec/subscriptions",
108
+ "organizations_url": "https://api.github.com/users/plataformatec/orgs",
109
+ "repos_url": "https://api.github.com/users/plataformatec/repos",
110
+ "events_url": "https://api.github.com/users/plataformatec/events{/privacy}",
111
+ "received_events_url": "https://api.github.com/users/plataformatec/received_events",
112
+ "type": "Organization",
113
+ "site_admin": false
114
+ },
115
+ "private": false,
116
+ "html_url": "https://github.com/plataformatec/devise",
117
+ "description": "Flexible authentication solution for Rails with Warden.",
118
+ "fork": false,
119
+ "url": "https://api.github.com/repos/plataformatec/devise",
120
+ "forks_url": "https://api.github.com/repos/plataformatec/devise/forks",
121
+ "keys_url": "https://api.github.com/repos/plataformatec/devise/keys{/key_id}",
122
+ "collaborators_url": "https://api.github.com/repos/plataformatec/devise/collaborators{/collaborator}",
123
+ "teams_url": "https://api.github.com/repos/plataformatec/devise/teams",
124
+ "hooks_url": "https://api.github.com/repos/plataformatec/devise/hooks",
125
+ "issue_events_url": "https://api.github.com/repos/plataformatec/devise/issues/events{/number}",
126
+ "events_url": "https://api.github.com/repos/plataformatec/devise/events",
127
+ "assignees_url": "https://api.github.com/repos/plataformatec/devise/assignees{/user}",
128
+ "branches_url": "https://api.github.com/repos/plataformatec/devise/branches{/branch}",
129
+ "tags_url": "https://api.github.com/repos/plataformatec/devise/tags",
130
+ "blobs_url": "https://api.github.com/repos/plataformatec/devise/git/blobs{/sha}",
131
+ "git_tags_url": "https://api.github.com/repos/plataformatec/devise/git/tags{/sha}",
132
+ "git_refs_url": "https://api.github.com/repos/plataformatec/devise/git/refs{/sha}",
133
+ "trees_url": "https://api.github.com/repos/plataformatec/devise/git/trees{/sha}",
134
+ "statuses_url": "https://api.github.com/repos/plataformatec/devise/statuses/{sha}",
135
+ "languages_url": "https://api.github.com/repos/plataformatec/devise/languages",
136
+ "stargazers_url": "https://api.github.com/repos/plataformatec/devise/stargazers",
137
+ "contributors_url": "https://api.github.com/repos/plataformatec/devise/contributors",
138
+ "subscribers_url": "https://api.github.com/repos/plataformatec/devise/subscribers",
139
+ "subscription_url": "https://api.github.com/repos/plataformatec/devise/subscription",
140
+ "commits_url": "https://api.github.com/repos/plataformatec/devise/commits{/sha}",
141
+ "git_commits_url": "https://api.github.com/repos/plataformatec/devise/git/commits{/sha}",
142
+ "comments_url": "https://api.github.com/repos/plataformatec/devise/comments{/number}",
143
+ "issue_comment_url": "https://api.github.com/repos/plataformatec/devise/issues/comments/{number}",
144
+ "contents_url": "https://api.github.com/repos/plataformatec/devise/contents/{+path}",
145
+ "compare_url": "https://api.github.com/repos/plataformatec/devise/compare/{base}...{head}",
146
+ "merges_url": "https://api.github.com/repos/plataformatec/devise/merges",
147
+ "archive_url": "https://api.github.com/repos/plataformatec/devise/{archive_format}{/ref}",
148
+ "downloads_url": "https://api.github.com/repos/plataformatec/devise/downloads",
149
+ "issues_url": "https://api.github.com/repos/plataformatec/devise/issues{/number}",
150
+ "pulls_url": "https://api.github.com/repos/plataformatec/devise/pulls{/number}",
151
+ "milestones_url": "https://api.github.com/repos/plataformatec/devise/milestones{/number}",
152
+ "notifications_url": "https://api.github.com/repos/plataformatec/devise/notifications{?since,all,participating}",
153
+ "labels_url": "https://api.github.com/repos/plataformatec/devise/labels{/name}"
154
+ },
155
+ "url": "https://api.github.com/notifications/threads/18296091",
156
+ "subscription_url": "https://api.github.com/notifications/threads/18296091/subscription"
157
+ },
158
+ {
159
+ "id": "18293519",
160
+ "unread": true,
161
+ "reason": "subscribed",
162
+ "updated_at": "2013-10-11T22:50:02Z",
163
+ "last_read_at": null,
164
+ "subject": {
165
+ "title": "confirmation_sent_at attribute is populated on resource creation when skip_confirmation_notification! is enabled ",
166
+ "url": "https://api.github.com/repos/plataformatec/devise/issues/2681",
167
+ "latest_comment_url": "https://api.github.com/repos/plataformatec/devise/issues/comments/26180460",
168
+ "type": "Issue"
169
+ },
170
+ "repository": {
171
+ "id": 308770,
172
+ "name": "devise",
173
+ "full_name": "plataformatec/devise",
174
+ "owner": {
175
+ "login": "plataformatec",
176
+ "id": 127679,
177
+ "avatar_url": "https://2.gravatar.com/avatar/7c12adb8b5521c060ab4630360a4fa27?d=https%3A%2F%2Fidenticons.github.com%2Fa248316fb518936eeae7161fd0a823f5.png",
178
+ "gravatar_id": "7c12adb8b5521c060ab4630360a4fa27",
179
+ "url": "https://api.github.com/users/plataformatec",
180
+ "html_url": "https://github.com/plataformatec",
181
+ "followers_url": "https://api.github.com/users/plataformatec/followers",
182
+ "following_url": "https://api.github.com/users/plataformatec/following{/other_user}",
183
+ "gists_url": "https://api.github.com/users/plataformatec/gists{/gist_id}",
184
+ "starred_url": "https://api.github.com/users/plataformatec/starred{/owner}{/repo}",
185
+ "subscriptions_url": "https://api.github.com/users/plataformatec/subscriptions",
186
+ "organizations_url": "https://api.github.com/users/plataformatec/orgs",
187
+ "repos_url": "https://api.github.com/users/plataformatec/repos",
188
+ "events_url": "https://api.github.com/users/plataformatec/events{/privacy}",
189
+ "received_events_url": "https://api.github.com/users/plataformatec/received_events",
190
+ "type": "Organization",
191
+ "site_admin": false
192
+ },
193
+ "private": false,
194
+ "html_url": "https://github.com/plataformatec/devise",
195
+ "description": "Flexible authentication solution for Rails with Warden.",
196
+ "fork": false,
197
+ "url": "https://api.github.com/repos/plataformatec/devise",
198
+ "forks_url": "https://api.github.com/repos/plataformatec/devise/forks",
199
+ "keys_url": "https://api.github.com/repos/plataformatec/devise/keys{/key_id}",
200
+ "collaborators_url": "https://api.github.com/repos/plataformatec/devise/collaborators{/collaborator}",
201
+ "teams_url": "https://api.github.com/repos/plataformatec/devise/teams",
202
+ "hooks_url": "https://api.github.com/repos/plataformatec/devise/hooks",
203
+ "issue_events_url": "https://api.github.com/repos/plataformatec/devise/issues/events{/number}",
204
+ "events_url": "https://api.github.com/repos/plataformatec/devise/events",
205
+ "assignees_url": "https://api.github.com/repos/plataformatec/devise/assignees{/user}",
206
+ "branches_url": "https://api.github.com/repos/plataformatec/devise/branches{/branch}",
207
+ "tags_url": "https://api.github.com/repos/plataformatec/devise/tags",
208
+ "blobs_url": "https://api.github.com/repos/plataformatec/devise/git/blobs{/sha}",
209
+ "git_tags_url": "https://api.github.com/repos/plataformatec/devise/git/tags{/sha}",
210
+ "git_refs_url": "https://api.github.com/repos/plataformatec/devise/git/refs{/sha}",
211
+ "trees_url": "https://api.github.com/repos/plataformatec/devise/git/trees{/sha}",
212
+ "statuses_url": "https://api.github.com/repos/plataformatec/devise/statuses/{sha}",
213
+ "languages_url": "https://api.github.com/repos/plataformatec/devise/languages",
214
+ "stargazers_url": "https://api.github.com/repos/plataformatec/devise/stargazers",
215
+ "contributors_url": "https://api.github.com/repos/plataformatec/devise/contributors",
216
+ "subscribers_url": "https://api.github.com/repos/plataformatec/devise/subscribers",
217
+ "subscription_url": "https://api.github.com/repos/plataformatec/devise/subscription",
218
+ "commits_url": "https://api.github.com/repos/plataformatec/devise/commits{/sha}",
219
+ "git_commits_url": "https://api.github.com/repos/plataformatec/devise/git/commits{/sha}",
220
+ "comments_url": "https://api.github.com/repos/plataformatec/devise/comments{/number}",
221
+ "issue_comment_url": "https://api.github.com/repos/plataformatec/devise/issues/comments/{number}",
222
+ "contents_url": "https://api.github.com/repos/plataformatec/devise/contents/{+path}",
223
+ "compare_url": "https://api.github.com/repos/plataformatec/devise/compare/{base}...{head}",
224
+ "merges_url": "https://api.github.com/repos/plataformatec/devise/merges",
225
+ "archive_url": "https://api.github.com/repos/plataformatec/devise/{archive_format}{/ref}",
226
+ "downloads_url": "https://api.github.com/repos/plataformatec/devise/downloads",
227
+ "issues_url": "https://api.github.com/repos/plataformatec/devise/issues{/number}",
228
+ "pulls_url": "https://api.github.com/repos/plataformatec/devise/pulls{/number}",
229
+ "milestones_url": "https://api.github.com/repos/plataformatec/devise/milestones{/number}",
230
+ "notifications_url": "https://api.github.com/repos/plataformatec/devise/notifications{?since,all,participating}",
231
+ "labels_url": "https://api.github.com/repos/plataformatec/devise/labels{/name}"
232
+ },
233
+ "url": "https://api.github.com/notifications/threads/18293519",
234
+ "subscription_url": "https://api.github.com/notifications/threads/18293519/subscription"
235
+ },
236
+ {
237
+ "id": "17313842",
238
+ "unread": true,
239
+ "reason": "subscribed",
240
+ "updated_at": "2013-10-11T19:31:54Z",
241
+ "last_read_at": "2013-10-01T01:56:51Z",
242
+ "subject": {
243
+ "title": "undefined method `add_attachment'",
244
+ "url": "https://api.github.com/repos/thoughtbot/paperclip/issues/1351",
245
+ "latest_comment_url": "https://api.github.com/repos/thoughtbot/paperclip/issues/comments/26165322",
246
+ "type": "Issue"
247
+ },
248
+ "repository": {
249
+ "id": 8393,
250
+ "name": "paperclip",
251
+ "full_name": "thoughtbot/paperclip",
252
+ "owner": {
253
+ "login": "thoughtbot",
254
+ "id": 6183,
255
+ "avatar_url": "https://1.gravatar.com/avatar/a95a04df2dae60397c38c9bd04492c53?d=https%3A%2F%2Fidenticons.github.com%2Fc14a2a57ead18f3532a5a8949382c536.png",
256
+ "gravatar_id": "a95a04df2dae60397c38c9bd04492c53",
257
+ "url": "https://api.github.com/users/thoughtbot",
258
+ "html_url": "https://github.com/thoughtbot",
259
+ "followers_url": "https://api.github.com/users/thoughtbot/followers",
260
+ "following_url": "https://api.github.com/users/thoughtbot/following{/other_user}",
261
+ "gists_url": "https://api.github.com/users/thoughtbot/gists{/gist_id}",
262
+ "starred_url": "https://api.github.com/users/thoughtbot/starred{/owner}{/repo}",
263
+ "subscriptions_url": "https://api.github.com/users/thoughtbot/subscriptions",
264
+ "organizations_url": "https://api.github.com/users/thoughtbot/orgs",
265
+ "repos_url": "https://api.github.com/users/thoughtbot/repos",
266
+ "events_url": "https://api.github.com/users/thoughtbot/events{/privacy}",
267
+ "received_events_url": "https://api.github.com/users/thoughtbot/received_events",
268
+ "type": "Organization",
269
+ "site_admin": false
270
+ },
271
+ "private": false,
272
+ "html_url": "https://github.com/thoughtbot/paperclip",
273
+ "description": "Easy file attachment management for ActiveRecord",
274
+ "fork": false,
275
+ "url": "https://api.github.com/repos/thoughtbot/paperclip",
276
+ "forks_url": "https://api.github.com/repos/thoughtbot/paperclip/forks",
277
+ "keys_url": "https://api.github.com/repos/thoughtbot/paperclip/keys{/key_id}",
278
+ "collaborators_url": "https://api.github.com/repos/thoughtbot/paperclip/collaborators{/collaborator}",
279
+ "teams_url": "https://api.github.com/repos/thoughtbot/paperclip/teams",
280
+ "hooks_url": "https://api.github.com/repos/thoughtbot/paperclip/hooks",
281
+ "issue_events_url": "https://api.github.com/repos/thoughtbot/paperclip/issues/events{/number}",
282
+ "events_url": "https://api.github.com/repos/thoughtbot/paperclip/events",
283
+ "assignees_url": "https://api.github.com/repos/thoughtbot/paperclip/assignees{/user}",
284
+ "branches_url": "https://api.github.com/repos/thoughtbot/paperclip/branches{/branch}",
285
+ "tags_url": "https://api.github.com/repos/thoughtbot/paperclip/tags",
286
+ "blobs_url": "https://api.github.com/repos/thoughtbot/paperclip/git/blobs{/sha}",
287
+ "git_tags_url": "https://api.github.com/repos/thoughtbot/paperclip/git/tags{/sha}",
288
+ "git_refs_url": "https://api.github.com/repos/thoughtbot/paperclip/git/refs{/sha}",
289
+ "trees_url": "https://api.github.com/repos/thoughtbot/paperclip/git/trees{/sha}",
290
+ "statuses_url": "https://api.github.com/repos/thoughtbot/paperclip/statuses/{sha}",
291
+ "languages_url": "https://api.github.com/repos/thoughtbot/paperclip/languages",
292
+ "stargazers_url": "https://api.github.com/repos/thoughtbot/paperclip/stargazers",
293
+ "contributors_url": "https://api.github.com/repos/thoughtbot/paperclip/contributors",
294
+ "subscribers_url": "https://api.github.com/repos/thoughtbot/paperclip/subscribers",
295
+ "subscription_url": "https://api.github.com/repos/thoughtbot/paperclip/subscription",
296
+ "commits_url": "https://api.github.com/repos/thoughtbot/paperclip/commits{/sha}",
297
+ "git_commits_url": "https://api.github.com/repos/thoughtbot/paperclip/git/commits{/sha}",
298
+ "comments_url": "https://api.github.com/repos/thoughtbot/paperclip/comments{/number}",
299
+ "issue_comment_url": "https://api.github.com/repos/thoughtbot/paperclip/issues/comments/{number}",
300
+ "contents_url": "https://api.github.com/repos/thoughtbot/paperclip/contents/{+path}",
301
+ "compare_url": "https://api.github.com/repos/thoughtbot/paperclip/compare/{base}...{head}",
302
+ "merges_url": "https://api.github.com/repos/thoughtbot/paperclip/merges",
303
+ "archive_url": "https://api.github.com/repos/thoughtbot/paperclip/{archive_format}{/ref}",
304
+ "downloads_url": "https://api.github.com/repos/thoughtbot/paperclip/downloads",
305
+ "issues_url": "https://api.github.com/repos/thoughtbot/paperclip/issues{/number}",
306
+ "pulls_url": "https://api.github.com/repos/thoughtbot/paperclip/pulls{/number}",
307
+ "milestones_url": "https://api.github.com/repos/thoughtbot/paperclip/milestones{/number}",
308
+ "notifications_url": "https://api.github.com/repos/thoughtbot/paperclip/notifications{?since,all,participating}",
309
+ "labels_url": "https://api.github.com/repos/thoughtbot/paperclip/labels{/name}"
310
+ },
311
+ "url": "https://api.github.com/notifications/threads/17313842",
312
+ "subscription_url": "https://api.github.com/notifications/threads/17313842/subscription"
313
+ },
314
+ {
315
+ "id": "18095169",
316
+ "unread": true,
317
+ "reason": "subscribed",
318
+ "updated_at": "2013-10-09T02:53:26Z",
319
+ "last_read_at": "2013-10-10T00:32:29Z",
320
+ "subject": {
321
+ "title": "Edit account w/o PW",
322
+ "url": "https://api.github.com/repos/plataformatec/devise/issues/2677",
323
+ "latest_comment_url": "https://api.github.com/repos/plataformatec/devise/issues/comments/25986220",
324
+ "type": "Issue"
325
+ },
326
+ "repository": {
327
+ "id": 308770,
328
+ "name": "devise",
329
+ "full_name": "plataformatec/devise",
330
+ "owner": {
331
+ "login": "plataformatec",
332
+ "id": 127679,
333
+ "avatar_url": "https://2.gravatar.com/avatar/7c12adb8b5521c060ab4630360a4fa27?d=https%3A%2F%2Fidenticons.github.com%2Fa248316fb518936eeae7161fd0a823f5.png",
334
+ "gravatar_id": "7c12adb8b5521c060ab4630360a4fa27",
335
+ "url": "https://api.github.com/users/plataformatec",
336
+ "html_url": "https://github.com/plataformatec",
337
+ "followers_url": "https://api.github.com/users/plataformatec/followers",
338
+ "following_url": "https://api.github.com/users/plataformatec/following{/other_user}",
339
+ "gists_url": "https://api.github.com/users/plataformatec/gists{/gist_id}",
340
+ "starred_url": "https://api.github.com/users/plataformatec/starred{/owner}{/repo}",
341
+ "subscriptions_url": "https://api.github.com/users/plataformatec/subscriptions",
342
+ "organizations_url": "https://api.github.com/users/plataformatec/orgs",
343
+ "repos_url": "https://api.github.com/users/plataformatec/repos",
344
+ "events_url": "https://api.github.com/users/plataformatec/events{/privacy}",
345
+ "received_events_url": "https://api.github.com/users/plataformatec/received_events",
346
+ "type": "Organization",
347
+ "site_admin": false
348
+ },
349
+ "private": false,
350
+ "html_url": "https://github.com/plataformatec/devise",
351
+ "description": "Flexible authentication solution for Rails with Warden.",
352
+ "fork": false,
353
+ "url": "https://api.github.com/repos/plataformatec/devise",
354
+ "forks_url": "https://api.github.com/repos/plataformatec/devise/forks",
355
+ "keys_url": "https://api.github.com/repos/plataformatec/devise/keys{/key_id}",
356
+ "collaborators_url": "https://api.github.com/repos/plataformatec/devise/collaborators{/collaborator}",
357
+ "teams_url": "https://api.github.com/repos/plataformatec/devise/teams",
358
+ "hooks_url": "https://api.github.com/repos/plataformatec/devise/hooks",
359
+ "issue_events_url": "https://api.github.com/repos/plataformatec/devise/issues/events{/number}",
360
+ "events_url": "https://api.github.com/repos/plataformatec/devise/events",
361
+ "assignees_url": "https://api.github.com/repos/plataformatec/devise/assignees{/user}",
362
+ "branches_url": "https://api.github.com/repos/plataformatec/devise/branches{/branch}",
363
+ "tags_url": "https://api.github.com/repos/plataformatec/devise/tags",
364
+ "blobs_url": "https://api.github.com/repos/plataformatec/devise/git/blobs{/sha}",
365
+ "git_tags_url": "https://api.github.com/repos/plataformatec/devise/git/tags{/sha}",
366
+ "git_refs_url": "https://api.github.com/repos/plataformatec/devise/git/refs{/sha}",
367
+ "trees_url": "https://api.github.com/repos/plataformatec/devise/git/trees{/sha}",
368
+ "statuses_url": "https://api.github.com/repos/plataformatec/devise/statuses/{sha}",
369
+ "languages_url": "https://api.github.com/repos/plataformatec/devise/languages",
370
+ "stargazers_url": "https://api.github.com/repos/plataformatec/devise/stargazers",
371
+ "contributors_url": "https://api.github.com/repos/plataformatec/devise/contributors",
372
+ "subscribers_url": "https://api.github.com/repos/plataformatec/devise/subscribers",
373
+ "subscription_url": "https://api.github.com/repos/plataformatec/devise/subscription",
374
+ "commits_url": "https://api.github.com/repos/plataformatec/devise/commits{/sha}",
375
+ "git_commits_url": "https://api.github.com/repos/plataformatec/devise/git/commits{/sha}",
376
+ "comments_url": "https://api.github.com/repos/plataformatec/devise/comments{/number}",
377
+ "issue_comment_url": "https://api.github.com/repos/plataformatec/devise/issues/comments/{number}",
378
+ "contents_url": "https://api.github.com/repos/plataformatec/devise/contents/{+path}",
379
+ "compare_url": "https://api.github.com/repos/plataformatec/devise/compare/{base}...{head}",
380
+ "merges_url": "https://api.github.com/repos/plataformatec/devise/merges",
381
+ "archive_url": "https://api.github.com/repos/plataformatec/devise/{archive_format}{/ref}",
382
+ "downloads_url": "https://api.github.com/repos/plataformatec/devise/downloads",
383
+ "issues_url": "https://api.github.com/repos/plataformatec/devise/issues{/number}",
384
+ "pulls_url": "https://api.github.com/repos/plataformatec/devise/pulls{/number}",
385
+ "milestones_url": "https://api.github.com/repos/plataformatec/devise/milestones{/number}",
386
+ "notifications_url": "https://api.github.com/repos/plataformatec/devise/notifications{?since,all,participating}",
387
+ "labels_url": "https://api.github.com/repos/plataformatec/devise/labels{/name}"
388
+ },
389
+ "url": "https://api.github.com/notifications/threads/18095169",
390
+ "subscription_url": "https://api.github.com/notifications/threads/18095169/subscription"
391
+ }
392
+ ]
@@ -0,0 +1,103 @@
1
+ [
2
+ {
3
+ "id": "1856134334",
4
+ "type": "WatchEvent",
5
+ "actor": {
6
+ "id": 222272,
7
+ "login": "AquarHEAD",
8
+ "gravatar_id": "55726c206ec597ea0e33fa04ce6b3110",
9
+ "url": "https://api.github.com/users/AquarHEAD",
10
+ "avatar_url": "https://1.gravatar.com/avatar/55726c206ec597ea0e33fa04ce6b3110?d=https%3A%2F%2Fa248.e.akamai.net%2Fassets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png"
11
+ },
12
+ "repo": {
13
+ "id": 7530454,
14
+ "name": "octokit/octokit.objc",
15
+ "url": "https://api.github.com/repos/octokit/octokit.objc"
16
+ },
17
+ "payload": {
18
+ "action": "started"
19
+ },
20
+ "public": true,
21
+ "created_at": "2013-10-12T00:31:17Z",
22
+ "org": {
23
+ "id": 3430433,
24
+ "login": "octokit",
25
+ "gravatar_id": "43f38795089d56a2a7092b7d0c71fa76",
26
+ "url": "https://api.github.com/orgs/octokit",
27
+ "avatar_url": "https://2.gravatar.com/avatar/43f38795089d56a2a7092b7d0c71fa76?d=https%3A%2F%2Fa248.e.akamai.net%2Fassets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png"
28
+ }
29
+ },
30
+ {
31
+ "id": "1855864567",
32
+ "type": "PushEvent",
33
+ "actor": {
34
+ "id": 432536,
35
+ "login": "jspahrsummers",
36
+ "gravatar_id": "cac992bb300ed4f3ed5c2a6049e552f9",
37
+ "url": "https://api.github.com/users/jspahrsummers",
38
+ "avatar_url": "https://2.gravatar.com/avatar/cac992bb300ed4f3ed5c2a6049e552f9?d=https%3A%2F%2Fa248.e.akamai.net%2Fassets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png"
39
+ },
40
+ "repo": {
41
+ "id": 7530454,
42
+ "name": "octokit/octokit.objc",
43
+ "url": "https://api.github.com/repos/octokit/octokit.objc"
44
+ },
45
+ "payload": {
46
+ "push_id": 242893644,
47
+ "size": 1,
48
+ "distinct_size": 1,
49
+ "ref": "refs/heads/master",
50
+ "head": "8fea084634887589a64aa13899bdd29051b5e0df",
51
+ "before": "99323f569590595331c9aa1ca8b9048cd22adb74",
52
+ "commits": [
53
+ {
54
+ "sha": "8fea084634887589a64aa13899bdd29051b5e0df",
55
+ "author": {
56
+ "email": "Justin.SpahrSummers@gmail.com",
57
+ "name": "Justin Spahr-Summers"
58
+ },
59
+ "message": "++RAC to v2.1.2",
60
+ "distinct": true,
61
+ "url": "https://api.github.com/repos/octokit/octokit.objc/commits/8fea084634887589a64aa13899bdd29051b5e0df"
62
+ }
63
+ ]
64
+ },
65
+ "public": true,
66
+ "created_at": "2013-10-11T19:05:15Z",
67
+ "org": {
68
+ "id": 3430433,
69
+ "login": "octokit",
70
+ "gravatar_id": "43f38795089d56a2a7092b7d0c71fa76",
71
+ "url": "https://api.github.com/orgs/octokit",
72
+ "avatar_url": "https://2.gravatar.com/avatar/43f38795089d56a2a7092b7d0c71fa76?d=https%3A%2F%2Fa248.e.akamai.net%2Fassets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png"
73
+ }
74
+ },
75
+ {
76
+ "id": "1855466235",
77
+ "type": "WatchEvent",
78
+ "actor": {
79
+ "id": 53949,
80
+ "login": "julienXX",
81
+ "gravatar_id": "c0390c7b2467df3df2c3c3d6b09b8297",
82
+ "url": "https://api.github.com/users/julienXX",
83
+ "avatar_url": "https://1.gravatar.com/avatar/c0390c7b2467df3df2c3c3d6b09b8297?d=https%3A%2F%2Fa248.e.akamai.net%2Fassets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png"
84
+ },
85
+ "repo": {
86
+ "id": 7530454,
87
+ "name": "octokit/octokit.objc",
88
+ "url": "https://api.github.com/repos/octokit/octokit.objc"
89
+ },
90
+ "payload": {
91
+ "action": "started"
92
+ },
93
+ "public": true,
94
+ "created_at": "2013-10-11T12:40:06Z",
95
+ "org": {
96
+ "id": 3430433,
97
+ "login": "octokit",
98
+ "gravatar_id": "43f38795089d56a2a7092b7d0c71fa76",
99
+ "url": "https://api.github.com/orgs/octokit",
100
+ "avatar_url": "https://2.gravatar.com/avatar/43f38795089d56a2a7092b7d0c71fa76?d=https%3A%2F%2Fa248.e.akamai.net%2Fassets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png"
101
+ }
102
+ }
103
+ ]
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ require File.expand_path('../../../spec_helper', __FILE__)
3
+
4
+ describe Agig::OptParser do
5
+
6
+ describe '#self.cast' do
7
+ let(:opts) { { host: "localhost" } }
8
+ subject { Agig::OptParser.cast opts }
9
+
10
+ context 'when string given' do
11
+ it { expect(subject[:host]).to be_an_instance_of String }
12
+ end
13
+ context 'when digit in first letter given' do
14
+ let(:opts) { { port: "16705" } }
15
+ it { expect(subject[:port]).to be_an_instance_of Fixnum }
16
+ end
17
+ context 'when decimal in first letter given' do
18
+ let(:opts) { { interval: "60.5" } }
19
+ it { expect(subject[:interval]).to be_an_instance_of Float }
20
+ end
21
+ context 'when nil given' do
22
+ let(:opts) { { log: nil } }
23
+ it { expect(subject[:log]).to be_truthy }
24
+ end
25
+ context 'when true given' do
26
+ let(:opts) { { debug: true } }
27
+ it { expect(subject[:debug]).to be_truthy }
28
+ end
29
+ context 'when false given' do
30
+ let(:opts) { { foreground: false } }
31
+ it { expect(subject[:foreground]).to be_falsey }
32
+ end
33
+ end
34
+
35
+ end
@@ -1,21 +1,77 @@
1
1
  # coding: utf-8
2
2
  require File.expand_path('../../../spec_helper', __FILE__)
3
+ require 'logger'
3
4
 
4
5
  describe Agig::Session do
6
+
7
+ let :log do
8
+ StringIO.new
9
+ end
10
+
11
+ let :oauth_token do
12
+ 'OAUTH_TOKEN_DUMMY'
13
+ end
14
+
5
15
  before do
6
- @session = described_class.new('localhost', nil, nil)
16
+ octokit_client = Octokit::Client.new(oauth_token: oauth_token)
17
+ @session = described_class.new('localhost', nil, Logger.new(log))
18
+ @session.instance_variable_set(:@client, octokit_client)
19
+ end
20
+
21
+ describe '#retrieve' do
22
+ let :long_time_ago do
23
+ Time.parse('Jan 1 2010')
24
+ end
25
+
26
+ before do
27
+ allow(@session).to receive(:reachable_url_for).and_return('')
28
+
29
+ %w(/notifications?all=true /user/received_events).each do |path|
30
+ stub_request(:get, "https://api.github.com#{path}")
31
+ .to_return(
32
+ status: 200,
33
+ headers: { 'Content-Type' => 'application/json; charset=utf-8' },
34
+ body: open("#{fixture_path}#{path}.json").read)
35
+ end
36
+ end
37
+
38
+ context 'When notifications have not been retrieved for a long time' do
39
+ before do
40
+ @session.instance_variable_set(:@notification_last_retrieved, long_time_ago)
41
+ end
42
+
43
+ it do
44
+ expect(@session).to \
45
+ receive(:post).with(anything(), anything(), '#notification', anything())
46
+ .exactly(5).times
47
+ @session.send(:retrieve, 0)
48
+ end
49
+ end
50
+
51
+ context 'When watches have not been retrieved for a long time' do
52
+ before do
53
+ @session.instance_variable_set(:@watch_last_retrieved, long_time_ago)
54
+ end
55
+
56
+ it do
57
+ expect(@session).to \
58
+ receive(:post).with(anything(), anything(), '#watch', anything())
59
+ .exactly(2).times
60
+ @session.send(:retrieve, 0)
61
+ end
62
+ end
7
63
  end
8
64
 
9
65
  describe '#reachable_url_for' do
10
- subject { @session.reachable_url_for(latest_comment_url) }
66
+ subject { @session.send(:reachable_url_for, latest_comment_url) }
11
67
 
12
68
  context 'When "https://api.github.com/repos/fastladder/fastladder/pulls/170" given' do
13
69
  before do
14
- @session.stub_chain(:client, :issue_comments).and_return([])
70
+ allow(@session).to receive_message_chain(:client, :issue_comments).and_return([])
15
71
  end
16
72
 
17
73
  let(:latest_comment_url) { 'https://api.github.com/repos/fastladder/fastladder/pulls/170' }
18
- it { should eq('https://github.com/fastladder/fastladder/pull/170') }
74
+ it { is_expected.to eq('https://github.com/fastladder/fastladder/pull/170') }
19
75
  end
20
76
  end
21
77
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,16 @@
1
1
  require 'bundler/setup'
2
+ require 'webmock/rspec'
3
+ require 'pry-byebug'
4
+
2
5
  require 'agig'
3
6
 
4
- RSpec.configure do |config|
7
+ def spec_path
8
+ File.dirname(__FILE__)
9
+ end
10
+
11
+ def fixture_path
12
+ spec_path + '/fixtures'
5
13
  end
14
+
15
+ require 'coveralls'
16
+ Coveralls.wear!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SHIBATA Hiroshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-26 00:00:00.000000000 Z
11
+ date: 2014-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-irc
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: json
28
+ name: string-irc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,35 +39,77 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: faraday
42
+ name: octokit
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.8.7
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.8.7
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: octokit
56
+ name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1.25'
62
- type: :runtime
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - "~>"
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: '1.25'
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry-byebug
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
69
111
  - !ruby/object:Gem::Dependency
70
- name: rspec
112
+ name: coveralls
71
113
  requirement: !ruby/object:Gem::Requirement
72
114
  requirements:
73
115
  - - ">="
@@ -90,6 +132,7 @@ extra_rdoc_files: []
90
132
  files:
91
133
  - ".gitignore"
92
134
  - ".rspec"
135
+ - ".travis.yml"
93
136
  - Gemfile
94
137
  - LICENSE
95
138
  - README.md
@@ -101,6 +144,9 @@ files:
101
144
  - lib/agig/optparse.rb
102
145
  - lib/agig/session.rb
103
146
  - lib/agig/version.rb
147
+ - spec/fixtures/notifications?all=true.json
148
+ - spec/fixtures/user/received_events.json
149
+ - spec/lib/agig/optparse_spec.rb
104
150
  - spec/lib/agig/session_spec.rb
105
151
  - spec/spec_helper.rb
106
152
  homepage: https://github.com/hsbt/agig
@@ -114,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
160
  requirements:
115
161
  - - ">="
116
162
  - !ruby/object:Gem::Version
117
- version: 1.9.2
163
+ version: 1.9.3
118
164
  required_rubygems_version: !ruby/object:Gem::Requirement
119
165
  requirements:
120
166
  - - ">="
@@ -122,12 +168,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
168
  version: '0'
123
169
  requirements: []
124
170
  rubyforge_project:
125
- rubygems_version: 2.1.3
171
+ rubygems_version: 2.4.4
126
172
  signing_key:
127
173
  specification_version: 4
128
174
  summary: agig is another Github IRC Gateway. agig is forked from gig.rb, and contained
129
175
  net-irc gems.
130
176
  test_files:
177
+ - spec/fixtures/notifications?all=true.json
178
+ - spec/fixtures/user/received_events.json
179
+ - spec/lib/agig/optparse_spec.rb
131
180
  - spec/lib/agig/session_spec.rb
132
181
  - spec/spec_helper.rb
133
182
  has_rdoc: