omnievent 0.1.0.pre4 → 0.1.0.pre6

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: 38717b9e58eab673d2701d9bd2fb29a47b39820614cf9b46ab2dfde98a940d7f
4
- data.tar.gz: 8f750f1bf92f031b333bb50a39e1dd8f355d641549ed271c9c0017689676c63c
3
+ metadata.gz: da7a854fa949e14a0f930de4108a7ca22b915290b1346ba36c82d82fc0a3559f
4
+ data.tar.gz: 055a064499e2ea885c1dfd6420f0e113ddf290cc8ed99d0a9479e68b83436e6f
5
5
  SHA512:
6
- metadata.gz: 4e5224989a966288fb06247ca102f5a93491703df0180e69532f3baf228488e3cee2872b244248418108717430413745e1c083526cb344bf59cd6536eafab2cc
7
- data.tar.gz: 5941e388487c35a43935675dc12a5a8af99756b86d98d053d3aed128b915d3032d12e2ced512889525c9a00fd0aa0326a294ee9e1c8810e389d1527b60a060d9
6
+ metadata.gz: '0793a016b99ed2bcd95c7a84a8a3529d5b6fecea4523c60168bdc5f9056774cff70f095cff09567cc4726b15d4acf206df1f44c3312a4d7839aa32f6d409c1e0'
7
+ data.tar.gz: 23ab950fea1a63fa33205b870123bd80e713266684e64bc5570351c85f4c17a638f04395aad4dc60bb19a48a6eaa7a141652b5591d542357c8514b96e7845e61
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omnievent (0.1.0.pre3)
4
+ omnievent (0.1.0.pre5)
5
5
  hashie (>= 3.4.6)
6
6
  iso-639 (~> 0.3.5)
7
7
  tzinfo (~> 2.0)
@@ -21,7 +21,7 @@ GEM
21
21
  hashie (5.0.0)
22
22
  i18n (1.12.0)
23
23
  concurrent-ruby (~> 1.0)
24
- iso-639 (0.3.5)
24
+ iso-639 (0.3.6)
25
25
  json (2.6.2)
26
26
  minitest (5.16.3)
27
27
  parallel (1.22.1)
@@ -10,8 +10,7 @@ module OmniEvent
10
10
  # Tells you if this is considered to be a valid EventHash.
11
11
  def valid?
12
12
  provider? &&
13
- data? &&
14
- data.valid? &&
13
+ (!data || data.valid?) &&
15
14
  (!metadata || metadata.valid?) &&
16
15
  (!associated_data || associated_data.valid?)
17
16
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OmniEvent
4
- VERSION = "0.1.0.pre4"
4
+ VERSION = "0.1.0.pre6"
5
5
  end
data/lib/omnievent.rb CHANGED
@@ -57,44 +57,38 @@ module OmniEvent
57
57
 
58
58
  # List events.
59
59
  def list_events(provider = nil, opts = {})
60
- validate_provider_arg(provider)
60
+ raise ArgumentError, "You need to pass a provider name as the first argument." unless provider
61
61
 
62
62
  strategy_instance(provider).request(:list_events, opts)
63
63
  end
64
64
 
65
65
  # Create event.
66
66
  def create_event(provider = nil, opts = {})
67
- validate_event_args(provider, opts)
67
+ raise ArgumentError, "You need to pass a provider name as the first argument." unless provider
68
+ raise ArgumentError, "You need to pass an :event in opts." unless opts_has_event?(opts)
69
+ raise ArgumentError, "Event is not valid." unless opts[:event].valid?
68
70
 
69
71
  strategy_instance(provider).request(:create_event, opts)
70
72
  end
71
73
 
72
74
  # Update event.
73
75
  def update_event(provider = nil, opts = {})
74
- validate_event_args(provider, opts)
76
+ raise ArgumentError, "You need to pass a provider name as the first argument." unless provider
77
+ raise ArgumentError, "You need to pass an :event in opts." unless opts_has_event?(opts)
75
78
 
76
79
  strategy_instance(provider).request(:update_event, opts)
77
80
  end
78
81
 
79
82
  # Destroy event.
80
83
  def destroy_event(provider = nil, opts = {})
81
- validate_event_args(provider, opts)
82
-
83
- strategy_instance(provider).request(:destroy_event, opts)
84
- end
85
-
86
- def validate_provider_arg(provider)
87
84
  raise ArgumentError, "You need to pass a provider name as the first argument." unless provider
88
- end
85
+ raise ArgumentError, "You need to pass an :event in opts." unless opts_has_event?(opts)
89
86
 
90
- def validate_event_args(provider, opts)
91
- validate_provider_arg(provider)
92
-
93
- raise ArgumentError, "You need to pass a valid as :event in opts." unless opts_have_valid_event?(opts)
87
+ strategy_instance(provider).request(:destroy_event, opts)
94
88
  end
95
89
 
96
- def opts_have_valid_event?(opts)
97
- opts[:event].present? && opts[:event].is_a?(OmniEvent::EventHash) && opts[:event].valid?
90
+ def opts_has_event?(opts)
91
+ opts[:event]&.is_a?(OmniEvent::EventHash)
98
92
  end
99
93
 
100
94
  def strategy_instance(provider)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnievent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre4
4
+ version: 0.1.0.pre6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angus McLeod
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-03 00:00:00.000000000 Z
11
+ date: 2024-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport