easy_manage_client 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/easy_manage_client/configuration.rb +7 -2
- data/lib/easy_manage_client/downloader.rb +14 -5
- data/lib/easy_manage_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a76fade94e067d12cbaabb791a719ed2e79dcfa64ae66e232a779cc0483ba600
|
4
|
+
data.tar.gz: e9be0d1c52f0ae3829cc15eb8e38accc0e2b1e146d49221fce8e2b924a85efff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da17c05394689bfa8b3ce671d4e36be138c9a076422295183fd237807d65ab25c6262f3dd2455597cd0c6587e7526e5d465021ca67f746a983bb290beec0e3ea
|
7
|
+
data.tar.gz: d6714937d30924165ff64872b1e1ffa5bf3273d0474ebed2cb0a43f60cf43cbcabd13bdfa5c2620f4b7bfbfa518794b64e36006716b518981951e164483a5fbe
|
data/README.md
CHANGED
@@ -28,7 +28,7 @@ Client must be configured before use. Configuration fields are as:
|
|
28
28
|
| --------------- | ------------------------------------------------------------------------------------------------------- |
|
29
29
|
| root_url | Root url of the EasyManage server. |
|
30
30
|
| auth_token | Your 2.0 authentication token string without the 'Bearer'. |
|
31
|
-
| extension | Dump format. Available values: 'json', '
|
31
|
+
| extension | Dump format. Available values: 'json', 'yaml' |
|
32
32
|
| download_folder | Information to which folder the dump will be downloaded. |
|
33
33
|
| compile_id | The id of the compiled version. If not passed, the client always downloads the latest compiled dump. |
|
34
34
|
|
@@ -39,7 +39,7 @@ Create a file in the `config/initializers` directory and configure client in thi
|
|
39
39
|
EasyManageClient.configure do |config|
|
40
40
|
config.root_url = 'https://easymanage.example.com'
|
41
41
|
config.auth_token = 'YOUR_SECRET_AUTH_TOKEN'
|
42
|
-
config.extension = '
|
42
|
+
config.extension = 'yaml'
|
43
43
|
config.download_folder = File.join(Rails.root, 'config', 'translations')
|
44
44
|
config.compile_id = 'SPECIAL_COMPILED_VERSION_ID'
|
45
45
|
end
|
@@ -84,7 +84,7 @@ If the download process will be performed only in the Rails initialization, the
|
|
84
84
|
EasyManageClient.configure(:dummy_profile) do |config|
|
85
85
|
config.root_url = 'https://easymanage.example.com'
|
86
86
|
config.auth_token = 'YOUR_SECRET_AUTH_TOKEN'
|
87
|
-
config.extension = '
|
87
|
+
config.extension = 'yaml'
|
88
88
|
config.download_folder = File.join(Rails.root, 'config', 'settings')
|
89
89
|
end
|
90
90
|
client = EasyManageClient::Downloader.new(profile: :dummy_profile)
|
@@ -99,9 +99,9 @@ Use rake task to download your compiled dump as below:
|
|
99
99
|
|
100
100
|
`rake easy_manage_client:download`
|
101
101
|
|
102
|
-
Pass profile to rake task:
|
102
|
+
Pass profile to rake task via environment variable:
|
103
103
|
|
104
|
-
`easy_manage_client:download
|
104
|
+
`rake easy_manage_client:download EASY_MANAGE_PROFILE=dummy_settings`
|
105
105
|
## Contributing
|
106
106
|
|
107
107
|
Bug reports and pull requests are welcome on GitHub at https://github.com/sertangulveren/easy_manage_client.
|
@@ -40,14 +40,19 @@ module EasyManageClient
|
|
40
40
|
|
41
41
|
# Configuration class
|
42
42
|
class Configuration
|
43
|
-
EXTENSION_TYPES = %w[
|
43
|
+
EXTENSION_TYPES = %w[yaml json].freeze
|
44
|
+
FILE_EXTENSION_TYPES = { 'yaml' => 'yml', 'json' => 'json' }.freeze
|
44
45
|
|
45
46
|
attr_accessor :profile, :root_url, :auth_token, :extension, :compile_id,
|
46
47
|
:download_folder
|
47
48
|
|
48
49
|
def initialize
|
49
50
|
self.profile = :default
|
50
|
-
self.extension = '
|
51
|
+
self.extension = 'yaml'
|
52
|
+
end
|
53
|
+
|
54
|
+
def file_extension
|
55
|
+
FILE_EXTENSION_TYPES[extension]
|
51
56
|
end
|
52
57
|
|
53
58
|
def check!
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module EasyManageClient
|
4
4
|
# Downloader
|
5
5
|
class Downloader < Core
|
6
|
+
# It decides which api endpoint to use and returns this endpoit.
|
6
7
|
def request_uri
|
7
8
|
# if version not specified, use latest uri
|
8
9
|
if ::EasyManageClient.configuration(profile).compile_id.nil?
|
@@ -13,46 +14,54 @@ module EasyManageClient
|
|
13
14
|
compiled_version_uri
|
14
15
|
end
|
15
16
|
|
17
|
+
# Call api, handle response, perform all actions according to success.
|
18
|
+
# Method returns true or false.
|
16
19
|
def perform
|
17
20
|
# make api call and handle response
|
18
21
|
super
|
19
|
-
|
20
|
-
# stop operation and return false
|
22
|
+
|
23
|
+
# If success is not true, stop operation and return false.
|
21
24
|
return false unless success
|
22
25
|
|
23
|
-
#
|
26
|
+
# Download data to the relevant location.
|
24
27
|
write_to_folder
|
25
28
|
true
|
26
29
|
end
|
27
30
|
|
31
|
+
# CRASH! If unsuccessful.
|
28
32
|
def perform!
|
29
33
|
perform
|
30
34
|
unless success
|
31
35
|
raise ::EasyManageClient::DownloadProcessFailed, response[:message]
|
32
36
|
end
|
33
37
|
|
38
|
+
# Everything is OK.
|
34
39
|
true
|
35
40
|
end
|
36
41
|
|
42
|
+
# Returns request uri from specified version.
|
37
43
|
def compiled_version_uri
|
38
44
|
'/api/projects/by_reference/' +
|
39
45
|
::EasyManageClient.configuration(profile).compile_id.to_s
|
40
46
|
end
|
41
47
|
|
48
|
+
# Returns request uri for latest version.
|
42
49
|
def latest_version_uri
|
43
50
|
'/api/projects/latest_compiled_version'
|
44
51
|
end
|
45
52
|
|
53
|
+
# Write content to download folder.
|
46
54
|
def write_to_folder
|
47
55
|
File.open(prepare_file_path_to_download, 'w') do |file|
|
48
56
|
file.write(response[:content])
|
49
57
|
end
|
50
58
|
end
|
51
59
|
|
60
|
+
# Prepares a file path from the specified extension and download folder.
|
52
61
|
def prepare_file_path_to_download
|
53
62
|
folder = ::EasyManageClient.configuration(profile).download_folder
|
54
|
-
|
55
|
-
File.join(folder, "#{response[:reference]}.#{
|
63
|
+
file_extension = ::EasyManageClient.configuration(profile).file_extension
|
64
|
+
File.join(folder, "#{response[:reference]}.#{file_extension}")
|
56
65
|
end
|
57
66
|
end
|
58
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_manage_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sertan Gülveren
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-01-
|
12
|
+
date: 2020-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dotenv
|