slack_resources 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +66 -1
- data/.rubocop.yml +10 -2
- data/Gemfile +0 -1
- data/Gemfile.lock +7 -7
- data/lib/generate_event_api_resources.rb +8 -0
- data/lib/slack_resources.rb +9 -1
- data/lib/slack_resources/generator/event_api/examples_preparation.rb +71 -0
- data/lib/{event_api → slack_resources/generator/event_api}/fetch.rb +0 -0
- data/lib/slack_resources/generator/event_api/strong_hash.rb +25 -0
- data/lib/slack_resources/generator/event_api/to_schema.rb +200 -0
- data/lib/slack_resources/generator/event_api/type_detection.rb +272 -0
- data/lib/slack_resources/generator/event_api/write.rb +123 -0
- data/lib/slack_resources/raw_data/event_api/_added_examples/emoji_changed.add.json +7 -0
- data/lib/slack_resources/raw_data/event_api/_added_examples/emoji_changed.remove.json +6 -0
- data/lib/slack_resources/{resources → raw_data}/event_api/_added_examples/event_callback.json +0 -0
- data/lib/slack_resources/raw_data/event_api/examples/app_mention.json +8 -0
- data/lib/slack_resources/raw_data/event_api/examples/app_rate_limited.json +7 -0
- data/lib/slack_resources/raw_data/event_api/examples/app_uninstalled.json +11 -0
- data/lib/slack_resources/raw_data/event_api/examples/channel_archive.json +5 -0
- data/lib/slack_resources/raw_data/event_api/examples/channel_created.json +9 -0
- data/lib/slack_resources/raw_data/event_api/examples/channel_deleted.json +4 -0
- data/lib/slack_resources/raw_data/event_api/examples/channel_history_changed.json +6 -0
- data/lib/slack_resources/raw_data/event_api/examples/channel_left.json +4 -0
- data/lib/slack_resources/raw_data/event_api/examples/channel_rename.json +8 -0
- data/lib/slack_resources/raw_data/event_api/examples/channel_unarchive.json +5 -0
- data/lib/slack_resources/raw_data/event_api/examples/dnd_updated.json +11 -0
- data/lib/slack_resources/raw_data/event_api/examples/dnd_updated_user.json +9 -0
- data/lib/slack_resources/raw_data/event_api/examples/email_domain_changed.json +5 -0
- data/lib/slack_resources/raw_data/event_api/examples/emoji_changed.json +8 -0
- data/lib/slack_resources/raw_data/event_api/examples/file_change.json +7 -0
- data/lib/slack_resources/raw_data/event_api/examples/file_comment_added.json +9 -0
- data/lib/slack_resources/raw_data/event_api/examples/file_comment_deleted.json +8 -0
- data/lib/slack_resources/raw_data/event_api/examples/file_comment_edited.json +9 -0
- data/lib/slack_resources/raw_data/event_api/examples/file_created.json +7 -0
- data/lib/slack_resources/raw_data/event_api/examples/file_deleted.json +5 -0
- data/lib/slack_resources/raw_data/event_api/examples/file_public.json +7 -0
- data/lib/slack_resources/raw_data/event_api/examples/file_shared.json +7 -0
- data/lib/slack_resources/raw_data/event_api/examples/file_unshared.json +7 -0
- data/lib/slack_resources/raw_data/event_api/examples/grid_migration_finished.json +12 -0
- data/lib/slack_resources/raw_data/event_api/examples/grid_migration_started.json +12 -0
- data/lib/slack_resources/raw_data/event_api/examples/group_archive.json +4 -0
- data/lib/slack_resources/raw_data/event_api/examples/group_close.json +5 -0
- data/lib/slack_resources/raw_data/event_api/examples/group_deleted.json +4 -0
- data/lib/slack_resources/raw_data/event_api/examples/group_history_changed.json +6 -0
- data/lib/slack_resources/raw_data/event_api/examples/group_left.json +4 -0
- data/lib/slack_resources/raw_data/event_api/examples/group_open.json +5 -0
- data/lib/slack_resources/raw_data/event_api/examples/group_rename.json +8 -0
- data/lib/slack_resources/raw_data/event_api/examples/group_unarchive.json +4 -0
- data/lib/slack_resources/raw_data/event_api/examples/im_close.json +5 -0
- data/lib/slack_resources/raw_data/event_api/examples/im_created.json +6 -0
- data/lib/slack_resources/raw_data/event_api/examples/im_history_changed.json +6 -0
- data/lib/slack_resources/raw_data/event_api/examples/im_open.json +5 -0
- data/lib/slack_resources/raw_data/event_api/examples/link_shared.json +33 -0
- data/lib/slack_resources/raw_data/event_api/examples/member_joined_channel.json +8 -0
- data/lib/slack_resources/raw_data/event_api/examples/member_left_channel.json +7 -0
- data/lib/slack_resources/raw_data/event_api/examples/message.app_home.json +20 -0
- data/lib/slack_resources/raw_data/event_api/examples/message.channels.json +20 -0
- data/lib/slack_resources/raw_data/event_api/examples/message.groups.json +20 -0
- data/lib/slack_resources/raw_data/event_api/examples/message.im.json +20 -0
- data/lib/slack_resources/raw_data/event_api/examples/message.json +7 -0
- data/lib/slack_resources/raw_data/event_api/examples/message.mpim.json +20 -0
- data/lib/slack_resources/raw_data/event_api/examples/pin_added.json +8 -0
- data/lib/slack_resources/raw_data/event_api/examples/pin_removed.json +9 -0
- data/lib/slack_resources/raw_data/event_api/examples/reaction_added.json +12 -0
- data/lib/slack_resources/raw_data/event_api/examples/reaction_removed.json +12 -0
- data/lib/slack_resources/raw_data/event_api/examples/resources_added.json +31 -0
- data/lib/slack_resources/raw_data/event_api/examples/resources_removed.json +31 -0
- data/lib/slack_resources/raw_data/event_api/examples/scope_denied.json +20 -0
- data/lib/slack_resources/raw_data/event_api/examples/scope_granted.json +20 -0
- data/lib/slack_resources/raw_data/event_api/examples/star_added.json +7 -0
- data/lib/slack_resources/raw_data/event_api/examples/star_removed.json +7 -0
- data/lib/slack_resources/raw_data/event_api/examples/subteam_created.json +28 -0
- data/lib/slack_resources/raw_data/event_api/examples/subteam_members_changed.json +17 -0
- data/lib/slack_resources/raw_data/event_api/examples/subteam_self_added.json +4 -0
- data/lib/slack_resources/raw_data/event_api/examples/subteam_self_removed.json +4 -0
- data/lib/slack_resources/raw_data/event_api/examples/subteam_updated.json +34 -0
- data/lib/slack_resources/raw_data/event_api/examples/team_domain_change.json +5 -0
- data/lib/slack_resources/raw_data/event_api/examples/team_join.json +5 -0
- data/lib/slack_resources/raw_data/event_api/examples/team_rename.json +4 -0
- data/lib/slack_resources/raw_data/event_api/examples/tokens_revoked.json +19 -0
- data/lib/slack_resources/raw_data/event_api/examples/url_verification.json +5 -0
- data/lib/slack_resources/raw_data/event_api/examples/user_change.json +5 -0
- data/lib/slack_resources/raw_data/event_api/examples/user_resource_denied.json +20 -0
- data/lib/slack_resources/raw_data/event_api/examples/user_resource_granted.json +20 -0
- data/lib/slack_resources/raw_data/event_api/examples/user_resource_removed.json +16 -0
- data/lib/slack_resources/{resources → raw_data}/event_api/meta.json +0 -72
- data/lib/{schema.json → slack_resources/raw_data/event_api/preset_schemas.json} +7 -0
- data/lib/slack_resources/resources/event_api.rb +38 -0
- data/lib/slack_resources/resources/event_api/details/app_mention.json +67 -46
- data/lib/slack_resources/resources/event_api/details/app_rate_limited.json +59 -41
- data/lib/slack_resources/resources/event_api/details/app_uninstalled.json +22 -16
- data/lib/slack_resources/resources/event_api/details/channel_archive.json +42 -30
- data/lib/slack_resources/resources/event_api/details/channel_created.json +63 -54
- data/lib/slack_resources/resources/event_api/details/channel_deleted.json +32 -23
- data/lib/slack_resources/resources/event_api/details/channel_history_changed.json +48 -33
- data/lib/slack_resources/resources/event_api/details/channel_left.json +32 -23
- data/lib/slack_resources/resources/event_api/details/channel_rename.json +58 -49
- data/lib/slack_resources/resources/event_api/details/channel_unarchive.json +42 -30
- data/lib/slack_resources/resources/event_api/details/dnd_updated.json +66 -54
- data/lib/slack_resources/resources/event_api/details/dnd_updated_user.json +62 -50
- data/lib/slack_resources/resources/event_api/details/email_domain_changed.json +39 -27
- data/lib/slack_resources/resources/event_api/details/emoji_changed.add.json +78 -0
- data/lib/slack_resources/resources/event_api/details/emoji_changed.json +85 -44
- data/lib/slack_resources/resources/event_api/details/emoji_changed.remove.json +77 -0
- data/lib/slack_resources/resources/event_api/details/event_callback.json +102 -72
- data/lib/slack_resources/resources/event_api/details/file_change.json +49 -37
- data/lib/slack_resources/resources/event_api/details/file_comment_added.json +61 -46
- data/lib/slack_resources/resources/event_api/details/file_comment_deleted.json +59 -44
- data/lib/slack_resources/resources/event_api/details/file_comment_edited.json +61 -46
- data/lib/slack_resources/resources/event_api/details/file_created.json +49 -37
- data/lib/slack_resources/resources/event_api/details/file_deleted.json +41 -29
- data/lib/slack_resources/resources/event_api/details/file_public.json +49 -37
- data/lib/slack_resources/resources/event_api/details/file_shared.json +49 -37
- data/lib/slack_resources/resources/event_api/details/file_unshared.json +49 -37
- data/lib/slack_resources/resources/event_api/details/grid_migration_finished.json +31 -22
- data/lib/slack_resources/resources/event_api/details/grid_migration_started.json +31 -22
- data/lib/slack_resources/resources/event_api/details/group_archive.json +32 -23
- data/lib/slack_resources/resources/event_api/details/group_close.json +42 -30
- data/lib/slack_resources/resources/event_api/details/group_deleted.json +32 -23
- data/lib/slack_resources/resources/event_api/details/group_history_changed.json +48 -33
- data/lib/slack_resources/resources/event_api/details/group_left.json +32 -23
- data/lib/slack_resources/resources/event_api/details/group_open.json +42 -30
- data/lib/slack_resources/resources/event_api/details/group_rename.json +58 -49
- data/lib/slack_resources/resources/event_api/details/group_unarchive.json +32 -23
- data/lib/slack_resources/resources/event_api/details/im_close.json +42 -30
- data/lib/slack_resources/resources/event_api/details/im_created.json +53 -41
- data/lib/slack_resources/resources/event_api/details/im_history_changed.json +48 -33
- data/lib/slack_resources/resources/event_api/details/im_open.json +42 -30
- data/lib/slack_resources/resources/event_api/details/link_shared.json +107 -83
- data/lib/slack_resources/resources/event_api/details/member_joined_channel.json +66 -48
- data/lib/slack_resources/resources/event_api/details/member_left_channel.json +58 -43
- data/lib/slack_resources/resources/event_api/details/message.app_home.json +74 -53
- data/lib/slack_resources/resources/event_api/details/message.channels.json +74 -56
- data/lib/slack_resources/resources/event_api/details/message.groups.json +74 -56
- data/lib/slack_resources/resources/event_api/details/message.im.json +74 -56
- data/lib/slack_resources/resources/event_api/details/message.json +106 -60
- data/lib/slack_resources/resources/event_api/details/message.mpim.json +74 -56
- data/lib/slack_resources/resources/event_api/details/pin_added.json +65 -47
- data/lib/slack_resources/resources/event_api/details/pin_removed.json +73 -52
- data/lib/slack_resources/resources/event_api/details/reaction_added.json +94 -73
- data/lib/slack_resources/resources/event_api/details/reaction_removed.json +94 -73
- data/lib/slack_resources/resources/event_api/details/resources_added.json +127 -115
- data/lib/slack_resources/resources/event_api/details/resources_removed.json +127 -115
- data/lib/slack_resources/resources/event_api/details/scope_denied.json +74 -59
- data/lib/slack_resources/resources/event_api/details/scope_granted.json +74 -59
- data/lib/slack_resources/resources/event_api/details/star_added.json +56 -41
- data/lib/slack_resources/resources/event_api/details/star_removed.json +56 -41
- data/lib/slack_resources/resources/event_api/details/subteam_created.json +177 -168
- data/lib/slack_resources/resources/event_api/details/subteam_members_changed.json +118 -82
- data/lib/slack_resources/resources/event_api/details/subteam_self_added.json +31 -22
- data/lib/slack_resources/resources/event_api/details/subteam_self_removed.json +31 -22
- data/lib/slack_resources/resources/event_api/details/subteam_updated.json +189 -180
- data/lib/slack_resources/resources/event_api/details/team_domain_change.json +38 -26
- data/lib/slack_resources/resources/event_api/details/team_join.json +35 -26
- data/lib/slack_resources/resources/event_api/details/team_rename.json +32 -23
- data/lib/slack_resources/resources/event_api/details/tokens_revoked.json +58 -49
- data/lib/slack_resources/resources/event_api/details/url_verification.json +32 -26
- data/lib/slack_resources/resources/event_api/details/user_change.json +35 -26
- data/lib/slack_resources/resources/event_api/details/user_resource_denied.json +82 -64
- data/lib/slack_resources/resources/event_api/details/user_resource_granted.json +82 -64
- data/lib/slack_resources/resources/event_api/details/user_resource_removed.json +41 -29
- data/lib/slack_resources/resources/event_api/examples/app_mention.json +4 -4
- data/lib/slack_resources/resources/event_api/examples/app_rate_limited.json +4 -4
- data/lib/slack_resources/resources/event_api/examples/app_uninstalled.json +1 -9
- data/lib/slack_resources/resources/event_api/examples/channel_archive.json +1 -1
- data/lib/slack_resources/resources/event_api/examples/channel_created.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/channel_deleted.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/channel_history_changed.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/channel_left.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/channel_rename.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/channel_unarchive.json +1 -1
- data/lib/slack_resources/resources/event_api/examples/dnd_updated.json +3 -3
- data/lib/slack_resources/resources/event_api/examples/dnd_updated_user.json +3 -3
- data/lib/slack_resources/resources/event_api/examples/email_domain_changed.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/emoji_changed.add.json +7 -0
- data/lib/slack_resources/resources/event_api/examples/emoji_changed.json +4 -5
- data/lib/slack_resources/resources/event_api/examples/emoji_changed.remove.json +8 -0
- data/lib/slack_resources/resources/event_api/examples/event_callback.json +7 -6
- data/lib/slack_resources/resources/event_api/examples/file_change.json +3 -3
- data/lib/slack_resources/resources/event_api/examples/file_comment_added.json +3 -3
- data/lib/slack_resources/resources/event_api/examples/file_comment_deleted.json +3 -3
- data/lib/slack_resources/resources/event_api/examples/file_comment_edited.json +3 -3
- data/lib/slack_resources/resources/event_api/examples/file_created.json +3 -3
- data/lib/slack_resources/resources/event_api/examples/file_deleted.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/file_public.json +3 -3
- data/lib/slack_resources/resources/event_api/examples/file_shared.json +3 -3
- data/lib/slack_resources/resources/event_api/examples/file_unshared.json +3 -3
- data/lib/slack_resources/resources/event_api/examples/grid_migration_finished.json +2 -10
- data/lib/slack_resources/resources/event_api/examples/grid_migration_started.json +2 -10
- data/lib/slack_resources/resources/event_api/examples/group_archive.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/group_close.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/group_deleted.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/group_history_changed.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/group_left.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/group_open.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/group_rename.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/group_unarchive.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/im_close.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/im_created.json +3 -3
- data/lib/slack_resources/resources/event_api/examples/im_history_changed.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/im_open.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/link_shared.json +18 -30
- data/lib/slack_resources/resources/event_api/examples/member_joined_channel.json +3 -3
- data/lib/slack_resources/resources/event_api/examples/member_left_channel.json +3 -3
- data/lib/slack_resources/resources/event_api/examples/message.app_home.json +7 -18
- data/lib/slack_resources/resources/event_api/examples/message.channels.json +7 -18
- data/lib/slack_resources/resources/event_api/examples/message.groups.json +7 -18
- data/lib/slack_resources/resources/event_api/examples/message.im.json +7 -18
- data/lib/slack_resources/resources/event_api/examples/message.json +6 -4
- data/lib/slack_resources/resources/event_api/examples/message.mpim.json +7 -18
- data/lib/slack_resources/resources/event_api/examples/pin_added.json +3 -3
- data/lib/slack_resources/resources/event_api/examples/pin_removed.json +4 -4
- data/lib/slack_resources/resources/event_api/examples/reaction_added.json +5 -5
- data/lib/slack_resources/resources/event_api/examples/reaction_removed.json +5 -5
- data/lib/slack_resources/resources/event_api/examples/resources_added.json +17 -28
- data/lib/slack_resources/resources/event_api/examples/resources_removed.json +17 -28
- data/lib/slack_resources/resources/event_api/examples/scope_denied.json +6 -17
- data/lib/slack_resources/resources/event_api/examples/scope_granted.json +6 -17
- data/lib/slack_resources/resources/event_api/examples/star_added.json +3 -3
- data/lib/slack_resources/resources/event_api/examples/star_removed.json +3 -3
- data/lib/slack_resources/resources/event_api/examples/subteam_created.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/subteam_members_changed.json +6 -6
- data/lib/slack_resources/resources/event_api/examples/subteam_self_added.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/subteam_self_removed.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/subteam_updated.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/team_domain_change.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/team_rename.json +2 -2
- data/lib/slack_resources/resources/event_api/examples/tokens_revoked.json +8 -16
- data/lib/slack_resources/resources/event_api/examples/url_verification.json +1 -1
- data/lib/slack_resources/resources/event_api/examples/user_resource_denied.json +6 -17
- data/lib/slack_resources/resources/event_api/examples/user_resource_granted.json +6 -17
- data/lib/slack_resources/resources/event_api/examples/user_resource_removed.json +3 -14
- data/lib/slack_resources/resources/event_api/schema.json +257 -105
- data/lib/slack_resources/resources/event_api/schemas/emoji_changed.add.json +42 -0
- data/lib/slack_resources/resources/event_api/schemas/emoji_changed.json +27 -9
- data/lib/slack_resources/resources/event_api/schemas/emoji_changed.remove.json +40 -0
- data/lib/slack_resources/resources/event_api/schemas/member_joined_channel.json +1 -4
- data/lib/slack_resources/resources/event_api/schemas/member_left_channel.json +1 -4
- data/lib/slack_resources/resources/event_api/schemas/message.app_home.json +1 -4
- data/lib/slack_resources/resources/event_api/schemas/message.channels.json +1 -7
- data/lib/slack_resources/resources/event_api/schemas/message.groups.json +1 -7
- data/lib/slack_resources/resources/event_api/schemas/message.im.json +1 -7
- data/lib/slack_resources/resources/event_api/schemas/message.json +39 -17
- data/lib/slack_resources/resources/event_api/schemas/message.mpim.json +1 -7
- data/lib/slack_resources/resources/event_api/schemas/resources_added.json +15 -15
- data/lib/slack_resources/resources/event_api/schemas/resources_removed.json +15 -15
- data/lib/slack_resources/resources/event_api/schemas/team_rename.json +2 -2
- data/lib/slack_resources/resources/event_api/schemas/url_verification.json +0 -6
- data/lib/slack_resources/resources/event_api/summary.json +4887 -3400
- data/slack_resources.gemspec +4 -2
- metadata +91 -8
- data/lib/event_api/write.rb +0 -364
- data/lib/slack_resources/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f80ba497575cdb836330fa4d5194cf448cd1b8bc81d06710bbbe446fee45ed03
|
4
|
+
data.tar.gz: 4093cb4eb9f3d0fa85deaa49ce53f5135aeb98087dc8c8346d6e89acefa3e13a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a72b6d58185091cc4459f140ad4f805942d970de11b09f8a7b55aec18f01e90e94e95ef0e8a695ab5b26fc312fe8a2435ef64e68ed6cc7758d2658d9cfd07ae
|
7
|
+
data.tar.gz: 13687631b5dd8823d972fa31ca1f506a88a45dbe5e1c3567ff8c3fe1600abd8a6c5dd72a70c35f9ffab71eb498d2d913ce703c543eb41ecfa8413ab5fd90f263
|
data/.circleci/config.yml
CHANGED
@@ -1,11 +1,62 @@
|
|
1
1
|
version: 2
|
2
2
|
jobs:
|
3
|
+
test:
|
4
|
+
parallelism: 1
|
5
|
+
docker:
|
6
|
+
- image: circleci/ruby:2.5.1
|
7
|
+
steps:
|
8
|
+
- checkout
|
9
|
+
|
10
|
+
- restore_cache:
|
11
|
+
keys:
|
12
|
+
- rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }}
|
13
|
+
- rails-demo-bundle-v2-
|
14
|
+
|
15
|
+
- run:
|
16
|
+
name: Bundle Install
|
17
|
+
command: bundle check || bundle install --path vendor/bundle
|
18
|
+
|
19
|
+
- save_cache:
|
20
|
+
key: rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }}
|
21
|
+
paths:
|
22
|
+
- vendor/bundle
|
23
|
+
|
24
|
+
- run:
|
25
|
+
name: Test
|
26
|
+
command: bundle exec rspec -cfd
|
27
|
+
- run:
|
28
|
+
name: Rubocop
|
29
|
+
command: bundle exec rubocop
|
30
|
+
|
3
31
|
deploy_gem:
|
4
32
|
parallelism: 1
|
5
33
|
docker:
|
6
|
-
- image: circleci/ruby
|
34
|
+
- image: circleci/ruby:2.5.1
|
7
35
|
steps:
|
8
36
|
- checkout
|
37
|
+
- run:
|
38
|
+
name: Deployment
|
39
|
+
command: ruby .circleci/gem_deployment.rb $RUBYGEMS_API_KEY
|
40
|
+
|
41
|
+
deploy_gem_minor:
|
42
|
+
parallelism: 1
|
43
|
+
docker:
|
44
|
+
- image: circleci/ruby:2.5.1
|
45
|
+
steps:
|
46
|
+
- checkout
|
47
|
+
- run:
|
48
|
+
name: Deployment
|
49
|
+
command: ruby .circleci/gem_deployment.rb $RUBYGEMS_API_KEY minor
|
50
|
+
|
51
|
+
deploy_gem_major:
|
52
|
+
parallelism: 1
|
53
|
+
docker:
|
54
|
+
- image: circleci/ruby:2.5.1
|
55
|
+
steps:
|
56
|
+
- checkout
|
57
|
+
- run:
|
58
|
+
name: Deployment
|
59
|
+
command: ruby .circleci/gem_deployment.rb $RUBYGEMS_API_KEY major
|
9
60
|
|
10
61
|
|
11
62
|
workflows:
|
@@ -20,3 +71,17 @@ workflows:
|
|
20
71
|
- deployment/gem
|
21
72
|
requires:
|
22
73
|
- test
|
74
|
+
- deploy_gem_minor:
|
75
|
+
filters:
|
76
|
+
branches:
|
77
|
+
only:
|
78
|
+
- deployment/gem_minor
|
79
|
+
requires:
|
80
|
+
- test
|
81
|
+
- deploy_gem_major:
|
82
|
+
filters:
|
83
|
+
branches:
|
84
|
+
only:
|
85
|
+
- deployment/gem_major
|
86
|
+
requires:
|
87
|
+
- test
|
data/.rubocop.yml
CHANGED
@@ -2,6 +2,8 @@ AllCops:
|
|
2
2
|
TargetRubyVersion: 2.5
|
3
3
|
Exclude:
|
4
4
|
- tmp
|
5
|
+
- lib/slack_resources/generator/event_api/fetch.rb
|
6
|
+
- vendor/**/*
|
5
7
|
|
6
8
|
Rails:
|
7
9
|
Enabled: true
|
@@ -27,7 +29,7 @@ Metrics/BlockLength:
|
|
27
29
|
- 'spec/**/*'
|
28
30
|
|
29
31
|
Metrics/MethodLength:
|
30
|
-
Max:
|
32
|
+
Max: 200
|
31
33
|
Exclude:
|
32
34
|
- db/migrate/*.rb
|
33
35
|
|
@@ -35,7 +37,7 @@ Metrics/ModuleLength:
|
|
35
37
|
Max: 150
|
36
38
|
|
37
39
|
Metrics/ClassLength:
|
38
|
-
Max:
|
40
|
+
Max: 300
|
39
41
|
Exclude:
|
40
42
|
- db/migrate/*.rb
|
41
43
|
|
@@ -94,3 +96,9 @@ Naming/UncommunicativeMethodParamName:
|
|
94
96
|
|
95
97
|
Layout/IndentArray:
|
96
98
|
EnforcedStyle: consistent
|
99
|
+
|
100
|
+
Metrics/ParameterLists:
|
101
|
+
Max: 20
|
102
|
+
|
103
|
+
Style/RescueModifier:
|
104
|
+
Enabled: false
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
slack_resources (0.
|
4
|
+
slack_resources (0.0.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -12,24 +12,24 @@ GEM
|
|
12
12
|
minitest (~> 5.1)
|
13
13
|
tzinfo (~> 1.1)
|
14
14
|
ast (2.4.0)
|
15
|
-
concurrent-ruby (1.1.
|
15
|
+
concurrent-ruby (1.1.4)
|
16
16
|
diff-lcs (1.3)
|
17
17
|
domain_name (0.5.20180417)
|
18
18
|
unf (>= 0.0.5, < 1.0.0)
|
19
19
|
dotenv (2.5.0)
|
20
20
|
http-cookie (1.0.3)
|
21
21
|
domain_name (~> 0.5)
|
22
|
-
i18n (1.
|
22
|
+
i18n (1.3.0)
|
23
23
|
concurrent-ruby (~> 1.0)
|
24
24
|
jaro_winkler (1.5.1)
|
25
25
|
mime-types (3.2.2)
|
26
26
|
mime-types-data (~> 3.2015)
|
27
27
|
mime-types-data (3.2018.0812)
|
28
|
-
mini_portile2 (2.
|
28
|
+
mini_portile2 (2.4.0)
|
29
29
|
minitest (5.11.3)
|
30
30
|
netrc (0.11.0)
|
31
|
-
nokogiri (1.
|
32
|
-
mini_portile2 (~> 2.
|
31
|
+
nokogiri (1.9.1)
|
32
|
+
mini_portile2 (~> 2.4.0)
|
33
33
|
onkcop (0.53.0.2)
|
34
34
|
rubocop (>= 0.53.0)
|
35
35
|
rubocop-rspec (>= 1.24.0)
|
@@ -73,7 +73,7 @@ GEM
|
|
73
73
|
unf (0.1.4)
|
74
74
|
unf_ext
|
75
75
|
unf_ext (0.0.7.5)
|
76
|
-
unicode-display_width (1.4.
|
76
|
+
unicode-display_width (1.4.1)
|
77
77
|
|
78
78
|
PLATFORMS
|
79
79
|
ruby
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'slack_resources'
|
3
|
+
|
4
|
+
FileUtils.rm_r('./lib/slack_resources/resources/event_api')
|
5
|
+
SlackResources::Generator::Writer.new(
|
6
|
+
output_dir: './lib/slack_resources/resources/event_api',
|
7
|
+
data_dir: './lib/slack_resources/raw_data/event_api'
|
8
|
+
).execute!
|
data/lib/slack_resources.rb
CHANGED
@@ -1,3 +1,11 @@
|
|
1
1
|
module SlackResources
|
2
|
-
require 'slack_resources/version'
|
2
|
+
require 'slack_resources/version' if File.exist?('./lib/slack_resources/version')
|
3
|
+
|
4
|
+
require 'slack_resources/generator/event_api/strong_hash'
|
5
|
+
require 'slack_resources/generator/event_api/examples_preparation'
|
6
|
+
require 'slack_resources/generator/event_api/to_schema'
|
7
|
+
require 'slack_resources/generator/event_api/type_detection'
|
8
|
+
require 'slack_resources/generator/event_api/write'
|
9
|
+
|
10
|
+
require 'slack_resources/resources/event_api'
|
3
11
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module SlackResources
|
2
|
+
module Generator
|
3
|
+
class ExamplePreparation
|
4
|
+
using StrongHash
|
5
|
+
|
6
|
+
def initialize(examples_dir:, added_examples_dir:)
|
7
|
+
@added_examples_dir = added_examples_dir
|
8
|
+
@examples_dir = examples_dir
|
9
|
+
end
|
10
|
+
|
11
|
+
def execute! # rubocop:disable Metrics/AbcSize
|
12
|
+
single_events = Set.new(raw_examples.map(&:first))
|
13
|
+
|
14
|
+
defined = Set.new
|
15
|
+
event_typed_examples = {}
|
16
|
+
alt_typed_examples = {}
|
17
|
+
|
18
|
+
raw_examples.each do |alt_event_type, event_type, example|
|
19
|
+
example['_raw_example'] = JSON.parse(example.to_json)
|
20
|
+
event_typed_examples.protect_merge!(event_type => example)
|
21
|
+
alt_typed_examples[alt_event_type] = JSON.parse(example.to_json)
|
22
|
+
|
23
|
+
next if defined.add?(event_type)
|
24
|
+
|
25
|
+
single_events.delete(event_type)
|
26
|
+
defined_example = event_typed_examples[event_type]
|
27
|
+
|
28
|
+
Set.new(defined_example.keys + example.keys).each do |k|
|
29
|
+
next if k == '_raw_example'
|
30
|
+
|
31
|
+
defined_value = defined_example[k]
|
32
|
+
additional_value = example[k]
|
33
|
+
|
34
|
+
next if defined_value == additional_value
|
35
|
+
|
36
|
+
if defined_value.is_a?(Hash) && defined_value[TypeDetection::SPECIAL_TYPE] == TypeDetection::MULTIPLE_EXAMPLES
|
37
|
+
(defined_value['items'] << additional_value).sort! { |a, b| a.to_s <=> b.to_s }
|
38
|
+
else
|
39
|
+
defined_example.merge!(
|
40
|
+
k => {
|
41
|
+
TypeDetection::SPECIAL_TYPE => TypeDetection::MULTIPLE_EXAMPLES,
|
42
|
+
'target' => k,
|
43
|
+
'items' => [defined_value, additional_value].sort! { |a, b| a.to_s <=> b.to_s },
|
44
|
+
}
|
45
|
+
)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
alt_typed_examples.select { |k, _| single_events.include?(k) }.protect_merge!(event_typed_examples)
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def all_files
|
56
|
+
Dir.glob(@added_examples_dir.join('**/*.json')) + Dir.glob(@examples_dir.join('**/*.json'))
|
57
|
+
end
|
58
|
+
|
59
|
+
def raw_examples
|
60
|
+
@raw_examples ||= all_files.map do |f|
|
61
|
+
example = JSON.parse(File.read(f))
|
62
|
+
alt_event_type = File.basename(f, '.json')
|
63
|
+
event_body = example['event'].presence || example
|
64
|
+
event_type = event_body['type']
|
65
|
+
|
66
|
+
[alt_event_type, event_type, event_body.key_ordered]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module SlackResources
|
2
|
+
module Generator
|
3
|
+
module StrongHash
|
4
|
+
refine Hash do
|
5
|
+
def protect_merge!(b)
|
6
|
+
b.keys.map do |new_key|
|
7
|
+
if self[new_key]
|
8
|
+
self[new_key] = b[new_key] if b[new_key].is_a?(Hash) && b[new_key]['type'].is_a?(Array)
|
9
|
+
else
|
10
|
+
self[new_key] = b[new_key]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def key_ordered
|
18
|
+
keys.sort.inject({}) do |a, k|
|
19
|
+
a.merge!(k => self[k])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,200 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'active_support/core_ext/object/blank'
|
3
|
+
require 'active_support/core_ext/hash/keys'
|
4
|
+
|
5
|
+
module SlackResources
|
6
|
+
module Generator
|
7
|
+
class ToSchema
|
8
|
+
using StrongHash
|
9
|
+
|
10
|
+
def initialize(example:, url:, preset:, key: 'root', defined: {}, defined_used: Set.new, parent: {}, root: nil)
|
11
|
+
@example = JSON.parse(example.to_json).key_ordered
|
12
|
+
@url = url
|
13
|
+
@preset = preset
|
14
|
+
@key = key
|
15
|
+
@defined = defined
|
16
|
+
@defined_used = defined_used
|
17
|
+
@parent = parent
|
18
|
+
@root = root || @example
|
19
|
+
end
|
20
|
+
|
21
|
+
def execute!
|
22
|
+
properties = @example.inject({}) do |a, (prop_name, value)|
|
23
|
+
type = TypeDetection.new(
|
24
|
+
parent_key: @key,
|
25
|
+
to_schema_instance: self,
|
26
|
+
prop_name: prop_name,
|
27
|
+
value: value,
|
28
|
+
container: @example,
|
29
|
+
preset: @preset
|
30
|
+
).execute!
|
31
|
+
|
32
|
+
@defined_used << type if type.is_a?(String)
|
33
|
+
|
34
|
+
definition =
|
35
|
+
case
|
36
|
+
when TypeDetection.default_type?(type)
|
37
|
+
{ 'type' => type }
|
38
|
+
when detail?(type)
|
39
|
+
type
|
40
|
+
when array_type?(type)
|
41
|
+
define_as_array(type, value)
|
42
|
+
else
|
43
|
+
ref_to(type)
|
44
|
+
end
|
45
|
+
|
46
|
+
a.merge(prop_name => definition)
|
47
|
+
end
|
48
|
+
|
49
|
+
[
|
50
|
+
{
|
51
|
+
'type' => 'object',
|
52
|
+
'description' => properties.blank? ? "definition snipped. learn more: #{@url}" : '(defined by script)',
|
53
|
+
'properties' => properties,
|
54
|
+
},
|
55
|
+
@defined,
|
56
|
+
@defined_used,
|
57
|
+
]
|
58
|
+
end
|
59
|
+
|
60
|
+
def root_schema?
|
61
|
+
@root == @example
|
62
|
+
end
|
63
|
+
|
64
|
+
def root_type
|
65
|
+
@root['type']
|
66
|
+
end
|
67
|
+
|
68
|
+
def root_type_prefix
|
69
|
+
@root_type_prefix ||= root_type.split('_').shift
|
70
|
+
end
|
71
|
+
|
72
|
+
def array_type?(type)
|
73
|
+
type.to_s[0..1] == '[]'
|
74
|
+
end
|
75
|
+
|
76
|
+
def detail?(type)
|
77
|
+
type.is_a?(Hash)
|
78
|
+
end
|
79
|
+
|
80
|
+
def define_as_array(array_type, values)
|
81
|
+
type = array_type[2..-1]
|
82
|
+
|
83
|
+
if TypeDetection.default_type?(type)
|
84
|
+
return {
|
85
|
+
'type' => 'array',
|
86
|
+
'items' => {
|
87
|
+
'type' => type,
|
88
|
+
},
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
if values.first.is_a?(Hash)
|
93
|
+
to_child_schema(
|
94
|
+
prop_name: type,
|
95
|
+
example: values.first,
|
96
|
+
key: type,
|
97
|
+
parent: @example
|
98
|
+
)
|
99
|
+
elsif values.first.is_a?(String)
|
100
|
+
define_string(type)
|
101
|
+
end
|
102
|
+
|
103
|
+
{
|
104
|
+
'type' => 'array',
|
105
|
+
'items' => ref_to(type),
|
106
|
+
}
|
107
|
+
end
|
108
|
+
|
109
|
+
def define_object(k, v, types)
|
110
|
+
ref_key = k == 'item' ? "#{root_type_prefix}_item" : k
|
111
|
+
|
112
|
+
to_child_schema(
|
113
|
+
prop_name: ref_key,
|
114
|
+
example: v,
|
115
|
+
key: k,
|
116
|
+
parent: types
|
117
|
+
)
|
118
|
+
|
119
|
+
ref_key
|
120
|
+
end
|
121
|
+
|
122
|
+
def define_special_type(prop_name, value, container, const)
|
123
|
+
@defined_used << prop_name
|
124
|
+
|
125
|
+
return prop_name if @parent[prop_name]
|
126
|
+
|
127
|
+
types = value['items'].map { |v| detect_default_type(prop_name, v, container) }.uniq
|
128
|
+
|
129
|
+
@defined[prop_name] =
|
130
|
+
if const
|
131
|
+
{ 'type' => normalize_type(types), enum: value['items'].uniq }
|
132
|
+
else
|
133
|
+
{ 'type' => normalize_type(types) }
|
134
|
+
end
|
135
|
+
|
136
|
+
prop_name
|
137
|
+
end
|
138
|
+
|
139
|
+
def normalize_type(types)
|
140
|
+
types.size == 1 ? types[0] : types
|
141
|
+
end
|
142
|
+
|
143
|
+
def define_string(prop_name)
|
144
|
+
define_default_type(prop_name, 'string', nil)
|
145
|
+
end
|
146
|
+
|
147
|
+
def define_default_type(prop_name, value, container, const = false)
|
148
|
+
@defined.protect_merge!(
|
149
|
+
prop_name => {
|
150
|
+
'type' => detect_default_type(prop_name, value, container, const),
|
151
|
+
}
|
152
|
+
)
|
153
|
+
@defined_used << prop_name
|
154
|
+
|
155
|
+
ref_to(prop_name)
|
156
|
+
end
|
157
|
+
|
158
|
+
def detect_default_type(prop_name, value, container, const = false)
|
159
|
+
return define_special_type(prop_name, value, container, const) if value.is_a?(Hash) && value[TypeDetection::SPECIAL_TYPE] == TypeDetection::MULTIPLE_EXAMPLES
|
160
|
+
|
161
|
+
case value
|
162
|
+
when Integer
|
163
|
+
'number'
|
164
|
+
when Array
|
165
|
+
'array'
|
166
|
+
when Hash
|
167
|
+
define_object(prop_name, value, container)
|
168
|
+
when true, false
|
169
|
+
'boolean'
|
170
|
+
when nil
|
171
|
+
'null'
|
172
|
+
else
|
173
|
+
'string'
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def ref_to(type)
|
178
|
+
{ '$ref' => "#/definitions/#{type}" }
|
179
|
+
end
|
180
|
+
|
181
|
+
def to_child_schema(params)
|
182
|
+
prop_name = params.delete(:prop_name)
|
183
|
+
SlackResources::Generator::ToSchema.new(
|
184
|
+
example: @example,
|
185
|
+
url: @url,
|
186
|
+
preset: @preset,
|
187
|
+
key: @key,
|
188
|
+
defined: @defined,
|
189
|
+
defined_used: @defined_used,
|
190
|
+
parent: @parent,
|
191
|
+
root: @root,
|
192
|
+
**params
|
193
|
+
).execute!.tap do |schema,|
|
194
|
+
@defined_used << prop_name
|
195
|
+
@defined[prop_name] = schema
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|