pansophy 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a413f73cf0d57dc704e9da49e2860f84fcdae63a
4
- data.tar.gz: 2c1be096963fd12f1c9451159633cb98ef79fc3d
3
+ metadata.gz: cdebda6b160a82a6835ec062189d36862fe01d42
4
+ data.tar.gz: aec932b36284a3f205991c4f628b420909d292f8
5
5
  SHA512:
6
- metadata.gz: e817397aaf1da9dc9ddff72c1717fc7f0d9c50c39a40e20de1cd6ec4cfc2284fd4221cfb223745b1fc2954b8fb611d21edb24db13fa3e5f29f08ab32a3eaf645
7
- data.tar.gz: 994926a1c90db92e416900bbc0f22d3924db32a474a0c91d0d80eb7aafc3e410708b3adb34f91fa8a5a542d06b270105a94c08f328ddcebde92b0efaaacf5c9e
6
+ metadata.gz: a4284eac32c6a539a641d37cc883e35e4f8cbbd5c625fb8a853445bafb1b50b346b70f89d827ed99515969f318e88e2d8d5f99ef80806172586135cd67d25a2b
7
+ data.tar.gz: c015c8e205e53dbf39bdec273c08a326c4d24684da5b556bb09260d6c89d6154b8900b24d777db181d00bf8c7100725908824fa888e4a1306eb9a7f1f6638a8c
@@ -31,3 +31,4 @@ require 'pansophy/connection'
31
31
  require 'pansophy/remote'
32
32
  require 'pansophy/local'
33
33
  require 'pansophy/synchronizer'
34
+ require 'pansophy/config_synchronizer'
@@ -0,0 +1,57 @@
1
+ require 'pansophy'
2
+ require 'facets/kernel/blank'
3
+
4
+ module Pansophy
5
+ class ConfigSynchronizer
6
+ attr_accessor :config_bucket_name, :config_remote_folder, :config_local_folder, :version
7
+
8
+ def merge
9
+ puts "Fetching remote configuration (version #{VERSION})"
10
+ verify_config_bucket_name!
11
+ Pansophy.merge(config_bucket_name, remote_path, local_path, overwrite: true)
12
+ puts 'done'
13
+ end
14
+
15
+ private
16
+
17
+ def config_bucket_name
18
+ @config_bucket_name ||= ENV['CONFIG_BUCKET_NAME']
19
+ end
20
+
21
+ def config_remote_folder
22
+ @config_remote_folder ||= (ENV['CONFIG_REMOTE_FOLDER'] || 'config')
23
+ end
24
+
25
+ def config_local_folder
26
+ @config_local_folder ||= (ENV['CONFIG_LOCAL_FOLDER'] || ConfigPath.find!)
27
+ end
28
+
29
+ def version
30
+ @version ||= (ENV['CONFIG_VERSION'] || '1.0')
31
+ end
32
+
33
+ def remote_path
34
+ Pathname.new(config_remote_folder).join(version.to_s).to_s
35
+ end
36
+
37
+ def local_path
38
+ config_local_folder.to_s
39
+ end
40
+
41
+ def verify_config_bucket_name!
42
+ return unless config_bucket_name.blank?
43
+ fail ConfigSynchronizerError, 'CONFIG_BUCKET_NAME is undefined'
44
+ end
45
+ end
46
+
47
+ class ConfigPath
48
+ def self.find!
49
+ # TODO: Extract this in a Rails specific gem
50
+ return Rails.root.join('config') if defined?(Rails)
51
+ fail ConfigSynchronizerError, 'Could not determine location of config folder'
52
+ end
53
+ end
54
+
55
+ class ConfigSynchronizerError < StandardError
56
+ end
57
+ end
@@ -0,0 +1,9 @@
1
+ namespace :config do
2
+ desc 'Synchronize config files from remote folder'
3
+ task :synchronize do
4
+ require 'pansophy/config_synchronizer'
5
+ require 'dotenv'
6
+ Dotenv.load
7
+ Pansophy::ConfigSynchronizer.new.pull
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Pansophy
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_dependency 'fog'
25
25
  spec.add_dependency 'adamantium'
26
+ spec.add_dependency 'facets'
26
27
 
27
28
  spec.add_development_dependency 'bundler'
28
29
  spec.add_development_dependency 'rake'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pansophy
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
  - Alessandro Berardi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: facets
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -171,6 +185,7 @@ files:
171
185
  - bin/console
172
186
  - bin/setup
173
187
  - lib/pansophy.rb
188
+ - lib/pansophy/config_synchronizer.rb
174
189
  - lib/pansophy/connection.rb
175
190
  - lib/pansophy/helpers.rb
176
191
  - lib/pansophy/helpers/path_builder.rb
@@ -185,6 +200,7 @@ files:
185
200
  - lib/pansophy/remote/read_directory.rb
186
201
  - lib/pansophy/remote/read_file.rb
187
202
  - lib/pansophy/synchronizer.rb
203
+ - lib/pansophy/tasks.rb
188
204
  - lib/pansophy/version.rb
189
205
  - pansophy.gemspec
190
206
  homepage: https://github.com/sealink/pansophy