configus 0.0.4 → 0.0.5

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b8a0371a1dc4ddac7c726ed2d7f1095cbc133ab3
4
+ data.tar.gz: f1944395474e964e680fffcbc05ac755027a6670
5
+ SHA512:
6
+ metadata.gz: 5a9f3d785e7842a3625d95b950858ee2db2402b4bb98ffd99b37b25220fe2e2b069e195938337de86e580f193397e194a707a519080703f68a5df469c6d4f17e
7
+ data.tar.gz: b45c82eaa4ad173212f96dbba9cf9293a07f381c14527f5815af48a8ff4b3e7bcf9986f7e5a11c1d7153cdd198686a939a62a11df710083ee3ae97be215dc9ed
@@ -0,0 +1 @@
1
+ repo_token: oybJW5C1ZdCRqiC1Ivn4mDjOqNdYipXts
@@ -1,7 +1,5 @@
1
1
  rvm:
2
- - 1.8.7
3
- - ree
4
- - 1.9.2
5
2
  - 1.9.3
3
+ - 2.0.0
6
4
  - rbx
7
5
  - jruby
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in configus.gemspec
4
4
  gemspec
5
+
6
+ gem 'rake'
7
+ gem 'rspec'
8
+ gem 'coveralls', :require => false
data/README.md CHANGED
@@ -1,11 +1,16 @@
1
1
  # Configus
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/configus.png)](https://rubygems.org/gems/configus)
4
+ [![Build Status](https://travis-ci.org/kaize/configus.png)](https://travis-ci.org/kaize/configus)
5
+ [![Dependency Status](https://gemnasium.com/kaize/configus.png)](https://gemnasium.com/kaize/configus)
6
+ [![Code Climate](https://codeclimate.com/github/kaize/configus.png)](https://codeclimate.com/github/kaize/configus)
7
+ [![Coverage Status](https://coveralls.io/repos/kaize/configus/badge.png?branch=master)](https://coveralls.io/r/kaize/configus)
8
+ [![Gem Version](http://stillmaintained.com/kaize/configus.png)](http://stillmaintained.com/kaize/configus)
9
+
3
10
  ## Summary
4
11
 
5
12
  Configus helps you easily manage environment specific settings
6
13
 
7
- [![Build Status](https://secure.travis-ci.org/mokevnin/configus.png)](http://travis-ci.org/mokevnin/configus)
8
-
9
14
  ## Installing
10
15
 
11
16
  Add this to your `Gemfile`:
@@ -16,42 +21,64 @@ Add this to your `Gemfile`:
16
21
 
17
22
  ### Definition
18
23
 
19
- Configus.build :development do # set current environment
20
- env :production do
21
- website_url 'http://example.com'
22
- email do
23
- pop do
24
- address 'pop.example.com'
25
- port 110
26
- end
27
- smtp do
28
- address 'smtp.example.com'
29
- port 25
30
- end
31
- end
24
+ ``` ruby
25
+ Configus.build :development do # set current environment
26
+ env :production do
27
+ site_name 'Example'
28
+ web do
29
+ domain 'example.com'
30
+ protocol 'https'
31
+ port 80
32
+ uri -> { "#{protocol}://#{domain}:#{port}" }
33
+ end
34
+ site_uri -> { web.uri }
35
+ email do
36
+ pop do
37
+ address 'pop.example.com'
38
+ port 110
32
39
  end
40
+ smtp do
41
+ address 'smtp.example.com'
42
+ port 25
43
+ end
44
+ end
45
+ end
33
46
 
34
- env :development, :parent => :production do
35
- website_url 'http://text.example.com'
36
- email do
37
- smtp do
38
- address 'smpt.text.example.com'
39
- end
40
- end
47
+ env :development, :parent => :production do
48
+ web do
49
+ domain 'localhost'
50
+ protocol 'http'
51
+ port 9292
52
+ end
53
+ email do
54
+ smtp do
55
+ address 'smpt.text.example.com'
41
56
  end
42
57
  end
58
+ end
59
+ end
60
+ ```
43
61
 
44
62
  ### Usage
45
63
 
46
- configus.website_url # => 'http://text.example.com'
64
+ configus.site_name # => 'Example'
65
+ configus.web.uri # => 'https://example.com:80'
66
+ configus.site_uri # => 'https://example.com:80'
47
67
  configus.email.pop.port # => 110
48
68
 
49
69
  ### Rails
50
70
 
51
- define your config in `config/initializers/configus.rb`
71
+ define your config in `lib/configus.rb`
52
72
 
53
73
  Configus.build Rails.env do
54
- # settigns
74
+ # settings
75
+ end
76
+
77
+ reload
78
+
79
+ # config/environments/development.rb
80
+ ActionDispatch::Reloader.to_prepare do
81
+ load Rails.root.join('lib/configus.rb')
55
82
  end
56
83
 
57
84
  ## Similar
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
  require 'rspec/core/rake_task'
3
+
3
4
  RSpec::Core::RakeTask.new(:spec)
5
+
4
6
  task :default => :spec
5
7
  task :test => :spec
@@ -17,8 +17,4 @@ Gem::Specification.new do |s|
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
-
21
- # specify any dependencies here; for example:
22
- s.add_development_dependency "rspec"
23
- s.add_runtime_dependency "rake"
24
20
  end
@@ -1,10 +1,11 @@
1
1
  require "configus/version"
2
- require 'configus/builder'
3
- require 'configus/proxy'
4
- require 'configus/config'
5
2
  require 'configus/core_ext/kernel'
6
3
 
7
4
  module Configus
5
+ autoload :Builder, 'configus/builder'
6
+ autoload :Proxy, 'configus/proxy'
7
+ autoload :Config, 'configus/config'
8
+
8
9
  def self.build(env, &block)
9
10
  @config = Builder.build(env, &block)
10
11
  end
@@ -39,6 +39,8 @@ module Configus
39
39
 
40
40
  def env(env, options = {}, &block)
41
41
  env = env.to_sym
42
+ raise ArgumentError, "Double definition of environment '#{env}'" if @envs.keys.include?(env)
43
+
42
44
  @envs[env] = {
43
45
  :options => options,
44
46
  }
@@ -10,12 +10,15 @@ module Configus
10
10
 
11
11
  (class << self; self; end).class_eval do
12
12
  config.each_pair do |key, value|
13
- if value.is_a? Hash
13
+ case value
14
+ when Hash
14
15
  value = Config.new(value)
16
+ when Proc
17
+ value
15
18
  end
16
19
 
17
20
  define_method key.to_sym do
18
- value
21
+ value.is_a?(Proc) ? instance_exec(&value) : value
19
22
  end
20
23
  end
21
24
  end
@@ -39,7 +42,7 @@ module Configus
39
42
  end
40
43
 
41
44
  def method_missing(meth, *args, &blk)
42
- raise "'#{meth}' key does not exists in your configus"
45
+ raise "'#{meth}' key does not exist in your configus"
43
46
  end
44
47
  end
45
48
  end
@@ -1,3 +1,3 @@
1
1
  module Configus
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -39,4 +39,17 @@ describe Configus::Builder do
39
39
  }
40
40
  }
41
41
  end
42
+
43
+ it 'should raise error' do
44
+ p = Proc.new do
45
+ env :production do
46
+ key_1 'value 1'
47
+ end
48
+
49
+ env :production do
50
+ key_2 'value 2'
51
+ end
52
+ end
53
+ expect{ Configus::Builder.new(:production, p) }.to raise_error ArgumentError
54
+ end
42
55
  end
@@ -39,3 +39,60 @@ describe Configus::Config do
39
39
  end
40
40
  end
41
41
 
42
+ describe "Hardcore" do
43
+
44
+ it 'should use defined value' do
45
+ p = Proc.new do
46
+ env :production do
47
+ foo 'bar'
48
+ bar 'bom'
49
+ baz -> { foo + bar }
50
+ end
51
+ end
52
+
53
+ builder = Configus::Builder.new(:production, p)
54
+ @options = builder.result
55
+ @config = Configus::Config.new(@options)
56
+
57
+ @config.foo == @options[:foo]
58
+ @config.bar == @options[:bar]
59
+ @config.baz == @options[:foo] + @options[:bar]
60
+ @config.baz == @config.foo + @config.bar
61
+ end
62
+
63
+ it "second" do
64
+ p = Proc.new do
65
+ env :a do
66
+ foo do
67
+ bar 'baz'
68
+ bom 'bim'
69
+ baz -> { bar + bim}
70
+ end
71
+ key1 do
72
+ key2 'value1'
73
+ key3 'value2'
74
+ key4 -> { key2 + key3}
75
+ end
76
+ end
77
+
78
+ env :b, parent: :a do
79
+ bom -> { foo.bar }
80
+ key1 do
81
+ key2 'value3'
82
+ end
83
+ end
84
+ end
85
+
86
+ builder_a = Configus::Builder.new(:a, p)
87
+ @options_a = builder_a.result
88
+ @config_a = Configus::Config.new(@options_a)
89
+
90
+ builder_b = Configus::Builder.new(:b, p)
91
+ @options_b = builder_b.result
92
+ @config_b = Configus::Config.new(@options_b)
93
+
94
+ @config_b.bom == @config_a.foo.bar
95
+ @config_b.key1.key4 == @config_b.key1.key2 + @config_a.key1.key3
96
+ end
97
+ end
98
+
@@ -1,3 +1,7 @@
1
- require 'configus'
2
1
  require 'bundler/setup'
2
+ Bundler.require
3
3
 
4
+ if ENV["TRAVIS"]
5
+ require 'coveralls'
6
+ Coveralls.wear!
7
+ end
metadata CHANGED
@@ -1,38 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mokevnin Kirill
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-02-11 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rspec
16
- requirement: &75431570 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
23
- prerelease: false
24
- version_requirements: *75431570
25
- - !ruby/object:Gem::Dependency
26
- name: rake
27
- requirement: &75431290 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *75431290
11
+ date: 2014-01-17 00:00:00.000000000 Z
12
+ dependencies: []
36
13
  description: Configus helps you easily manage environment specific settings
37
14
  email:
38
15
  - mokevnin@gmail.com
@@ -40,8 +17,9 @@ executables: []
40
17
  extensions: []
41
18
  extra_rdoc_files: []
42
19
  files:
43
- - .gitignore
44
- - .travis.yml
20
+ - ".coveralls.yml"
21
+ - ".gitignore"
22
+ - ".travis.yml"
45
23
  - Gemfile
46
24
  - README.md
47
25
  - Rakefile
@@ -57,27 +35,28 @@ files:
57
35
  - spec/spec_helper.rb
58
36
  homepage: https://github.com/kaize/configus
59
37
  licenses: []
38
+ metadata: {}
60
39
  post_install_message:
61
40
  rdoc_options: []
62
41
  require_paths:
63
42
  - lib
64
43
  required_ruby_version: !ruby/object:Gem::Requirement
65
- none: false
66
44
  requirements:
67
- - - ! '>='
45
+ - - ">="
68
46
  - !ruby/object:Gem::Version
69
47
  version: '0'
70
48
  required_rubygems_version: !ruby/object:Gem::Requirement
71
- none: false
72
49
  requirements:
73
- - - ! '>='
50
+ - - ">="
74
51
  - !ruby/object:Gem::Version
75
52
  version: '0'
76
53
  requirements: []
77
54
  rubyforge_project: configus
78
- rubygems_version: 1.8.10
55
+ rubygems_version: 2.2.0
79
56
  signing_key:
80
- specification_version: 3
57
+ specification_version: 4
81
58
  summary: Configus helps you easily manage environment specific settings
82
- test_files: []
83
- has_rdoc:
59
+ test_files:
60
+ - spec/configus/builder_spec.rb
61
+ - spec/configus/config_spec.rb
62
+ - spec/spec_helper.rb