easy_manage_client 0.1.0 → 0.1.1

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: 516e8348314da4e3265d1d59ec548ea634a756aa3e5d957dcf5c7e067e206522
4
- data.tar.gz: e5b3eb4b2559746393c38d4847de3d57bec07cde5278966e571d44d0c38116ba
3
+ metadata.gz: a76fade94e067d12cbaabb791a719ed2e79dcfa64ae66e232a779cc0483ba600
4
+ data.tar.gz: e9be0d1c52f0ae3829cc15eb8e38accc0e2b1e146d49221fce8e2b924a85efff
5
5
  SHA512:
6
- metadata.gz: ce4eea5e6b968b44c528fe12096bd64ddca6238c347576768ce177679efe596bb5e5f7989dfad10cfc6ca12726cad1a5f35c7414246b463500825a75dbfc8533
7
- data.tar.gz: 5ec2aad214355b7e032760edf9533d5f3d10116a6a0dbc06098d09b36d35f9f02be31b0eb87a0a32db23d40eb29a13fda00ad910ca61a7cf9d6c989217cce49d
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', 'yml' |
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 = 'yml'
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 = 'yml'
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 PROFILE=dummy_settings`
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[yml json].freeze
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 = 'yml'
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
- # if success is not true
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
- # download data to the relevant location
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
- extension = ::EasyManageClient.configuration(profile).extension
55
- File.join(folder, "#{response[:reference]}.#{extension}")
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EasyManageClient
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  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.0
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-28 00:00:00.000000000 Z
12
+ date: 2020-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dotenv