condensable 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/condensable.gemspec +29 -0
- data/lib/condensable.rb +13 -0
- data/lib/condensable/gravity_absorber.rb +48 -0
- data/lib/condensable/gravity_absorber/class_level_methods.rb +14 -0
- data/lib/condensable/version.rb +3 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c6ea08e4308bdf976b25b1f70487fb7137b4db98
|
4
|
+
data.tar.gz: 0ff5ce4b1c839155adeab6271b99c5f052453723
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1b95ac4d80a2f650c9b1e0247ec18543144a4cb6b68ef183107a1677f58ecdbfd420ae4c24c2309ba67b42853b573b69aa89f4edbf287a39335879ef7bcd1a8f
|
7
|
+
data.tar.gz: e6452e087c9bc95a6986381a7e5384adb44a6680313e660f78c59a16d4778549e51d677206bd10d09589b5deebb6db1b6cb987e7589f804a35604208c66c11a1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Adam Pahlevi
|
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,39 @@
|
|
1
|
+
# Condensable
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/blackhole`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'condensable'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install condensable
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/condensable/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "condensable"
|
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
|
data/bin/setup
ADDED
data/condensable.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'condensable/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "condensable"
|
8
|
+
spec.version = Condensable::VERSION
|
9
|
+
spec.authors = ["Adam Pahlevi"]
|
10
|
+
spec.email = ["adam.pahlevi@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = 'Think of it like a Hash, but instead, access and assign a value by using dot notation.'
|
13
|
+
spec.description = %q{Hash values are set/retrieved using a number, a string, symbol or other hashable object.
|
14
|
+
If the value is almost always stored as a string/symbol,
|
15
|
+
retrieving from hash is quite ambiguous because Ruby
|
16
|
+
treat symbol and string differently, which is good.
|
17
|
+
Condensable class allow creating accessor on demand.}
|
18
|
+
spec.homepage = "https://github.com/saveav/condensable"
|
19
|
+
spec.license = "MIT"
|
20
|
+
|
21
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.3"
|
29
|
+
end
|
data/lib/condensable.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "condensable/version"
|
2
|
+
require "condensable/gravity_absorber"
|
3
|
+
require "condensable/gravity_absorber/class_level_methods"
|
4
|
+
|
5
|
+
module Condensable
|
6
|
+
# map class with default values
|
7
|
+
DEFAULT_VALUES = {}
|
8
|
+
|
9
|
+
def self.included(base)
|
10
|
+
base.include(Condensable::GravityAbsorber)
|
11
|
+
base.extend(Condensable::GravityAbsorber::ClassLevelMethods)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Condensable
|
2
|
+
# handle when an instance variable is not defined, absorber will create one
|
3
|
+
# on the fly
|
4
|
+
module GravityAbsorber
|
5
|
+
def included(base)
|
6
|
+
base.extend(GravityAbsorber::ClassLevelMethods)
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing(method_name, *args, &block)
|
10
|
+
if method_name.to_s[-1] == '='
|
11
|
+
# get proper attribute name, by removing "="
|
12
|
+
attribute_name = method_name[0..-2]
|
13
|
+
instance_eval do
|
14
|
+
eval %Q{
|
15
|
+
def #{attribute_name}=(arg)
|
16
|
+
@#{attribute_name} = arg
|
17
|
+
end
|
18
|
+
def #{attribute_name}
|
19
|
+
@#{attribute_name}
|
20
|
+
end
|
21
|
+
}
|
22
|
+
end # instance eval
|
23
|
+
|
24
|
+
send(method_name, *args)
|
25
|
+
else
|
26
|
+
condensable_missing_attribute(method_name, *args)
|
27
|
+
end
|
28
|
+
end # method missing
|
29
|
+
|
30
|
+
def condensable_missing_attribute(method_name, *args)
|
31
|
+
default_handle_arg = Condensable::DEFAULT_VALUES[self.class.to_s]
|
32
|
+
|
33
|
+
if default_handle_arg == :raise_error
|
34
|
+
raise NoMethodError, "#{method_name} is undefined"
|
35
|
+
elsif default_handle_arg == nil
|
36
|
+
return nil
|
37
|
+
elsif default_handle_arg.is_a?(Symbol)
|
38
|
+
if method(default_handle_arg).arity == 0
|
39
|
+
send(default_handle_arg)
|
40
|
+
else
|
41
|
+
send(default_handle_arg, method_name, *args)
|
42
|
+
end
|
43
|
+
elsif default_handle_arg.is_a?(String)
|
44
|
+
return default_handle_arg
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Condensable
|
2
|
+
module GravityAbsorber
|
3
|
+
module ClassLevelMethods
|
4
|
+
module_function
|
5
|
+
|
6
|
+
# configuration block
|
7
|
+
def condensable options
|
8
|
+
if options[:default]
|
9
|
+
Condensable::DEFAULT_VALUES[self.to_s] = options[:default]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: condensable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam Pahlevi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-24 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.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
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.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '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: '3.3'
|
55
|
+
description: |-
|
56
|
+
Hash values are set/retrieved using a number, a string, symbol or other hashable object.
|
57
|
+
If the value is almost always stored as a string/symbol,
|
58
|
+
retrieving from hash is quite ambiguous because Ruby
|
59
|
+
treat symbol and string differently, which is good.
|
60
|
+
Condensable class allow creating accessor on demand.
|
61
|
+
email:
|
62
|
+
- adam.pahlevi@gmail.com
|
63
|
+
executables: []
|
64
|
+
extensions: []
|
65
|
+
extra_rdoc_files: []
|
66
|
+
files:
|
67
|
+
- ".gitignore"
|
68
|
+
- ".rspec"
|
69
|
+
- ".travis.yml"
|
70
|
+
- CODE_OF_CONDUCT.md
|
71
|
+
- Gemfile
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- bin/console
|
76
|
+
- bin/setup
|
77
|
+
- condensable.gemspec
|
78
|
+
- lib/condensable.rb
|
79
|
+
- lib/condensable/gravity_absorber.rb
|
80
|
+
- lib/condensable/gravity_absorber/class_level_methods.rb
|
81
|
+
- lib/condensable/version.rb
|
82
|
+
homepage: https://github.com/saveav/condensable
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.4.5
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Think of it like a Hash, but instead, access and assign a value by using
|
106
|
+
dot notation.
|
107
|
+
test_files: []
|
108
|
+
has_rdoc:
|