splatter 0.0.1

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
+ SHA1:
3
+ metadata.gz: da023b1c9bb69849dbd2bf83f5ac6003d4013c00
4
+ data.tar.gz: 2c31048dfd8bb9c36dec5c3b6c678334cd5cbafd
5
+ SHA512:
6
+ metadata.gz: 780be0ed97e4c6d70ad8b95dfef91ec98ebaa0f7f8ef5078eafe3ea2da5ab1de9dd67c69f9b11e6f2a6acd5058625bea3787f44d3c6ac59c18077db0602b5a6c
7
+ data.tar.gz: b71e6b651e4f0fd8279da59ae0af8ee713a3925ff3db40734f80de9e6f1f53ad2de63ea04259a3dd3bfc0423338940623c1231e014f58c444d735cbc3e5cd312
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Vincent Roy
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,72 @@
1
+ # Splatter
2
+
3
+ Expand constructor arguments to instance variables base on `splat`.
4
+
5
+ This was inspired by [Gourmet Service Objects](http://brewhouse.io/blog/2014/04/30/gourmet-service-objects.html), but to use without Virtus.
6
+
7
+ ## Usage
8
+
9
+ ### Splatter::Init
10
+
11
+ ```ruby
12
+ class AcceptInvite
13
+ include Splatter::Init
14
+
15
+ splat :invite, :user
16
+
17
+ def call
18
+ @invite.accept!(@user)
19
+ UserMailer.invite_accepted(invite).deliver
20
+ end
21
+ end
22
+
23
+ AcceptInvite.new(invite, user).call
24
+ ```
25
+
26
+ ### Splatter::Service
27
+
28
+ ```ruby
29
+ class AcceptInvite
30
+ include Splatter::Init
31
+ include Splatter::Service
32
+
33
+ splat :invite, :user
34
+
35
+ def call
36
+ @invite.accept!(@user)
37
+ UserMailer.invite_accepted(invite).deliver
38
+ end
39
+ end
40
+
41
+ AcceptInvite.call(invite, user)
42
+ ```ruby
43
+
44
+ ### Splatter
45
+
46
+ Use `include Splatter` to include both, `Splatter::Init` and `Splatter::Service`
47
+
48
+
49
+ ## Installation
50
+
51
+ Add this line to your application's Gemfile:
52
+
53
+ ```ruby
54
+ gem 'splatter'
55
+ ```
56
+
57
+ And then execute:
58
+
59
+ $ bundle
60
+
61
+ Or install it yourself as:
62
+
63
+ $ gem install splatter
64
+
65
+
66
+ ## Contributing
67
+
68
+ 1. Fork it ( https://github.com/exploid/splatter/fork )
69
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
70
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
71
+ 4. Push to the branch (`git push origin my-new-feature`)
72
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,25 @@
1
+ module Splatter
2
+ module Init
3
+
4
+ def self.included(base)
5
+ base.extend(ClassMethods)
6
+ end
7
+
8
+ module ClassMethods
9
+ def splat(*args)
10
+ if args.empty?
11
+ @splatter_args
12
+ else
13
+ @splatter_args = args
14
+ end
15
+ end
16
+ end
17
+
18
+ def initialize(*args)
19
+ self.class.splat.each do |name|
20
+ instance_variable_set("@#{name}", args.shift)
21
+ end
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ module Splatter
2
+ module Service
3
+
4
+ def self.included(base)
5
+ base.extend(ClassMethods)
6
+ end
7
+
8
+ module ClassMethods
9
+ def call(*args)
10
+ new(*args).call
11
+ end
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Splatter
2
+ VERSION = "0.0.1"
3
+ end
data/lib/splatter.rb ADDED
@@ -0,0 +1,12 @@
1
+ require "splatter/init"
2
+ require "splatter/service"
3
+ require "splatter/version"
4
+
5
+ module Splatter
6
+
7
+ def self.included(base)
8
+ base.include(Splatter::Service)
9
+ base.include(Splatter::Init)
10
+ end
11
+
12
+ end
data/splatter.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'splatter/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "splatter"
8
+ spec.version = Splatter::VERSION
9
+ spec.authors = ["Vincent Roy"]
10
+ spec.email = ["vincentroy8@gmail.com"]
11
+ spec.summary = %q{Expand constructor arguments to instance variables base on `splat`.}
12
+ spec.homepage = "https://github.com/exploid/splatter"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.7"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: splatter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Vincent Roy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-18 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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
+ description:
42
+ email:
43
+ - vincentroy8@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/splatter.rb
54
+ - lib/splatter/init.rb
55
+ - lib/splatter/service.rb
56
+ - lib/splatter/version.rb
57
+ - splatter.gemspec
58
+ homepage: https://github.com/exploid/splatter
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.2.0
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Expand constructor arguments to instance variables base on `splat`.
82
+ test_files: []
83
+ has_rdoc: