dot_configure 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +72 -0
- data/Rakefile +2 -0
- data/dot_configure.gemspec +26 -0
- data/lib/dot_configure.rb +1 -0
- data/lib/dot_configure/dot_configure.rb +32 -0
- data/lib/dot_configure/options.rb +12 -0
- data/lib/dot_configure/version.rb +4 -0
- data/spec/dot_configure/dot_configure_spec.rb +0 -0
- data/spec/spec_helper.rb +81 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 892831f35dc73723c677c0278bb976b642f9e559
|
4
|
+
data.tar.gz: bfdb7f99a65ecd6fa8341e503d8cfe5cd90e8498
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 493b8d5fdc8c7e544328eb5c9c0c3bac6c25d3ade8e4deaa379a185d802556c39c6a90126348d25c51a597bbec92ffd6de830959e5ead85f643052202de56c41
|
7
|
+
data.tar.gz: eec8a37edf42c8f73b01cd401c3bad2d31cc9e1f9ff73259b4402eb85f48c2daf3f009e64cf751fa44c6a79462397cd15b89df2d70555c19aa55efe025c25536
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.DS_Store*
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Joseph Lorich (joseph@lorich.me)
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# .configure
|
2
|
+
|
3
|
+
Easily add configuration options to classes, modules, and object instances.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'dot_configure'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
#####Extend DotConfigure to provide Class and Module level options
|
18
|
+
|
19
|
+
class TestClass
|
20
|
+
extend DotConfigure
|
21
|
+
end
|
22
|
+
|
23
|
+
`TestClass` will now have a configure method and options!
|
24
|
+
|
25
|
+
TestClass.configure do |config|
|
26
|
+
config.dot_configure_rules = true
|
27
|
+
end
|
28
|
+
|
29
|
+
=> #<DotConfigure::Options dot_configure_rules=true>
|
30
|
+
|
31
|
+
The resulting options are now available at `TestClass.options`
|
32
|
+
|
33
|
+
#####Include DotConfigure to provide instance level options
|
34
|
+
When you `include` dotconfigure, rather than extend, you get all the Class/Module level options, but also get seperate instance-level options objects.
|
35
|
+
|
36
|
+
class TestClass
|
37
|
+
include DotConfigure
|
38
|
+
end
|
39
|
+
|
40
|
+
> `TestClass.new.options`
|
41
|
+
=> #<DotConfigure::Options>
|
42
|
+
|
43
|
+
Class/Module and instance level options are completely separate so each individual object can have it's own information.
|
44
|
+
|
45
|
+
#####DotConfigure::Options
|
46
|
+
The options returned are an [OpenStruct](http://www.ruby-doc.org/stdlib-2.0/libdoc/ostruct/rdoc/OpenStruct.html) that has been extended in `dot_configure/options.rb` to allow for specific monkey-patching if desired. OpenStructs allow for hash, string and dot access to any values.
|
47
|
+
|
48
|
+
> `TestClass.options.dot_configure_rules`
|
49
|
+
=> true
|
50
|
+
|
51
|
+
> `TestClass.options[:dot_configure_rules]`
|
52
|
+
=> true
|
53
|
+
|
54
|
+
> `TestClass.options['dot_configure_rules']`
|
55
|
+
=> true
|
56
|
+
|
57
|
+
#####Locking
|
58
|
+
When calling `configure` can also pass in `lock: true` to prevent further write access to the options. Once configured with the lock setting, any subsequent attempts to call `.configure` will fail. Also, calls to `.options` will return a cloned options hash so modifications will not be saved.
|
59
|
+
|
60
|
+
To call a locking configure method simply set the keyword argument:
|
61
|
+
|
62
|
+
TestClass.configure(lock: true) do |config|
|
63
|
+
config.dot_configure_rules = true
|
64
|
+
end
|
65
|
+
|
66
|
+
## Contributing
|
67
|
+
|
68
|
+
1. Fork it ( https://github.com/jlorich/dot_configure/fork )
|
69
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
70
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
71
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
72
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dot_configure/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "dot_configure"
|
8
|
+
spec.version = DotConfigure::VERSION
|
9
|
+
spec.authors = ["Joey Lorich"]
|
10
|
+
spec.email = ["jospeh@lorich.me"]
|
11
|
+
spec.summary = %q{Simple configuration options}
|
12
|
+
spec.description = %q{Simple configuration options}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.3.2'
|
23
|
+
spec.add_development_dependency 'pry-byebug', '~> 1.3.3'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.0.0'
|
25
|
+
spec.add_development_dependency 'clint_eastwood', '~> 0.0.1'
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'dot_configure/dot_configure'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'dot_configure/options'
|
2
|
+
|
3
|
+
# A configureable options implementation for any module
|
4
|
+
module DotConfigure
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(DotConfigure)
|
7
|
+
end
|
8
|
+
|
9
|
+
# Memoizes the configuration
|
10
|
+
def options
|
11
|
+
@options ||= Options.new(default_options)
|
12
|
+
|
13
|
+
@options.locked? ? @options.clone : @options
|
14
|
+
end
|
15
|
+
|
16
|
+
# Configure the options
|
17
|
+
def configure(lock: false)
|
18
|
+
fail 'You must specify a configuration block when calling configure' unless block_given?
|
19
|
+
fail 'Configuration already set' if options.locked?
|
20
|
+
yield(options)
|
21
|
+
|
22
|
+
options.locked = lock
|
23
|
+
options
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
# Customizable default options
|
29
|
+
def default_options
|
30
|
+
{}
|
31
|
+
end
|
32
|
+
end
|
File without changes
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'pry-byebug'
|
2
|
+
require 'dot_configure'
|
3
|
+
|
4
|
+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
5
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
6
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
7
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
8
|
+
#
|
9
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
10
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
11
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
12
|
+
# individual file that may not need all of that loaded. Instead, make a
|
13
|
+
# separate helper file that requires this one and then use it only in the specs
|
14
|
+
# that actually need it.
|
15
|
+
#
|
16
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
17
|
+
# users commonly want.
|
18
|
+
#
|
19
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
20
|
+
RSpec.configure do |config|
|
21
|
+
# The settings below are suggested to provide a good initial experience
|
22
|
+
# with RSpec, but feel free to customize to your heart's content.
|
23
|
+
# These two settings work together to allow you to limit a spec run
|
24
|
+
# to individual examples or groups you care about by tagging them with
|
25
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
26
|
+
# get run.
|
27
|
+
config.filter_run :focus
|
28
|
+
config.run_all_when_everything_filtered = true
|
29
|
+
|
30
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
31
|
+
# file, and it's useful to allow more verbose output when running an
|
32
|
+
# individual spec file.
|
33
|
+
if config.files_to_run.one?
|
34
|
+
# Use the documentation formatter for detailed output,
|
35
|
+
# unless a formatter has already been configured
|
36
|
+
# (e.g. via a command-line flag).
|
37
|
+
config.default_formatter = 'doc'
|
38
|
+
end
|
39
|
+
|
40
|
+
# Print the 10 slowest examples and example groups at the
|
41
|
+
# end of the spec run, to help surface which specs are running
|
42
|
+
# particularly slow.
|
43
|
+
config.profile_examples = 10
|
44
|
+
|
45
|
+
# Run specs in random order to surface order dependencies. If you find an
|
46
|
+
# order dependency and want to debug it, you can fix the order by providing
|
47
|
+
# the seed, which is printed after each run.
|
48
|
+
# --seed 1234
|
49
|
+
config.order = :random
|
50
|
+
|
51
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
52
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
53
|
+
# test failures related to randomization by passing the same `--seed` value
|
54
|
+
# as the one that triggered the failure.
|
55
|
+
Kernel.srand config.seed
|
56
|
+
|
57
|
+
# rspec-expectations config goes here. You can use an alternate
|
58
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
59
|
+
# assertions if you prefer.
|
60
|
+
config.expect_with :rspec do |expectations|
|
61
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
62
|
+
# For more details, see:
|
63
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
64
|
+
expectations.syntax = :expect
|
65
|
+
end
|
66
|
+
|
67
|
+
config.color = true
|
68
|
+
|
69
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
70
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
71
|
+
config.mock_with :rspec do |mocks|
|
72
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
73
|
+
# For more details, see:
|
74
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
75
|
+
mocks.syntax = :expect
|
76
|
+
|
77
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
78
|
+
# a real object. This is generally recommended.
|
79
|
+
mocks.verify_partial_doubles = true
|
80
|
+
end
|
81
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dot_configure
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joey Lorich
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 10.3.2
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 10.3.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry-byebug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.3
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.3
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: clint_eastwood
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.0.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.0.1
|
83
|
+
description: Simple configuration options
|
84
|
+
email:
|
85
|
+
- jospeh@lorich.me
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- dot_configure.gemspec
|
96
|
+
- lib/dot_configure.rb
|
97
|
+
- lib/dot_configure/dot_configure.rb
|
98
|
+
- lib/dot_configure/options.rb
|
99
|
+
- lib/dot_configure/version.rb
|
100
|
+
- spec/dot_configure/dot_configure_spec.rb
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
homepage: ''
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.0.14
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: Simple configuration options
|
126
|
+
test_files:
|
127
|
+
- spec/dot_configure/dot_configure_spec.rb
|
128
|
+
- spec/spec_helper.rb
|