getto-initialize_with 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: b37a703983aa465826161b560b81e813adea5457c44876ec4700792e01354644
4
+ data.tar.gz: 7258a96e07024a1ba452b0cdff70016f127167593a7298303ada7299aafa68f7
5
+ SHA512:
6
+ metadata.gz: cebf5bf00e128e3c92198d78c1ce3ab26add7e1c14fe2a85f1df633828029c5b323e73af55d297250f4ff13cbd52413e8d33c96934274be372143f5b4cba8dc3
7
+ data.tar.gz: 83300202136e16e908fb029200d1f75699584b87c1d24de170e44167946be79b262392480634b45f225259e1dfefa39218f236fc75e03ae4464f989940e8afe3
data/.envrc ADDED
@@ -0,0 +1,5 @@
1
+ export APP_ROOT=$(pwd)
2
+
3
+ export DOCKER_WRAPPER_IMAGE_ruby=2.5.1
4
+
5
+ export GIT_RELEASE_VERSION_FILE=lib/getto/initialize_with/version.rb
@@ -0,0 +1,7 @@
1
+ git_release_request_dump_version_local(){
2
+ bundle
3
+ git add Gemfile.lock
4
+ }
5
+ git_release_request_after_tag(){
6
+ git push github master --tags
7
+ }
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /vendor/
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,12 @@
1
+ image: ruby:2.5.1
2
+
3
+ cache:
4
+ paths:
5
+ - vendor/
6
+
7
+ test:
8
+ except:
9
+ - tags
10
+ script:
11
+ - bundle
12
+ - bundle exec rake
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
5
+ before_install: gem install bundler -v 1.16.2
6
+ deploy:
7
+ provider: rubygems
8
+ on:
9
+ tags: true
10
+ api_key:
11
+ secure: "ZyXduNzZ7KYXpJ72KLriIiFwVUN9ZEHsKeF0Luvk/PQb9efFewO1xx31BhJi8aYeiAVqY8WdWmbEXUS9CviWiyAhdQhb6Z7CgpnXNbLwBVarlXbAe4KbHxlbHRTf8OeVATw76uaCPafIB3l1tSkrWNhILD+FIHWsUcj4+lH43LA0oLCMB5o79rH1jwHjDVXIatARpVqpwgfoz/KJsVtqaJgIX5vU+ae5D4INCqD5T4mSbTKp4Li32YpMrAxR3IUuPR1CJAcfCLC6Yy0yjGUi7QpbCQkLzjJ0wu1OYq8CjLc8sU+4ifnc7VymWrF3FmvEDi4tjSlU+oFrc2C0tsT9JUUPZDcIlJ6yQ1oJ6uSC9SIYJwTCR/n+yZ6Vk32sqEr90ZLdUyXIZHwk/TaxU0GqFNqyTKFEgzhGZDnxq98AG5PRgu0OIOa1KqPCiyCyIYLa/ffiPjHk++ztv8aTErBkL03gqrNAHXDdXm6uruABP0fl1J7z+MqNFs5zJgHHCSKSiYVPng2VTUuYazaJvup0qlfVVENxV/Bgz52/bz0QMI4OIaWDhC/cky9DPn7k0AcgVDFSdcDzIfZu7jqK2uqssE8lgxzHab9p9oXeTMPJTLVKS8bpLF1yiuCgBOczYLKZBfjT0tY4hiCOmQCfVgaijXj2VwQ7OwzdWhOndROrofM="
@@ -0,0 +1,7 @@
1
+ # Version : 0.2.0
2
+
3
+ fix: travisci secret
4
+
5
+ ## commits
6
+
7
+ * fix: travis secret
@@ -0,0 +1,7 @@
1
+ # Version : 0.3.0
2
+
3
+ fix: release request hook
4
+
5
+ ## commits
6
+
7
+ * fix: release request hook
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Version : 0.3.0
2
+
3
+ fix: release request hook
4
+
5
+ # Version : 0.2.0
6
+
7
+ fix: travisci secret
8
+
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in getto-initialize_with.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ getto-initialize_with (0.3.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ docile (1.3.1)
10
+ json (2.1.0)
11
+ minitest (5.11.3)
12
+ rake (10.5.0)
13
+ simplecov (0.16.1)
14
+ docile (~> 1.1)
15
+ json (>= 1.8, < 3)
16
+ simplecov-html (~> 0.10.0)
17
+ simplecov-html (0.10.2)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ bundler (~> 1.16)
24
+ getto-initialize_with!
25
+ minitest (~> 5.0)
26
+ rake (~> 10.0)
27
+ simplecov (~> 0.16)
28
+
29
+ BUNDLED WITH
30
+ 1.16.2
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 shun@getto.systems
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,136 @@
1
+ # getto-initialize_with
2
+
3
+ [rubygems: getto-initialize_with](https://rubygems.org/gems/getto-initialize_with)
4
+
5
+ Define initialize method that require specific parameters
6
+
7
+ - purpose : for type annotation
8
+
9
+ ```ruby
10
+ require "getto/initialize_with"
11
+
12
+ class MyClass
13
+ include Getto::InitializeWith
14
+
15
+ initialize_with(
16
+ :time,
17
+
18
+ # assert expire is a Integer
19
+ expire: Integer,
20
+
21
+ # assert repository respond to methods
22
+ repository: [
23
+ :account_exists?,
24
+ ],
25
+ )
26
+ end
27
+
28
+ class Repository
29
+ def account_exists?
30
+ true
31
+ end
32
+ end
33
+
34
+
35
+ my_class = MyClass.new(
36
+ time: :now,
37
+ expire: 10,
38
+ repository: Repository.new,
39
+ )
40
+ my_class.time # => :now
41
+ my_class.expire # => 10
42
+ my_class.repository # => Repository instance
43
+ ```
44
+
45
+
46
+ ###### Table of Contents
47
+
48
+ - [Requirements](#Requirements)
49
+ - [Usage](#Usage)
50
+ - [License](#License)
51
+
52
+ <a id="Requirements"></a>
53
+ ## Requirements
54
+
55
+ - developed on ruby: 2.5.1
56
+
57
+
58
+ <a id="Usage"></a>
59
+ ## Usage
60
+
61
+ ```ruby
62
+ require "getto/initialize_with"
63
+
64
+ class MyClass
65
+ include Getto::InitializeWith
66
+
67
+ initialize_with(
68
+ :time,
69
+
70
+ expire: Integer,
71
+
72
+ repository: [
73
+ :account_exists?,
74
+ ],
75
+ )
76
+ end
77
+ ```
78
+
79
+ ### Errors
80
+
81
+ - missing argument
82
+
83
+ ```ruby
84
+ # raise "argument missing" becouse missing `repository`
85
+ my_class = MyClass.new(time: :now, expire: 10)
86
+ ```
87
+
88
+ - unknown argument
89
+
90
+ ```ruby
91
+ # raise "unknown argument" because including `unknown`
92
+ my_class = MyClass.new(time: :now, expire: 10, repository: Repository.new, unknown: :argument)
93
+ ```
94
+
95
+ - type check failed
96
+
97
+ ```ruby
98
+ # raise "argument type error" because `expire` is not a Integer
99
+ my_class = MyClass.new(time: :now, expire: "10", repository: Repository.new)
100
+ ```
101
+
102
+ - object not satisfied signature
103
+
104
+ ```ruby
105
+ # raise "argument type error" because `repository` is not respond to [:account_exists?]
106
+ my_class = MyClass.new(time: :now, expire: 10, repository: Object.new)
107
+ ```
108
+
109
+
110
+ ## Install
111
+
112
+ Add this line to your application's Gemfile:
113
+
114
+ ```ruby
115
+ gem 'getto-initialize_with'
116
+ ```
117
+
118
+ And then execute:
119
+
120
+ ```
121
+ $ bundle
122
+ ```
123
+
124
+ Or install it yourself as:
125
+
126
+ ```
127
+ $ gem install getto-initialize_with
128
+ ```
129
+
130
+
131
+ <a id="License"></a>
132
+ ## License
133
+
134
+ getto/initialize_with is licensed under the [MIT](LICENSE) license.
135
+
136
+ Copyright &copy; since 2018 shun@getto.systems
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,35 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "getto/initialize_with/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.required_ruby_version = ">= 2.5.1"
7
+
8
+ spec.name = "getto-initialize_with"
9
+ spec.version = Getto::InitializeWith::VERSION
10
+ spec.authors = ["shun@getto.systems"]
11
+ spec.email = ["shun@getto.systems"]
12
+
13
+ spec.summary = %q{initialize_with helper}
14
+ spec.description = %q{Define initialize method that require specific parameters}
15
+ spec.homepage = "https://github.com/getto-systems/getto-initialize_with"
16
+ spec.license = "MIT"
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+
28
+ spec.extra_rdoc_files = ['README.md', 'LICENSE']
29
+ spec.rdoc_options = %w[--title Getto::InitializeWith --main README.md]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.16"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "minitest", "~> 5.0"
34
+ spec.add_development_dependency "simplecov", "~> 0.16"
35
+ end
@@ -0,0 +1,5 @@
1
+ module Getto
2
+ module InitializeWith
3
+ VERSION = "0.3.0"
4
+ end
5
+ end
@@ -0,0 +1,47 @@
1
+ module Getto
2
+ module InitializeWith
3
+ def self.included(m)
4
+ m.singleton_class.class_eval do
5
+ define_method :initialize_with do |*names,**specs|
6
+ define_method :initialize do |**hash|
7
+ names.each do |name|
8
+ raise ArgumentError, "argument missing: #{name}" unless hash.has_key?(name)
9
+ instance_variable_set :"@#{name}", hash.delete(name)
10
+ end
11
+
12
+ specs.each do |name,spec|
13
+ raise ArgumentError, "argument missing: #{name}" unless hash.has_key?(name)
14
+
15
+ entry = hash.delete(name)
16
+
17
+ case
18
+ when spec.is_a?(Class)
19
+ unless entry.is_a?(spec)
20
+ raise ArgumentError, "argument type error: #{name} is not a #{spec}"
21
+ end
22
+ when spec.respond_to?(:each)
23
+ spec.each do |method|
24
+ unless entry.respond_to?(method)
25
+ raise ArgumentError, "argument type error: #{name} is not respond_to #{method}"
26
+ end
27
+ end
28
+ else
29
+ # :nocov:
30
+ raise ArgumentError, "invalid spec: #{spec}"
31
+ # :nocov:
32
+ end
33
+
34
+ instance_variable_set :"@#{name}", entry
35
+ end
36
+
37
+ raise ArgumentError, "unknown argument: #{hash.keys.join(",")}" unless hash.empty?
38
+
39
+ self
40
+ end
41
+
42
+ attr_reader(*(names + specs.keys))
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: getto-initialize_with
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - shun@getto.systems
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-10-27 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.16'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.16'
69
+ description: Define initialize method that require specific parameters
70
+ email:
71
+ - shun@getto.systems
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files:
75
+ - README.md
76
+ - LICENSE
77
+ files:
78
+ - ".envrc"
79
+ - ".git_release_request.rc.sh"
80
+ - ".gitignore"
81
+ - ".gitlab-ci.yml"
82
+ - ".travis.yml"
83
+ - CHANGELOG.md
84
+ - CHANGELOG/0.2.0.md
85
+ - CHANGELOG/0.3.0.md
86
+ - Gemfile
87
+ - Gemfile.lock
88
+ - LICENSE
89
+ - README.md
90
+ - Rakefile
91
+ - getto-initialize_with.gemspec
92
+ - lib/getto/initialize_with.rb
93
+ - lib/getto/initialize_with/version.rb
94
+ homepage: https://github.com/getto-systems/getto-initialize_with
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options:
100
+ - "--title"
101
+ - Getto::InitializeWith
102
+ - "--main"
103
+ - README.md
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 2.5.1
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.7.7
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: initialize_with helper
122
+ test_files: []