external_services 0.1.4 → 0.1.5
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 +8 -8
- data/Rakefile +1 -1
- data/config/locales/en.yml +5 -0
- data/lib/external_services/active_record.rb +16 -2
- data/lib/external_services/api.rb +1 -1
- data/lib/external_services/version.rb +1 -1
- data/lib/generators/service_generator.rb +1 -2
- data/lib/rspec/configuration.rb +2 -2
- data/lib/rspec/helpers.rb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
YWNlM2UzYTQxZGE4ZmNiMDVmMTA3ZTc3ZjI3OTc1MjE5MWViYmNiYg==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
Mjg2YmE2MmIzZDcwYTdmYTY3OGY5NWE1NmZkY2QyM2RkMmFkOWE5OA==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
NTMzOGQzZTdmMmZjZDg0ODY1NzM3MmVlNTliM2Y4ZDk1ZGI5ZDI1ZGM0NDlh
|
|
10
|
+
MGM1NGQ3MmRjYTgwN2RhMmYxM2QwNDVlZDdjZTdiZjhlNTFjNzhhOGQ0ZjNl
|
|
11
|
+
NGIxMTdjZmEzYjdhZTA0NTg3MzhkOGZlODMwZmVmZTI3MjI1ZDM=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
ZmNmNDE2MTIzMzQ2ZjYzNWUyMTVmODdkMzU0ZGE0OWUyZDFlOTI4MWM3YzE1
|
|
14
|
+
ZjhjNDQwY2ZmNmQ2YzQ4MzMyYzVmZGQzNTY3NmE5YzcwOWFiYzI4MmY3OThi
|
|
15
|
+
MjA4YmQyZTMyYTM1YWM1Nzc4NjM5ZGQ3Mjk5YzUyYTllZjJmOTc=
|
data/Rakefile
CHANGED
|
@@ -14,7 +14,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
|
14
14
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
APP_RAKEFILE = File.expand_path(
|
|
17
|
+
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
|
|
18
18
|
|
|
19
19
|
load 'rails/tasks/engine.rake'
|
|
20
20
|
|
|
@@ -88,7 +88,7 @@ module ExternalServices
|
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
-
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
91
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
92
92
|
def define_external_service_callbacks(name, options = {})
|
|
93
93
|
service_assoc = :"#{name}_service"
|
|
94
94
|
only_api_actions = (options[:only_api_actions] == true)
|
|
@@ -101,6 +101,9 @@ module ExternalServices
|
|
|
101
101
|
before_save do
|
|
102
102
|
public_send(:"build_#{service_assoc}") if public_send(service_assoc).blank?
|
|
103
103
|
end
|
|
104
|
+
|
|
105
|
+
before_update :halt_on_external_services_unsynced
|
|
106
|
+
before_destroy :halt_on_external_services_unsynced
|
|
104
107
|
end
|
|
105
108
|
|
|
106
109
|
after_save :"#{name}_on_create", if: :id_changed?
|
|
@@ -130,8 +133,19 @@ module ExternalServices
|
|
|
130
133
|
public_send(service_assoc).on_subject_revive(self) unless only_api_actions
|
|
131
134
|
end
|
|
132
135
|
protected :"#{name}_on_revive"
|
|
136
|
+
|
|
137
|
+
protected def halt_on_external_services_unsynced
|
|
138
|
+
unless external_services_synced?
|
|
139
|
+
errors.add :base, :external_services_not_synced
|
|
140
|
+
if ::ActiveRecord::VERSION::MAJOR < 5
|
|
141
|
+
return false
|
|
142
|
+
else
|
|
143
|
+
throw :abort
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
133
147
|
end
|
|
134
|
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
|
148
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
135
149
|
|
|
136
150
|
include callbacks_module
|
|
137
151
|
end
|
|
@@ -7,12 +7,11 @@ module ExternalServices
|
|
|
7
7
|
class ServiceGenerator < ::Rails::Generators::NamedBase
|
|
8
8
|
source_root File.expand_path('../templates/services', __FILE__)
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
class_option(
|
|
12
11
|
:only_api_actions,
|
|
13
12
|
type: :boolean,
|
|
14
13
|
default: false,
|
|
15
|
-
desc:
|
|
14
|
+
desc: 'Do not generate service model class'
|
|
16
15
|
)
|
|
17
16
|
|
|
18
17
|
desc 'Generates specified model and API classes.'
|
data/lib/rspec/configuration.rb
CHANGED
|
@@ -5,14 +5,14 @@ module ExternalServices
|
|
|
5
5
|
|
|
6
6
|
def add_external_service(name)
|
|
7
7
|
Disabler.add_external_service name
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
mod = Module.new do
|
|
10
10
|
define_method :"describe_#{name}_api" do |object:, **kwargs, &blk|
|
|
11
11
|
describe_external_service_api(object: object, api_name: name, **kwargs, &blk)
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
extend mod
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
end
|
data/lib/rspec/helpers.rb
CHANGED
|
@@ -65,6 +65,9 @@ module ExternalServices
|
|
|
65
65
|
|
|
66
66
|
if :destroy.in? methods
|
|
67
67
|
it 'creates action on delete' do
|
|
68
|
+
@api_object.send("#{@id_key}=", SecureRandom.hex)
|
|
69
|
+
@api_object.save
|
|
70
|
+
|
|
68
71
|
if @api_object.respond_to?(:descendants)
|
|
69
72
|
@api_object.reload.descendants.each(&:delete)
|
|
70
73
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: external_services
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sergey Gnuskov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-10-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -78,6 +78,7 @@ files:
|
|
|
78
78
|
- app/models/external_services/api_action.rb
|
|
79
79
|
- app/models/external_services/service.rb
|
|
80
80
|
- bin/rails
|
|
81
|
+
- config/locales/en.yml
|
|
81
82
|
- external_services.gemspec
|
|
82
83
|
- lib/external_services.rb
|
|
83
84
|
- lib/external_services/active_record.rb
|