webhook_system 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8cf0345d592bd7eddd4df0589e308f442300f2e
4
- data.tar.gz: e45bc8b040f4e262dcc29ebff36283975cdf658b
3
+ metadata.gz: 845cc8863c319a2a78ff235cbb41256a9bdbe850
4
+ data.tar.gz: afa19be64345c961c0989c09d09fc80341200ab4
5
5
  SHA512:
6
- metadata.gz: 2f73f386866cb8dacc605cebc14cd9bf2fa667b451a502eabf72cdef52cf7dfaa4b0e4c28787f5f1f9dc7a584046feb29a95baeb39c60eb343e4a0a99fc88a7a
7
- data.tar.gz: bebab60ba8f6780a73aa93c8090acdd3e67ce7b416ab2c2634c249d61d0080010629b7b936a83d0a01e7390e400ba0166ab8a134030f033befbf532b39a13076
6
+ metadata.gz: 0285d5a6e08624c92cdddf4eceed759c55f2839c139d922c09c8d82302114b0dcfba8416dae5ea5cb965ca8bdcc971c323087397ddae26b309217c9c1fb11820
7
+ data.tar.gz: de888a90628e3987dc5f4b0416d7eef83e8afc6f1972135c6545ecd8839f4cacb570ef4f1d73900cadc3cd808a10329c6b43c0adb60bd805278942d858b0e3a6
data/.rubocop.yml CHANGED
@@ -45,6 +45,8 @@ Style/CollectionMethods:
45
45
  Metrics/LineLength:
46
46
  Max: 120
47
47
  AllowURI: true
48
+ Exclude:
49
+ - spec/**/*
48
50
 
49
51
  # Align with the style guide, we don't prefer anything
50
52
  Style/CollectionMethods:
data/CHANGELOG.md CHANGED
@@ -0,0 +1,13 @@
1
+ # Change Log
2
+
3
+ ## [v0.1.0](https://github.com/payrollhero/webhook_system/tree/v0.1.0) (2016-02-05)
4
+ [Full Changelog](https://github.com/payrollhero/webhook_system/compare/v0.0.1...v0.1.0)
5
+
6
+ - Add easy topic mass assignment and url validation [\#2](https://github.com/payrollhero/webhook_system/pull/2) ([piotrb](https://github.com/piotrb))
7
+
8
+ ## [v0.0.1](https://github.com/payrollhero/webhook_system/tree/v0.0.1) (2016-02-05)
9
+ - Initial implementation of the webhook system [\#1](https://github.com/payrollhero/webhook_system/pull/1) ([piotrb](https://github.com/piotrb))
10
+
11
+
12
+
13
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/Rakefile CHANGED
@@ -42,5 +42,5 @@ end
42
42
 
43
43
  desc "Updates the changelog"
44
44
  task :changelog do
45
- sh "github_changelog_generator payrollhero/ph_utility --simple-list"
45
+ sh "github_changelog_generator payrollhero/webhook_system --simple-list"
46
46
  end
@@ -17,21 +17,33 @@ module WebhookSystem
17
17
  def as_json
18
18
  result = { 'event' => event_name }
19
19
  each_attribute do |attribute_name, attribute_method|
20
+ validate_attribute_name attribute_name
20
21
  result[attribute_name.to_s] = public_send(attribute_method).as_json
21
22
  end
22
- result
23
+ result.deep_stringify_keys
24
+ end
25
+
26
+ def self.key_is_reserved?(key)
27
+ key.to_s.in? %w(event)
23
28
  end
24
29
 
25
30
  private
26
31
 
27
- def each_attribute
32
+ def validate_attribute_name(key)
33
+ if self.class.key_is_reserved?(key)
34
+ message = "#{self.class.name} should not be defining an attribute named #{key} since its reserved"
35
+ raise ArgumentError, message
36
+ end
37
+ end
38
+
39
+ def each_attribute(&block)
28
40
  case payload_attributes
29
41
  when Array
30
42
  payload_attributes.each do |attribute_name|
31
43
  yield(attribute_name, attribute_name)
32
44
  end
33
45
  when Hash
34
- payload_attributes.each
46
+ payload_attributes.each(&block)
35
47
  else
36
48
  raise ArgumetError, "don't know how to deal with payload_attributes: #{payload_attributes.inspect}"
37
49
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module WebhookSystem
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.1.1'.freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webhook_system
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Banasik