Class: TentClient

Inherits:
Object
  • Object
show all
Defined in:
lib/tent-client.rb,
lib/tent-client/app.rb,
lib/tent-client/post.rb,
lib/tent-client/group.rb,
lib/tent-client/profile.rb,
lib/tent-client/version.rb,
lib/tent-client/follower.rb,
lib/tent-client/discovery.rb,
lib/tent-client/following.rb,
lib/tent-client/cycle_http.rb,
lib/tent-client/link_header.rb,
lib/tent-client/post_attachment.rb,
lib/tent-client/app_authorization.rb,
lib/tent-client/middleware/mac_auth.rb,
lib/tent-client/middleware/encode_json.rb,
lib/tent-client/middleware/accept_header.rb

Defined Under Namespace

Modules: Middleware Classes: App, AppAuthorization, CycleHTTP, Discovery, Follower, Following, Group, LinkHeader, Post, PostAttachment, Profile

Constant Summary collapse

MEDIA_TYPE =
'application/vnd.tent.v0+json'.freeze
PROFILE_REL =
'https://tent.io/rels/profile'.freeze
VERSION =
'0.0.1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_urls = [], options = {}) ⇒ TentClient

Returns a new instance of TentClient.



29
30
31
32
33
# File 'lib/tent-client.rb', line 29

def initialize(server_urls = [], options={})
  @server_urls = Array(server_urls)
  @faraday_adapter = options.delete(:faraday_adapter)
  @options = options
end

Instance Attribute Details

#faraday_adapterObject (readonly)

Returns the value of attribute faraday_adapter.



27
28
29
# File 'lib/tent-client.rb', line 27

def faraday_adapter
  @faraday_adapter
end

#server_urlsObject (readonly)

Returns the value of attribute server_urls.



27
28
29
# File 'lib/tent-client.rb', line 27

def server_urls
  @server_urls
end

Instance Method Details

#appObject



70
71
72
# File 'lib/tent-client.rb', line 70

def app
  App.new(self)
end

#discover(url) ⇒ Object



54
55
56
# File 'lib/tent-client.rb', line 54

def discover(url)
  Discovery.new(self, url).tap { |d| d.perform }
end

#followerObject



58
59
60
# File 'lib/tent-client.rb', line 58

def follower
  Follower.new(self)
end

#followingObject



62
63
64
# File 'lib/tent-client.rb', line 62

def following
  Following.new(self)
end

#groupObject



66
67
68
# File 'lib/tent-client.rb', line 66

def group
  Group.new(self)
end

#httpObject



35
36
37
38
39
40
41
42
43
# File 'lib/tent-client.rb', line 35

def http
  @http ||= CycleHTTP.new(self) do |f|
    f.use Middleware::EncodeJson unless @options[:skip_serialization]
    f.response :multi_json, :content_type => /\bjson\Z/ unless @options[:skip_serialization]
    f.use Middleware::AcceptHeader
    f.use Middleware::MacAuth, @options
    f.adapter *Array(faraday_adapter)
  end
end

#postObject



74
75
76
# File 'lib/tent-client.rb', line 74

def post
  Post.new(self)
end

#profileObject



78
79
80
# File 'lib/tent-client.rb', line 78

def profile
  Profile.new(self)
end

#server_url=(v) ⇒ Object



49
50
51
52
# File 'lib/tent-client.rb', line 49

def server_url=(v)
  @server_urls = Array(v)
  @http = nil # reset Faraday connection
end