itsf_services 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: a107130b7ab2bb78b7d67cc18e8be8bcf8398bab
4
+ data.tar.gz: cb7585bc4d51edf185959e0ad24db3cc2e81b4a1
5
+ SHA512:
6
+ metadata.gz: 244bc213550b0db6f7ef9e026e34206409b221fdef68c6153ce27d1cdc98d514bd89a8ec506d6ea7f40e7de233474e88c28575401d71807437990199146d5dc0
7
+ data.tar.gz: 745ed006d51aec988758b2982fb4ee2752f0d06203d7d95081c8b3a383a64828491f35636194b702aa7e4ee5718f4ff5edfd129f2a91980336bfe72a19c96306
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Roberto Vasquez Angel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = Itsf::Services
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Itsf::Services'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+ Bundler::GemHelper.install_tasks
19
+
20
+
21
+
22
+ task default: :test
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,14 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. It is generally better to create a new file per style scope.
11
+ *
12
+ *= require_tree .
13
+ *= require_self
14
+ */
@@ -0,0 +1,6 @@
1
+ module Itsf
2
+ module Services
3
+ class ApplicationController < ActionController::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Itsf
2
+ module Services
3
+ module ApplicationHelper
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Services</title>
5
+ <%= stylesheet_link_tag "itsf/services/application", media: "all" %>
6
+ <%= javascript_include_tag "itsf/services/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Itsf::Services::Engine.routes.draw do
2
+ end
@@ -0,0 +1,4 @@
1
+ module Itsf
2
+ module Services
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ module Itsf
2
+ module Services
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace Itsf::Services
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,41 @@
1
+ module Itsf
2
+ module Services
3
+ module V2
4
+ module Response
5
+ class Base
6
+ extend ActiveModel::Naming
7
+
8
+ attr_reader :errors
9
+ attr_writer :success
10
+
11
+ def initialize
12
+ @errors = ActiveModel::Errors.new(self)
13
+ # @success = false
14
+ end
15
+
16
+ def success?
17
+ @errors.blank?
18
+ end
19
+
20
+ def read_attribute_for_validation(attr)
21
+ send(attr)
22
+ end
23
+
24
+ def self.human_attribute_name(attr, options = {})
25
+ attr
26
+ end
27
+
28
+ def self.lookup_ancestors
29
+ [self]
30
+ end
31
+
32
+ private
33
+
34
+ def errors=(errors)
35
+ @errors = errors
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,73 @@
1
+ require 'forwardable'
2
+
3
+ module Itsf
4
+ module Services
5
+ module V2
6
+ module Service
7
+ class Base
8
+ include ActiveModel::Validations
9
+ extend Forwardable
10
+
11
+ def_delegator :@instrumenter, :instrument
12
+ attr_accessor :instrumenter
13
+ attr_reader :response
14
+
15
+ def self.i18n_scope
16
+ 'activerecord'
17
+ end
18
+
19
+ def self.call(attributes = {}, *args)
20
+ new(attributes, *args).send(:do_work)
21
+ end
22
+
23
+ def initialize(attributes = {}, *args)
24
+ options = args.extract_options!
25
+ options.reverse_merge!({ :instrumenter => ActiveSupport::Notifications })
26
+
27
+ @errors = ActiveModel::Errors.new(self)
28
+
29
+ initialize_instrumenter(options[:instrumenter])
30
+ instrument('initialize.export_to_sap.payment.dzb') do
31
+ initialize_attributes if respond_to?(:initialize_attributes)
32
+ set_attributes(attributes)
33
+ initialize_response
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def set_attributes(attributes)
40
+ attributes.each do |name, value|
41
+ send("#{name}=", value)
42
+ end
43
+ end
44
+
45
+ def initialize_instrumenter(instrumenter)
46
+ @instrumenter = instrumenter
47
+ end
48
+
49
+ def initialize_response
50
+ if self.class.const_defined?('Response')
51
+ @response = "#{self.class}::Response".constantize.new
52
+ else
53
+ @response = Services::V2::Response::Base.new
54
+ end
55
+ end
56
+
57
+ def respond
58
+ response
59
+ end
60
+
61
+ def response
62
+ set_errors_on_response
63
+ @response
64
+ end
65
+
66
+ def set_errors_on_response
67
+ @response.send(:'errors=', @errors)
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,5 @@
1
+ module Itsf
2
+ module Services
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'itsf/services/v2/service/base'
2
+ require 'itsf/services/v2/response/base'
3
+
4
+ require "itsf/services"
5
+ require "itsf/services/engine"
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :services do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+ class NavigationTest < ActionDispatch::IntegrationTest
4
+ fixtures :all
5
+
6
+ # test "the truth" do
7
+ # assert true
8
+ # end
9
+ end
10
+
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class Itsf::Services::Test < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, Itsf::Services
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../..//config/environment.rb", __FILE__)
5
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path("../..//db/migrate", __FILE__)]
6
+ require "rails/test_help"
7
+
8
+ # Filter out Minitest backtrace while allowing backtrace from other libraries
9
+ # to be shown.
10
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
11
+
12
+ # Load support files
13
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
14
+
15
+ # Load fixtures from the engine
16
+ if ActiveSupport::TestCase.respond_to?(:fixture_path=)
17
+ ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
18
+ ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "files"
19
+ ActiveSupport::TestCase.fixtures :all
20
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: itsf_services
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Roberto Vasquez Angel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ description: Provides Service Objects with rich Responses.
28
+ email:
29
+ - roberto.vasquez@anwr-group.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - MIT-LICENSE
35
+ - README.rdoc
36
+ - Rakefile
37
+ - app/assets/javascripts/itsf/services/application.js
38
+ - app/assets/stylesheets/itsf/services/application.css
39
+ - app/controllers/itsf/services/application_controller.rb
40
+ - app/helpers/itsf/services/application_helper.rb
41
+ - app/views/layouts/itsf/services/application.html.erb
42
+ - config/routes.rb
43
+ - lib/itsf/services.rb
44
+ - lib/itsf/services/engine.rb
45
+ - lib/itsf/services/v2/response/base.rb
46
+ - lib/itsf/services/v2/service/base.rb
47
+ - lib/itsf/services/version.rb
48
+ - lib/itsf_services.rb
49
+ - lib/tasks/itsf/services_tasks.rake
50
+ - test/integration/navigation_test.rb
51
+ - test/itsf/services_test.rb
52
+ - test/test_helper.rb
53
+ homepage: https://github.com/robotex82/itsf_services
54
+ licenses:
55
+ - MIT
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.4.8
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: ITSF Services Rails Engine.
77
+ test_files:
78
+ - test/integration/navigation_test.rb
79
+ - test/itsf/services_test.rb
80
+ - test/test_helper.rb