app_env_config 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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05ecf33ef6a7807e6f0964c17a857eb8d792c2d0
|
4
|
+
data.tar.gz: caeed0bd4c8ae51499786e2395048df6fe27a238
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 996af4e3194947f77f3ee7c261720069549ade737ebeeeba350745edb2e0b8e71ec7eb079a0607c597c433dd3db6d445a4c261fe331d437648d6e6989048f9f2
|
7
|
+
data.tar.gz: 3f790e3b0b758c4623fa3220a8efb8b7e6627f2e4f91a799dd10d856c5969b92af6578d3c9c6c8da69b5d0cb70c3cec9e00696460dc0424f9aff8cf81af46c08
|
Binary file
|
data/app_env_config.gemspec
CHANGED
@@ -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 = '
|
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'
|
@@ -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
|
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.
|
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
|
-
|
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:
|
67
|
+
homepage_uri: https://github.com/sergeyustinov/app_env_config
|
65
68
|
post_install_message:
|
66
69
|
rdoc_options: []
|
67
70
|
require_paths:
|