pelita 0.1.0 → 0.2.0
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 +4 -4
- data/PELITA_VERSION +1 -1
- data/lib/core_ext/core_ext.rb +2 -0
- data/lib/pelita.rb +2 -1
- data/lib/pelita/application.rb +1 -0
- data/lib/pelita/application/base.rb +37 -0
- data/lib/pelita/container.rb +6 -0
- data/lib/pelita/entity.rb +1 -0
- data/lib/pelita/entity/base.rb +7 -0
- data/lib/pelita/operation.rb +1 -0
- data/lib/pelita/operation/attempt_adapter.rb +16 -12
- data/lib/pelita/operation/base.rb +11 -9
- data/lib/pelita/pelita.rb +15 -1
- data/lib/pelita/persistence.rb +1 -0
- data/lib/pelita/persistence/container.rb +9 -0
- data/lib/pelita/repository.rb +1 -0
- data/lib/pelita/repository/base.rb +6 -0
- data/lib/pelita/sql.rb +2 -0
- data/lib/pelita/sql/migration.rb +7 -0
- data/lib/pelita/sql/rake_task.rb +1 -0
- data/lib/pelita/types.rb +7 -0
- data/lib/pelita/validation.rb +7 -0
- metadata +19 -4
- data/lib/core_ext.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16995980a5965cdafe77936d109c28e878a57e6e
|
4
|
+
data.tar.gz: 6701d1e239a0464078f92a9d7c0e11ab9b3652db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6da94fb161ea7572ca2f3bb805017f295695bdd2a700f36bedec763539d51985d5ad2684560bc207fc869dbbdec253f716978e9c469a9c03599b5750112d9ace
|
7
|
+
data.tar.gz: 8fccf36a4bf5a31ac2203ca8322793d6b15d3d43c1f0f569ce1cc7a56b4f4c03e66d14bb1deb28c423e15a9ed48f59b0f0c1190403aa921d8e0b105da86c0699
|
data/PELITA_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/pelita.rb
CHANGED
@@ -3,9 +3,10 @@ require 'dry-configurable'
|
|
3
3
|
require 'dry-struct'
|
4
4
|
require 'dry-transaction'
|
5
5
|
require 'dry-validation'
|
6
|
+
require 'rack-protection'
|
6
7
|
require 'roda'
|
7
8
|
require 'rom'
|
8
9
|
require 'rom-repository'
|
9
10
|
|
10
|
-
require_relative 'core_ext'
|
11
|
+
require_relative 'core_ext/core_ext'
|
11
12
|
require_relative 'pelita/pelita'
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'application/base'
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Pelita
|
2
|
+
module Application
|
3
|
+
class Base < Roda
|
4
|
+
extend Dry::Configurable
|
5
|
+
|
6
|
+
# Load or set initial configurations
|
7
|
+
setting :root, File.expand_path('')
|
8
|
+
setting :env, ENV['PELITA_ENV'] || 'development'
|
9
|
+
|
10
|
+
# Setup routing tree
|
11
|
+
plugin :multi_run
|
12
|
+
route do |r|
|
13
|
+
r.multi_run
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.generate_connection_string(db_config)
|
17
|
+
conn_string = db_config['adapter']
|
18
|
+
|
19
|
+
unless db_config['host'].blank?
|
20
|
+
host_string = db_config['host']
|
21
|
+
host_string = "#{host_string}:#{db_config['port']}" unless db_config['port'].blank?
|
22
|
+
|
23
|
+
unless db_config['username'].blank?
|
24
|
+
user_string = db_config['username']
|
25
|
+
user_string = "#{user_string}:#{db_config['password']}" unless db_config['password'].blank?
|
26
|
+
host_string = "#{user_string}@#{host_string}"
|
27
|
+
end
|
28
|
+
|
29
|
+
conn_string = "#{conn_string}://#{host_string}"
|
30
|
+
conn_string = "#{conn_string}/#{db_config['database']}" unless db_config['database'].blank?
|
31
|
+
end
|
32
|
+
|
33
|
+
return conn_string
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'entity/base'
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'operation/base'
|
@@ -1,16 +1,20 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module Pelita
|
2
|
+
module Operation
|
3
|
+
class AttemptAdapter < Dry::Transaction::StepAdapters
|
4
|
+
include Dry::Monads::Either::Mixin
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
def call(step, input, *args)
|
7
|
+
unless step.options[:catch]
|
8
|
+
raise ArgumentError, "+attempt+ steps require one or more exception classes provided via +catch:+"
|
9
|
+
end
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
step.operation.call(input, *args)
|
12
|
+
rescue *Array(step.options[:catch]) => e
|
13
|
+
e = step.options[:raise].new(e.message) if step.options[:raise]
|
14
|
+
input["error"] = e
|
15
|
+
Left(input)
|
16
|
+
end
|
17
|
+
end
|
14
18
|
end
|
15
19
|
end
|
16
|
-
Dry::Transaction::StepAdapters.register :attempt, AttemptAdapter.new
|
20
|
+
Dry::Transaction::StepAdapters.register :attempt, Pelita::Operation::AttemptAdapter.new
|
@@ -1,16 +1,18 @@
|
|
1
1
|
require_relative 'attempt_adapter'
|
2
2
|
|
3
3
|
module Pelita
|
4
|
-
|
5
|
-
|
4
|
+
module Operation
|
5
|
+
class Base
|
6
|
+
include Dry::Transaction
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
def authorize!(options)
|
9
|
+
if options["current_user"].signed_in?
|
10
|
+
options["result.policy.default"] = true
|
11
|
+
Right(options)
|
12
|
+
else
|
13
|
+
options["result.policy.default"] = false
|
14
|
+
Left(options)
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
data/lib/pelita/pelita.rb
CHANGED
@@ -1 +1,15 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'container'
|
2
|
+
|
3
|
+
# Building blocks
|
4
|
+
require_relative 'application'
|
5
|
+
require_relative 'entity'
|
6
|
+
require_relative 'repository'
|
7
|
+
require_relative 'operation'
|
8
|
+
|
9
|
+
# Persistences
|
10
|
+
require_relative 'persistence'
|
11
|
+
require_relative 'sql'
|
12
|
+
|
13
|
+
# Functionalities
|
14
|
+
require_relative 'types'
|
15
|
+
require_relative 'validation'
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'persistence/container'
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'repository/base'
|
data/lib/pelita/sql.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rom/sql/rake_task'
|
data/lib/pelita/types.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pelita
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giovanni Sakti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bcrypt
|
@@ -288,13 +288,28 @@ files:
|
|
288
288
|
- LICENSE
|
289
289
|
- PELITA_VERSION
|
290
290
|
- README.md
|
291
|
-
- lib/core_ext.rb
|
292
291
|
- lib/core_ext/blank.rb
|
292
|
+
- lib/core_ext/core_ext.rb
|
293
293
|
- lib/core_ext/snake_case.rb
|
294
294
|
- lib/pelita.rb
|
295
|
+
- lib/pelita/application.rb
|
296
|
+
- lib/pelita/application/base.rb
|
297
|
+
- lib/pelita/container.rb
|
298
|
+
- lib/pelita/entity.rb
|
299
|
+
- lib/pelita/entity/base.rb
|
300
|
+
- lib/pelita/operation.rb
|
295
301
|
- lib/pelita/operation/attempt_adapter.rb
|
296
302
|
- lib/pelita/operation/base.rb
|
297
303
|
- lib/pelita/pelita.rb
|
304
|
+
- lib/pelita/persistence.rb
|
305
|
+
- lib/pelita/persistence/container.rb
|
306
|
+
- lib/pelita/repository.rb
|
307
|
+
- lib/pelita/repository/base.rb
|
308
|
+
- lib/pelita/sql.rb
|
309
|
+
- lib/pelita/sql/migration.rb
|
310
|
+
- lib/pelita/sql/rake_task.rb
|
311
|
+
- lib/pelita/types.rb
|
312
|
+
- lib/pelita/validation.rb
|
298
313
|
- pelita.gemspec
|
299
314
|
homepage: http://github.com/giosakti/pelita
|
300
315
|
licenses:
|
@@ -316,7 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
316
331
|
version: '0'
|
317
332
|
requirements: []
|
318
333
|
rubyforge_project:
|
319
|
-
rubygems_version: 2.
|
334
|
+
rubygems_version: 2.6.11
|
320
335
|
signing_key:
|
321
336
|
specification_version: 4
|
322
337
|
summary: No surprise, configurable glue microframework for building API in Ruby
|
data/lib/core_ext.rb
DELETED