acts_as_parameter_object 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 +14 -0
- data/.pryrc +5 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +5 -0
- data/LICENSE +22 -0
- data/README.md +38 -0
- data/Rakefile +15 -0
- data/acts_as_parameter_object.gemspec +30 -0
- data/lib/acts_as_parameter_object.rb +15 -0
- data/lib/acts_as_parameter_object/version.rb +3 -0
- data/spec/acts_as_parameter_object_spec.rb +22 -0
- data/spec/spec_helper.rb +12 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d8153b26d3491626a492885dfe9e11e909f70fda
|
4
|
+
data.tar.gz: 2353b40777554f2411e3230a549676e47535f87c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a3b8b46b5bb52a4f7cb72b33981df80a6d8fe1a02cb1c10006098cbacacc9f519f9e35c23842dc6c3c34c91b64664c9aa1aa1fab5c8b66e310e0ee47447806e4
|
7
|
+
data.tar.gz: 9b1e66ee74b8ca307680354fdb28a791ad30da0b53cb061ca2422ab97e6c8b2a5364bc05cf98e82d7d8b74371ca71efb94662b5b1cdf5659e61c1b6dd747ac47
|
data/.gitignore
ADDED
data/.pryrc
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Naotoshi SEO
|
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,38 @@
|
|
1
|
+
# acts_as_parameter_object
|
2
|
+
|
3
|
+
testing ruby: 1.9.2, 1.9.3, 2.0.0
|
4
|
+
|
5
|
+
## About acts_as_parameter_object
|
6
|
+
|
7
|
+
ActsAsParameterObject creates a model which acts as a Parameter Object. cf. [Refactoring: Ruby Edition](http://www.amazon.com/dp/0321603508).
|
8
|
+
|
9
|
+
## Example
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
class ParameterObjectExample
|
13
|
+
include ActsAsParameterObject
|
14
|
+
|
15
|
+
attr_accessor :title
|
16
|
+
validates_presence_of :title
|
17
|
+
|
18
|
+
def initialize(params = {})
|
19
|
+
@title = params[:title]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
ParameterObjectExample.new(:foo => 'bar').valid? #=> false
|
24
|
+
```
|
25
|
+
|
26
|
+
You can use all of ActiveModel::Validations methods.
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create new [Pull Request](../../pull/new/master)
|
35
|
+
|
36
|
+
## Copyright
|
37
|
+
|
38
|
+
Copyright (c) 2013 Naotoshi SEO. See [LICENSE](LICENSE) for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
require 'rspec/core'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
7
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
8
|
+
end
|
9
|
+
task :default => :spec
|
10
|
+
|
11
|
+
desc 'Open an irb session preloaded with the gem library'
|
12
|
+
task :console do
|
13
|
+
sh 'irb -rubygems -I lib -r acts_as_parameter_object.rb'
|
14
|
+
end
|
15
|
+
task :c => :console
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#! /usr/bin/env gem build
|
2
|
+
# encoding: utf-8
|
3
|
+
$:.push File.expand_path('../lib', __FILE__)
|
4
|
+
require 'acts_as_parameter_object/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = 'acts_as_parameter_object'
|
8
|
+
gem.version = ActsAsParameterObject::VERSION
|
9
|
+
gem.authors = ["Naotoshi Seo"]
|
10
|
+
gem.email = ["sonots@gmail.com"]
|
11
|
+
gem.homepage = "https://github.com/sonots/acts_as_parameter_object"
|
12
|
+
gem.summary = "Acts as a Parameter Object cf. Refactoring: Ruby Edition"
|
13
|
+
gem.description = gem.summary
|
14
|
+
gem.licenses = ["MIT"]
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($\)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
gem.add_runtime_dependency "activemodel"
|
22
|
+
|
23
|
+
# for testing
|
24
|
+
gem.add_development_dependency "rake"
|
25
|
+
gem.add_development_dependency "rspec", "~> 2.11"
|
26
|
+
|
27
|
+
# for debug
|
28
|
+
gem.add_development_dependency "pry"
|
29
|
+
gem.add_development_dependency "pry-nav"
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'active_model'
|
2
|
+
require 'acts_as_parameter_object/version'
|
3
|
+
|
4
|
+
module ActsAsParameterObject
|
5
|
+
def self.included(base)
|
6
|
+
base.send(:include, ActiveModel::Validations)
|
7
|
+
base.extend(ClassMethods)
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
def parameter_object?
|
12
|
+
self.included_modules.include?(ActsAsParameterObject)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class ParameterObjectExample
|
4
|
+
include ActsAsParameterObject
|
5
|
+
attr_accessor :title
|
6
|
+
validates_presence_of :title
|
7
|
+
def initialize(params = {})
|
8
|
+
@title = params[:title]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ParameterObjectExample do
|
13
|
+
context "#parameter_object?" do
|
14
|
+
it { described_class.should be_parameter_object }
|
15
|
+
end
|
16
|
+
|
17
|
+
# should be able to use methods of ActiveModel::Validations
|
18
|
+
context "#validates_presence_of" do
|
19
|
+
it { described_class.new.should_not be_valid }
|
20
|
+
it { described_class.new(title: 'test').should be_valid }
|
21
|
+
end
|
22
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "bundler/setup"
|
3
|
+
require "pry"
|
4
|
+
require "acts_as_parameter_object"
|
5
|
+
|
6
|
+
ROOT = File.dirname(__FILE__)
|
7
|
+
Dir[File.expand_path("support/**/*.rb", ROOT)].each {|f| require f }
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: acts_as_parameter_object
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Naotoshi Seo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '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: '2.11'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.11'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry-nav
|
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: 'Acts as a Parameter Object cf. Refactoring: Ruby Edition'
|
84
|
+
email:
|
85
|
+
- sonots@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .pryrc
|
92
|
+
- .rspec
|
93
|
+
- .travis.yml
|
94
|
+
- CHANGELOG.md
|
95
|
+
- Gemfile
|
96
|
+
- LICENSE
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- acts_as_parameter_object.gemspec
|
100
|
+
- lib/acts_as_parameter_object.rb
|
101
|
+
- lib/acts_as_parameter_object/version.rb
|
102
|
+
- spec/acts_as_parameter_object_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
homepage: https://github.com/sonots/acts_as_parameter_object
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.0.2
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: 'Acts as a Parameter Object cf. Refactoring: Ruby Edition'
|
128
|
+
test_files:
|
129
|
+
- spec/acts_as_parameter_object_spec.rb
|
130
|
+
- spec/spec_helper.rb
|