dps 0.0.5 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe7b47341b7ee6cfcfea62768d08d2441382b115ba0802c5384c027583fdcc3b
4
- data.tar.gz: 478059cf86753fdd53b799ed55461f46c879845c6955e2921a0fc22e3c5eb166
3
+ metadata.gz: f44694279c28ea0625208f237acd9447d82a2cc1c470a850184759415b68e434
4
+ data.tar.gz: 62fa3342cefcf8f019c548cf3191bea4576d4d3efc494bcecd1288bd5e1b591c
5
5
  SHA512:
6
- metadata.gz: 9c068dd5c68a18db6af24900af5a0754346e6fbb91ea3ad120bf1e891702e9a9bcd4481a3c172b94c20034f7dffa2b0c3a420603eeeb9e391ef5fa5af7fe99ae
7
- data.tar.gz: dfc37110a43169941b058ebc80f6f69fc4970c141c1709238708b11180e8241803db55e06a5610ba57cb94e54ab4f2443a3d098d29219fe2ebd56d6dedbf74dc
6
+ metadata.gz: d55c84067b0f512c47c7d5ca8e66bdf9bd0303f398000eb1439a430602a88e94a8a22829a0f95a8bb3287377ffbbbfc925b8f0d84675a219bafc421004abaa94
7
+ data.tar.gz: 007afa21d7158259787ead1c8824b53f7d1c81d60e174854c0f5743337454ebfccad4947ba1994f3e39163d07c2639350e4e2acc26db5a1568ac220f9588d5a1
data/README.md CHANGED
@@ -26,10 +26,10 @@ Or install it yourself as:
26
26
 
27
27
 
28
28
  ```ruby
29
- DPS::DNS.get_endpoint('example.com')
29
+ Dps::DNS.get_endpoint('example.com')
30
30
 
31
31
  # if `tworgy.com` has a DNS TXT record with the value 'dps:endpoint url=https://tworgy.com/dps'
32
32
 
33
- DPS::DNS.get_endpoint('tworgy.com') # returns 'https://tworgy.com/dps'
33
+ Dps::DNS.get_endpoint('tworgy.com') # returns 'https://tworgy.com/dps'
34
34
  ```
35
35
 
@@ -0,0 +1,5 @@
1
+ module Dps
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ require_dependency "dps/application_controller"
2
+
3
+ module Dps
4
+ class InfoController < ApplicationController
5
+
6
+ def show
7
+ if Dps.endpoints.present?
8
+ render json: "Endpoints are: #{Dps.endpoints}"
9
+ else
10
+ render json: "No endpoints specified", status: 501
11
+ end
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,35 @@
1
+ require_dependency "dps/application_controller"
2
+
3
+ module Dps
4
+ class PaymentsController < ApplicationController
5
+ before_action :load_endpoint
6
+
7
+ def new
8
+ if @endpoint_renderer.present?
9
+ @endpoint_renderer.instance_method(:render_new_payment).bind(self).call
10
+ else
11
+ render json: "Could not process endpoint '#{@endpoint}'", status: 501
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def load_endpoint
18
+ @endpoint = params[:endpoint]
19
+ @endpoint_renderer = Dps.get_new_payment_renderer(@endpoint)
20
+ end
21
+
22
+ def payment_params
23
+ params.require(:payment).permit(
24
+ :payer,
25
+ :recipient,
26
+
27
+ transaction: [
28
+ :type,
29
+ :ref
30
+ ]
31
+ )
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>DPS engine</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "dps/engine/application", media: "all" %>
9
+ <%= javascript_include_tag "dps/engine/application" %>
10
+ </head>
11
+ <body>
12
+
13
+ <%= yield %>
14
+
15
+ </body>
16
+ </html>
@@ -0,0 +1,13 @@
1
+ Dps::Engine.routes.draw do
2
+ scope '/dps/v1' do
3
+
4
+ resource :info, only: [:show], controller: 'info'
5
+
6
+ resources :payments, only: [] do
7
+ collection do
8
+ get 'new/:endpoint', action: 'new'
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ class CreateDpsEngineArticles < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :dps_engine_articles do |t|
4
+ t.string :title
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateDpsEngineAdminUsersArticles < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :dps_engine_admin_users_articles do |t|
4
+ t.string :title
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateDpsEngineAdminUsersNodes < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :dps_engine_admin_users_nodes do |t|
4
+ t.string :title
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
data/lib/dps.rb CHANGED
@@ -1,7 +1,33 @@
1
+ require 'dbc'
1
2
  require "dps/dns"
3
+ require "dps/engine"
2
4
  require "dps/version"
3
5
 
4
- module DPS
6
+ module Dps
5
7
  class Error < StandardError; end
6
- # Your code goes here...
8
+ class ProcNotSetError < StandardError; end
9
+
10
+ mattr_accessor :endpoints
11
+ mattr_accessor :new_payment_endpoints_renderers
12
+ self.new_payment_endpoints_renderers = {}
13
+
14
+ def self.setup
15
+ yield(self)
16
+ end
17
+
18
+ def self.get_new_payment_renderer(endpoint)
19
+ begin
20
+ new_payment_endpoints_renderers.fetch(endpoint.to_sym)
21
+ rescue KeyError
22
+ ProcNotSetError.new("Endpoint proc not set: '#{endpoint}'")
23
+ end
24
+ end
25
+
26
+ def self.new_payment_renderer(endpoint, renderer)
27
+ DBC.require(!renderer.is_a?(Class), "Renderer '#{renderer}' must not be a Class for delegation to work.")
28
+ DBC.require(renderer.is_a?(Module), "Renderer '#{renderer}' must be a Module for delegation to work.")
29
+
30
+ new_payment_endpoints_renderers[endpoint.to_sym] = renderer
31
+ end
32
+
7
33
  end
@@ -1,6 +1,6 @@
1
1
  require 'dnsruby'
2
2
 
3
- module DPS
3
+ module Dps
4
4
  class DNS
5
5
 
6
6
  class << self
@@ -0,0 +1,5 @@
1
+ module Dps
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Dps
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
- module DPS
2
- VERSION = "0.0.5"
1
+ module Dps
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Holroyd
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-25 00:00:00.000000000 Z
11
+ date: 2019-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dnsruby
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.61'
27
+ - !ruby/object:Gem::Dependency
28
+ name: matholroyd-dbc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,34 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '3.8'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sqlite3
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.3.6
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.3.6
69
111
  description: Direct Payment Standard (DPS) specifies a common way for entities to
70
112
  advertise payment options as well as facilitate payments directly between 2 parties.
71
113
  This library contains tools to interact with or implement a DPS server.
@@ -75,14 +117,19 @@ executables: []
75
117
  extensions: []
76
118
  extra_rdoc_files: []
77
119
  files:
78
- - ".gitignore"
79
- - Gemfile
80
- - LICENSE.txt
81
120
  - README.md
82
121
  - Rakefile
83
- - dps.gemspec
122
+ - app/controllers/dps/application_controller.rb
123
+ - app/controllers/dps/info_controller.rb
124
+ - app/controllers/dps/payments_controller.rb
125
+ - app/views/layouts/dps/application.html.erb
126
+ - config/routes.rb
127
+ - db/migrate/20190319025700_create_dps_engine_articles.rb
128
+ - db/migrate/20190319034641_create_dps_engine_admin_users_articles.rb
129
+ - db/migrate/20190319041143_create_dps_engine_admin_users_nodes.rb
84
130
  - lib/dps.rb
85
131
  - lib/dps/dns.rb
132
+ - lib/dps/engine.rb
86
133
  - lib/dps/version.rb
87
134
  homepage: https://github.com/matholroyd/dps-ruby
88
135
  licenses:
data/.gitignore DELETED
@@ -1,14 +0,0 @@
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
12
-
13
- # 'gem bump' assumes Gemfile.lock is not being checked in, so ignore it.
14
- Gemfile.lock
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in dps.gemspec
6
- gemspec
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2019 Mat Holroyd
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.
@@ -1,39 +0,0 @@
1
- lib = File.expand_path("../lib", __FILE__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "dps/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "dps"
7
- spec.version = DPS::VERSION
8
- spec.authors = ["Mat Holroyd"]
9
- spec.email = ['dps@matholroyd.com']
10
-
11
- spec.summary = %q{DPS is a collection of tools to help interact with or implement a DPS server}
12
- spec.description = %q{Direct Payment Standard (DPS) specifies a common way for entities to advertise payment options as well as facilitate payments directly between 2 parties. This library contains tools to interact with or implement a DPS server.}
13
- spec.homepage = "https://github.com/matholroyd/dps-ruby"
14
- spec.license = "MIT"
15
-
16
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
- # to allow pushing to a single host or delete this section to allow pushing to any host.
18
- if spec.respond_to?(:metadata)
19
- spec.metadata["allowed_push_host"] = 'https://rubygems.org'
20
- else
21
- raise "RubyGems 2.0 or newer is required to protect against " \
22
- "public gem pushes."
23
- end
24
-
25
- # Specify which files should be added to the gem when it is released.
26
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
28
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
- end
30
- spec.bindir = "exe"
31
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
- spec.require_paths = ["lib"]
33
-
34
- spec.add_dependency "dnsruby", "~> 1.61"
35
-
36
- spec.add_development_dependency "bundler", "~> 1.17.a"
37
- spec.add_development_dependency "rake", "~> 12.3"
38
- spec.add_development_dependency "rspec", "~> 3.8"
39
- end