annotate app/lib/clients.rb @ 237:961d362e42c7 legit-client

The url in entity media isn't unique as they all point to the same thing
author nanaya <me@nanaya.net>
date Sat, 15 Jul 2023 01:47:34 +0900
parents 17461f7682a2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
219
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
1 class Clients
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
2 def self.client_options(id)
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
3 {
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
4 :timeouts => {
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
5 :connect => 5,
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
6 :read => 5,
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
7 :write => 5,
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
8 },
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
9 }.merge $cfg[:twitter][id]
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
10 end
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
11
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
12 def self.instance
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
13 @@instance ||= self.new
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
14 end
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
15
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
16 def initialize
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
17 @clients = {}
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
18 end
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
19
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
20 def get(id)
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
21 @clients[id] ||= Twitter::REST::Client.new(self.class.client_options id)
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
22 end
17461f7682a2 One client for everyone
nanaya <me@nanaya.pro>
parents:
diff changeset
23 end