service-object 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4971f713ea12612c6981e741c1d45d45a9f71e76dea348553b3ae4f299fc23cf
4
+ data.tar.gz: 6ef30457a7d0dc93198f03b203c47f2435a941722685b93e8ecf1c80235bcadb
5
+ SHA512:
6
+ metadata.gz: bcb44d2d261b822c6046fed9d6c703a28c1b63b1d95f42c82c70dddcb3c25a0b3b7b2e6e50dde162d6de97c929348d5f6fba60615dbee7878fe3fa860aa85f0d
7
+ data.tar.gz: 8618cb9e9453a49ef906e6d27125ade41a548a6eaba24c5f26ddcfb692dd4d0453400684efebf0cb9be7b151786903e4e2d05d413255e3fb1649cc2df6f994e8
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /.idea/
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails_service.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Rei
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.
@@ -0,0 +1,62 @@
1
+ # Service Object
2
+ inspired by [active_service](https://github.com/chloerei/active_service) .
3
+
4
+ Service Object is a service object abstraction which implement service-object-pattern introduced by http://brewhouse.io/blog/2014/04/30/gourmet-service-objects.html .
5
+
6
+ It is lightweight and fast, almost no performance loss. It's testing friendly, works great with all test framework like minitest/rspec.
7
+
8
+ It also add a service layer in Rails, you can use Rails generator to generate service file like controller and model.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'service-object'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ ## Usage
23
+
24
+
25
+ Declare a service like so:
26
+
27
+ ```ruby
28
+ class AcceptInvite
29
+
30
+ def self.call(invite, user)
31
+ invite.accept!(user)
32
+ UserMailer.invite_accepted(invite).deliver
33
+ end
34
+
35
+ end
36
+ ```
37
+
38
+
39
+
40
+ ## Rails generator
41
+
42
+ If you are using Rails:
43
+
44
+ ```bash
45
+ rails g service AcceptInvite
46
+ ```
47
+
48
+ It will create template service files in app/services and test/services.
49
+
50
+ ## Development
51
+
52
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
53
+
54
+ 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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
55
+
56
+ ## Contributing
57
+
58
+ 1. Fork it ( https://github.com/leihb/service_object )
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create a new Pull Request
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "test"
6
+ t.test_files = FileList['test/**/*_test.rb']
7
+ end
8
+
9
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "service"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,24 @@
1
+ require 'rails/generators/named_base'
2
+
3
+ module Rails
4
+ module Generators
5
+ class ServiceGenerator < Rails::Generators::NamedBase
6
+ desc 'This generator creates a service file at app/services'
7
+
8
+ def self.default_generator_root
9
+ File.dirname(__FILE__)
10
+ end
11
+
12
+ check_class_collision suffix: 'Service'
13
+
14
+ def create_service_file
15
+ template 'service.rb', File.join('app/services', class_path, "#{file_name}.rb")
16
+ end
17
+
18
+ def create_test_file
19
+ template 'test.rb', File.join('test/services', class_path, "#{file_name}_test.rb")
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,12 @@
1
+ <% module_namespacing do -%>
2
+ class <%= class_name %>
3
+ def initialize
4
+ end
5
+
6
+ def call
7
+ end
8
+
9
+ def self.call
10
+ end
11
+ end
12
+ <% end -%>
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= class_name %>ServiceTest < Service::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ <% end -%>
@@ -0,0 +1,9 @@
1
+ require "service/version"
2
+
3
+ if defined?(Rails)
4
+ require "service/test_case"
5
+ require "service/railtie"
6
+ end
7
+
8
+ module Service
9
+ end
@@ -0,0 +1,4 @@
1
+ module Service
2
+ class Railtie < Rails::Railtie
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ require 'active_support/test_case'
2
+
3
+ module Service
4
+ class TestCase < ActiveSupport::TestCase
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module Service
2
+ VERSION = "0.1.2"
3
+ end
@@ -0,0 +1,24 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'service/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "service-object"
7
+ spec.version = Service::VERSION
8
+ spec.authors = %w(Leihb Rei)
9
+ spec.email = ["leihaibo1992@gmail.com"]
10
+
11
+ spec.summary = %q{Rails Service Object abstraction.}
12
+ spec.description = %q{Rails Service Object abstraction.}
13
+ spec.homepage = "https://github.com/leihb/rails_service/"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.8"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest"
24
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: service-object
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Leihb
8
+ - Rei
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2018-04-13 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.8'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.8'
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.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: minitest
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ description: Rails Service Object abstraction.
57
+ email:
58
+ - leihaibo1992@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - lib/rails/generators/service/service_generator.rb
72
+ - lib/rails/generators/service/templates/service.rb
73
+ - lib/rails/generators/service/templates/test.rb
74
+ - lib/service.rb
75
+ - lib/service/railtie.rb
76
+ - lib/service/test_case.rb
77
+ - lib/service/version.rb
78
+ - service_object.gemspec
79
+ homepage: https://github.com/leihb/rails_service/
80
+ licenses:
81
+ - MIT
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.7.6
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: Rails Service Object abstraction.
103
+ test_files: []