power-types 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: 9d8d84c3744f92654b42fb2ccd339cf2c1e89c10
4
+ data.tar.gz: b1583c97cb542a6284b0389822e421516bfbd3b0
5
+ SHA512:
6
+ metadata.gz: 23e19ac6431e3231a5591b1cead007eb69c1a2e13b7e086192bae32a893b286b522bb9fa24ab16749fa2a8da66cf9ba294a95b04f7587d265df5a80afef9039f
7
+ data.tar.gz: 6a0a8aafd3056d2b2fe01049c3c7519d174d341d00a877487e4511f77cb5b47dd68386bec7c424028a2da56ca21a4d6bb4772ed9d81208cf044690a6b1878aaa
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.4
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at iobaixas@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in power_types.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,46 @@
1
+ watch(%r{^spec/.+_spec\.rb$})
2
+ # A sample Guardfile
3
+ # More info at https://github.com/guard/guard#readme
4
+
5
+ ## Uncomment and set this to only include directories you want to watch
6
+ # directories %w(app lib config test spec feature)
7
+
8
+ ## Uncomment to clear the screen before every task
9
+ # clearing :on
10
+
11
+ ## Make Guard exit when config is changed so it can be restarted
12
+ #
13
+ ## Note: if you want Guard to automatically start up again, run guard in a
14
+ ## shell loop, e.g.:
15
+ #
16
+ # $ while bundle exec guard; do echo "Restarting Guard..."; done
17
+ #
18
+ ## Note: if you are using the `directories` clause above and you are not
19
+ ## watching the project directory ('.'), the you will want to move the Guardfile
20
+ ## to a watched dir and symlink it back, e.g.
21
+ #
22
+ # $ mkdir config
23
+ # $ mv Guardfile config/
24
+ # $ ln -s config/Guardfile .
25
+ #
26
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
27
+ #
28
+ watch ("Guardfile") do
29
+ UI.info "Exiting because Guard must be restarted for changes to take effect"
30
+ exit 0
31
+ end
32
+
33
+ # Note: The cmd option is now required due to the increasing number of ways
34
+ # rspec may be run, below are examples of the most common uses.
35
+ # * bundler: 'bundle exec rspec'
36
+ # * bundler binstubs: 'bin/rspec'
37
+ # * spring: 'bin/rspec' (This will use spring if running and you have
38
+ # installed the spring binstubs per the docs)
39
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
40
+ # * 'just' rspec: 'rspec'
41
+
42
+ guard :rspec, cmd: 'bundle exec rspec' do
43
+ watch(%r{^spec/.+_spec\.rb$})
44
+ watch(%r{^lib/power_types/(.+)\.rb$}) { "spec" } # { |m| "spec/#{m[1]}_spec.rb" }
45
+ watch('spec/spec_helper.rb') { "spec" }
46
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Ignacio Baixas
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/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,11 @@
1
+ module PowerTypes
2
+ class InitGenerator < Rails::Generators::Base
3
+ desc "This generator creates the folder structure for the power-types gem"
4
+ def create_folders
5
+ empty_directory "app/commands/"
6
+ empty_directory "app/services/"
7
+ empty_directory "app/utils/"
8
+ empty_directory "app/values/"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ module Rails
2
+ class CommandGenerator < Rails::Generators::NamedBase
3
+ source_root File.expand_path("../templates", __FILE__)
4
+
5
+ argument :attributes, type: :array, default: [], banner: "field field"
6
+
7
+ desc "This generator creates a new command at app/commands"
8
+ def create_command
9
+ template('command.rb', "app/commands/#{file_name.underscore}.rb")
10
+ template('command_spec.rb', "specs/commands/#{file_name.underscore}_spec.rb")
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module Rails
2
+ class ServiceGenerator < Rails::Generators::NamedBase
3
+ source_root File.expand_path("../templates", __FILE__)
4
+
5
+ argument :attributes, type: :array, default: [], banner: "field field"
6
+
7
+ desc "This generator creates a new service at app/services"
8
+ def create_service
9
+ return puts "Service name must end with 'Service'" unless class_name.ends_with? "Service"
10
+ template('service.rb', "app/services/#{file_name.underscore}.rb")
11
+ template('service_spec.rb', "specs/services/#{file_name.underscore}_spec.rb")
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ class <%= class_name %> < PowerTypes::Command.new(<%= attributes_names.map { |n| ":#{n}" }.join(', ') %>)
2
+ def perform
3
+ # Command code goes here
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ require 'rails_helper'
2
+
3
+ describe <%= class_name %> do
4
+ def perform(*_args)
5
+ described_class.for(*_args)
6
+ end
7
+
8
+ pending "describe what perform does here"
9
+ end
@@ -0,0 +1,3 @@
1
+ class <%= class_name %> < PowerTypes::Service.new(<%= attributes_names.map { |n| ":#{n}" }.join(', ') %>)
2
+ # Service code goes here
3
+ end
@@ -0,0 +1,9 @@
1
+ require 'rails_helper'
2
+
3
+ describe <%= class_name %> do
4
+ def build(*_args)
5
+ described_class.new(*_args)
6
+ end
7
+
8
+ pending "describe what your service does here"
9
+ end
@@ -0,0 +1 @@
1
+ require 'power_types'
@@ -0,0 +1,6 @@
1
+ require "power_types/version"
2
+ require "power_types/patterns/service"
3
+ require "power_types/patterns/command"
4
+
5
+ module PowerTypes
6
+ end
@@ -0,0 +1,17 @@
1
+ module PowerTypes
2
+ module Command
3
+ def self.new(*_attributes)
4
+ Service.new(*_attributes).tap do |klass|
5
+ klass.class_eval do
6
+ def self.for(kwargs = {})
7
+ new(kwargs).perform
8
+ end
9
+
10
+ def perform
11
+ raise NotImplementedError, "Command must implement `perform`"
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,37 @@
1
+ module PowerTypes
2
+ module Service
3
+ # rubocop:disable Metrics/MethodLength
4
+ def self.new(*_attributes)
5
+ attr_names = []
6
+ attr_defaults = {}
7
+
8
+ _attributes.each do |att|
9
+ if att.is_a? Hash
10
+ attr_defaults.merge! att
11
+ attr_names += att.keys
12
+ else
13
+ attr_names << att
14
+ end
15
+ end
16
+
17
+ Class.new do
18
+ def logger
19
+ Rails.logger
20
+ end
21
+
22
+ define_method(:initialize) do |kwargs = {}|
23
+ unless (kwargs.keys - attr_names).empty?
24
+ raise ArgumentError, "Unexpected arguments: #{(kwargs.keys - attr_names).join(', ')}"
25
+ end
26
+
27
+ kwargs = attr_defaults.merge kwargs
28
+ attr_names.map do |a|
29
+ raise ArgumentError, "Missing parameter: #{a}" unless kwargs.key? a
30
+ instance_variable_set "@#{a}", kwargs[a]
31
+ end
32
+ end
33
+ end
34
+ end
35
+ # rubocop:enable Metrics/MethodLength
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module PowerTypes
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'power_types/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "power-types"
8
+ spec.version = PowerTypes::VERSION
9
+ spec.authors = ["Ignacio Baixas", "Felipe Balart"]
10
+ spec.email = ["ignacio@platan.us", "felipe@platan.us"]
11
+
12
+ spec.summary = %q{Power Types for Rails by Platanus}
13
+ spec.description = %q{Power Types for Rails by Platanus}
14
+ spec.homepage = "https://github.com/platanus/power-types"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake", "~> 10.4"
24
+ spec.add_development_dependency "rspec", "~> 3.1"
25
+ spec.add_development_dependency "rspec-nc", "~> 0.2"
26
+ spec.add_development_dependency "guard", "~> 2.11"
27
+ spec.add_development_dependency "guard-rspec", "~> 4.5"
28
+ spec.add_development_dependency "terminal-notifier-guard", "~> 1.6", ">= 1.6.1"
29
+ spec.add_development_dependency "pry", "~> 0.10"
30
+ spec.add_development_dependency "pry-remote", "~> 0.1"
31
+ spec.add_development_dependency "pry-byebug", "~> 3.2"
32
+ spec.add_development_dependency "pry-nav", "~> 0.2"
33
+ end
metadata ADDED
@@ -0,0 +1,228 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: power-types
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ignacio Baixas
8
+ - Felipe Balart
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2016-07-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.6'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.6'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.4'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.4'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '3.1'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3.1'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec-nc
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '0.2'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.2'
70
+ - !ruby/object:Gem::Dependency
71
+ name: guard
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '2.11'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '2.11'
84
+ - !ruby/object:Gem::Dependency
85
+ name: guard-rspec
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '4.5'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '4.5'
98
+ - !ruby/object:Gem::Dependency
99
+ name: terminal-notifier-guard
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '1.6'
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: 1.6.1
108
+ type: :development
109
+ prerelease: false
110
+ version_requirements: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - "~>"
113
+ - !ruby/object:Gem::Version
114
+ version: '1.6'
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 1.6.1
118
+ - !ruby/object:Gem::Dependency
119
+ name: pry
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.10'
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.10'
132
+ - !ruby/object:Gem::Dependency
133
+ name: pry-remote
134
+ requirement: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.1'
139
+ type: :development
140
+ prerelease: false
141
+ version_requirements: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.1'
146
+ - !ruby/object:Gem::Dependency
147
+ name: pry-byebug
148
+ requirement: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.2'
153
+ type: :development
154
+ prerelease: false
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '3.2'
160
+ - !ruby/object:Gem::Dependency
161
+ name: pry-nav
162
+ requirement: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.2'
167
+ type: :development
168
+ prerelease: false
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.2'
174
+ description: Power Types for Rails by Platanus
175
+ email:
176
+ - ignacio@platan.us
177
+ - felipe@platan.us
178
+ executables: []
179
+ extensions: []
180
+ extra_rdoc_files: []
181
+ files:
182
+ - ".gitignore"
183
+ - ".rspec"
184
+ - ".travis.yml"
185
+ - CODE_OF_CONDUCT.md
186
+ - Gemfile
187
+ - Guardfile
188
+ - LICENSE.txt
189
+ - Rakefile
190
+ - lib/generators/power_types/init_generator.rb
191
+ - lib/generators/rails/command_generator.rb
192
+ - lib/generators/rails/service_generator.rb
193
+ - lib/generators/rails/templates/command.rb
194
+ - lib/generators/rails/templates/command_spec.rb
195
+ - lib/generators/rails/templates/service.rb
196
+ - lib/generators/rails/templates/service_spec.rb
197
+ - lib/power-types.rb
198
+ - lib/power_types.rb
199
+ - lib/power_types/patterns/command.rb
200
+ - lib/power_types/patterns/service.rb
201
+ - lib/power_types/version.rb
202
+ - power_types.gemspec
203
+ homepage: https://github.com/platanus/power-types
204
+ licenses:
205
+ - MIT
206
+ metadata: {}
207
+ post_install_message:
208
+ rdoc_options: []
209
+ require_paths:
210
+ - lib
211
+ required_ruby_version: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ required_rubygems_version: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - ">="
219
+ - !ruby/object:Gem::Version
220
+ version: '0'
221
+ requirements: []
222
+ rubyforge_project:
223
+ rubygems_version: 2.6.4
224
+ signing_key:
225
+ specification_version: 4
226
+ summary: Power Types for Rails by Platanus
227
+ test_files: []
228
+ has_rdoc: