icalia-sdk-event-core 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +7 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +6 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +43 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/icalia-sdk-event-core.gemspec +46 -0
  13. data/lib/icalia-sdk-event-core/serialization/deserializable_cloud_identity.rb +22 -0
  14. data/lib/icalia-sdk-event-core/serialization/deserializable_code_check_run.rb +39 -0
  15. data/lib/icalia-sdk-event-core/serialization/deserializable_code_check_run_event.rb +20 -0
  16. data/lib/icalia-sdk-event-core/serialization/deserializable_code_check_suite.rb +21 -0
  17. data/lib/icalia-sdk-event-core/serialization/deserializable_code_issue.rb +39 -0
  18. data/lib/icalia-sdk-event-core/serialization/deserializable_code_issue_occurrence.rb +16 -0
  19. data/lib/icalia-sdk-event-core/serialization/deserializable_code_repository.rb +15 -0
  20. data/lib/icalia-sdk-event-core/serialization/deserializable_code_repository_event.rb +42 -0
  21. data/lib/icalia-sdk-event-core/serialization/deserializable_membership_event.rb +21 -0
  22. data/lib/icalia-sdk-event-core/serialization/deserializable_oauth_access_token_event.rb +17 -0
  23. data/lib/icalia-sdk-event-core/serialization/deserializable_organization.rb +15 -0
  24. data/lib/icalia-sdk-event-core/serialization/deserializable_organization_event.rb +17 -0
  25. data/lib/icalia-sdk-event-core/serialization/deserializable_property_resource.rb +13 -0
  26. data/lib/icalia-sdk-event-core/serialization/deserializable_resource_action.rb +11 -0
  27. data/lib/icalia-sdk-event-core/serialization/deserializable_resource_creation_timestamp.rb +11 -0
  28. data/lib/icalia-sdk-event-core/serialization/deserializable_resource_identity.rb +20 -0
  29. data/lib/icalia-sdk-event-core/serialization/deserializable_resource_timestamps.rb +12 -0
  30. data/lib/icalia-sdk-event-core/serialization/deserializable_user.rb +14 -0
  31. data/lib/icalia-sdk-event-core/serialization.rb +51 -0
  32. data/lib/icalia-sdk-event-core/version.rb +7 -0
  33. data/lib/icalia-sdk-event-core.rb +8 -0
  34. metadata +136 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8e6f9df03e4ce21111fc46031e820da6f77d97bb8d5e38cfea15af561274cf3f
4
+ data.tar.gz: 26691c4dfd26837b959a3408c2ad35b370f460d58e3bce9f00e126583744df09
5
+ SHA512:
6
+ metadata.gz: 7d2f06fb8bd57d48018e660f6e3508beedd9cde3b45285993468a05804f495335424e5b45f4e6bff90010d359616a31705b81ff8463480481413b6fdba9f4c41
7
+ data.tar.gz: c6099bac783fdad6a15c56987fae7db132c1fde05b887db37b2ece9a9071170193f03d1b64b4ff6ce9cd13f403307a1d62fa71af8d5b9e82e03f3efc07911d11
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 1.17.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at TODO: Write your email address. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in icalia-sdk-event-core.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Icalia::Sdk::Events::Core
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/icalia/sdk/events/core`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'icalia-sdk-event-core'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install icalia-sdk-event-core
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/icalia-sdk-event-core. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Icalia::Sdk::Events::Core project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/icalia-sdk-event-core/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "icalia/sdk/events/core"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'icalia-sdk-event-core/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'icalia-sdk-event-core'
9
+ spec.version = Icalia::Event::CORE_VERSION
10
+ spec.authors = ['Roberto Quintanilla']
11
+ spec.email = %w[vov@icalialabs.com]
12
+
13
+ spec.summary = 'Icalia SDK for Ruby - Events Core Library'
14
+ spec.description = 'Official Icalia SDK for Icalia Events Core' \
15
+ 'This gem is part of the Icalia SDK for Ruby.'
16
+ spec.homepage = 'https://github.com/IcaliaLabs/icalia-sdk-ruby'
17
+ spec.license = 'MIT'
18
+
19
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
21
+ if spec.respond_to?(:metadata)
22
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
23
+
24
+ spec.metadata['homepage_uri'] = spec.homepage
25
+ spec.metadata['source_code_uri'] = 'https://github.com/IcaliaLabs/icalia-sdk-ruby'
26
+ spec.metadata['changelog_uri'] = 'https://github.com/IcaliaLabs/icalia-sdk-ruby'
27
+ else
28
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
29
+ 'public gem pushes.'
30
+ end
31
+
32
+ # Specify which files should be added to the gem when it is released.
33
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
34
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
35
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
36
+ end
37
+ spec.bindir = 'exe'
38
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
39
+ spec.require_paths = %w[lib]
40
+
41
+ spec.add_dependency 'jsonapi-deserializable', '~> 0.2.0'
42
+
43
+ spec.add_development_dependency 'bundler', '~> 1.17'
44
+ spec.add_development_dependency 'rake', '~> 10.0'
45
+ spec.add_development_dependency 'rspec', '~> 3.0'
46
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia::Event
4
+ #= DeserializableCloudIdentity
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia Event's `User` object
8
+ class DeserializableCloudIdentity < JSONAPI::Deserializable::Resource
9
+ include DeserializableResourceTimestamps
10
+
11
+ attributes :name, :provider
12
+
13
+ attribute(:'identity-type') { |value| Hash[type: value] }
14
+ attribute(:'id-at-provider') { |value| Hash[uid: value.to_s] }
15
+
16
+ has_one :'directory-entry' do |_rel, id, type|
17
+ next Hash[] if type.blank?
18
+
19
+ Hash["#{type}_id".to_sym => id]
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,39 @@
1
+ module Icalia::Event
2
+ #= DeserializableCheckRun
3
+ #
4
+ # This class is responsible for converting a JSONAPI.org representation
5
+ # of an Icalia Event's `CheckRun` object
6
+ class DeserializableCheckRun < JSONAPI::Deserializable::Resource
7
+ include DeserializableResourceTimestamps
8
+
9
+ id { |value| Hash[unique_id: value] }
10
+
11
+ attributes :name
12
+
13
+ attribute(:branch) { |value| Hash[head_branch: value] }
14
+ attribute(:'commit-sha') { |value| Hash[head_sha: value] }
15
+
16
+ attribute :status do |value|
17
+ case value
18
+ when 'started' then Hash[status: 'in_progress']
19
+ when 'finished', 'failed', 'cancelled' then Hash[status: 'completed']
20
+ else Hash[status: 'queued']
21
+ end
22
+ end
23
+
24
+ attributes :conclusion, :output
25
+
26
+ attribute(:'created-at') { |value| Hash[created_at: value] }
27
+ attribute(:'started-at') { |value| Hash[started_at: value] }
28
+ attribute(:'updated-at') { |value| Hash[updated_at: value] }
29
+ attribute(:'completed-at') { |value| Hash[completed_at: value] }
30
+
31
+ has_one :'code-repository' do |_rel, id, _type|
32
+ Hash[tracked_repo_unique_id: id]
33
+ end
34
+
35
+ has_one :'check-suite' do |_rel, id, _type|
36
+ Hash[check_suite_id: CheckSuite.where(unique_id: id).pluck(:id).last]
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,20 @@
1
+ module Icalia::Event
2
+ #= DeserializableCodeCheckRunEvent
3
+ #
4
+ # This class is responsible for converting a JSONAPI.org representation
5
+ # of an Icalia Event's `CodeCheckRunEvent` object
6
+ class DeserializableCodeCheckRunEvent < JSONAPI::Deserializable::Resource
7
+ include DeserializableResourceAction
8
+ include DeserializableResourceCreationTimestamp
9
+
10
+ id { |value| Hash[unique_id: value] }
11
+
12
+ has_one :'check-run' do |_rel, id, type|
13
+ Hash[check_run: id]
14
+ end
15
+
16
+ has_one :'check-suite' do |_rel, id, _type|
17
+ Hash[check_suite_id: CheckSuite.where(unique_id: id).pluck(:id).last]
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ module Icalia::Event
2
+ #= DeserializableCodeCheckRunEvent
3
+ #
4
+ # This class is responsible for converting a JSONAPI.org representation
5
+ # of an Icalia Event's `CodeCheckRunEvent` object
6
+ class DeserializableCodeCheckRunEvent < JSONAPI::Deserializable::Resource
7
+ include DeserializableResourceIdentity
8
+ include DeserializableResourceAction
9
+ include DeserializableResourceCreationTimestamp
10
+
11
+ id { |value| Hash[unique_id: value] }
12
+
13
+ has_one :'check-run' do |_rel, id, type|
14
+ Hash[check_run: id]
15
+ end
16
+
17
+ has_one :'check-suite' do |_rel, id, _type|
18
+ Hash[check_suite_id: CheckSuite.where(unique_id: id).pluck(:id).last]
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia::Event
4
+ #= DeserializableCodeIssue
5
+ #
6
+ # Converts a JSONAPI.org serialization of a `CodeIssue` object from a
7
+ # Notification topic into an `ActionController::Parameters` object that can be
8
+ # used to create or update code issue data
9
+ class DeserializableCodeIssue < JSONAPI::Deserializable::Resource
10
+ include DeserializableResourceIdentity
11
+
12
+ LOCATION_DATA_KEYS = %w[path start-line end-line]
13
+
14
+ def self.deserialize_location_data(location_data)
15
+ location_data
16
+ .slice(*LOCATION_DATA_KEYS)
17
+ .transform_keys { |key| key.underscore.to_sym }
18
+ end
19
+
20
+ attribute(:path) { |value| Hash[filename: value] }
21
+
22
+ attribute :location do |value|
23
+ Hash[location: deserialize_location_data(value)]
24
+ end
25
+
26
+ attribute :'other-locations' do |value|
27
+ other_locations_data = (value || [])
28
+ .map { |data| deserialize_location_data data }
29
+
30
+ Hash[other_locations: other_locations_data]
31
+ end
32
+
33
+ attribute(:content) { |value| Hash[content: value] }
34
+ attribute(:description) { |value| Hash[message: value] }
35
+
36
+ attribute(:'check-name') { |value| Hash[check_name: value] }
37
+ attribute(:'engine-name') { |value| Hash[engine_name: value] }
38
+ end
39
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia::Event
4
+ #= DeserializableCodeIssueOccurrence
5
+ #
6
+ # Converts a JSONAPI.org serialization of a `CodeIssueOcurrence` object
7
+ # notification into an `ActionController::Parameters` object that can be used
8
+ # to create or update repo data
9
+ class DeserializableCodeIssueOccurrence < JSONAPI::Deserializable::Resource
10
+ include DeserializableResourceIdentity
11
+
12
+ has_one(:'check-run') { |_rel, id, _type| Hash[check_run_unique_id: id] }
13
+
14
+ has_one(:issue) { |_rel, id, _type| Hash[code_issue_id: id] }
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia::Event
4
+ #= DeserializableCodeRepository
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia Event's `CodeRepository` object
8
+ class DeserializableCodeRepository < JSONAPI::Deserializable::Resource
9
+ include DeserializableResourceIdentity # id and type
10
+ include DeserializablePropertyResource # has one owner
11
+ include DeserializableResourceCreationTimestamp
12
+
13
+ attributes :name, :private, :fork, :'default-branch'
14
+ end
15
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia::Event
4
+ #= DeserializableCodeRepositoryEvent
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia Event's `CodeRepositoryEvent` object that can be used to create or
8
+ # update a code-repository data
9
+ class DeserializableCodeRepositoryEvent < JSONAPI::Deserializable::Resource
10
+ include DeserializableResourceIdentity
11
+ include DeserializableResourceAction
12
+ include DeserializableResourceCreationTimestamp
13
+
14
+ attributes :name
15
+
16
+ attribute(:branch) { |value| Hash[head_branch: value] }
17
+ attribute(:'commit-sha') { |value| Hash[head_sha: value] }
18
+
19
+ attribute :status do |value|
20
+ case value
21
+ when 'started' then Hash[status: 'in_progress']
22
+ when 'finished', 'failed', 'cancelled' then Hash[status: 'completed']
23
+ else Hash[status: 'queued']
24
+ end
25
+ end
26
+
27
+ attributes :conclusion, :output
28
+
29
+ attribute(:'created-at') { |value| Hash[created_at: value] }
30
+ attribute(:'started-at') { |value| Hash[started_at: value] }
31
+ attribute(:'updated-at') { |value| Hash[updated_at: value] }
32
+ attribute(:'completed-at') { |value| Hash[completed_at: value] }
33
+
34
+ has_one :'code-repository' do |_rel, id, _type|
35
+ Hash[tracked_repo_unique_id: id]
36
+ end
37
+
38
+ has_one :'check-suite' do |_rel, id, _type|
39
+ Hash[check_suite_id: CheckSuite.where(unique_id: id).pluck(:id).last]
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia::Event
4
+ #= DeserializableMembershipEvent
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia Event's `MembershipEvent` object
8
+ class DeserializableMembershipEvent < JSONAPI::Deserializable::Resource
9
+ include DeserializableResourceIdentity
10
+ include DeserializableResourceAction
11
+ include DeserializableResourceCreationTimestamp
12
+
13
+ has_one :member do |_rel, id, type|
14
+ Hash[member_id: id, member_type: classify_type(type)]
15
+ end
16
+
17
+ has_one :organization do |_rel, id, type|
18
+ Hash[organization_id: id, organization_type: classify_type(type)]
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia::Event
4
+ #= DeserializableIcaliaAccessTokenEvent
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia OAuth Access Token event
8
+ class DeserializableOAuthAccessTokenEvent < JSONAPI::Deserializable::Resource
9
+ include DeserializableResourceIdentity
10
+ include DeserializableResourceAction
11
+ include DeserializableResourceCreationTimestamp
12
+
13
+ has_one :token do |_rel, id, type|
14
+ Hash[token_id: id, token_type: classify_type(type)]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia::Event
4
+ #= DeserializableOrganization
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia Event's `Organization` object
8
+ class DeserializableOrganization < JSONAPI::Deserializable::Resource
9
+ include DeserializableResourceIdentity # id and type
10
+ include DeserializablePropertyResource # has one owner
11
+ include DeserializableResourceTimestamps # created_at and updated_at
12
+
13
+ attributes :name, :email
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia::Event
4
+ #= DeserializableOrganizationEvent
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia Event's `OrganizationEvent` object
8
+ class DeserializableOrganizationEvent < JSONAPI::Deserializable::Resource
9
+ include DeserializableResourceIdentity
10
+ include DeserializableResourceAction
11
+ include DeserializableResourceCreationTimestamp
12
+
13
+ has_one :organization do |_rel, id, type|
14
+ Hash[organization_id: id, organization_type: classify_type(type)]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia::Event
4
+ module DeserializablePropertyResource
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ has_one :owner do |_rel, id, type|
9
+ Hash[owner_id: id, owner_type: classify_type(type)]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia::Event
4
+ module DeserializableResourceAction
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ attribute(:action) { |value| Hash[action: value] }
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia::Event
4
+ module DeserializableResourceCreationTimestamp
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ attribute(:'created-at') { |value| Hash[updated_at: value] }
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia::Event
4
+ module DeserializableResourceIdentity
5
+ extend ActiveSupport::Concern
6
+
7
+ delegate :classify_type, to: :class
8
+
9
+ included do
10
+ id { |value| Hash[id: value] }
11
+ type { |value| Hash[type: classify_type(value)] }
12
+ end
13
+
14
+ module ClassMethods
15
+ def classify_type(type)
16
+ type.underscore.camelize
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia::Event
4
+ module DeserializableResourceTimestamps
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ include DeserializableResourceCreationTimestamp
9
+ attribute(:'updated-at') { |value| Hash[updated_at: value] }
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia::Event
4
+ #= DeserializableUser
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia Event's `User` object
8
+ class DeserializableUser < JSONAPI::Deserializable::Resource
9
+ include DeserializableResourceIdentity
10
+ include DeserializableResourceTimestamps
11
+
12
+ attributes :email
13
+ end
14
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ module Event
5
+ serialization_path = 'icalia-sdk-event-core/serialization'
6
+
7
+ # Deserialization Modules:
8
+ autoload :DeserializableResourceIdentity,
9
+ "#{serialization_path}/deserializable_resource_identity"
10
+
11
+ autoload :DeserializableResourceAction,
12
+ "#{serialization_path}/deserializable_resource_action"
13
+
14
+ autoload :DeserializableResourceCreationTimestamp,
15
+ "#{serialization_path}/deserializable_resource_creation_timestamp"
16
+
17
+ autoload :DeserializableResourceTimestamps,
18
+ "#{serialization_path}/deserializable_resource_timestamps"
19
+
20
+ autoload :DeserializablePropertyResource,
21
+ "#{serialization_path}/deserializable_property_resource"
22
+
23
+ # Deserializable Events
24
+
25
+ autoload :DeserializableMembershipEvent,
26
+ "#{serialization_path}/deserializable_membership_event"
27
+
28
+ autoload :DeserializableOrganizationEvent,
29
+ "#{serialization_path}/deserializable_organization_event"
30
+
31
+ autoload :DeserializableOAuthAccessTokenEvent,
32
+ "#{serialization_path}/deserializable_oauth_access_token_event"
33
+
34
+ # Deserializable Objects
35
+
36
+ autoload :DeserializableUser,
37
+ "#{serialization_path}/deserializable_user"
38
+
39
+ autoload :DeserializableOrganization,
40
+ "#{serialization_path}/deserializable_organization"
41
+
42
+ autoload :DeserializableCodeRepositoryEvent,
43
+ "#{serialization_path}/deserializable_code_repository_event"
44
+
45
+ autoload :DeserializableCodeRepository,
46
+ "#{serialization_path}/deserializable_code_repository"
47
+
48
+ autoload :DeserializableCloudIdentity,
49
+ "#{serialization_path}/deserializable_cloud_identity"
50
+ end
51
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ module Event
5
+ CORE_VERSION = '0.1.0'
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'icalia-sdk-event-core/version'
4
+ require 'icalia-sdk-event-core/serialization'
5
+
6
+ module Icalia::Event
7
+ class Error < StandardError; end
8
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: icalia-sdk-event-core
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Roberto Quintanilla
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-08-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jsonapi-deserializable
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.17'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.17'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: Official Icalia SDK for Icalia Events CoreThis gem is part of the Icalia
70
+ SDK for Ruby.
71
+ email:
72
+ - vov@icalialabs.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - CODE_OF_CONDUCT.md
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/setup
87
+ - icalia-sdk-event-core.gemspec
88
+ - lib/icalia-sdk-event-core.rb
89
+ - lib/icalia-sdk-event-core/serialization.rb
90
+ - lib/icalia-sdk-event-core/serialization/deserializable_cloud_identity.rb
91
+ - lib/icalia-sdk-event-core/serialization/deserializable_code_check_run.rb
92
+ - lib/icalia-sdk-event-core/serialization/deserializable_code_check_run_event.rb
93
+ - lib/icalia-sdk-event-core/serialization/deserializable_code_check_suite.rb
94
+ - lib/icalia-sdk-event-core/serialization/deserializable_code_issue.rb
95
+ - lib/icalia-sdk-event-core/serialization/deserializable_code_issue_occurrence.rb
96
+ - lib/icalia-sdk-event-core/serialization/deserializable_code_repository.rb
97
+ - lib/icalia-sdk-event-core/serialization/deserializable_code_repository_event.rb
98
+ - lib/icalia-sdk-event-core/serialization/deserializable_membership_event.rb
99
+ - lib/icalia-sdk-event-core/serialization/deserializable_oauth_access_token_event.rb
100
+ - lib/icalia-sdk-event-core/serialization/deserializable_organization.rb
101
+ - lib/icalia-sdk-event-core/serialization/deserializable_organization_event.rb
102
+ - lib/icalia-sdk-event-core/serialization/deserializable_property_resource.rb
103
+ - lib/icalia-sdk-event-core/serialization/deserializable_resource_action.rb
104
+ - lib/icalia-sdk-event-core/serialization/deserializable_resource_creation_timestamp.rb
105
+ - lib/icalia-sdk-event-core/serialization/deserializable_resource_identity.rb
106
+ - lib/icalia-sdk-event-core/serialization/deserializable_resource_timestamps.rb
107
+ - lib/icalia-sdk-event-core/serialization/deserializable_user.rb
108
+ - lib/icalia-sdk-event-core/version.rb
109
+ homepage: https://github.com/IcaliaLabs/icalia-sdk-ruby
110
+ licenses:
111
+ - MIT
112
+ metadata:
113
+ allowed_push_host: https://rubygems.org
114
+ homepage_uri: https://github.com/IcaliaLabs/icalia-sdk-ruby
115
+ source_code_uri: https://github.com/IcaliaLabs/icalia-sdk-ruby
116
+ changelog_uri: https://github.com/IcaliaLabs/icalia-sdk-ruby
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubygems_version: 3.0.3
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: Icalia SDK for Ruby - Events Core Library
136
+ test_files: []