pelita 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86ce8c980f28c6da05cdf73b4cc3632374c2fd84
4
- data.tar.gz: 4c84e2e6e327a1679d1dad2435a12a8ba5d1d38e
3
+ metadata.gz: 16995980a5965cdafe77936d109c28e878a57e6e
4
+ data.tar.gz: 6701d1e239a0464078f92a9d7c0e11ab9b3652db
5
5
  SHA512:
6
- metadata.gz: 9bcdf0e320bed15cdcabd62177d8d1e0ccb8ebd820b681a26b2d05f7711e903a64c2fab568ccac2c30110489ee3eb6f5233eaac2c4c2a633a8b771395d9f0bdc
7
- data.tar.gz: 9d37a79354ca7dff4395cf8afbdd26c7fe0bd4988a0ff11d33aa6ab0aac906d0388e9d3e54838979c21e23d416c7884c9f1faebe39ae8f05019458c1077c89e6
6
+ metadata.gz: 6da94fb161ea7572ca2f3bb805017f295695bdd2a700f36bedec763539d51985d5ad2684560bc207fc869dbbdec253f716978e9c469a9c03599b5750112d9ace
7
+ data.tar.gz: 8fccf36a4bf5a31ac2203ca8322793d6b15d3d43c1f0f569ce1cc7a56b4f4c03e66d14bb1deb28c423e15a9ed48f59b0f0c1190403aa921d8e0b105da86c0699
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -0,0 +1,2 @@
1
+ require_relative 'blank'
2
+ require_relative 'snake_case'
@@ -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,6 @@
1
+ require 'dry/system/container'
2
+
3
+ module Pelita
4
+ class Container < Dry::System::Container
5
+ end
6
+ end
@@ -0,0 +1 @@
1
+ require_relative 'entity/base'
@@ -0,0 +1,7 @@
1
+ module Pelita
2
+ module Entity
3
+ class Base < Dry::Struct
4
+ constructor_type :schema
5
+ end
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ require_relative 'operation/base'
@@ -1,16 +1,20 @@
1
- class AttemptAdapter < Dry::Transaction::StepAdapters
2
- include Dry::Monads::Either::Mixin
1
+ module Pelita
2
+ module Operation
3
+ class AttemptAdapter < Dry::Transaction::StepAdapters
4
+ include Dry::Monads::Either::Mixin
3
5
 
4
- def call(step, input, *args)
5
- unless step.options[:catch]
6
- raise ArgumentError, "+attempt+ steps require one or more exception classes provided via +catch:+"
7
- end
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
- step.operation.call(input, *args)
10
- rescue *Array(step.options[:catch]) => e
11
- e = step.options[:raise].new(e.message) if step.options[:raise]
12
- input["error"] = e
13
- Left(input)
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
- class Operation
5
- include Dry::Transaction
4
+ module Operation
5
+ class Base
6
+ include Dry::Transaction
6
7
 
7
- def authorize!(options)
8
- if options["current_user"].signed_in?
9
- options["result.policy.default"] = true
10
- Right(options)
11
- else
12
- options["result.policy.default"] = false
13
- Left(options)
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
@@ -1 +1,15 @@
1
- require_relative 'operation/base'
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,9 @@
1
+ require 'rom'
2
+
3
+ module Pelita
4
+ module Persistence
5
+ def self.container(*args, &block)
6
+ ROM.container(*args, &block)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1 @@
1
+ require_relative 'repository/base'
@@ -0,0 +1,6 @@
1
+ module Pelita
2
+ module Repository
3
+ class Base < ROM::Repository
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,2 @@
1
+ require_relative 'sql/migration'
2
+ require_relative 'sql/rake_task'
@@ -0,0 +1,7 @@
1
+ module Pelita
2
+ module SQL
3
+ def self.migration(*args, &block)
4
+ ROM::SQL.migration(*args, &block)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ require 'rom/sql/rake_task'
@@ -0,0 +1,7 @@
1
+ module Pelita
2
+ module Types
3
+ def self.module
4
+ Dry::Types.module
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Pelita
2
+ module Validation
3
+ def self.Schema(base = Dry::Validation::Schema, **options, &block)
4
+ Dry::Validation.Schema(base, options, &block)
5
+ end
6
+ end
7
+ end
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.1.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-06-26 00:00:00.000000000 Z
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.5.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
@@ -1,2 +0,0 @@
1
- require_relative 'core_ext/blank'
2
- require_relative 'core_ext/snake_case'