atig 0.3.12 → 0.4.0.beta1

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: 3a668ea6939dbd49b48c52d0e89c8d8493e718f0
4
- data.tar.gz: 6d9d3a3f73da3132bad8d87388ffdb5e80660273
3
+ metadata.gz: 975f7bc77cc611f0825ec3ae132d4c530494297c
4
+ data.tar.gz: 72f9b9c6390ac1b9b740a5641476cb1901a50fde
5
5
  SHA512:
6
- metadata.gz: 3e0cb65867555b96e19e536647c007491d9737a8b09d5de43f6d12075afd3a0a585b974d776409e78236d2fd7ed2d1edb72e96501a3c98daace0f525b992c6b3
7
- data.tar.gz: 9ca51fc9cd745a12a9d9c9d49786198c600005da9b42adf1b569eddd12de33e4ef9ae7778b36f6b2d6493fe2945d4ecf22bbd7ec0ca95dbec462441e25cd149f
6
+ metadata.gz: 96f4e9f26a887e3b56e62e523fbe62285b328b4399948134aac7a45628a5d452b2b05dcff52cbbf92626785d4ee3c58afa9a61ff033bad74898ae9f9ad94ede0
7
+ data.tar.gz: f3532ae36835e30cfb899caf36adb8d0ebcf27e415c07ab66f8ddd0563e97fc8f9e31a1c890c5ad5dc6f7e1c4d29149de378bd24b626eb35613fe2c88e8ee57e
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+
5
+ script: bundle exec rake spec
data/atig.gemspec CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |gem|
24
24
 
25
25
  gem.add_development_dependency 'bundler'
26
26
  gem.add_development_dependency 'rspec'
27
+ gem.add_development_dependency 'coveralls'
27
28
  end
data/lib/atig/agent.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'atig/agent/own_list'
2
1
  require 'atig/agent/full_list'
3
2
  require 'atig/agent/following'
4
3
  require 'atig/agent/list_status'
@@ -22,15 +22,15 @@ module Atig
22
22
 
23
23
  def update(api)
24
24
  if @db.followings.empty?
25
- friends = api.page("statuses/friends/#{@db.me.id}", :users)
25
+ friends = api.page("friends/list", :users, {:user_id => @db.me.id})
26
26
  else
27
27
  @db.me = api.post("account/update_profile")
28
28
  return if @db.me.friends_count == @db.followings.size
29
- friends = api.page("statuses/friends/#{@db.me.id}", :users)
29
+ friends = api.page("friends/list", :users, {:user_id => @db.me.id})
30
30
  end
31
31
 
32
32
  if @opts.only
33
- followers = api.page("followers/ids/#{@db.me.id}", :ids)
33
+ followers = api.page("friends/ids", :ids, {:user_id => @db.me.id})
34
34
  friends.each do|friend|
35
35
  friend[:only] = !followers.include?(friend.id)
36
36
  end
@@ -7,8 +7,8 @@ module Atig
7
7
  module Agent
8
8
  class FullList < List
9
9
  def entry_points
10
- [ "#{@db.me.screen_name}/lists",
11
- "#{@db.me.screen_name}/lists/subscriptions"
10
+ [
11
+ "lists/list",
12
12
  ]
13
13
  end
14
14
 
@@ -12,16 +12,16 @@ module Atig
12
12
  @db = db
13
13
  log :info, "initialize"
14
14
 
15
- @db.lists.on_invalidated{|name|
15
+ @db.lists.on_invalidated do |name|
16
16
  log :info, "invalidated #{name}"
17
- api.delay(0){|t|
17
+ api.delay(0) do |t|
18
18
  if name == :all then
19
19
  full_update t
20
20
  else
21
- @db.lists[name].update t.page("#{@db.me.screen_name}/#{name}/members", :users, true)
21
+ @db.lists[name].update t.page("lists/members", :users, {:owner_screen_name => @db.me.screen_name, :slug => name})
22
22
  end
23
- }
24
- }
23
+ end
24
+ end
25
25
  api.repeat( interval ) do|t|
26
26
  self.full_update t
27
27
  end
@@ -29,11 +29,11 @@ module Atig
29
29
 
30
30
  def full_update(t)
31
31
  lists = entry_points.map{|entry|
32
- t.page(entry, :lists, true)
33
- }.flatten
32
+ t.get(entry)
33
+ }.flatten.compact
34
34
 
35
35
  users = {}
36
- lists.map do|list|
36
+ lists.map do |list|
37
37
  name = if list.user.screen_name == @db.me.screen_name then
38
38
  "#{list.slug}"
39
39
  else
@@ -41,8 +41,8 @@ module Atig
41
41
  end
42
42
  begin
43
43
  users[name] =
44
- t.page("#{list.user.screen_name}/#{list.slug}/members", :users, true)
45
- rescue APIFailed => e
44
+ t.page("lists/members", :users, {:owner_screen_name => list.user.screen_name, :slug => list.slug})
45
+ rescue => e
46
46
  log :error, e.inspect
47
47
  users[name] =
48
48
  @db.lists.find_by_list_name(list.slug)
@@ -20,8 +20,9 @@ class Atig::Agent::ListStatus
20
20
  q = {}
21
21
  q.update(:since_id => @prev[name]) if @prev.key?(name)
22
22
 
23
- screen_name,slug = parse name
24
- statuses = t.get("#{screen_name}/lists/#{slug}/statuses",q)
23
+ screen_name, slug = parse name
24
+ q.update(:owner_screen_name => screen_name, :slug => slug)
25
+ statuses = t.get("lists/statuses", q)
25
26
  statuses.reverse_each do|status|
26
27
  db.statuses.transaction do|d|
27
28
  d.add(:status => status,
@@ -9,7 +9,7 @@ module Atig
9
9
  super
10
10
  end
11
11
  def interval; 180 end
12
- def path; '/statuses/mentions' end
12
+ def path; '/statuses/mentions_timeline' end
13
13
  def source; :mention end
14
14
  end
15
15
  end
@@ -17,7 +17,7 @@ module Atig
17
17
  end
18
18
 
19
19
  def update(api)
20
- @db.noretweets.clear.concat( api.get("friendships/no_retweet_ids") )
20
+ @db.noretweets.clear.concat( api.get("friendships/no_retweets/ids") )
21
21
  end
22
22
  end
23
23
  end
@@ -73,4 +73,3 @@ module Atig
73
73
  end
74
74
  end
75
75
  end
76
-
@@ -1,4 +1,5 @@
1
1
  # -*- mode:ruby; coding:utf-8 -*-
2
+
2
3
  require 'atig/command/command'
3
4
  require 'atig/levenshtein'
4
5
 
@@ -9,11 +9,11 @@ module Atig
9
9
  @gateway = gateway
10
10
  @api = api
11
11
  @db = db
12
- @gateway.ctcp_action(*command_name) do |target, mesg, command, args|
12
+ @gateway.ctcp_action(*command_name) do |target, mesg, command, args|
13
13
  action(target, mesg, command, args){|m|
14
14
  gateway[target].notify m
15
15
  }
16
- end
16
+ end
17
17
  end
18
18
 
19
19
  def find_by_tid(tid)
@@ -1,5 +1,5 @@
1
1
  # -*- mode:ruby; coding:utf-8 -*-
2
- require 'time'
2
+
3
3
  require 'atig/command/command'
4
4
  require 'atig/command/info'
5
5
 
@@ -20,7 +20,7 @@ module Atig
20
20
  text = mesg.split(" ", 3)[2]
21
21
  api.delay(0) do|t|
22
22
  t.post("direct_messages/new",{
23
- :user => user,
23
+ :screen_name => user,
24
24
  :text => text
25
25
  })
26
26
  yield "Sent message to #{user}: #{text}"
@@ -14,7 +14,7 @@ module Atig
14
14
  args.each do|tid|
15
15
  if entry = Info.find_status(db, tid)
16
16
  api.delay(0){|t|
17
- res = t.post("favorites/#{method}/#{entry.status.id}")
17
+ res = t.post("favorites/#{method}", {:id => entry.status.id})
18
18
  yield "#{command.upcase}: #{entry.user.screen_name}: #{entry.status.text}"
19
19
  }
20
20
  else
@@ -86,6 +86,7 @@ END
86
86
  end
87
87
 
88
88
  private
89
+
89
90
  def run_filters(entry)
90
91
  status = entry.status.merge(:tid=>entry.tid, :sid=>entry.sid)
91
92
  @filters.inject(status) {|x, f| f.call x }.text
data/lib/atig/oauth.rb CHANGED
@@ -21,6 +21,7 @@ module Atig
21
21
 
22
22
  attr_reader :access
23
23
  attr_reader :oauth
24
+
24
25
  def initialize(context, nick)
25
26
  uri = URI(context.opts.api_base)
26
27
  site = "http://#{uri.host}"
data/lib/atig/option.rb CHANGED
@@ -29,7 +29,7 @@ module Atig
29
29
  end
30
30
  end
31
31
 
32
- default_value :api_base, 'https://api.twitter.com/1/'
32
+ default_value :api_base, 'https://api.twitter.com/1.1/'
33
33
  default_value :stream_api_base, 'https://userstream.twitter.com/2/'
34
34
  default_value :search_api_base, 'http://search.twitter.com/'
35
35
 
data/lib/atig/twitter.rb CHANGED
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env ruby
2
1
  # -*- coding: utf-8 -*-
2
+
3
3
  require 'atig/basic_twitter'
4
4
  require 'atig/http'
5
5
 
@@ -12,16 +12,14 @@ module Atig
12
12
  @http = Atig::Http.new @log
13
13
  end
14
14
 
15
- # authenticate = trueでないとSSL verified errorがでることがある
16
- def page(path, name, authenticate = true, &block)
15
+ def page(path, name, opts = {}, &block)
17
16
  limit = 0.98 * @remain # 98% of IP based rate limit
18
17
  r = []
19
18
  cursor = -1
20
19
  1.upto(limit) do |num|
21
- # next_cursor にアクセスするとNot found が返ってくることがあるので,その時はbreak
22
- ret = api(path, { :cursor => cursor }, { :authenticate => authenticate }) rescue break
23
- arr = ret[name.to_s]
24
- r.concat arr
20
+ options = {:cursor => cursor}.merge(opts)
21
+ ret = api(path, options, { :authenticate => true })
22
+ r.concat ret[name]
25
23
  cursor = ret[:next_cursor]
26
24
  break if cursor.zero?
27
25
  end
data/lib/atig/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Atig
2
- VERSION = "0.3.12"
2
+ VERSION = "0.4.0.beta1"
3
3
  end
@@ -15,7 +15,7 @@ describe Atig::Command::Dm do
15
15
 
16
16
  it "should post the status by API" do
17
17
  @api.should_receive(:post).with('direct_messages/new',
18
- {:user=>'mzp', :text=> 'blah blah'})
18
+ {:screen_name => 'mzp', :text => 'blah blah'})
19
19
  @channel.should_receive(:notify).with("Sent message to mzp: blah blah")
20
20
  call '#twitter', "dm", %w(mzp blah blah)
21
21
  end
@@ -18,35 +18,35 @@ describe Atig::Command::Favorite do
18
18
  end
19
19
 
20
20
  it "should post fav by tid" do
21
- @api.should_receive(:post).with("favorites/create/1")
21
+ @api.should_receive(:post).with("favorites/create", {:id => "1"})
22
22
  @channel.should_receive(:notify).with("FAV: mzp: blah blah")
23
23
 
24
24
  call "#twitter","fav",%w(a)
25
25
  end
26
26
 
27
27
  it "should post fav by sid" do
28
- @api.should_receive(:post).with("favorites/create/1")
28
+ @api.should_receive(:post).with("favorites/create", {:id => "1"})
29
29
  @channel.should_receive(:notify).with("FAV: mzp: blah blah")
30
30
 
31
31
  call "#twitter","fav",%w(mzp:a)
32
32
  end
33
33
 
34
34
  it "should post fav by screen name" do
35
- @api.should_receive(:post).with("favorites/create/1")
35
+ @api.should_receive(:post).with("favorites/create", {:id => "1"})
36
36
  @channel.should_receive(:notify).with("FAV: mzp: blah blah")
37
37
 
38
38
  call "#twitter","fav",%w(mzp)
39
39
  end
40
40
 
41
41
  it "should post fav by screen name with at" do
42
- @api.should_receive(:post).with("favorites/create/1")
42
+ @api.should_receive(:post).with("favorites/create", {:id => "1"})
43
43
  @channel.should_receive(:notify).with("FAV: mzp: blah blah")
44
44
 
45
45
  call "#twitter","fav",%w(@mzp)
46
46
  end
47
47
 
48
48
  it "should post unfav" do
49
- @api.should_receive(:post).with("favorites/destroy/1")
49
+ @api.should_receive(:post).with("favorites/destroy", {:id => "1"})
50
50
  @channel.should_receive(:notify).with("UNFAV: mzp: blah blah")
51
51
 
52
52
  call "#twitter","unfav",%w(a)
data/spec/option_spec.rb CHANGED
@@ -69,7 +69,7 @@ describe Atig::Option do
69
69
  end
70
70
 
71
71
  it "should have default value" do
72
- @opt.api_base.should == 'https://api.twitter.com/1/'
72
+ @opt.api_base.should == 'https://api.twitter.com/1.1/'
73
73
  end
74
74
 
75
75
  it "should list up all fields" do
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,6 @@ require 'bundler'
5
5
  Bundler.setup
6
6
  Bundler.require :default, :test
7
7
 
8
-
9
8
  require 'atig/monkey'
10
9
  require 'command_helper'
11
10
 
@@ -15,7 +14,7 @@ RSpec::Matchers.define :be_text do |text|
15
14
  end
16
15
  end
17
16
 
18
- def status(text,opt={})
17
+ def status(text, opt = {})
19
18
  Atig::TwitterStruct.make(opt.merge('text' => text))
20
19
  end
21
20
 
@@ -26,10 +25,13 @@ def user(id, name)
26
25
  user
27
26
  end
28
27
 
29
- def entry(user,status,name='entry',id=0)
28
+ def entry(user, status, name = 'entry', id = 0)
30
29
  entry = stub name
31
30
  entry.stub!('id').and_return(id)
32
31
  entry.stub!('user').and_return(user)
33
32
  entry.stub!('status').and_return(status)
34
33
  entry
35
34
  end
35
+
36
+ require 'coveralls'
37
+ Coveralls.wear!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12
4
+ version: 0.4.0.beta1
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-04-02 00:00:00.000000000 Z
11
+ date: 2013-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: coveralls
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description: Atig.rb is Twitter Irc Gateway.
112
126
  email:
113
127
  - shibata.hiroshi@gmail.com
@@ -118,6 +132,7 @@ extra_rdoc_files: []
118
132
  files:
119
133
  - .gitignore
120
134
  - .rspec
135
+ - .travis.yml
121
136
  - Gemfile
122
137
  - Gemfile.lock
123
138
  - README.mkdn
@@ -159,8 +174,6 @@ files:
159
174
  - lib/atig/agent/list_status.rb
160
175
  - lib/atig/agent/mention.rb
161
176
  - lib/atig/agent/noretweets.rb
162
- - lib/atig/agent/other_list.rb
163
- - lib/atig/agent/own_list.rb
164
177
  - lib/atig/agent/stream_follow.rb
165
178
  - lib/atig/agent/timeline.rb
166
179
  - lib/atig/agent/user_stream.rb
@@ -300,9 +313,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
300
313
  version: '0'
301
314
  required_rubygems_version: !ruby/object:Gem::Requirement
302
315
  requirements:
303
- - - '>='
316
+ - - '>'
304
317
  - !ruby/object:Gem::Version
305
- version: '0'
318
+ version: 1.3.1
306
319
  requirements: []
307
320
  rubyforge_project:
308
321
  rubygems_version: 2.0.3
@@ -1,18 +0,0 @@
1
- # -*- mode:ruby; coding:utf-8 -*-
2
-
3
- require 'atig/util'
4
- require 'atig/agent/list'
5
-
6
- module Atig
7
- module Agent
8
- class OtherList < List
9
- def entry_points
10
- [ "#{@db.me.screen_name}/lists/subscriptions" ]
11
- end
12
-
13
- def interval
14
- 3600
15
- end
16
- end
17
- end
18
- end
@@ -1,18 +0,0 @@
1
- # -*- mode:ruby; coding:utf-8 -*-
2
-
3
- require 'atig/util'
4
- require 'atig/agent/list'
5
-
6
- module Atig
7
- module Agent
8
- class OwnList < List
9
- def entry_points
10
- [ "#{@db.me.screen_name}/lists" ]
11
- end
12
-
13
- def interval
14
- 3600
15
- end
16
- end
17
- end
18
- end