phraseapp-rest 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5a5a272b0670ebe10aae74e43fad430ff6e24b37528b9de21f81e48abac480d
4
- data.tar.gz: 52f2fe992459573931d2f2ae0df72fe385c9ac5b52e457fa8dfead7b124ef600
3
+ metadata.gz: aeb5a1f70cc0b3bbc18e09db604d9d4d371dc1c2cd3be5c3654a6bcb1ec95df3
4
+ data.tar.gz: 8d59180055808da44bda6677f6250391660efa02afc710fea82a27329212219a
5
5
  SHA512:
6
- metadata.gz: dfbe176509ba75e52c82d7e0599e9d1939788e24c5f655b50c0624888662d1f0ed3fc56a2ca7051748dbab39bf9117ceed7861c361b0467c87a92383ce442843
7
- data.tar.gz: a781f2e78575d6001db433de3d2388d2f8d7e9f3c8fbbbfb7a48ae232eeb09450cb0f5452c97165f65320b620a11be367519ea8bcb0c5cc75b96ec4520be5379
6
+ metadata.gz: 8db678e36e6c2be20a1a852a5a67b967636af6f84737ee698793f691f395f2c69693fe891a35fd193a503f0c2b95ff678a891713b5880d362a000dfa50741f15
7
+ data.tar.gz: 31079849e5161246bd714439d9e0d11b26cdd2bd12ab8450f5093c433e5cb50b615530d74a84d97d0874535c60403ef7debe6e83a74cbb0bc4cd49a40ad647a5
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'phraseapp-rest/version'
4
+ require_relative 'phraseapp-rest/configuration'
4
5
  require_relative 'phraseapp-rest/factory'
5
6
  require_relative 'phraseapp-rest/parameter/base'
6
7
  require_relative 'phraseapp-rest/query/base'
@@ -8,3 +9,19 @@ require_relative 'phraseapp-rest/resource/key'
8
9
  require_relative 'phraseapp-rest/resource/locale'
9
10
  require_relative 'phraseapp-rest/resource/project'
10
11
  require_relative 'phraseapp-rest/resource/translation'
12
+
13
+ module Phraseapp
14
+ module Rest
15
+ def self.configuration
16
+ @configuration ||= Configuration.new
17
+ end
18
+
19
+ def self.reset
20
+ @configuration = Configuration.new
21
+ end
22
+
23
+ def self.configure
24
+ yield(configuration)
25
+ end
26
+ end
27
+ end
@@ -10,23 +10,18 @@ module Phraseapp
10
10
  end
11
11
 
12
12
  def get(path)
13
- response @client::Request.execute(
13
+ rsp, err = @client::Request.execute(
14
14
  url: "#{BASE_URL}#{path}",
15
15
  method: :get,
16
16
  user: @token,
17
- content_type: :json,
18
- accept: :json,
17
+ content_type: :json, accept: :json,
19
18
  verify_ssl: TRUE
20
19
  )
21
- end
22
-
23
- private
24
-
25
- def response(call)
26
- rsp, err = call
27
- raise err.inspect if err
28
-
29
20
  rsp
21
+ rescue RestClient::ExceptionWithResponse => e
22
+ return '[]' if e.response = 404
23
+
24
+ raise e
30
25
  end
31
26
  end
32
27
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Phraseapp
4
+ module Rest
5
+ class Configuration
6
+ attr_writer :token
7
+
8
+ def initialize
9
+ @token = nil
10
+ end
11
+
12
+ def token
13
+ raise 'Phraseapp api token not defined' if @token.nil?
14
+
15
+ @token
16
+ end
17
+ end
18
+ end
19
+ end
@@ -7,7 +7,10 @@ module Phraseapp
7
7
  module Rest
8
8
  class Factory
9
9
  def self.api
10
- Phraseapp::Rest::Api.new(rest_client: RestClient, token: ENV['PHRASEAPP_API_KEY'])
10
+ Phraseapp::Rest::Api.new(
11
+ rest_client: RestClient,
12
+ token: Phraseapp::Rest.configuration.token
13
+ )
11
14
  end
12
15
  end
13
16
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Phraseapp
4
4
  module Rest
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phraseapp-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Nepote
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-11 00:00:00.000000000 Z
11
+ date: 2018-11-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A ruby gem to interact with Phraseapp REST resources
14
14
  email: snepote@gmail.com
@@ -18,6 +18,7 @@ extra_rdoc_files: []
18
18
  files:
19
19
  - lib/phraseapp-rest.rb
20
20
  - lib/phraseapp-rest/api.rb
21
+ - lib/phraseapp-rest/configuration.rb
21
22
  - lib/phraseapp-rest/factory.rb
22
23
  - lib/phraseapp-rest/parameter/base.rb
23
24
  - lib/phraseapp-rest/query/base.rb
@@ -28,10 +29,11 @@ files:
28
29
  - lib/phraseapp-rest/resource/project.rb
29
30
  - lib/phraseapp-rest/resource/translation.rb
30
31
  - lib/phraseapp-rest/version.rb
31
- homepage: http://rubygems.org/gems/phraseapp-rest
32
+ homepage: https://rubygems.org/gems/phraseapp-rest
32
33
  licenses:
33
34
  - MIT
34
- metadata: {}
35
+ metadata:
36
+ source_code_uri: https://github.com/snepote/phraseapp-rest
35
37
  post_install_message:
36
38
  rdoc_options: []
37
39
  require_paths: