Class: Rosette::Client::Api
- Inherits:
-
Object
- Object
- Rosette::Client::Api
- Defined in:
- lib/rosette/client/api.rb
Constant Summary collapse
- DEFAULT_HOST =
'localhost'
- DEFAULT_PORT =
8080
- DEFAULT_VERSION =
'v1'
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #add_or_update_translation(params) ⇒ Object
- #commit(params) ⇒ Object
- #diff(params) ⇒ Object
- #export(params) ⇒ Object
-
#initialize(options = {}) ⇒ Api
constructor
A new instance of Api.
- #locales(params) ⇒ Object
- #repo_snapshot(params) ⇒ Object
- #show(params) ⇒ Object
- #snapshot(params) ⇒ Object
- #status(params) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Api
Returns a new instance of Api.
26 27 28 29 30 |
# File 'lib/rosette/client/api.rb', line 26 def initialize( = {}) @host = .fetch(:host, DEFAULT_HOST) @port = .fetch(:port, DEFAULT_PORT) @version = .fetch(:version, DEFAULT_VERSION) end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
17 18 19 |
# File 'lib/rosette/client/api.rb', line 17 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
17 18 19 |
# File 'lib/rosette/client/api.rb', line 17 def port @port end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
17 18 19 |
# File 'lib/rosette/client/api.rb', line 17 def version @version end |
Class Method Details
.url_join(*args) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/rosette/client/api.rb', line 19 def self.url_join(*args) args .map { |arg| arg.gsub(/\A\/(.*)\/\z/, '\1') } # remove slashes .reject { |arg| arg.empty? } # get rid of empties .join('/') end |
Instance Method Details
#add_or_update_translation(params) ⇒ Object
56 57 58 |
# File 'lib/rosette/client/api.rb', line 56 def add_or_update_translation(params) wrap(make_request(:post, 'translations/add_or_update.json', params)) end |
#commit(params) ⇒ Object
44 45 46 |
# File 'lib/rosette/client/api.rb', line 44 def commit(params) wrap(make_request(:get, 'git/commit.json', params)) end |
#diff(params) ⇒ Object
32 33 34 |
# File 'lib/rosette/client/api.rb', line 32 def diff(params) wrap(make_request(:get, 'git/diff.json', params)) end |
#export(params) ⇒ Object
60 61 62 |
# File 'lib/rosette/client/api.rb', line 60 def export(params) wrap(make_request(:get, 'translations/export.json', params)) end |
#locales(params) ⇒ Object
64 65 66 |
# File 'lib/rosette/client/api.rb', line 64 def locales(params) wrap(make_request(:get, 'locales.json', params)) end |
#repo_snapshot(params) ⇒ Object
52 53 54 |
# File 'lib/rosette/client/api.rb', line 52 def repo_snapshot(params) wrap(make_request(:get, 'git/repo_snapshot.json', params)) end |
#show(params) ⇒ Object
36 37 38 |
# File 'lib/rosette/client/api.rb', line 36 def show(params) wrap(make_request(:get, 'git/show.json', params)) end |
#snapshot(params) ⇒ Object
48 49 50 |
# File 'lib/rosette/client/api.rb', line 48 def snapshot(params) wrap(make_request(:get, 'git/snapshot.json', params)) end |
#status(params) ⇒ Object
40 41 42 |
# File 'lib/rosette/client/api.rb', line 40 def status(params) wrap(make_request(:get, 'git/status.json', params)) end |