hummus 0.3.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6e29013b2a57d73231a2e3b4ce5c244e58ae1a49957919f603ee287fa9413118
4
+ data.tar.gz: e755c9b9c5731dd6299c5309acc0f78a33ce82a73653b776c52a5a6c6b20db06
5
+ SHA512:
6
+ metadata.gz: 49932e3b3e79bb7147000e02ed90d75b2f3a4ae249900621e47f2b5dc2a678f4b2122536eb0b385076383cce5b78e42a2e65e3d8ac9cef4b511f4e8d9ae6e27e
7
+ data.tar.gz: ff95719d9285448f6db7d596f10e2fec08868b9100a92af98e5b884d660796c1a9273b40520ab37aa9de4134112145329b3246a0a706c11b60e2475979d60c0e
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.0
7
+ before_install: gem install bundler -v 2.0.1
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'chickpea', git: 'https://github.com/annacrombie/chickpea.git', branch: :master
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Stone Tickle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Hummus
2
+
3
+ Settings for ruby objects
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'hummus'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install hummus
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ class CoolClass
25
+ include Hummus.cfg(
26
+ path: '/a/cool/path',
27
+ value: 93,
28
+ do_this: true
29
+ )
30
+ end
31
+
32
+ CoolClass.path #=> '/a/cool/path'
33
+ CoolClass.value #=> 93
34
+ CoolClass.do_this? #=> true
35
+
36
+ CoolClass.dont_do_this
37
+ CoolClass.do_this? #=> false
38
+
39
+ CoolClass.value = 'hello'
40
+ # TypeError, expecting boolean
41
+ ```
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'hummus'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/hummus.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'hummus/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'hummus'
7
+ spec.version = Hummus::VERSION
8
+ spec.authors = ['Stone Tickle']
9
+ spec.email = ['lattis@mochiro.moe']
10
+
11
+ spec.summary = 'simple config helper'
12
+ spec.license = 'MIT'
13
+
14
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
15
+ `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ end
19
+
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'chickpea', '~> 0.2'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 2.0'
27
+ spec.add_development_dependency 'rake', '~> 12.3'
28
+ spec.add_development_dependency 'rspec', '~> 3.8'
29
+ spec.add_development_dependency 'simplecov'
30
+ end
data/lib/config.rb ADDED
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Achiever
4
+ module Config
5
+ DEFAULT = {
6
+ data: {},
7
+ mtime: Time.at(0),
8
+ achievements_file: 'config/achievements.yml',
9
+ default_image: '',
10
+ default_type: 'accumulation',
11
+ default_visibility: 'visible'
12
+ }.freeze
13
+ PRIVATE = %i[data mtime].freeze
14
+
15
+ class << self
16
+ def append_features(rcvr, names: %i[config configure], prefix: :'')
17
+ methods_for(DEFAULT, rcvr, prefix) +
18
+ names.map do |name|
19
+ # If called with a block, executes the block setting the argument to rcvr,
20
+ # else returns the configuration hash
21
+ rcvr.define_singleton_method(name) do |&block|
22
+ @config ||= Achiever::Config::DEFAULT.dup
23
+
24
+ block.nil? ? @config : block.call(rcvr)
25
+ end
26
+ end
27
+ end
28
+
29
+ # define convinence methods for each of the configuration paramaters special
30
+ # methods added for parameters that take booleans, e.g. dont_xxxx or xxxx!
31
+ def methods_for(config, rcvr, prefix)
32
+ config.reject { |k, _| PRIVATE.include?(k) }.map do |k, v|
33
+ (case v
34
+ when true, false
35
+ [[:"dont_#{k}", -> { @config[k] = false }],
36
+ [:"do_#{k}", -> { @config[k] = true }],
37
+ [:"#{k}!", -> { @config[k] = true }],
38
+ [:"#{k}?", -> { @config[k] }],
39
+ [:"#{k}=", lambda { |l|
40
+ unless [TrueClass, FalseClass].include?(l.class)
41
+ raise TypeError, "expected #{l.inspect} to be a kind_of? Bool (true, or false)"
42
+ end
43
+
44
+ @config[k] = l
45
+ }]]
46
+ else
47
+ [[:"#{k}=", lambda { |l|
48
+ unless l.is_a?(v.class)
49
+ raise TypeError, "expected #{l.inspect} to be a kind_of? #{v.class}"
50
+ end
51
+
52
+ @config[k] = l
53
+ }]]
54
+ end +
55
+ [[:"#{k}", -> { @config[k] }]]
56
+ ).map do |meth, body|
57
+ rcvr.define_singleton_method(:"#{prefix}#{meth}", &body)
58
+ end
59
+ end.flatten
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,7 @@
1
+ module Hummus
2
+ class << self
3
+ def setup(hash)
4
+ Hummus::Hook.dup.tap { |h| h.stash = Chickpea.new(hash) }
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ module Hummus
2
+ module Hook
3
+ class << self
4
+ attr_accessor :stash
5
+
6
+ def hook(rcvr)
7
+ stash = @stash
8
+
9
+ rcvr.define_singleton_method(:config) do |&block|
10
+ return stash if block.nil?
11
+
12
+ block.call(stash)
13
+ end
14
+
15
+ rcvr.const_set(:HummusHook, self)
16
+ end
17
+
18
+ alias append_features hook
19
+ alias prepend_features hook
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module Hummus
2
+ VERSION = '0.3.0'.freeze
3
+ end
data/lib/hummus.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'chickpea'
2
+
3
+ require 'hummus/core'
4
+ require 'hummus/hook'
5
+ require 'hummus/version'
6
+
7
+ module Hummus; end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hummus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Stone Tickle
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-04-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chickpea
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.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.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - lattis@mochiro.moe
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - hummus.gemspec
100
+ - lib/config.rb
101
+ - lib/hummus.rb
102
+ - lib/hummus/core.rb
103
+ - lib/hummus/hook.rb
104
+ - lib/hummus/version.rb
105
+ homepage:
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubygems_version: 3.0.3
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: simple config helper
128
+ test_files: []