configliere 0.4.8 → 0.4.10

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/CHANGELOG.textile CHANGED
@@ -1,3 +1,12 @@
1
+ h2. Version 0.4.10
2
+
3
+ Minor improvement to the sub-command (git-style) module. Still not great.
4
+
5
+ h2. Version 0.4.9
6
+
7
+ Gemfile dependencies less aggressive.
8
+ Uses MultiJSON; removed strict dependency on JSON
9
+
1
10
  h2. Version 0.4.7
2
11
 
3
12
  * can now load JSON
data/Gemfile CHANGED
@@ -1,27 +1,40 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'json'
3
+ gem 'multi_json', ">= 1.1"
4
+ gem 'oj', ">= 1.2"
5
+ gem 'json', :platform => :jruby
4
6
 
5
- # Add dependencies to develop your gem here.
6
- # Include everything needed to run rake, tests, features, etc.
7
+ # Only necessary if you want to use Configliere::Prompt
8
+ gem 'highline', ">= 1.5.2"
9
+
10
+ # Only gems that you want listed as development dependencies in the gemspec
7
11
  group :development do
8
- gem 'bundler', "~> 1.0.12"
9
- gem 'yard', "~> 0.6.7"
10
- gem 'jeweler', "~> 1.5.2"
11
- gem 'rspec', "~> 2.5.0"
12
- gem 'spork', "~> 0.9.0.rc5"
13
- gem 'RedCloth' # for yard
12
+ gem 'bundler', "~> 1.1"
13
+ gem 'rake'
14
14
  end
15
15
 
16
- group :development do
17
- # Only necessary if you want to use Configliere::Prompt
18
- gem 'highline', ">= 1.5.2"
16
+ # Gems you would use if hacking on this gem (rather than with it)
17
+ group :support do
18
+ gem 'jeweler', ">= 1.6"
19
+ gem 'pry'
20
+ gem 'yard', ">= 0.7"
21
+ gem 'rspec', "~> 2.8"
22
+ end
23
+
24
+ group :doc do
25
+ gem 'RedCloth', ">= 4.2", :require => "redcloth"
26
+ gem 'redcarpet', ">= 2.1"
19
27
  end
20
28
 
21
- group :optional do
22
- # only interesting for coverage testing
23
- gem 'rcov', ">= 0.9.9"
24
- gem 'reek'
25
- gem 'roodi'
26
- gem 'watchr'
29
+ # Gems for testing and coverage
30
+ group :test do
31
+ gem 'simplecov', ">= 0.5", :platform => :ruby_19
32
+ #
33
+ gem 'guard', ">= 1.0"
34
+ gem 'guard-rspec', ">= 0.6"
35
+ gem 'guard-yard'
36
+ #
37
+ if RUBY_PLATFORM.include?('darwin')
38
+ gem 'rb-fsevent', ">= 0.9"
39
+ end
27
40
  end
data/Guardfile ADDED
@@ -0,0 +1,14 @@
1
+ # -*- ruby -*-
2
+
3
+ format = 'progress' # 'doc' for more verbose, 'progress' for less
4
+ tags = %w[ ] # builder_spec model_spec
5
+
6
+ guard 'rspec', :version => 2, :cli => "--format #{format} #{ tags.map{|tag| "--tag #{tag}"}.join(' ') }" do
7
+ watch(%r{^spec/.+_spec\.rb$})
8
+ watch(%r{^examples/(\w+)/(.+)\.rb$}) { |m| "spec/examples/#{m[1]}_spec.rb" }
9
+ watch(%r{^examples/(\w+)\.rb$}) { |m| "spec/examples/#{m[1]}_spec.rb" }
10
+ watch(%r{^lib/(.+)/(.+)\.rb$}) { |m| "spec/#{m[1]}/#{m[2]}_spec.rb" }
11
+ watch(%r{^lib/(\w+)\.rb$}) { |m| "spec/#{m[1]}}_spec.rb" }
12
+ watch('spec/spec_helper.rb') { 'spec' }
13
+ watch(/spec\/support\/(.+)\.rb/) { 'spec' }
14
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,95 @@
1
+ # License for Configliere
2
+
3
+ The configliere code is __Copyright (c) 2011, 2012 Infochimps, Inc__
4
+
5
+ This code is licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an **AS IS** BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
10
+
11
+ __________________________________________________________________________
12
+
13
+ # Apache License
14
+
15
+
16
+ Apache License
17
+ Version 2.0, January 2004
18
+ http://www.apache.org/licenses/
19
+
20
+ _TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION_
21
+
22
+ ## 1. Definitions.
23
+
24
+ * **License** shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
25
+
26
+ * **Licensor** shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
27
+
28
+ * **Legal Entity** shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
29
+
30
+ * **You** (or **Your**) shall mean an individual or Legal Entity exercising permissions granted by this License.
31
+
32
+ * **Source** form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
33
+
34
+ * **Object** form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
35
+
36
+ * **Work** shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
37
+
38
+ * **Derivative Works** shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
39
+
40
+ * **Contribution** shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
41
+
42
+ * **Contributor** shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
43
+
44
+ ## 2. Grant of Copyright License.
45
+
46
+ Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
47
+
48
+ ## 3. Grant of Patent License.
49
+
50
+ Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
51
+
52
+ ## 4. Redistribution.
53
+
54
+ You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
55
+
56
+ - (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
57
+ - (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
58
+ - (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
59
+ - (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
60
+
61
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
62
+
63
+ ## 5. Submission of Contributions.
64
+
65
+ Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
66
+
67
+ ## 6. Trademarks.
68
+
69
+ This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
70
+
71
+ ## 7. Disclaimer of Warranty.
72
+
73
+ Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
74
+
75
+ ## 8. Limitation of Liability.
76
+
77
+ In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
78
+
79
+ ## 9. Accepting Warranty or Additional Liability.
80
+
81
+ While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
82
+
83
+ _END OF TERMS AND CONDITIONS_
84
+
85
+ ## APPENDIX: How to apply the Apache License to your work.
86
+
87
+ To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets `[]` replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
88
+
89
+ > Copyright [yyyy] [name of copyright owner]
90
+ >
91
+ > Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
92
+ >
93
+ > http://www.apache.org/licenses/LICENSE-2.0
94
+ >
95
+ > Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
- require 'rubygems'
1
+ require 'rubygems' unless defined?(Gem)
2
2
  require 'bundler'
3
3
  begin
4
- Bundler.setup(:default, :development)
4
+ Bundler.setup(:default, :development, :support)
5
5
  rescue Bundler::BundlerError => e
6
6
  $stderr.puts e.message
7
7
  $stderr.puts "Run `bundle install` to install missing gems"
@@ -12,80 +12,53 @@ require 'rake'
12
12
  begin
13
13
  require 'jeweler'
14
14
  Jeweler::Tasks.new do |gem|
15
- gem.name = "configliere"
16
- gem.homepage = "http://infochimps.com/labs"
17
- gem.license = "MIT"
18
- gem.summary = %Q{Wise, discreet configuration management}
15
+ gem.name = "configliere"
16
+ gem.homepage = "http://infochimps.com/tools"
17
+ gem.license = "Apache"
18
+ gem.summary = %Q{Wise, discreet configuration management}
19
+ gem.email = "coders@infochimps.org"
20
+ gem.authors = ["infochimps", "mrflip"]
21
+ gem.executables = []
19
22
  gem.description = %Q{ You've got a script. It's got some settings. Some settings are for this module, some are for that module. Most of them don't change. Except on your laptop, where the paths are different. Or when you're in production mode. Or when you're testing from the command line.
20
23
 
21
24
  "" So, Consigliere of mine, I think you should tell your Don what everyone knows. "" -- Don Corleone
22
25
 
23
26
  Configliere manage settings from many sources: static constants, simple config files, environment variables, commandline options, straight ruby. You don't have to predefine anything, but you can ask configliere to type-convert, require, document or password-obscure any of its fields. Modules can define config settings independently of each other and the main program.
24
27
  } #'
25
- gem.email = "coders@infochimps.org"
26
- gem.authors = ["infochimps", "mrflip"]
27
- gem.executables = []
28
28
  end
29
29
  Jeweler::RubygemsDotOrgTasks.new
30
30
  rescue LoadError
31
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
32
- end
33
-
34
-
35
- require 'rspec/core'
36
- require 'rspec/core/rake_task'
37
- RSpec::Core::RakeTask.new(:spec) do |spec|
38
- spec.pattern = FileList['spec/**/*_spec.rb']
31
+ puts "Jeweler (or a dependency) not available. Install it with: bundle install"
39
32
  end
40
33
 
41
34
  begin
42
- #
35
+ require 'rspec/core'
36
+ require 'rspec/core/rake_task'
37
+ RSpec::Core::RakeTask.new(:spec) do |spec|
38
+ spec.pattern = FileList['spec/**/*_spec.rb']
39
+ end
40
+
43
41
  # if rcov shits the bed with ruby 1.9, see
44
42
  # https://github.com/relevance/rcov/issues/31
45
- #
46
43
  RSpec::Core::RakeTask.new(:rcov) do |spec|
47
44
  spec.pattern = 'spec/**/*_spec.rb'
48
45
  spec.rcov = true
49
46
  spec.rcov_opts = %w[ --exclude .rvm --no-comments --text-summary]
50
47
  end
51
48
  rescue LoadError
52
- task :rspec do
53
- abort "Rspec is not available. In order to run spec, you must: sudo gem install rspec"
54
- end
49
+ task(:rspec){ abort "Rspec is not available. In order to run spec, you must: bundle install" }
50
+ task(:rcov ){ abort "Rspec is not available. In order to run coverage, you must: bundle install" }
55
51
  end
56
52
 
57
53
  begin
58
- require 'reek/rake/task'
59
- Reek::Rake::Task.new do |t|
60
- t.fail_on_error = true
61
- t.verbose = false
62
- t.source_files = 'lib/**/*.rb'
63
- end
64
- rescue LoadError
65
- task :reek do
66
- abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
67
- end
68
- end
69
-
70
- begin
71
- require 'roodi'
72
- require 'roodi_task'
73
- RoodiTask.new do |t|
74
- t.verbose = false
54
+ require 'yard'
55
+ YARD::Rake::YardocTask.new do
56
+ Bundler.setup(:default, :development, :doc)
75
57
  end
76
58
  rescue LoadError
77
- task :roodi do
78
- abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
59
+ task :yardoc do
60
+ abort "YARD is not available. In order to run yardoc, you must: bundle install"
79
61
  end
80
62
  end
81
63
 
82
64
  task :default => :spec
83
-
84
- begin
85
- require 'yard'
86
- YARD::Rake::YardocTask.new
87
- rescue LoadError
88
- task :yardoc do
89
- abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
90
- end
91
- end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.8
1
+ 0.4.10
data/configliere.gemspec CHANGED
@@ -4,30 +4,26 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{configliere}
8
- s.version = "0.4.8"
7
+ s.name = "configliere"
8
+ s.version = "0.4.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{infochimps}, %q{mrflip}]
12
- s.date = %q{2011-08-26}
13
- s.description = %q{ You've got a script. It's got some settings. Some settings are for this module, some are for that module. Most of them don't change. Except on your laptop, where the paths are different. Or when you're in production mode. Or when you're testing from the command line.
14
-
15
- "" So, Consigliere of mine, I think you should tell your Don what everyone knows. "" -- Don Corleone
16
-
17
- Configliere manage settings from many sources: static constants, simple config files, environment variables, commandline options, straight ruby. You don't have to predefine anything, but you can ask configliere to type-convert, require, document or password-obscure any of its fields. Modules can define config settings independently of each other and the main program.
18
- }
19
- s.email = %q{coders@infochimps.org}
11
+ s.authors = ["infochimps", "mrflip"]
12
+ s.date = "2012-06-30"
13
+ s.description = " You've got a script. It's got some settings. Some settings are for this module, some are for that module. Most of them don't change. Except on your laptop, where the paths are different. Or when you're in production mode. Or when you're testing from the command line.\n\n \"\" So, Consigliere of mine, I think you should tell your Don what everyone knows. \"\" -- Don Corleone\n\nConfigliere manage settings from many sources: static constants, simple config files, environment variables, commandline options, straight ruby. You don't have to predefine anything, but you can ask configliere to type-convert, require, document or password-obscure any of its fields. Modules can define config settings independently of each other and the main program.\n"
14
+ s.email = "coders@infochimps.org"
20
15
  s.extra_rdoc_files = [
21
- "LICENSE",
16
+ "LICENSE.md",
22
17
  "README.textile"
23
18
  ]
24
19
  s.files = [
25
- ".document",
20
+ ".rspec",
26
21
  ".watchr",
27
22
  "CHANGELOG.textile",
28
23
  "FEATURES.txt",
29
24
  "Gemfile",
30
- "LICENSE",
25
+ "Guardfile",
26
+ "LICENSE.md",
31
27
  "README.textile",
32
28
  "Rakefile",
33
29
  "VERSION",
@@ -44,6 +40,7 @@ Configliere manage settings from many sources: static constants, simple config f
44
40
  "examples/env_var_script.rb",
45
41
  "examples/help_message_demo.rb",
46
42
  "examples/independent_config.rb",
43
+ "examples/joke.rb",
47
44
  "examples/prompt.rb",
48
45
  "examples/simple_script.rb",
49
46
  "examples/simple_script.yaml",
@@ -74,65 +71,37 @@ Configliere manage settings from many sources: static constants, simple config f
74
71
  "spec/spec.opts",
75
72
  "spec/spec_helper.rb"
76
73
  ]
77
- s.homepage = %q{http://infochimps.com/labs}
78
- s.licenses = [%q{MIT}]
79
- s.require_paths = [%q{lib}]
80
- s.rubygems_version = %q{1.8.6}
81
- s.summary = %q{Wise, discreet configuration management}
82
- s.test_files = [
83
- "examples/config_block_script.rb",
84
- "examples/encrypted_script.rb",
85
- "examples/env_var_script.rb",
86
- "examples/help_message_demo.rb",
87
- "examples/independent_config.rb",
88
- "examples/prompt.rb",
89
- "examples/simple_script.rb",
90
- "spec/configliere/commandline_spec.rb",
91
- "spec/configliere/commands_spec.rb",
92
- "spec/configliere/config_block_spec.rb",
93
- "spec/configliere/config_file_spec.rb",
94
- "spec/configliere/crypter_spec.rb",
95
- "spec/configliere/deep_hash_spec.rb",
96
- "spec/configliere/define_spec.rb",
97
- "spec/configliere/encrypted_spec.rb",
98
- "spec/configliere/env_var_spec.rb",
99
- "spec/configliere/param_spec.rb",
100
- "spec/configliere/prompt_spec.rb",
101
- "spec/configliere_spec.rb",
102
- "spec/spec_helper.rb"
103
- ]
74
+ s.homepage = "http://infochimps.com/tools"
75
+ s.licenses = ["Apache"]
76
+ s.require_paths = ["lib"]
77
+ s.rubygems_version = "1.8.11"
78
+ s.summary = "Wise, discreet configuration management"
104
79
 
105
80
  if s.respond_to? :specification_version then
106
81
  s.specification_version = 3
107
82
 
108
83
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
84
+ s.add_runtime_dependency(%q<multi_json>, [">= 1.1"])
85
+ s.add_runtime_dependency(%q<oj>, [">= 1.2"])
109
86
  s.add_runtime_dependency(%q<json>, [">= 0"])
110
- s.add_development_dependency(%q<bundler>, ["~> 1.0.12"])
111
- s.add_development_dependency(%q<yard>, ["~> 0.6.7"])
112
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
113
- s.add_development_dependency(%q<rspec>, ["~> 2.5.0"])
114
- s.add_development_dependency(%q<spork>, ["~> 0.9.0.rc5"])
115
- s.add_development_dependency(%q<RedCloth>, [">= 0"])
116
- s.add_development_dependency(%q<highline>, [">= 1.5.2"])
87
+ s.add_runtime_dependency(%q<highline>, [">= 1.5.2"])
88
+ s.add_development_dependency(%q<bundler>, ["~> 1.1"])
89
+ s.add_development_dependency(%q<rake>, [">= 0"])
117
90
  else
91
+ s.add_dependency(%q<multi_json>, [">= 1.1"])
92
+ s.add_dependency(%q<oj>, [">= 1.2"])
118
93
  s.add_dependency(%q<json>, [">= 0"])
119
- s.add_dependency(%q<bundler>, ["~> 1.0.12"])
120
- s.add_dependency(%q<yard>, ["~> 0.6.7"])
121
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
122
- s.add_dependency(%q<rspec>, ["~> 2.5.0"])
123
- s.add_dependency(%q<spork>, ["~> 0.9.0.rc5"])
124
- s.add_dependency(%q<RedCloth>, [">= 0"])
125
94
  s.add_dependency(%q<highline>, [">= 1.5.2"])
95
+ s.add_dependency(%q<bundler>, ["~> 1.1"])
96
+ s.add_dependency(%q<rake>, [">= 0"])
126
97
  end
127
98
  else
99
+ s.add_dependency(%q<multi_json>, [">= 1.1"])
100
+ s.add_dependency(%q<oj>, [">= 1.2"])
128
101
  s.add_dependency(%q<json>, [">= 0"])
129
- s.add_dependency(%q<bundler>, ["~> 1.0.12"])
130
- s.add_dependency(%q<yard>, ["~> 0.6.7"])
131
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
132
- s.add_dependency(%q<rspec>, ["~> 2.5.0"])
133
- s.add_dependency(%q<spork>, ["~> 0.9.0.rc5"])
134
- s.add_dependency(%q<RedCloth>, [">= 0"])
135
102
  s.add_dependency(%q<highline>, [">= 1.5.2"])
103
+ s.add_dependency(%q<bundler>, ["~> 1.1"])
104
+ s.add_dependency(%q<rake>, [">= 0"])
136
105
  end
137
106
  end
138
107
 
data/examples/joke.rb ADDED
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.dirname(__FILE__)+'/../lib'
3
+ require 'configliere'
4
+
5
+ Settings.use :commands
6
+
7
+ Settings.define_command :q1, :description => "The first joke (question)"
8
+ Settings.define_command :q2, :description => "The second joke (question)"
9
+ Settings.define_command :q3, :description => "The third joke (question)"
10
+
11
+ Settings.define_command :a1, :description => "The first joke (answer -- all ages)"
12
+ Settings.define_command :a2, :description => "The second joke (answer -- PG-13, themes of death)" do |cmd|
13
+ cmd.define :age_limit, :type => Integer, :default => 13, :description => "minimum age to be able to enjoy joke 2"
14
+ end
15
+ Settings.define_command :a3, :description => "The third joke (answer -- R, strong language)" do |cmd|
16
+ cmd.define :age_limit, :type => Integer, :default => 17, :description => "minimum age to be able to enjoy joke 3"
17
+ cmd.define :bleep, :type => :boolean, :default => false, :description => "if enabled, solecisms will be bowlerized"
18
+ end
19
+
20
+ Settings.define :debug, :type => :boolean, :default => false, :description => "show verbose progress", :internal => true
21
+ Settings.define :age, :type => Integer, :required => true, :description => "Your age, in human years"
22
+ Settings.define :fake_id, :type => :boolean, :default => false, :description => "A fake ID might be enough to bypass the age test"
23
+
24
+ class Clown
25
+
26
+ def q1
27
+ puts "what do you call a deer with no eyes?"
28
+ end
29
+
30
+ def a1
31
+ q1
32
+ puts "no-eye deer"
33
+ end
34
+
35
+ def q2
36
+ puts "what do you call a dead deer with no eyes?"
37
+ end
38
+
39
+ def a2
40
+ q2
41
+ puts "still no-eye deer"
42
+ end
43
+
44
+ def q3
45
+ puts "what do you call a dead, castrated deer with no eyes?"
46
+ end
47
+
48
+ def a3
49
+ q3
50
+ puts "still no-#{Settings[:bleep] ? 'bleeping' : 'fucking'} no-eye deer"
51
+ end
52
+
53
+ def check_age_limit!
54
+ return if not Settings[:age_limit]
55
+ if Settings[:fake_id]
56
+ puts "ok but you didn't hear it from me...\n\n"
57
+ return true
58
+ end
59
+ if (Settings.age < Settings[:age_limit])
60
+ warn "Sorry kid, you're too young for this joke. Try this again when you're older (or maybe ask for --help)"
61
+ exit(1)
62
+ end
63
+ end
64
+
65
+ def check_command!
66
+ if not Settings.command_name
67
+ Settings.die "Which joke would you like to hear?"
68
+ end
69
+ end
70
+
71
+ def run
72
+ check_command!
73
+ check_age_limit!
74
+ self.public_send(Settings.command_name)
75
+ end
76
+ end
77
+
78
+ Settings.resolve!
79
+
80
+ if Settings.debug
81
+ puts " -- received command #{Settings.command_name}, settings #{Settings}"
82
+ puts ""
83
+ puts ""
84
+ end
85
+
86
+
87
+ Clown.new.run
@@ -21,7 +21,9 @@ module Configliere
21
21
  command_configuration = Configliere::Param.new
22
22
  command_configuration.use :commandline, :env_var
23
23
  yield command_configuration if block_given?
24
- commands[cmd] = options.merge(:config => command_configuration)
24
+ commands[cmd] = options
25
+ commands[cmd][:config] = command_configuration
26
+ commands[cmd]
25
27
  end
26
28
 
27
29
  def commands
@@ -34,9 +36,14 @@ module Configliere
34
36
 
35
37
  def resolve!
36
38
  super()
37
- commands.each_value do |cmd_info|
39
+ commands.each do |cmd, cmd_info|
38
40
  cmd_info[:config].resolve!
39
41
  end
42
+ if command_name
43
+ sub_config = commands[command_name][:config]
44
+ adoptable = sub_config.send(:definitions).keys
45
+ merge!(sub_config.select{|k,v| adoptable.include?(k) } )
46
+ end
40
47
  self
41
48
  end
42
49
 
@@ -72,6 +79,7 @@ module Configliere
72
79
  help = ["\nAvailable commands:"]
73
80
  commands.sort_by(&:to_s).each do |cmd, info|
74
81
  help << (" %-27s %s" % [cmd, info[:description]]) unless info[:internal]
82
+ info[:config].param_lines[1..-1].each{|line| help << " #{line}" } rescue nil
75
83
  end
76
84
  help << "\nRun `#{script_base_and_command.first} help COMMAND' for more help on COMMAND" if commands.include?(:help)
77
85
  help.flatten.join("\n")
@@ -33,7 +33,7 @@ module Configliere
33
33
  case filetype(filename)
34
34
  when 'json' then read_json(File.open(filename), options)
35
35
  when 'yaml' then read_yaml(File.open(filename), options)
36
- else read_yaml(File.open(filename), options)
36
+ else read_yaml(File.open(filename), options)
37
37
  end
38
38
  rescue Errno::ENOENT => e
39
39
  warn "Loading empty configliere settings file #{filename}"
@@ -56,7 +56,8 @@ module Configliere
56
56
  # we depend on you to require some sort of JSON
57
57
  #
58
58
  def read_json json_str, options={}
59
- new_data = JSON.load(json_str) || {}
59
+ require 'multi_json'
60
+ new_data = MultiJson.load(json_str) || {}
60
61
  # Extract the :env (production/development/etc)
61
62
  if options[:env]
62
63
  new_data = new_data[options[:env]] || {}
data/lib/configliere.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'date' # type conversion
2
2
  require 'time' # type conversion
3
- require 'yaml' # read files
4
3
  require 'fileutils' # so save! can mkdir
5
4
  require 'configliere/deep_hash' # magic hash for params
6
5
  require 'configliere/param' # params container
@@ -12,7 +12,7 @@ describe Configliere::ConfigFile do
12
12
 
13
13
  describe 'loading a yaml config file' do
14
14
  before do
15
- @fake_file = '{ :my_param: val_from_file }'
15
+ @fake_file = "---\nmy_param: val_from_file"
16
16
  end
17
17
 
18
18
  describe 'successfully' do
@@ -10,6 +10,6 @@ describe "Configliere" do
10
10
  end
11
11
 
12
12
  it 'requires corresponding plugins when you call use' do
13
- lambda{ Configliere.use(:param, :foo) }.should raise_error(LoadError, 'no such file to load -- configliere/foo')
13
+ lambda{ Configliere.use(:param, :foo) }.should raise_error(LoadError, /no.*load.*configliere\/foo/)
14
14
  end
15
15
  end
data/spec/spec_helper.rb CHANGED
@@ -1,23 +1,8 @@
1
1
  # encoding: UTF-8
2
- require 'rubygems'
3
- require 'spork'
2
+ require 'rubygems' unless defined?(Gem)
4
3
  require 'rspec'
5
4
 
6
- Spork.prefork do
7
- # Loading more in this block will cause your tests to run faster.
8
- # However, changes don't take effect until you restart spork.
9
-
10
- $LOAD_PATH.unshift(File.dirname(__FILE__))
11
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
12
-
13
- require 'configliere'
14
-
15
- RSpec.configure do |config|
16
- end
17
- end
18
-
19
- Spork.each_run do
20
- # This code will be run each time you run your specs.
21
-
22
- end
5
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
6
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
23
7
 
8
+ require 'configliere'
metadata CHANGED
@@ -1,123 +1,107 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: configliere
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.10
4
5
  prerelease:
5
- version: 0.4.8
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - infochimps
9
9
  - mrflip
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
-
14
- date: 2011-08-26 00:00:00 Z
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: json
18
- requirement: &id001 !ruby/object:Gem::Requirement
13
+ date: 2012-06-30 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: multi_json
17
+ requirement: &70312657570540 !ruby/object:Gem::Requirement
19
18
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '1.1'
24
23
  type: :runtime
25
24
  prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *70312657570540
26
+ - !ruby/object:Gem::Dependency
27
+ name: oj
28
+ requirement: &70312657570060 !ruby/object:Gem::Requirement
30
29
  none: false
31
- requirements:
32
- - - ~>
33
- - !ruby/object:Gem::Version
34
- version: 1.0.12
35
- type: :development
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
36
35
  prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: yard
40
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *70312657570060
37
+ - !ruby/object:Gem::Dependency
38
+ name: json
39
+ requirement: &70312657569580 !ruby/object:Gem::Requirement
41
40
  none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 0.6.7
46
- type: :development
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ type: :runtime
47
46
  prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: jeweler
51
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *70312657569580
48
+ - !ruby/object:Gem::Dependency
49
+ name: highline
50
+ requirement: &70312657569100 !ruby/object:Gem::Requirement
52
51
  none: false
53
- requirements:
54
- - - ~>
55
- - !ruby/object:Gem::Version
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
56
55
  version: 1.5.2
57
- type: :development
58
- prerelease: false
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: rspec
62
- requirement: &id005 !ruby/object:Gem::Requirement
63
- none: false
64
- requirements:
65
- - - ~>
66
- - !ruby/object:Gem::Version
67
- version: 2.5.0
68
- type: :development
56
+ type: :runtime
69
57
  prerelease: false
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
72
- name: spork
73
- requirement: &id006 !ruby/object:Gem::Requirement
58
+ version_requirements: *70312657569100
59
+ - !ruby/object:Gem::Dependency
60
+ name: bundler
61
+ requirement: &70312657584980 !ruby/object:Gem::Requirement
74
62
  none: false
75
- requirements:
63
+ requirements:
76
64
  - - ~>
77
- - !ruby/object:Gem::Version
78
- version: 0.9.0.rc5
65
+ - !ruby/object:Gem::Version
66
+ version: '1.1'
79
67
  type: :development
80
68
  prerelease: false
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
83
- name: RedCloth
84
- requirement: &id007 !ruby/object:Gem::Requirement
69
+ version_requirements: *70312657584980
70
+ - !ruby/object:Gem::Dependency
71
+ name: rake
72
+ requirement: &70312657584500 !ruby/object:Gem::Requirement
85
73
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: "0"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
90
78
  type: :development
91
79
  prerelease: false
92
- version_requirements: *id007
93
- - !ruby/object:Gem::Dependency
94
- name: highline
95
- requirement: &id008 !ruby/object:Gem::Requirement
96
- none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: 1.5.2
101
- type: :development
102
- prerelease: false
103
- version_requirements: *id008
104
- description: " You've got a script. It's got some settings. Some settings are for this module, some are for that module. Most of them don't change. Except on your laptop, where the paths are different. Or when you're in production mode. Or when you're testing from the command line.\n\n \"\" So, Consigliere of mine, I think you should tell your Don what everyone knows. \"\" -- Don Corleone\n\n\
105
- Configliere manage settings from many sources: static constants, simple config files, environment variables, commandline options, straight ruby. You don't have to predefine anything, but you can ask configliere to type-convert, require, document or password-obscure any of its fields. Modules can define config settings independently of each other and the main program.\n"
80
+ version_requirements: *70312657584500
81
+ description: ! " You've got a script. It's got some settings. Some settings are for
82
+ this module, some are for that module. Most of them don't change. Except on your
83
+ laptop, where the paths are different. Or when you're in production mode. Or when
84
+ you're testing from the command line.\n\n \"\" So, Consigliere of mine, I think
85
+ you should tell your Don what everyone knows. \"\" -- Don Corleone\n\nConfigliere
86
+ manage settings from many sources: static constants, simple config files, environment
87
+ variables, commandline options, straight ruby. You don't have to predefine anything,
88
+ but you can ask configliere to type-convert, require, document or password-obscure
89
+ any of its fields. Modules can define config settings independently of each other
90
+ and the main program.\n"
106
91
  email: coders@infochimps.org
107
92
  executables: []
108
-
109
93
  extensions: []
110
-
111
- extra_rdoc_files:
112
- - LICENSE
94
+ extra_rdoc_files:
95
+ - LICENSE.md
113
96
  - README.textile
114
- files:
115
- - .document
97
+ files:
98
+ - .rspec
116
99
  - .watchr
117
100
  - CHANGELOG.textile
118
101
  - FEATURES.txt
119
102
  - Gemfile
120
- - LICENSE
103
+ - Guardfile
104
+ - LICENSE.md
121
105
  - README.textile
122
106
  - Rakefile
123
107
  - VERSION
@@ -134,6 +118,7 @@ files:
134
118
  - examples/env_var_script.rb
135
119
  - examples/help_message_demo.rb
136
120
  - examples/independent_config.rb
121
+ - examples/joke.rb
137
122
  - examples/prompt.rb
138
123
  - examples/simple_script.rb
139
124
  - examples/simple_script.yaml
@@ -163,54 +148,32 @@ files:
163
148
  - spec/configliere_spec.rb
164
149
  - spec/spec.opts
165
150
  - spec/spec_helper.rb
166
- homepage: http://infochimps.com/labs
167
- licenses:
168
- - MIT
151
+ homepage: http://infochimps.com/tools
152
+ licenses:
153
+ - Apache
169
154
  post_install_message:
170
155
  rdoc_options: []
171
-
172
- require_paths:
156
+ require_paths:
173
157
  - lib
174
- required_ruby_version: !ruby/object:Gem::Requirement
158
+ required_ruby_version: !ruby/object:Gem::Requirement
175
159
  none: false
176
- requirements:
177
- - - ">="
178
- - !ruby/object:Gem::Version
179
- hash: -3607110922924291664
180
- segments:
160
+ requirements:
161
+ - - ! '>='
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ segments:
181
165
  - 0
182
- version: "0"
183
- required_rubygems_version: !ruby/object:Gem::Requirement
166
+ hash: -1763180514100081494
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
184
168
  none: false
185
- requirements:
186
- - - ">="
187
- - !ruby/object:Gem::Version
188
- version: "0"
169
+ requirements:
170
+ - - ! '>='
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
189
173
  requirements: []
190
-
191
174
  rubyforge_project:
192
- rubygems_version: 1.8.6
175
+ rubygems_version: 1.8.11
193
176
  signing_key:
194
177
  specification_version: 3
195
178
  summary: Wise, discreet configuration management
196
- test_files:
197
- - examples/config_block_script.rb
198
- - examples/encrypted_script.rb
199
- - examples/env_var_script.rb
200
- - examples/help_message_demo.rb
201
- - examples/independent_config.rb
202
- - examples/prompt.rb
203
- - examples/simple_script.rb
204
- - spec/configliere/commandline_spec.rb
205
- - spec/configliere/commands_spec.rb
206
- - spec/configliere/config_block_spec.rb
207
- - spec/configliere/config_file_spec.rb
208
- - spec/configliere/crypter_spec.rb
209
- - spec/configliere/deep_hash_spec.rb
210
- - spec/configliere/define_spec.rb
211
- - spec/configliere/encrypted_spec.rb
212
- - spec/configliere/env_var_spec.rb
213
- - spec/configliere/param_spec.rb
214
- - spec/configliere/prompt_spec.rb
215
- - spec/configliere_spec.rb
216
- - spec/spec_helper.rb
179
+ test_files: []
data/.document DELETED
@@ -1,7 +0,0 @@
1
- README.textile
2
- lib/**/*.rb
3
- bin/*
4
- -
5
- LICENSE
6
- CHANGELOG.textile
7
- VERSION
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009 mrflip
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.