fast_cqrs 0.1.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb6fbd421c52ee2e12bb6f6f8ed91ed982f677f9822fd0b2a2d96b6a69b4a717
4
- data.tar.gz: c2b5f5f80607433188e269c1ed320d7860c1b23484ae469627e888a20446cfbf
3
+ metadata.gz: 194793fceace66ffc0629475aca67047c69c977ef3d9d6e45561f73056a0cd7d
4
+ data.tar.gz: 6fced80ae64e1773f68e5f5ecab6860e8d6261a96275a6349231283f47f8a36a
5
5
  SHA512:
6
- metadata.gz: 0b7fb848f60d6e8f11147055edba61ce01978c5f928e6a36117ee9bdf0c2ff32436b11e728b2163b68b21fa2f6a8fcd02a1aefa135baed7ce34060b788b9ed12
7
- data.tar.gz: 629e11ff7d505a9ff058d202e53a940e19b691fcdbce284aed585bd36f18fa4f15e89549b49c051fbadb939c469d214ba44792315c72f450d60c9ded0aac998c
6
+ metadata.gz: 8a68d3416791afaf06bd67b0568ff977df9b36177f7d039759cab05b24ec2cda12b5294945bc99e9a800f38d1086c57a808cf779d68df98e9899fb9c97bbb281
7
+ data.tar.gz: 5f10db1d6d3ecfd85b98cf31512509072436ff3527367a9d2d62870bc21dc6e822d9c400f2c274fc710ddf3e76c209a48fa89f3992d3c176d2002c2e8f7e4424
@@ -1,10 +1,8 @@
1
- name: Ruby Gem
1
+ name: Test & Release
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [ master ]
6
- pull_request:
7
- branches: [ master ]
5
+ branches: [ release ]
8
6
 
9
7
  jobs:
10
8
  build:
@@ -17,22 +15,12 @@ jobs:
17
15
  uses: actions/setup-ruby@v1
18
16
  with:
19
17
  version: 2.7.x
18
+ - name: Install dependencies
19
+ run: bundle install
20
+ - name: Rubocop lint check
21
+ run: bundle exec rubocop
20
22
  - name: Run tests
21
- run: |
22
- bundle install
23
- bundle exec rspec
24
- # - name: Publish to GPR
25
- # run: |
26
- # mkdir -p $HOME/.gem
27
- # touch $HOME/.gem/credentials
28
- # chmod 0600 $HOME/.gem/credentials
29
- # printf -- "---\n:github: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
30
- # gem build *.gemspec
31
- # gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
32
- # env:
33
- # GEM_HOST_API_KEY: ${{secrets.GPR_AUTH_TOKEN}}
34
- # OWNER: driggl
35
-
23
+ run: bundle exec rspec
36
24
  - name: Publish to RubyGems
37
25
  run: |
38
26
  mkdir -p $HOME/.gem
@@ -0,0 +1,25 @@
1
+ name: Run tests
2
+
3
+ on:
4
+ push:
5
+ branches-ignore: [ release ]
6
+ pull_request:
7
+ branches: [ master release ]
8
+
9
+ jobs:
10
+ build:
11
+ name: Build + Test
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby 2.7.1
17
+ uses: actions/setup-ruby@v1
18
+ with:
19
+ version: 2.7.x
20
+ - name: Install dependencies
21
+ run: bundle install
22
+ - name: Rubocop lint check
23
+ run: bundle exec rubocop
24
+ - name: Run tests
25
+ run: bundle exec rspec
@@ -0,0 +1,46 @@
1
+ require:
2
+ - rubocop-performance
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.7.1
6
+
7
+ Layout/DotPosition:
8
+ EnforcedStyle: trailing
9
+
10
+ # Commonly used screens these days easily fit more than 80 characters.
11
+ Metrics/BlockLength:
12
+ Exclude:
13
+ - 'spec/**/*'
14
+ - 'fast_cqrs.gemspec'
15
+
16
+ Style/DoubleNegation:
17
+ Enabled: false
18
+
19
+ Layout/LineLength:
20
+ Max: 120
21
+ Layout/EmptyLinesAroundAttributeAccessor:
22
+ Enabled: true
23
+ Layout/SpaceAroundMethodCallOperator:
24
+ Enabled: true
25
+ Lint/DeprecatedOpenSSLConstant:
26
+ Enabled: true
27
+ Lint/MixedRegexpCaptureTypes:
28
+ Enabled: true
29
+ Lint/RaiseException:
30
+ Enabled: true
31
+ Lint/StructNewOverride:
32
+ Enabled: true
33
+ Style/ExponentialNotation:
34
+ Enabled: true
35
+ Style/HashEachMethods:
36
+ Enabled: true
37
+ Style/HashTransformKeys:
38
+ Enabled: true
39
+ Style/HashTransformValues:
40
+ Enabled: true
41
+ Style/RedundantRegexpCharacterClass:
42
+ Enabled: true
43
+ Style/RedundantRegexpEscape:
44
+ Enabled: true
45
+ Style/SlicingWithRange:
46
+ Enabled: true
data/Gemfile CHANGED
@@ -1,7 +1,9 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in fast_cqrs.gemspec
4
6
  gemspec
5
7
 
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
8
+ gem 'rake', '~> 12.0'
9
+ gem 'rspec', '~> 3.0'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fast_cqrs (0.1.1)
4
+ fast_cqrs (0.2.0)
5
5
  dry-matcher
6
6
  dry-monads
7
7
  dry-struct
@@ -11,21 +11,22 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- concurrent-ruby (1.1.6)
14
+ ast (2.4.0)
15
+ concurrent-ruby (1.1.7)
15
16
  diff-lcs (1.3)
16
- dry-configurable (0.11.5)
17
+ dry-configurable (0.11.6)
17
18
  concurrent-ruby (~> 1.0)
18
19
  dry-core (~> 0.4, >= 0.4.7)
19
20
  dry-equalizer (~> 0.2)
20
21
  dry-container (0.7.2)
21
22
  concurrent-ruby (~> 1.0)
22
23
  dry-configurable (~> 0.1, >= 0.1.3)
23
- dry-core (0.4.9)
24
+ dry-core (0.4.10)
24
25
  concurrent-ruby (~> 1.0)
25
26
  dry-equalizer (0.3.0)
26
27
  dry-inflector (0.2.0)
27
- dry-initializer (3.0.3)
28
- dry-logic (1.0.6)
28
+ dry-initializer (3.0.4)
29
+ dry-logic (1.0.8)
29
30
  concurrent-ruby (~> 1.0)
30
31
  dry-core (~> 0.2)
31
32
  dry-equalizer (~> 0.2)
@@ -35,7 +36,7 @@ GEM
35
36
  concurrent-ruby (~> 1.0)
36
37
  dry-core (~> 0.4, >= 0.4.4)
37
38
  dry-equalizer
38
- dry-schema (1.5.1)
39
+ dry-schema (1.5.6)
39
40
  concurrent-ruby (~> 1.0)
40
41
  dry-configurable (~> 0.8, >= 0.8.3)
41
42
  dry-core (~> 0.4)
@@ -55,15 +56,21 @@ GEM
55
56
  dry-equalizer (~> 0.3)
56
57
  dry-inflector (~> 0.1, >= 0.1.2)
57
58
  dry-logic (~> 1.0, >= 1.0.2)
58
- dry-validation (1.5.0)
59
+ dry-validation (1.5.6)
59
60
  concurrent-ruby (~> 1.0)
60
61
  dry-container (~> 0.7, >= 0.7.1)
61
62
  dry-core (~> 0.4)
62
63
  dry-equalizer (~> 0.2)
63
64
  dry-initializer (~> 3.0)
64
- dry-schema (~> 1.5)
65
+ dry-schema (~> 1.5, >= 1.5.2)
65
66
  ice_nine (0.11.2)
67
+ parallel (1.19.1)
68
+ parser (2.7.1.3)
69
+ ast (~> 2.4.0)
70
+ rainbow (3.0.0)
66
71
  rake (12.3.3)
72
+ regexp_parser (1.7.1)
73
+ rexml (3.2.4)
67
74
  rspec (3.9.0)
68
75
  rspec-core (~> 3.9.0)
69
76
  rspec-expectations (~> 3.9.0)
@@ -77,6 +84,21 @@ GEM
77
84
  diff-lcs (>= 1.2.0, < 2.0)
78
85
  rspec-support (~> 3.9.0)
79
86
  rspec-support (3.9.3)
87
+ rubocop (0.85.1)
88
+ parallel (~> 1.10)
89
+ parser (>= 2.7.0.1)
90
+ rainbow (>= 2.2.2, < 4.0)
91
+ regexp_parser (>= 1.7)
92
+ rexml
93
+ rubocop-ast (>= 0.0.3)
94
+ ruby-progressbar (~> 1.7)
95
+ unicode-display_width (>= 1.4.0, < 2.0)
96
+ rubocop-ast (0.0.3)
97
+ parser (>= 2.7.0.1)
98
+ rubocop-performance (1.6.1)
99
+ rubocop (>= 0.71.0)
100
+ ruby-progressbar (1.10.1)
101
+ unicode-display_width (1.7.0)
80
102
 
81
103
  PLATFORMS
82
104
  ruby
@@ -85,6 +107,8 @@ DEPENDENCIES
85
107
  fast_cqrs!
86
108
  rake (~> 12.0)
87
109
  rspec (~> 3.0)
110
+ rubocop
111
+ rubocop-performance
88
112
 
89
113
  BUNDLED WITH
90
114
  2.1.4
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- ![Ruby Gem](https://github.com/driggl/fast_cqrs/workflows/Ruby%20Gem/badge.svg?branch=master)
1
+ ![Run tests](https://github.com/driggl/fast_cqrs/workflows/Run%20tests/badge.svg?branch=master&event=push)
2
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/ba5ae197b61f418ba9c4fdb0239aa8f4)](https://app.codacy.com/gh/driggl/fast_cqrs?utm_source=github.com&utm_medium=referral&utm_content=driggl/fast_cqrs&utm_campaign=Badge_Grade_Dashboard)
3
+ [![Gem Version](https://badge.fury.io/rb/fast_cqrs.svg)](https://badge.fury.io/rb/fast_cqrs)
2
4
 
3
5
  # FastCqrs
4
6
 
@@ -97,6 +99,10 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
97
99
 
98
100
  Bug reports and pull requests are welcome on GitHub at https://github.com/driggl/fast_cqrs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/driggl/fast_cqrs/blob/master/CODE_OF_CONDUCT.md).
99
101
 
102
+ ### Publishing new version
103
+
104
+ 1. Push commit with updated `version.rb` file to the `release` branch. The new version will be automatically pushed to [rubygems](https://rubygems.org).
105
+ 2. Create release on github including change log.
100
106
 
101
107
  ## License
102
108
 
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "fast_cqrs"
4
+ require 'bundler/setup'
5
+ require 'fast_cqrs'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "fast_cqrs"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -1,35 +1,40 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'lib/fast_cqrs/version'
2
4
 
3
5
  Gem::Specification.new do |spec|
4
- spec.name = "fast_cqrs"
6
+ spec.name = 'fast_cqrs'
5
7
  spec.version = FastCqrs::VERSION
6
- spec.authors = ["Sebastian Wilgosz"]
7
- spec.email = ["sebastian@driggl.com"]
8
+ spec.authors = ['Sebastian Wilgosz']
9
+ spec.email = ['sebastian@driggl.com']
8
10
 
9
- spec.summary = %q{A lightweight CQRS scaffold for ruby-based web applications.}
10
- spec.description = %q{Write CQRS applications easily using functional endpoints without a hassle.}
11
- spec.homepage = "https://github.com/driggl/fast_cqrs"
12
- spec.license = "MIT"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
11
+ spec.summary = 'A lightweight CQRS scaffold for ruby-based web applications.'
12
+ spec.description = 'Write CQRS applications easily using functional endpoints without a hassle.'
13
+ spec.homepage = 'https://github.com/driggl/fast_cqrs'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
14
16
 
15
17
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
16
18
 
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = "https://github.com/driggl/fast_cqrs"
19
- spec.metadata["changelog_uri"] = "https://github.com/driggl/fast_cqrs/releases"
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = 'https://github.com/driggl/fast_cqrs'
21
+ spec.metadata['changelog_uri'] = 'https://github.com/driggl/fast_cqrs/releases'
20
22
 
21
23
  # Specify which files should be added to the gem when it is released.
22
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
26
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
27
  end
26
- spec.bindir = "exe"
28
+ spec.bindir = 'exe'
27
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
- spec.require_paths = ["lib"]
30
+ spec.require_paths = ['lib']
29
31
 
30
32
  spec.add_dependency 'dry-matcher'
31
33
  spec.add_dependency 'dry-monads'
32
34
  spec.add_dependency 'dry-struct'
33
35
  spec.add_dependency 'dry-types'
34
36
  spec.add_dependency 'dry-validation'
37
+
38
+ spec.add_development_dependency 'rubocop'
39
+ spec.add_development_dependency 'rubocop-performance'
35
40
  end
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fast_cqrs/version'
2
4
  require 'fast_cqrs/authorizer'
3
5
  require 'fast_cqrs/request'
4
6
  require 'fast_cqrs/transaction'
7
+ require 'fast_cqrs/query'
5
8
 
6
9
  module FastCqrs
7
10
  class Error < StandardError; end
@@ -3,6 +3,10 @@
3
3
  require 'dry/monads'
4
4
 
5
5
  module FastCqrs
6
+ # A base Authorizer class used to validate the access to the given resource
7
+ # an easy to use hash.
8
+ # Usage: Inherit and override the #authorize method
9
+ #
6
10
  class Authorizer
7
11
  def self.inherited(klass)
8
12
  super
@@ -11,16 +15,17 @@ module FastCqrs
11
15
  end
12
16
  end
13
17
 
14
- def call(**)
15
- return Success() if authorize
18
+ def call(subject: nil, auth: nil)
19
+ return Success() if authorize(subject, auth)
20
+
16
21
  fail!
17
22
  end
18
23
 
19
24
  protected
20
25
 
21
26
  # Override this in the inherited class
22
- def authorize
23
- true
27
+ def authorize(_subject, _auth)
28
+ false
24
29
  end
25
30
 
26
31
  private
@@ -4,6 +4,10 @@ require 'ostruct'
4
4
 
5
5
  module FastCqrs
6
6
  module Deserializer
7
+ # Transforms the JSON API request body to a flat hash
8
+ # Input: { data: { id: 1, type: 'foo', attributes: { bar: 'bar' } } }
9
+ # Output: { id: 1, resource_type: 'foo', bar: 'bar' }
10
+ #
7
11
  class JsonApi
8
12
  IncorrectFormat = Class.new(StandardError)
9
13
  HashInputRequired = Class.new(StandardError)
@@ -28,4 +32,4 @@ module FastCqrs
28
32
  end
29
33
  end
30
34
  end
31
- end
35
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry/matcher/result_matcher'
4
+ require 'dry/monads'
5
+ require 'dry/validation'
6
+
7
+ module FastCqrs
8
+ # A base transaction class to process the request.
9
+ # Usage: Inherit and override the #call
10
+ #
11
+ class Query
12
+ Dry::Validation.load_extensions(:monads)
13
+ def self.inherited(klass)
14
+ super
15
+ klass.class_eval do
16
+ include Dry::Monads[:do, :result, :try]
17
+ include Dry::Matcher.for(:call, with: Dry::Matcher::ResultMatcher)
18
+ end
19
+ end
20
+
21
+ def call(_input, _auth: nil)
22
+ Success()
23
+ end
24
+ end
25
+ end
@@ -3,6 +3,11 @@
3
3
  require 'dry/monads'
4
4
 
5
5
  module FastCqrs
6
+ # A base Request class uses deserializer to parse the Rack::Request body into
7
+ # an easy to use hash. Useful when more data are required
8
+ # than passed in the input
9
+ # Usage: Inherit and override the #model method
10
+ #
6
11
  class Request
7
12
  include Dry::Monads[:result, :try]
8
13
 
@@ -5,6 +5,9 @@ require 'dry/monads'
5
5
  require 'dry/validation'
6
6
 
7
7
  module FastCqrs
8
+ # A base transaction class to process the request.
9
+ # Usage: Inherit and override the #call
10
+ #
8
11
  class Transaction
9
12
  Dry::Validation.load_extensions(:monads)
10
13
  def self.inherited(klass)
@@ -15,7 +18,7 @@ module FastCqrs
15
18
  end
16
19
  end
17
20
 
18
- def call(input, **)
21
+ def call(_input, _auth: nil)
19
22
  Success()
20
23
  end
21
24
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FastCqrs
2
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
3
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_cqrs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Wilgosz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-09 00:00:00.000000000 Z
11
+ date: 2020-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-matcher
@@ -80,6 +80,34 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
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: rubocop-performance
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  description: Write CQRS applications easily using functional endpoints without a hassle.
84
112
  email:
85
113
  - sebastian@driggl.com
@@ -88,8 +116,10 @@ extensions: []
88
116
  extra_rdoc_files: []
89
117
  files:
90
118
  - ".github/workflows/gem-push.yml"
119
+ - ".github/workflows/gem-test.yml"
91
120
  - ".gitignore"
92
121
  - ".rspec"
122
+ - ".rubocop.yml"
93
123
  - ".ruby-gemset"
94
124
  - ".ruby-version"
95
125
  - ".travis.yml"
@@ -105,6 +135,7 @@ files:
105
135
  - lib/fast_cqrs.rb
106
136
  - lib/fast_cqrs/authorizer.rb
107
137
  - lib/fast_cqrs/deserializer/json_api.rb
138
+ - lib/fast_cqrs/query.rb
108
139
  - lib/fast_cqrs/request.rb
109
140
  - lib/fast_cqrs/transaction.rb
110
141
  - lib/fast_cqrs/version.rb
@@ -131,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
162
  - !ruby/object:Gem::Version
132
163
  version: '0'
133
164
  requirements: []
134
- rubygems_version: 3.1.2
165
+ rubygems_version: 3.1.4
135
166
  signing_key:
136
167
  specification_version: 4
137
168
  summary: A lightweight CQRS scaffold for ruby-based web applications.