rdux 0.4.0 → 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: 32c03f6ef68f19c9b2a00f688e995f085d01e8adddca45615a19349a5c4dc602
4
- data.tar.gz: 42298a7b25fa3de1f8c11b572f7c8248f28343d88962811e266744c8de873b49
3
+ metadata.gz: 0eef143c3400a105457f40a8a9c4923ac3ceda1f55368d7bc2a8de146b9bf18d
4
+ data.tar.gz: 3fd1831ee4745709a83d3046bc923fbaba15f6c00c219dc768efcc6c7d6c4c3c
5
5
  SHA512:
6
- metadata.gz: 44b54602854ba8f15ff235892f9f34c585c0b54291e14622af0be5cb289eb44cd9f8bcd31d40c8d39390ad20da701cd3a08abf020c34e803cb8ac3183be8e4b9
7
- data.tar.gz: fa8d26cc9d9ef09d6205bbdb722692f48780d4124ce802feaee630631c82bb21de9af13f55de812aa7690b85408bb11c824c6dde345ccc1a91be49be9208a450
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
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.4.0'
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.4.0
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-06 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
@@ -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