agig 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6a22b08f80d8b1e5d354479cf9954650c56ee0d6
4
+ data.tar.gz: ca2456f59d82696dfc188e5bb1bc7f2dde48fb7c
5
+ SHA512:
6
+ metadata.gz: de511993088e6600f796cef55ac1d07478b0da3c7b15b9a519af97f85653d1380f93dcd43caff8404edbce8fa22553359da6a25a8bdd0b909fc85555ac1147ca
7
+ data.tar.gz: f49693ef41268abd84d8ccc90a60b46405bd428235d7a281f797fc9e6fd5eede8a8b3d4bee755eebb74a502abdeaee34b26bf8a01d5e32c3fd41b4fd8a761921
@@ -8,6 +8,8 @@ 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
+
11
13
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
14
  gem.files = `git ls-files`.split("\n")
13
15
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -16,6 +18,6 @@ Gem::Specification.new do |gem|
16
18
  gem.version = Agig::VERSION
17
19
 
18
20
  gem.add_dependency 'net-irc'
19
- gem.add_dependency 'nokogiri'
20
- gem.add_dependency 'certified'
21
+ gem.add_dependency 'json'
22
+ gem.add_dependency 'octokit'
21
23
  end
@@ -1,12 +1,3 @@
1
- =begin
2
- # gig.rb
3
-
4
- Github IRC Gateway
5
-
6
- =end
7
-
8
- $KCODE = "u" unless defined? ::Encoding
9
-
10
1
  require "agig/version"
11
2
  require "agig/client"
12
3
  require "agig/optparse"
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'net/irc'
3
2
  require 'logger'
4
3
 
@@ -1,32 +1,9 @@
1
- require 'rubygems'
2
- require 'net/irc'
3
- require 'nokogiri'
4
- require 'certified'
5
-
6
- require 'open-uri'
7
1
  require 'ostruct'
8
2
  require 'time'
3
+ require 'net/irc'
4
+ require 'octokit'
9
5
 
10
6
  class Agig::Session < Net::IRC::Server::Session
11
- EVENTS = {
12
- 'DownloadEvent' => '6',
13
- 'GistEvent' => '10',
14
- 'WatchEvent' => '15',
15
- 'FollowEvent' => '15',
16
- 'CreateEvent' => '13',
17
- 'ForkEvent' => '3',
18
- 'PushEvent' => '14',
19
- }
20
-
21
- CHANNEL_SELECTOR = {
22
- 'GistEvent' => '#activity',
23
- 'ForkEvent' => '#activity',
24
- 'FollowEvent' => '#activity',
25
- 'WatchEvent' => '#activity',
26
- 'PullRequestEvent' => '#pull_requests',
27
- 'PullRequestReviewCommentEvent' => '#pull_requests',
28
- }
29
-
30
7
  def server_name
31
8
  "github"
32
9
  end
@@ -35,21 +12,17 @@ class Agig::Session < Net::IRC::Server::Session
35
12
  "0.0.0"
36
13
  end
37
14
 
38
- def main_channel
39
- @opts.main_channel || "#github"
40
- end
41
-
42
- def channels
43
- CHANNEL_SELECTOR.values.uniq << main_channel
44
- end
45
-
46
- def channel(type)
47
- CHANNEL_SELECTOR[type] || main_channel
15
+ def channel
16
+ "#github"
48
17
  end
49
18
 
50
19
  def initialize(*args)
51
20
  super
52
- @last_retrieved = Time.now
21
+ @last_retrieved = Time.now.utc
22
+ end
23
+
24
+ def client
25
+ @client ||= Octokit::Client.new(login: @nick, password: @pass)
53
26
  end
54
27
 
55
28
  def on_disconnected
@@ -69,31 +42,25 @@ class Agig::Session < Net::IRC::Server::Session
69
42
  else value
70
43
  end
71
44
  }
72
- channels.each {|c| post @nick, JOIN, c }
45
+ post @nick, JOIN, channel
73
46
 
74
47
  @retrieve_thread = Thread.start do
75
48
  loop do
76
49
  begin
77
50
  @log.info 'retrieveing feed...'
78
- atom = open("https://github.com/#{@nick}.private.atom?token=#{@pass}").read
79
- ns = {'a' => 'http://www.w3.org/2005/Atom'}
80
- entries = Nokogiri::XML(atom).xpath('/a:feed/a:entry', ns).map do |entry|
81
- {
82
- :datetime => Time.parse(entry.xpath('string(a:published)', ns)),
83
- :id => entry.xpath('string(a:id)', ns),
84
- :title => entry.xpath('string(a:title)', ns),
85
- :author => entry.xpath('string(a:author/a:name)', ns),
86
- :link => entry.xpath('string(a:link/@href)', ns),
87
- }
88
- end
89
51
 
90
- entries.reverse_each do |entry|
91
- next if entry[:datetime].utc <= @last_retrieved.utc
92
- type = entry[:id][%r|tag:github.com,2008:(.+?)/\d+|, 1]
93
- post entry[:author], PRIVMSG, channel(type), "\003#{EVENTS[type] || '5'}#{entry[:title]}\017 \00314#{entry[:link]}\017"
52
+ entries = client.notifications
53
+
54
+ entries.sort_by(&:updated_at).reverse_each do |entry|
55
+ updated_at = Time.parse(entry[:updated_at]).utc
56
+ next if updated_at <= @last_retrieved
57
+
58
+ subject = entry['subject']
59
+ post entry['repository']['owner']['login'], PRIVMSG, "#github", "\0035#{subject['title']}\017 \00314#{subject['latest_comment_url']}\017"
60
+
61
+ @last_retrieved = updated_at
94
62
  end
95
63
 
96
- @last_retrieved = entries.first[:datetime]
97
64
  @log.info 'sleep'
98
65
  sleep 30
99
66
  rescue Exception => e
@@ -1,3 +1,3 @@
1
1
  module Agig
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - SHIBATA Hiroshi
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-27 00:00:00.000000000 Z
11
+ date: 2013-03-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: net-irc
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
- name: nokogiri
28
+ name: json
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
- name: certified
42
+ name: octokit
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  description: another Github IRC Gateway
@@ -81,28 +74,26 @@ files:
81
74
  - lib/agig/version.rb
82
75
  homepage: https://github.com/hsbt/agig
83
76
  licenses: []
77
+ metadata: {}
84
78
  post_install_message:
85
79
  rdoc_options: []
86
80
  require_paths:
87
81
  - lib
88
82
  required_ruby_version: !ruby/object:Gem::Requirement
89
- none: false
90
83
  requirements:
91
- - - ! '>='
84
+ - - '>='
92
85
  - !ruby/object:Gem::Version
93
- version: '0'
86
+ version: 1.9.2
94
87
  required_rubygems_version: !ruby/object:Gem::Requirement
95
- none: false
96
88
  requirements:
97
- - - ! '>='
89
+ - - '>='
98
90
  - !ruby/object:Gem::Version
99
91
  version: '0'
100
92
  requirements: []
101
93
  rubyforge_project:
102
- rubygems_version: 1.8.24
94
+ rubygems_version: 2.0.1
103
95
  signing_key:
104
- specification_version: 3
96
+ specification_version: 4
105
97
  summary: agig is another Github IRC Gateway. agig is forked from gig.rb, and contained
106
98
  net-irc gems.
107
99
  test_files: []
108
- has_rdoc: