app_env_config 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
  SHA1:
3
- metadata.gz: 0ce333131da66af028dc9de9434a7e9fc008a969
4
- data.tar.gz: 2883fa5728e82b990c684a9071081b1937af829c
3
+ metadata.gz: 05ecf33ef6a7807e6f0964c17a857eb8d792c2d0
4
+ data.tar.gz: caeed0bd4c8ae51499786e2395048df6fe27a238
5
5
  SHA512:
6
- metadata.gz: 45a9d2ce2031d55d8cbdb7da08f2fa5da4254de24fc06325afee7e4547e4de49a3245bfe76d5edc7abd6771322f18e097f2dc7a0ec08f656e1d36a719c9ee0e4
7
- data.tar.gz: da9fb647a27962276251771590d526dcb7aa395829c7cb613ff0a5782cd8bdd21f99c58b34635da5bc3fb61c5f7445dcf4c766a0b258e3307af62d1650f71562
6
+ metadata.gz: 996af4e3194947f77f3ee7c261720069549ade737ebeeeba350745edb2e0b8e71ec7eb079a0607c597c433dd3db6d445a4c261fe331d437648d6e6989048f9f2
7
+ data.tar.gz: 3f790e3b0b758c4623fa3220a8efb8b7e6627f2e4f91a799dd10d856c5969b92af6578d3c9c6c8da69b5d0cb70c3cec9e00696460dc0424f9aff8cf81af46c08
Binary file
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = 'Simple config loader from yml'
12
12
  spec.description = 'Provide ability to load config from yml files and use it at enviroments configuration files and in whole app'
13
- spec.homepage = 'http://itspark.pro'
13
+ spec.homepage = 'https://github.com/sergeyustinov/app_env_config'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
@@ -1,3 +1,3 @@
1
1
  module AppEnvConfig
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,45 @@
1
+ require 'rails/generators/base'
2
+
3
+ module AppEnvConfig
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('../templates', __dir__)
7
+
8
+ desc 'Copy conifg file to application and set APP_CONFIG constant for next use'
9
+
10
+ def copy_yml
11
+ copy_file 'app_config.yml', 'config/app_config.yml'
12
+ end
13
+
14
+ def create_constant
15
+ write_to_file(
16
+ file: 'config/environment.rb',
17
+ line: 'Rails.application.initialize!',
18
+ content_before: "APP_CONFIG = AppEnvConfig.get('app_config')",
19
+ shift: "\n" * 2
20
+ )
21
+ end
22
+
23
+ protected
24
+
25
+ def file_contain_content?(options = {})
26
+ file_content = File.read(options[:file])
27
+
28
+ (options[:content_before].blank? || file_content.include?(options[:content_before])) &&
29
+ (options[:content_after].blank? || file_content.include?(options[:content_after]))
30
+ end
31
+
32
+ def write_to_file(options = {})
33
+ return if file_contain_content?(options)
34
+
35
+ gsub_file options[:file], /(#{Regexp.escape(options[:line])})/mi do |match|
36
+ [
37
+ options[:content_before].presence,
38
+ match,
39
+ options[:content_after].presence
40
+ ].compact.join(options.fetch(:shift, "\n"))
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,11 @@
1
+ default: &default
2
+ title: App title
3
+
4
+ development:
5
+ <<: *default
6
+
7
+ test:
8
+ <<: *default
9
+
10
+ production:
11
+ <<: *default
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_env_config
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
  - Sergey U
@@ -52,16 +52,19 @@ files:
52
52
  - LICENSE.txt
53
53
  - README.md
54
54
  - Rakefile
55
+ - app_env_config-0.1.0.gem
55
56
  - app_env_config.gemspec
56
57
  - bin/console
57
58
  - bin/setup
58
59
  - lib/app_env_config.rb
59
60
  - lib/app_env_config/version.rb
60
- homepage: http://itspark.pro
61
+ - lib/generators/app_env_config/install_generator.rb
62
+ - lib/generators/templates/app_config.yml
63
+ homepage: https://github.com/sergeyustinov/app_env_config
61
64
  licenses:
62
65
  - MIT
63
66
  metadata:
64
- homepage_uri: http://itspark.pro
67
+ homepage_uri: https://github.com/sergeyustinov/app_env_config
65
68
  post_install_message:
66
69
  rdoc_options: []
67
70
  require_paths: