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 +4 -4
- data/lib/phraseapp-rest.rb +17 -0
- data/lib/phraseapp-rest/api.rb +6 -11
- data/lib/phraseapp-rest/configuration.rb +19 -0
- data/lib/phraseapp-rest/factory.rb +4 -1
- data/lib/phraseapp-rest/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aeb5a1f70cc0b3bbc18e09db604d9d4d371dc1c2cd3be5c3654a6bcb1ec95df3
|
|
4
|
+
data.tar.gz: 8d59180055808da44bda6677f6250391660efa02afc710fea82a27329212219a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8db678e36e6c2be20a1a852a5a67b967636af6f84737ee698793f691f395f2c69693fe891a35fd193a503f0c2b95ff678a891713b5880d362a000dfa50741f15
|
|
7
|
+
data.tar.gz: 31079849e5161246bd714439d9e0d11b26cdd2bd12ab8450f5093c433e5cb50b615530d74a84d97d0874535c60403ef7debe6e83a74cbb0bc4cd49a40ad647a5
|
data/lib/phraseapp-rest.rb
CHANGED
|
@@ -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
|
data/lib/phraseapp-rest/api.rb
CHANGED
|
@@ -10,23 +10,18 @@ module Phraseapp
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def get(path)
|
|
13
|
-
|
|
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(
|
|
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
|
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.
|
|
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
|
+
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:
|
|
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:
|