constfig 0.0.2 → 0.0.3

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.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.0.3
2
+
3
+ - fixed typos and added intro section to README
4
+
1
5
  # 0.0.2
2
6
 
3
7
  - improved README
data/README.md CHANGED
@@ -2,11 +2,48 @@
2
2
 
3
3
  Simple configuration for Ruby.
4
4
 
5
- Allows you to define configuration CONSTANTS that take values from ENV.
5
+ Allows you to define configuration CONSTANTS that take values from environment
6
+ variables. With support for default values, required variables and type
7
+ conversions.
6
8
 
7
9
  [![Build Status](https://travis-ci.org/astrails/constfig.png)](https://travis-ci.org/astrails/constfig)
8
10
  [![Code Climate](https://codeclimate.com/github/astrails/constfig.png)](https://codeclimate.com/github/astrails/constfig)
9
11
 
12
+ ## Introduction
13
+
14
+ The are multiple ways of configuring your Rails application for different
15
+ environments (e.g. staging, production, etc.). One of the popular ones is
16
+ through environment variables. For example Heroku uses this type of
17
+ configuration extensively.
18
+
19
+ One of the benefits of it is that configuration values are never stored in the
20
+ source control system, which improves security (for sensitive configuration
21
+ parameters) and also makes it easier to try different configuration setups w/o
22
+ changing the sources or re-deploying the application.
23
+
24
+ On the other hand writing `(ENV['PRIMARY_DOMAIN'] || "myapp.com")` every time
25
+ you need your domain string becomes cumbersome pretty fast, not to mention
26
+ duplication and having the default repeated all over the place.
27
+
28
+ A competent programmer will of course only do this once, and re-use the value
29
+ everywhere. Something like this:
30
+
31
+ PRIMARY_DOMAIN = ENV['PRIMARY_DOMAIN'].presence || 'myapp.com'
32
+ S3_BUCKET = ENV['S3_BUCKET'] || raise 'missing S3_BUCKET'
33
+ ORDER_EXPIRATION_DAYS = (ENV['ORDER_EXPIRATION_DAYS'].presence || 1).to_i
34
+
35
+ But it quickly becomes complicated, and again, quite a bit of similarly looking
36
+ code that begs to be refactored out.
37
+
38
+ This gem is something I extracted from a couple of my latest projects. It
39
+ allows you to do just that, have a configuration parameters stored in constants
40
+ with values coming from environment variables and ability to provide defaults
41
+ or have required parameters (i.e. fail if missing).
42
+
43
+ I just released version 0.0.1 of [constfig](https://rubygems.org/gems/constfig)
44
+ to rubygems. Sources are of course on
45
+ [github](https://github.com/astrails/constfig).
46
+
10
47
  ## Installation
11
48
 
12
49
  Add this line to your application's Gemfile:
@@ -69,7 +106,7 @@ defaults for non-production environments.
69
106
  There is one caveat with Rails on Heroku. By default Heroku doesn't provide
70
107
  environment variables to your application during the `rake assets:precompile`
71
108
  stage of slug compilation. If you don't take care of it your application will
72
- fail to compile its assets and might fail to work in produciton. To take care
109
+ fail to compile its assets and might fail to work in production. To take care
73
110
  of it you can either use Heroku Labs
74
111
  [user-env-compile](https://devcenter.heroku.com/articles/labs-user-env-compile)
75
112
  option, or (and this is what I'd recommend) you can use development defaults
@@ -83,7 +120,7 @@ For example in Rails you con do this:
83
120
 
84
121
  define_config :DEFAULT_DOMAIN
85
122
 
86
- In development and test environments it willuse 'myapp.dev' ad
123
+ In development and test environments it will use 'myapp.dev' ad
87
124
  `PRIMARY_DOMAIN`, but in production and staging environment it will fail unless
88
125
  `PRIMARY_DOMAIN` is provided by environment.
89
126
 
data/constfig.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Constfig::VERSION
9
9
  gem.authors = ["Vitaly Kushner"]
10
10
  gem.email = ["vitaly@astrails.com"]
11
- gem.description = %q{Simple Constnt Configuration for Ruby. Creates CONSTANTS with values from ENV}
11
+ gem.description = %q{Simple Constnt Configuration for Ruby. Allows you to define configuration CONSTANTS that take values from environment variables. With support for default values, required variables and type conversions.}
12
12
  gem.summary = %q{Simple Constnt configuration for Ruby.}
13
13
  gem.homepage = "http://astrails.com/blog/constfig"
14
14
 
@@ -1,3 +1,3 @@
1
1
  module Constfig
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constfig
3
3
  version: !ruby/object:Gem::Version
4
+ version: 0.0.3
4
5
  prerelease:
5
- version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Vitaly Kushner
@@ -11,8 +11,9 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2013-05-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: Simple Constnt Configuration for Ruby. Creates CONSTANTS with values
15
- from ENV
14
+ description: Simple Constnt Configuration for Ruby. Allows you to define configuration
15
+ CONSTANTS that take values from environment variables. With support for default
16
+ values, required variables and type conversions.
16
17
  email:
17
18
  - vitaly@astrails.com
18
19
  executables: []
@@ -40,23 +41,23 @@ rdoc_options: []
40
41
  require_paths:
41
42
  - lib
42
43
  required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
43
45
  requirements:
44
46
  - - ! '>='
45
47
  - !ruby/object:Gem::Version
48
+ version: '0'
46
49
  segments:
47
50
  - 0
48
- hash: 2038963096202275797
49
- version: '0'
50
- none: false
51
+ hash: -4468990784169410071
51
52
  required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
52
54
  requirements:
53
55
  - - ! '>='
54
56
  - !ruby/object:Gem::Version
57
+ version: '0'
55
58
  segments:
56
59
  - 0
57
- hash: 2038963096202275797
58
- version: '0'
59
- none: false
60
+ hash: -4468990784169410071
60
61
  requirements: []
61
62
  rubyforge_project:
62
63
  rubygems_version: 1.8.25