Class: Locomotive::Wagon::PushBaseCommand
- Inherits:
-
Struct
- Object
- Struct
- Locomotive::Wagon::PushBaseCommand
show all
- Extended by:
- Forwardable
- Defined in:
- lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb
Defined Under Namespace
Classes: SkipPersistingException
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client
3
4
5
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 3
def api_client
@api_client
end
|
#content_assets_pusher ⇒ Object
Returns the value of attribute content_assets_pusher
3
4
5
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 3
def content_assets_pusher
@content_assets_pusher
end
|
#filter ⇒ Object
Returns the value of attribute filter
3
4
5
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 3
def filter
@filter
end
|
#remote_site ⇒ Object
Returns the value of attribute remote_site
3
4
5
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 3
def remote_site
@remote_site
end
|
#steam_services ⇒ Object
Returns the value of attribute steam_services
3
4
5
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 3
def steam_services
@steam_services
end
|
Class Method Details
.push(api_client, steam_services, content_assets_pusher, remote_site) {|instance| ... } ⇒ Object
9
10
11
12
13
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 9
def self.push(api_client, steam_services, content_assets_pusher, remote_site)
instance = new(api_client, steam_services, content_assets_pusher, remote_site)
yield instance if block_given?
instance.push
end
|
Instance Method Details
#_push ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 29
def _push
entities.each do |entity|
decorated = decorate(entity)
begin
instrument :persist, label: label_for(decorated)
persist(decorated)
instrument :persist_with_success
rescue SkipPersistingException => e
instrument :skip_persisting
rescue Locomotive::Coal::ServerSideError => e
instrument :persist_with_error, message: 'Locomotive Back-office error. Contact your administrator or check your application logs.'
raise e
rescue Exception => e
instrument :persist_with_error, message: e.message
raise e
end
end
end
|
#_push_with_timezone ⇒ Object
23
24
25
26
27
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 23
def _push_with_timezone
Time.use_zone(current_site.try(:timezone)) do
_push
end
end
|
#default_locale ⇒ Object
57
58
59
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 57
def default_locale
current_site.default_locale
end
|
#instrument(action = nil, payload = {}, &block) ⇒ Object
48
49
50
51
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 48
def instrument(action = nil, payload = {}, &block)
name = ['wagon.push', [*action]].flatten.compact.join('.')
ActiveSupport::Notifications.instrument(name, { name: resource_name }.merge(payload), &block)
end
|
#locales ⇒ Object
61
62
63
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 61
def locales
current_site.locales
end
|
#only(entities) ⇒ Object
77
78
79
80
81
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 77
def only(entities)
@only_entities = entities.map do |entity_or_filter|
Locomotive::Wagon::Glob.new(entity_or_filter.gsub(/\A\//, '')).to_regexp
end
end
|
#path ⇒ Object
65
66
67
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 65
def path
File.expand_path(repositories.adapter.options[:path])
end
|
#push ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 15
def push
instrument do
instrument :start
self._push_with_timezone
instrument :done
end
end
|
#resource_name ⇒ Object
53
54
55
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 53
def resource_name
self.class.name[/::Push(\w+)Command$/, 1].underscore
end
|
#with_data ⇒ Object
69
70
71
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 69
def with_data
@with_data = true
end
|
#with_data? ⇒ Boolean
73
74
75
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb', line 73
def with_data?
!!@with_data
end
|