rdux 0.3.1 → 0.4.1

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
  SHA256:
3
- metadata.gz: 35cf30e3852b2520fb9988cae024c347caa472dc9466750ff0577ec733a0aebf
4
- data.tar.gz: 9346d160451a0e3365c36ec521eadb3593286baedca6f5c272b16caa7ad63773
3
+ metadata.gz: 0eef143c3400a105457f40a8a9c4923ac3ceda1f55368d7bc2a8de146b9bf18d
4
+ data.tar.gz: 3fd1831ee4745709a83d3046bc923fbaba15f6c00c219dc768efcc6c7d6c4c3c
5
5
  SHA512:
6
- metadata.gz: 0bac032050e6bac502f01e7773e1ddd1fe92410d94a6f14b9dfc58d3cae0811fa41e69a29d5c63fb9ab9640dce45bfb8d293c8c9ab4a4c832a517a81046f1313
7
- data.tar.gz: bbfd1964c7e87318f655476888049540858bc815a4e68042ea1d0d32c661a77583fd85b41551c1e73749158ab7d3c791d3ca9cd2e453dce98950666e78ac5909
6
+ metadata.gz: 45d228402c630f1470c1bca298ece96eb39c1de62d6368890ac9959d6c331f77ee48703bcbf56b684b30f22214665789d8bbbada18b691f9e01a18e058cd0fba
7
+ data.tar.gz: c518e31ce369986564bdc735602480499dfbecf0f4c90f7e873a3e73b016c14cf2e9367e954d99e4e05a56c6f1a17f70c592ceebbd39d7fa82ed077695f94cf4
data/README.md CHANGED
@@ -10,7 +10,7 @@ $ bin/rails db:migrate
10
10
 
11
11
  ### Code structure
12
12
 
13
- ### Dispatch action
13
+ #### Dispatch action
14
14
 
15
15
  ```ruby
16
16
  Rdux.perform(
@@ -23,6 +23,12 @@ Rdux.perform(
23
23
  )
24
24
  ```
25
25
 
26
+ #### Return
27
+
28
+ ```ruby
29
+ Rdux::Result[true, { activity: activity }]
30
+ ```
31
+
26
32
  ## Installation
27
33
  Add this line to your application's Gemfile:
28
34
 
@@ -42,9 +48,20 @@ $ gem install rdux
42
48
 
43
49
  ## Test
44
50
 
51
+ ### Setup
52
+
53
+ ```bash
54
+ $ cd test/dummy
55
+ $ DB=all bin/rails db:create
56
+ $ DB=all bin/rails db:prepare
57
+ $ cd ../..
58
+ ```
59
+
60
+ ### Run tests
61
+
45
62
  ```bash
46
- $ DB=postgres bin/test
47
- $ DB=sqlite bin/test
63
+ $ DB=postgres bin/rails test
64
+ $ DB=sqlite bin/rails test
48
65
  ```
49
66
 
50
67
  ## License
@@ -8,7 +8,7 @@ module Rdux
8
8
  belongs_to :rdux_action, optional: true, class_name: 'Rdux::Action'
9
9
  has_many :rdux_actions, class_name: 'Rdux::Action', foreign_key: 'rdux_action_id'
10
10
 
11
- serialize :down_payload, JSON
11
+ serialize :down_payload, JSON if ActiveRecord::Base.connection.adapter_name != 'PostgreSQL'
12
12
 
13
13
  scope :up, -> { where(down_at: nil) }
14
14
  scope :down, -> { where.not(down_at: nil) }
@@ -47,7 +47,7 @@ module Rdux
47
47
  !q.count.positive?
48
48
  end
49
49
 
50
- def action_creator(meth)
50
+ def action_performer(meth)
51
51
  name_const = name.to_s.classify.constantize
52
52
  return name_const if name_const.respond_to?(meth)
53
53
  return unless name_const.is_a?(Class)
@@ -57,7 +57,7 @@ module Rdux
57
57
  end
58
58
 
59
59
  def perform_action(meth, payload, opts)
60
- responder = action_creator(meth)
60
+ responder = action_performer(meth)
61
61
  return if responder.nil?
62
62
 
63
63
  if opts.any?
@@ -5,9 +5,11 @@ module Rdux
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
- serialize :up_payload, JSON
9
- serialize :up_result, JSON
10
- serialize :meta, JSON
8
+ if ActiveRecord::Base.connection.adapter_name != 'PostgreSQL'
9
+ serialize :up_payload, JSON
10
+ serialize :up_result, JSON
11
+ serialize :meta, JSON
12
+ end
11
13
 
12
14
  validates :name, presence: true
13
15
  validates :up_payload, presence: true
@@ -5,7 +5,7 @@ class CreateRduxFailedActions < ActiveRecord::Migration[7.0]
5
5
  create_table :rdux_failed_actions do |t|
6
6
  t.string :name, null: false
7
7
  t.column :up_payload, (ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' ? :jsonb : :text), null: false
8
- t.boolean :up_payload_sanitized, default: false
8
+ t.boolean :up_payload_sanitized, default: false, null: false
9
9
  t.column :up_result, (ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' ? :jsonb : :text)
10
10
  t.column :meta, (ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' ? :jsonb : :text)
11
11
  t.string :stream_hash
@@ -7,7 +7,7 @@ class CreateRduxActions < ActiveRecord::Migration[7.0]
7
7
  t.column :up_payload, (ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' ? :jsonb : :text), null: false
8
8
  t.column :down_payload, (ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' ? :jsonb : :text)
9
9
  t.datetime :down_at
10
- t.boolean :up_payload_sanitized, default: false
10
+ t.boolean :up_payload_sanitized, default: false, null: false
11
11
  t.column :up_result, (ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' ? :jsonb : :text)
12
12
  t.column :meta, (ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' ? :jsonb : :text)
13
13
  t.string :stream_hash
data/lib/rdux/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rdux
4
- VERSION = '0.3.1'
4
+ VERSION = '0.4.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zbigniew Humeniuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-04 00:00:00.000000000 Z
11
+ date: 2023-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 1.54.1
53
+ version: 1.55.1
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 1.54.1
60
+ version: 1.55.1
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rubocop-rails
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -111,7 +111,6 @@ files:
111
111
  - lib/rdux/result.rb
112
112
  - lib/rdux/sanitize.rb
113
113
  - lib/rdux/version.rb
114
- - lib/tasks/test.rake
115
114
  homepage: https://artofcode.co
116
115
  licenses:
117
116
  - MIT
@@ -132,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
131
  - !ruby/object:Gem::Version
133
132
  version: '0'
134
133
  requirements: []
135
- rubygems_version: 3.4.10
134
+ rubygems_version: 3.4.18
136
135
  signing_key:
137
136
  specification_version: 4
138
137
  summary: Rdux adds a new layer to Rails apps - actions.
data/lib/tasks/test.rake DELETED
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- namespace :test do
4
- desc 'Run tests with the SQLite database'
5
- task :sqlite do
6
- # Set an environment variable to change the database configuration
7
- ENV['DB'] = 'sqlite'
8
- Rake::Task['test'].invoke
9
- end
10
-
11
- desc 'Run tests with the Postgres database'
12
- task :postgres do
13
- ENV['DB'] = 'postgres'
14
- Rake::Task['test'].invoke
15
- end
16
- end