active_method 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1d5e11d7ed75a94873fb99d6f8b03300800a76b5b400794d195dc4127ceeb3e2
4
+ data.tar.gz: 8004a835cfd838a079467e1d5307216f4ca2ec2e84a48819ff46f99dd8372745
5
+ SHA512:
6
+ metadata.gz: 2f97a88bb3f53bd43e29823b2ec9bc27251b76a988e28ec510d60ab207433bad35545d93407ae217546d3ed9c56fff1078315745e6e4f74092430dc8c62653a8
7
+ data.tar.gz: '038421de6e5ce8df43ec48c3abd72c67d12ce54ffd0bbe99c24407f47fc8efddf5b12fe56ebe6123ac875d8649993ed01a0e239c3eaf5bc6c64ea2856ad990f6'
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.5.0] - 2022-08-28
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders 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, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at hopper.gee@hey.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in active_method.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+
12
+ gem "debug"
13
+ gem "matrixeval-ruby"
14
+ gem "simplecov"
data/Gemfile.lock ADDED
@@ -0,0 +1,50 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ active_method (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ concurrent-ruby (1.1.10)
10
+ debug (1.6.2)
11
+ irb (>= 1.3.6)
12
+ reline (>= 0.3.1)
13
+ docile (1.4.0)
14
+ io-console (0.5.11)
15
+ irb (1.4.1)
16
+ reline (>= 0.3.0)
17
+ matrixeval (0.4.3)
18
+ concurrent-ruby
19
+ rainbow (~> 3.1)
20
+ terminal-table
21
+ matrixeval-ruby (0.4.0)
22
+ matrixeval (~> 0.4.2)
23
+ minitest (5.16.2)
24
+ rainbow (3.1.1)
25
+ rake (13.0.6)
26
+ reline (0.3.1)
27
+ io-console (~> 0.5)
28
+ simplecov (0.21.2)
29
+ docile (~> 1.1)
30
+ simplecov-html (~> 0.11)
31
+ simplecov_json_formatter (~> 0.1)
32
+ simplecov-html (0.12.3)
33
+ simplecov_json_formatter (0.1.4)
34
+ terminal-table (3.0.2)
35
+ unicode-display_width (>= 1.1.1, < 3)
36
+ unicode-display_width (2.2.0)
37
+
38
+ PLATFORMS
39
+ arm64-darwin-21
40
+
41
+ DEPENDENCIES
42
+ active_method!
43
+ debug
44
+ matrixeval-ruby
45
+ minitest (~> 5.0)
46
+ rake (~> 13.0)
47
+ simplecov
48
+
49
+ BUNDLED WITH
50
+ 2.3.12
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Hopper Gee
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,37 @@
1
+ # ActiveMethod
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/active_method`. 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
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ $ bundle add active_method
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ $ gem install active_method
16
+
17
+ ## Usage
18
+
19
+ TODO: Write usage instructions here
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ 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`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/active_method. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/active_method/blob/master/CODE_OF_CONDUCT.md).
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
34
+
35
+ ## Code of Conduct
36
+
37
+ Everyone interacting in the ActiveMethod project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/active_method/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
12
+ task default: :test
@@ -0,0 +1,113 @@
1
+ module ActiveMethod
2
+ class Base
3
+
4
+ class Argument
5
+ attr_reader :name, :default
6
+
7
+ def initialize(name, default: nil)
8
+ @name = name
9
+ @default = default
10
+ end
11
+ end
12
+
13
+ class << self
14
+
15
+ def call(*args)
16
+ new(*args).call
17
+ end
18
+
19
+ def arguments
20
+ class_variable_get(:@@arguments)
21
+ end
22
+
23
+ def keyword_arguments
24
+ class_variable_get(:@@keyword_arguments)
25
+ end
26
+
27
+ def inherited(subclass)
28
+ subclass.init_arguments
29
+ subclass.init_keyword_arguments
30
+ end
31
+
32
+ protected
33
+
34
+ def method_missing(method_name, *args)
35
+ case method_name.to_s
36
+ when /^argument(_\d)*$/
37
+ parse_argument(method_name, *args)
38
+ when 'keyword_argument'
39
+ parse_keyword_argument(*args)
40
+ else
41
+ super
42
+ end
43
+ end
44
+
45
+ def parse_argument(method_name, name, opts = {})
46
+ _, index = method_name.to_s.split('_')
47
+ if index.nil?
48
+ index = (arguments.keys.max || 0) + 1
49
+ end
50
+ arguments[Integer(index)] = Argument.new(name, **opts)
51
+
52
+ define_method name do
53
+ instance_variable_get("@#{name}")
54
+ end
55
+ end
56
+
57
+ def parse_keyword_argument(name, opts = {})
58
+ keyword_arguments << Argument.new(name, **opts)
59
+
60
+ define_method name do
61
+ instance_variable_get("@#{name}")
62
+ end
63
+ end
64
+
65
+ def init_arguments
66
+ return if self.class_variable_defined?(:@@arguments)
67
+
68
+ self.class_variable_set(:@@arguments, {})
69
+ end
70
+
71
+ def init_keyword_arguments
72
+ return if self.class_variable_defined?(:@@keyword_arguments)
73
+
74
+ self.class_variable_set(:@@keyword_arguments, [])
75
+ end
76
+ end
77
+
78
+ def initialize(*args)
79
+ arguments.each do |index, argument|
80
+ begin
81
+ instance_variable_set("@#{argument.name}", args.fetch(index - 1))
82
+ rescue IndexError
83
+ instance_variable_set("@#{argument.name}", argument.default)
84
+ end
85
+ end
86
+
87
+ opts = args[arguments.count] || {}
88
+ keyword_arguments.each do |argument|
89
+ if opts.key?(argument.name.to_sym)
90
+ instance_variable_set("@#{argument.name}", opts[argument.name.to_sym])
91
+ elsif opts.key?(argument.name.to_s)
92
+ instance_variable_set("@#{argument.name}", opts[argument.name.to_s])
93
+ else
94
+ instance_variable_set("@#{argument.name}", argument.default)
95
+ end
96
+ end
97
+ end
98
+
99
+ def call
100
+ end
101
+
102
+ private
103
+
104
+ def arguments
105
+ self.class.arguments
106
+ end
107
+
108
+ def keyword_arguments
109
+ self.class.keyword_arguments
110
+ end
111
+
112
+ end
113
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveMethod
4
+ VERSION = "0.5.0"
5
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "active_method/version"
4
+
5
+ module ActiveMethod
6
+ autoload :Base, "active_method/base"
7
+ end
data/matrixeval.yml ADDED
@@ -0,0 +1,70 @@
1
+ version: 0.4
2
+ target: ruby
3
+ project_name: active_method
4
+ parallel_workers: number_of_processors
5
+ # commands:
6
+ # - ps
7
+ # - top
8
+ # - an_additional_command
9
+ # mounts:
10
+ # - /a/path/need/to/mount:/a/path/mount/to
11
+ matrix:
12
+ ruby:
13
+ variants:
14
+ - key: 2.7
15
+ container:
16
+ image: ruby:2.7.6
17
+ - key: 3.0
18
+ container:
19
+ image: ruby:3.0.4
20
+ - key: 3.1
21
+ default: true
22
+ container:
23
+ image: ruby:3.1.2
24
+ # - key: jruby-9.3
25
+ # container:
26
+ # image: jruby:9.3
27
+ # env:
28
+ # PATH: "/opt/jruby/bin:/app/bin:/bundle/bin:$PATH"
29
+ # mounts:
30
+ # - /a/path/need/to/mount:/a/path/mount/to
31
+
32
+ # rails:
33
+ # variants:
34
+ # - key: 6.1
35
+ # default: true
36
+ # env:
37
+ # RAILS_VERSION: "~> 6.1.0"
38
+ # - key: 7.0
39
+ # env:
40
+ # RAILS_VERSION: "~> 7.0.0"
41
+ # another:
42
+ # variants:
43
+ # - key: key1
44
+ # default: true
45
+ # env:
46
+ # ENV_KEY: 1
47
+ # - key: key2
48
+ # env:
49
+ # ENV_KEY: 2
50
+
51
+ exclude:
52
+ # - ruby: 3.0
53
+ # rails: 4.2
54
+ # - ruby: jruby-9.3
55
+ # rails: 7.0
56
+
57
+ docker-compose-extend:
58
+ # services:
59
+ # postgres:
60
+ # image: postgres:12.8
61
+ # volumes:
62
+ # - postgres12:/var/lib/postgresql/data
63
+ # environment:
64
+ # POSTGRES_HOST_AUTH_METHOD: trust
65
+
66
+ # redis:
67
+ # image: redis:6.2-alpine
68
+
69
+ # volumes:
70
+ # postgres12:
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_method
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Hopper Gee
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-08-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Refactor your obscure method to a method object
14
+ email:
15
+ - hopper.gee@hey.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - CHANGELOG.md
21
+ - CODE_OF_CONDUCT.md
22
+ - Gemfile
23
+ - Gemfile.lock
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - lib/active_method.rb
28
+ - lib/active_method/base.rb
29
+ - lib/active_method/version.rb
30
+ - matrixeval.yml
31
+ homepage: https://github.com/hoppergee/active_method
32
+ licenses:
33
+ - MIT
34
+ metadata:
35
+ homepage_uri: https://github.com/hoppergee/active_method
36
+ source_code_uri: https://github.com/hoppergee/active_method
37
+ changelog_uri: https://github.com/hoppergee/solidservice/blob/main/CHANGELOG.md
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.6.0
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubygems_version: 3.3.7
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: A method object base class
57
+ test_files: []