interage-service 0.1.0

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: 995d2395a237edc1079c83bc9c712220aa1d95aff05b348c64590e7d066617d7
4
+ data.tar.gz: 20fb966e9f1bfdc7abbb2b846a337df41a4f808e1bd7d5e80472a63e3216560c
5
+ SHA512:
6
+ metadata.gz: edbdd592cdcca98f4ff599acd22057062eda9a634f72c0e1cd6cfc8cfc86f19b4bac1912ead23ba3ee1fefa74911ef47d534a014159357109eabbd3e3f32a580
7
+ data.tar.gz: 8509a6e6bc27ba814a338c762aee3fc04b7fdad52339362446f540ef337aec8c00515c34d90aec0865b8d0757e26de6db00331ed3737a2533962d330f8d51fea
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --require spec_helper
2
+ --format documentation
3
+ --force-color
4
+ --order rand
@@ -0,0 +1,22 @@
1
+ require:
2
+ - rubocop-rspec
3
+ - rubocop-performance
4
+
5
+ Documentation:
6
+ Enabled: false
7
+
8
+ Style/EmptyMethod:
9
+ Enabled: false
10
+
11
+ Style/SymbolArray:
12
+ Enabled: false
13
+
14
+ Style/WordArray:
15
+ Enabled: false
16
+
17
+ AllCops:
18
+ TargetRubyVersion: 2.6
19
+ Exclude:
20
+ - bin/**/*
21
+ - vendor/**/*
22
+ - lib/generators/interage/service/*/templates/**/*.rb
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.2
7
+ before_install: gem install bundler -v 2.0.1
data/Gemfile ADDED
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ group :development, :test do
8
+ # https://github.com/rubocop-hq/rubocop#quickstart
9
+ gem 'rubocop', '~> 0.67.2'
10
+ # https://github.com/backus/rubocop-rspec
11
+ gem 'rubocop-rspec', '~> 1.32'
12
+ # https://github.com/rubocop-hq/rubocop-performance/#usage
13
+ gem 'rubocop-performance', '~> 1.1'
14
+ # https://github.com/rspec/rspec#install
15
+ gem 'rspec', '~> 3.8'
16
+ # https://github.com/pry/pry#installation
17
+ gem 'pry', '~> 0.12.2'
18
+ # https://github.com/presidentbeef/brakeman
19
+ gem 'brakeman', '~> 4.3', '>= 4.3.1', require: false
20
+ # https://github.com/rails/rails/tree/master/activesupport#download-and-installation
21
+ gem 'activesupport', '~> 5.2', '>= 5.2.3'
22
+ end
@@ -0,0 +1,80 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ interage-service (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (5.2.3)
10
+ concurrent-ruby (~> 1.0, >= 1.0.2)
11
+ i18n (>= 0.7, < 2)
12
+ minitest (~> 5.1)
13
+ tzinfo (~> 1.1)
14
+ ast (2.4.0)
15
+ brakeman (4.5.0)
16
+ coderay (1.1.2)
17
+ concurrent-ruby (1.1.5)
18
+ diff-lcs (1.3)
19
+ i18n (1.6.0)
20
+ concurrent-ruby (~> 1.0)
21
+ jaro_winkler (1.5.2)
22
+ method_source (0.9.2)
23
+ minitest (5.11.3)
24
+ parallel (1.17.0)
25
+ parser (2.6.2.1)
26
+ ast (~> 2.4.0)
27
+ pry (0.12.2)
28
+ coderay (~> 1.1.0)
29
+ method_source (~> 0.9.0)
30
+ psych (3.1.0)
31
+ rainbow (3.0.0)
32
+ rake (10.5.0)
33
+ rspec (3.8.0)
34
+ rspec-core (~> 3.8.0)
35
+ rspec-expectations (~> 3.8.0)
36
+ rspec-mocks (~> 3.8.0)
37
+ rspec-core (3.8.0)
38
+ rspec-support (~> 3.8.0)
39
+ rspec-expectations (3.8.2)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.8.0)
42
+ rspec-mocks (3.8.0)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.8.0)
45
+ rspec-support (3.8.0)
46
+ rubocop (0.67.2)
47
+ jaro_winkler (~> 1.5.1)
48
+ parallel (~> 1.10)
49
+ parser (>= 2.5, != 2.5.1.1)
50
+ psych (>= 3.1.0)
51
+ rainbow (>= 2.2.2, < 4.0)
52
+ ruby-progressbar (~> 1.7)
53
+ unicode-display_width (>= 1.4.0, < 1.6)
54
+ rubocop-performance (1.1.0)
55
+ rubocop (>= 0.67.0)
56
+ rubocop-rspec (1.32.0)
57
+ rubocop (>= 0.60.0)
58
+ ruby-progressbar (1.10.0)
59
+ thread_safe (0.3.6)
60
+ tzinfo (1.2.5)
61
+ thread_safe (~> 0.1)
62
+ unicode-display_width (1.5.0)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ activesupport (~> 5.2, >= 5.2.3)
69
+ brakeman (~> 4.3, >= 4.3.1)
70
+ bundler (~> 2.0)
71
+ interage-service!
72
+ pry (~> 0.12.2)
73
+ rake (~> 10.0)
74
+ rspec (~> 3.8)
75
+ rubocop (~> 0.67.2)
76
+ rubocop-performance (~> 1.1)
77
+ rubocop-rspec (~> 1.32)
78
+
79
+ BUNDLED WITH
80
+ 2.0.1
@@ -0,0 +1,40 @@
1
+ # Interage::Service
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'interage-service', '~> 0.1'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ ```bash
14
+ bundle install
15
+ ```
16
+
17
+ Or install it yourself as:
18
+
19
+ ```bash
20
+ gem install interage-service
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ You can use a Rails generator to create `ApplicationService`:
26
+
27
+ ```bash
28
+ rails g interage:service:install
29
+ ```
30
+
31
+ And you can use a Rails generator to create service classes:
32
+
33
+
34
+ ```bash
35
+ rails g interage:service:create CustomersByDocument Customer
36
+ ```
37
+
38
+ ## Contributing
39
+
40
+ Bug reports and merge services are welcome on GitLab at https://gitlab.com/[USERNAME]/interage-service.
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'brakeman' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("brakeman", "brakeman")
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1 || ">= 0.a"
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_version
64
+ @bundler_version ||= begin
65
+ env_var_version || cli_arg_version ||
66
+ lockfile_version || "#{Gem::Requirement.default}.a"
67
+ end
68
+ end
69
+
70
+ def load_bundler!
71
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
72
+
73
+ # must dup string for RG < 1.8 compatibility
74
+ activate_bundler(bundler_version.dup)
75
+ end
76
+
77
+ def activate_bundler(bundler_version)
78
+ if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
79
+ bundler_version = "< 2"
80
+ end
81
+ gem_error = activation_error_handling do
82
+ gem "bundler", bundler_version
83
+ end
84
+ return if gem_error.nil?
85
+ require_error = activation_error_handling do
86
+ require "bundler/version"
87
+ end
88
+ return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
89
+ warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
90
+ exit 42
91
+ end
92
+
93
+ def activation_error_handling
94
+ yield
95
+ nil
96
+ rescue StandardError, LoadError => e
97
+ e
98
+ end
99
+ end
100
+
101
+ m.load_bundler!
102
+
103
+ if m.invoked_as_script?
104
+ load Gem.bin_path("bundler", "bundle")
105
+ end
data/bin/ci ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ echo -e "\e[1;36m$ bin/brakeman --force-scan \e[0m"
6
+ bin/brakeman --force-scan
7
+
8
+ echo -e "\e[1;36m$ bin/rubocop \e[0m"
9
+ bin/rubocop
10
+
11
+ echo -e "\e[1;36m$ bin/rspec \e[0m"
12
+ bin/rspec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "interage/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(__FILE__)
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rubocop' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rubocop", "rubocop")
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'interage/service/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'interage-service'
9
+ spec.version = Interage::Service::VERSION
10
+ spec.authors = ['Walmir Neto']
11
+ spec.email = ['owalmirneto@gmail.com']
12
+
13
+ spec.summary = 'Application Service for Interage'
14
+ spec.description = 'Use Net::HTTP to make services'
15
+ spec.homepage = 'https://gitlab.com/interage/patterns/service'
16
+ spec.licenses = ['MIT']
17
+
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
+
21
+ spec.metadata['homepage_uri'] = spec.homepage
22
+ spec.metadata['source_code_uri'] = spec.homepage
23
+ spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/master/CHANGES"
24
+ else
25
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
26
+ 'public gem pushes.'
27
+ end
28
+
29
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
30
+ `git ls-files -z`.split("\x0").reject do |file|
31
+ file.match(%r{^(test|spec|features)/}) || file.split('.').last == 'gem'
32
+ end
33
+ end
34
+
35
+ spec.bindir = 'exe'
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ['lib']
38
+
39
+ spec.add_development_dependency 'bundler', '~> 2.0'
40
+ spec.add_development_dependency 'rake', '~> 10.0'
41
+ spec.add_development_dependency 'rspec', '~> 3.0'
42
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Interage
4
+ class ApplicationService
5
+ attr_reader :errors
6
+
7
+ # Call your service
8
+ #
9
+ # Example:
10
+ # Foo.call(arg1: 1, arg2: 2)
11
+ #
12
+ # Arguments:
13
+ # args: (Hash)
14
+ #
15
+ # Return:
16
+ # perform's return
17
+ def self.call(**args)
18
+ new(args).perform
19
+ end
20
+
21
+ def initialize(args = {})
22
+ args.each { |key, value| set_private_ivar(key, value) }
23
+ end
24
+
25
+ # Implement this method to run your service
26
+ def perform
27
+ raise NotImplementedError,
28
+ "Please implement 'perform' method in your #{self.class.name}"
29
+ end
30
+
31
+ def success?
32
+ errors.blank?
33
+ end
34
+
35
+ private
36
+
37
+ def set_private_ivar(key, value)
38
+ instance_variable_set("@#{key}", value)
39
+
40
+ self.class.class_eval do
41
+ private
42
+
43
+ attr_reader key.to_sym
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'interage/service/version'
4
+ require 'active_support/core_ext/module'
5
+
6
+ module Interage
7
+ module Service
8
+ class Error < StandardError
9
+ end
10
+ end
11
+
12
+ autoload :ApplicationService, 'interage/application_service'
13
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Interage
4
+ module Service
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: interage-service
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Walmir Neto
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-03-24 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: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.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: '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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Use Net::HTTP to make services
56
+ email:
57
+ - owalmirneto@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".rubocop.yml"
65
+ - ".travis.yml"
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - README.md
69
+ - Rakefile
70
+ - bin/brakeman
71
+ - bin/bundle
72
+ - bin/ci
73
+ - bin/console
74
+ - bin/rspec
75
+ - bin/rubocop
76
+ - bin/setup
77
+ - interage-service.gemspec
78
+ - lib/interage/application_service.rb
79
+ - lib/interage/service.rb
80
+ - lib/interage/service/version.rb
81
+ homepage: https://gitlab.com/interage/patterns/service
82
+ licenses:
83
+ - MIT
84
+ metadata:
85
+ allowed_push_host: https://rubygems.org
86
+ homepage_uri: https://gitlab.com/interage/patterns/service
87
+ source_code_uri: https://gitlab.com/interage/patterns/service
88
+ changelog_uri: https://gitlab.com/interage/patterns/service/blob/master/CHANGES
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubygems_version: 3.0.6
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Application Service for Interage
108
+ test_files: []