apps 0.2.1 → 0.3.0

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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/README.md +103 -19
  4. data/bin/setup +1 -2
  5. data/exe/apps +0 -0
  6. data/lib/apps/common/schema.rb +8 -0
  7. data/lib/apps/common/schema/base.rb +91 -0
  8. data/lib/apps/common/schema/concerns.rb +10 -0
  9. data/lib/apps/common/schema/concerns/potential_action.rb +35 -0
  10. data/lib/apps/gmail/markup.rb +158 -0
  11. data/lib/apps/gmail/schema.rb +21 -0
  12. data/lib/apps/gmail/schema/action.rb +19 -0
  13. data/lib/apps/gmail/schema/confirm_action.rb +21 -0
  14. data/lib/apps/gmail/schema/email_message.rb +15 -0
  15. data/lib/apps/gmail/schema/event.rb +41 -0
  16. data/lib/apps/gmail/schema/parcel_delivery.rb +43 -0
  17. data/lib/apps/gmail/schema/place.rb +24 -0
  18. data/lib/apps/gmail/schema/postal_address.rb +22 -0
  19. data/lib/apps/gmail/schema/rsvp_action.rb +25 -0
  20. data/lib/apps/gmail/schema/save_action.rb +20 -0
  21. data/lib/apps/gmail/schema/track_action.rb +20 -0
  22. data/lib/apps/gmail/schema/view_action.rb +20 -0
  23. data/lib/apps/outlook/actionable_messages.rb +13 -0
  24. data/lib/apps/outlook/schema.rb +20 -0
  25. data/lib/apps/outlook/schema/action.rb +14 -0
  26. data/lib/apps/outlook/schema/action_card.rb +42 -0
  27. data/lib/apps/outlook/schema/concerns.rb +14 -0
  28. data/lib/apps/outlook/schema/concerns/sections.rb +27 -0
  29. data/lib/apps/outlook/schema/concerns/sorted_potential_action.rb +17 -0
  30. data/lib/apps/outlook/schema/date_input.rb +17 -0
  31. data/lib/apps/outlook/schema/http_post.rb +44 -0
  32. data/lib/apps/outlook/schema/input.rb +23 -0
  33. data/lib/apps/outlook/schema/invoke_add_in_command.rb +33 -0
  34. data/lib/apps/outlook/schema/message_card.rb +39 -0
  35. data/lib/apps/outlook/schema/multichoice_input.rb +32 -0
  36. data/lib/apps/outlook/schema/open_uri.rb +24 -0
  37. data/lib/apps/outlook/schema/section.rb +52 -0
  38. data/lib/apps/outlook/schema/text_input.rb +20 -0
  39. data/lib/apps/version.rb +4 -1
  40. data/lib/examples.rb +121 -0
  41. data/package.json +12 -0
  42. metadata +37 -16
  43. data/lib/apps/adapters/gmail/markup.rb +0 -42
  44. data/lib/apps/adapters/gmail/markup/action.rb +0 -23
  45. data/lib/apps/adapters/gmail/markup/base.rb +0 -37
  46. data/lib/apps/adapters/gmail/markup/base_context.rb +0 -23
  47. data/lib/apps/adapters/gmail/markup/confirm_action.rb +0 -23
  48. data/lib/apps/adapters/gmail/markup/email_message.rb +0 -22
  49. data/lib/apps/adapters/gmail/markup/event.rb +0 -40
  50. data/lib/apps/adapters/gmail/markup/parcel_delivery.rb +0 -47
  51. data/lib/apps/adapters/gmail/markup/place.rb +0 -27
  52. data/lib/apps/adapters/gmail/markup/postal_address.rb +0 -26
  53. data/lib/apps/adapters/gmail/markup/rsvp_action.rb +0 -27
  54. data/lib/apps/adapters/gmail/markup/save_action.rb +0 -22
  55. data/lib/apps/adapters/gmail/markup/track_action.rb +0 -24
  56. data/lib/apps/adapters/gmail/markup/view_action.rb +0 -24
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Van Horn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-22 00:00:00.000000000 Z
11
+ date: 2018-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -74,21 +74,42 @@ files:
74
74
  - bin/setup
75
75
  - exe/apps
76
76
  - lib/apps.rb
77
- - lib/apps/adapters/gmail/markup.rb
78
- - lib/apps/adapters/gmail/markup/action.rb
79
- - lib/apps/adapters/gmail/markup/base.rb
80
- - lib/apps/adapters/gmail/markup/base_context.rb
81
- - lib/apps/adapters/gmail/markup/confirm_action.rb
82
- - lib/apps/adapters/gmail/markup/email_message.rb
83
- - lib/apps/adapters/gmail/markup/event.rb
84
- - lib/apps/adapters/gmail/markup/parcel_delivery.rb
85
- - lib/apps/adapters/gmail/markup/place.rb
86
- - lib/apps/adapters/gmail/markup/postal_address.rb
87
- - lib/apps/adapters/gmail/markup/rsvp_action.rb
88
- - lib/apps/adapters/gmail/markup/save_action.rb
89
- - lib/apps/adapters/gmail/markup/track_action.rb
90
- - lib/apps/adapters/gmail/markup/view_action.rb
77
+ - lib/apps/common/schema.rb
78
+ - lib/apps/common/schema/base.rb
79
+ - lib/apps/common/schema/concerns.rb
80
+ - lib/apps/common/schema/concerns/potential_action.rb
81
+ - lib/apps/gmail/markup.rb
82
+ - lib/apps/gmail/schema.rb
83
+ - lib/apps/gmail/schema/action.rb
84
+ - lib/apps/gmail/schema/confirm_action.rb
85
+ - lib/apps/gmail/schema/email_message.rb
86
+ - lib/apps/gmail/schema/event.rb
87
+ - lib/apps/gmail/schema/parcel_delivery.rb
88
+ - lib/apps/gmail/schema/place.rb
89
+ - lib/apps/gmail/schema/postal_address.rb
90
+ - lib/apps/gmail/schema/rsvp_action.rb
91
+ - lib/apps/gmail/schema/save_action.rb
92
+ - lib/apps/gmail/schema/track_action.rb
93
+ - lib/apps/gmail/schema/view_action.rb
94
+ - lib/apps/outlook/actionable_messages.rb
95
+ - lib/apps/outlook/schema.rb
96
+ - lib/apps/outlook/schema/action.rb
97
+ - lib/apps/outlook/schema/action_card.rb
98
+ - lib/apps/outlook/schema/concerns.rb
99
+ - lib/apps/outlook/schema/concerns/sections.rb
100
+ - lib/apps/outlook/schema/concerns/sorted_potential_action.rb
101
+ - lib/apps/outlook/schema/date_input.rb
102
+ - lib/apps/outlook/schema/http_post.rb
103
+ - lib/apps/outlook/schema/input.rb
104
+ - lib/apps/outlook/schema/invoke_add_in_command.rb
105
+ - lib/apps/outlook/schema/message_card.rb
106
+ - lib/apps/outlook/schema/multichoice_input.rb
107
+ - lib/apps/outlook/schema/open_uri.rb
108
+ - lib/apps/outlook/schema/section.rb
109
+ - lib/apps/outlook/schema/text_input.rb
91
110
  - lib/apps/version.rb
111
+ - lib/examples.rb
112
+ - package.json
92
113
  homepage: https://github.com/joelvh/apps
93
114
  licenses:
94
115
  - MIT
@@ -1,42 +0,0 @@
1
- require_relative 'markup/event'
2
- require_relative 'markup/email_message'
3
- require_relative 'markup/parcel_delivery'
4
- require_relative 'markup/confirm_action'
5
- require_relative 'markup/save_action'
6
- require_relative 'markup/view_action'
7
- require_relative 'markup/track_action'
8
-
9
- module Apps
10
- module Adapters
11
- module Gmail
12
- module Markup
13
- class << self
14
- def build_confirm_action(description: nil, **attrs)
15
- EmailMessage.new(description: description, action: ConfirmAction.new(**attrs))
16
- end
17
-
18
- def build_save_action(description: nil, **attrs)
19
- EmailMessage.new(description: description, action: SaveAction.new(**attrs))
20
- end
21
-
22
- def build_rsvp_action(**attrs)
23
- Event.new(**attrs).tap do |event|
24
- event.build_location unless event.location
25
- event.build_rsvp_actions unless event.actions.any?
26
- end
27
- end
28
-
29
- def build_view_action(target: nil, **attrs)
30
- EmailMessage.new(action: ViewAction.new(target: target), **attrs)
31
- end
32
-
33
- def build_track_action(target: nil, **attrs)
34
- ParcelDelivery.new(action: TrackAction.new(target: target), **attrs).tap do |email|
35
- email.build_delivery_address unless email.delivery_address
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,23 +0,0 @@
1
- require_relative 'base'
2
-
3
- module Apps
4
- module Adapters
5
- module Gmail
6
- module Markup
7
- class Action < Base
8
-
9
- attr_accessor :handler_url
10
-
11
- def as_json
12
- prune super.merge(
13
- "handler" => {
14
- "@type" => "HttpActionHandler",
15
- "url" => handler_url
16
- }
17
- )
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,37 +0,0 @@
1
- require 'json'
2
-
3
- module Apps
4
- module Adapters
5
- module Gmail
6
- module Markup
7
- class Base
8
- def initialize(**attrs)
9
- attrs.each do |name, value|
10
- next if value.nil?
11
-
12
- instance_variable_set(:"@#{name}", value)
13
- end
14
- end
15
-
16
- def type
17
- @type ||= self.class.name.split('::')[-1]
18
- end
19
-
20
- def as_json
21
- { "@type" => type }
22
- end
23
-
24
- def to_json(pretty: false)
25
- pretty ? JSON.pretty_generate(as_json) : JSON.dump(as_json)
26
- end
27
-
28
- protected
29
-
30
- def prune(hash)
31
- hash.reject { |_, value| value.nil? }
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,23 +0,0 @@
1
- require_relative 'base'
2
-
3
- module Apps
4
- module Adapters
5
- module Gmail
6
- module Markup
7
- class BaseContext < Base
8
- def as_json
9
- { "@context" => "http://schema.org" }.merge(super)
10
- end
11
-
12
- def to_script
13
- buffer = []
14
- buffer << %{<script type="application/ld+json">}
15
- buffer << to_json(pretty: true)
16
- buffer << %{</script>}
17
- buffer.join("\n")
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,23 +0,0 @@
1
- require_relative 'action'
2
-
3
- module Apps
4
- module Adapters
5
- module Gmail
6
- module Markup
7
- # See: https://developers.google.com/gmail/markup/reference/one-click-action
8
- # See: https://developers.google.com/gmail/markup/reference/types/ConfirmAction
9
- class ConfirmAction < Action
10
-
11
- attr_accessor :name, :confirmed
12
-
13
- def as_json
14
- prune super.merge(
15
- "name" => name,
16
- "confirmed" => confirmed&.as_json # Thing
17
- )
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,22 +0,0 @@
1
- require_relative 'base_context'
2
-
3
- module Apps
4
- module Adapters
5
- module Gmail
6
- module Markup
7
- class EmailMessage < BaseContext
8
-
9
- attr_reader :action
10
- attr_accessor :description, :publisher
11
-
12
- def as_json
13
- prune super.merge(
14
- "potentialAction" => action&.as_json,
15
- "publisher" => publisher&.as_json # Organization
16
- )
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,40 +0,0 @@
1
- require_relative 'base_context'
2
- require_relative 'rsvp_action'
3
- require_relative 'place'
4
-
5
- module Apps
6
- module Adapters
7
- module Gmail
8
- module Markup
9
- class Event < BaseContext
10
-
11
- attr_accessor :name, :start_date, :end_date, :location
12
-
13
- def as_json
14
- prune super.merge(
15
- "name" => name,
16
- "startDate" => start_date,
17
- "endDate" => end_date,
18
- "location" => location&.as_json,
19
- "potentialAction" => actions.map(&:as_json)
20
- )
21
- end
22
-
23
- def actions
24
- @actions ||= []
25
- end
26
-
27
- def build_location(**attrs)
28
- self.location = Place.new(**attrs).tap do |place|
29
- place.build_address unless place.address
30
- end
31
- end
32
-
33
- def build_rsvp_actions
34
- actions.clear.concat(%w[Yes No Maybe].map { |response| RsvpAction.new(response: response) })
35
- end
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,47 +0,0 @@
1
- require_relative 'base_context'
2
- require_relative 'postal_address'
3
-
4
- module Apps
5
- module Adapters
6
- module Gmail
7
- module Markup
8
- class ParcelDelivery < BaseContext
9
-
10
- attr_reader :action
11
- attr_accessor :delivery_address, :expected_arrival_until, :carrier_name
12
- attr_accessor :product_name, :order_number, :merchant_name
13
- attr_accessor :tracking_url
14
-
15
- def as_json
16
- prune super.merge(
17
- "deliveryAddress" => delivery_address&.as_json,
18
- "expectedArrivalUntil" => expected_arrival_until,
19
- "carrier" => {
20
- "@type" => "Organization",
21
- "name" => carrier_name
22
- },
23
- "itemShipped" => {
24
- "@type" => "Product",
25
- "name" => product_name
26
- },
27
- "partOfOrder" => {
28
- "@type" => "Order",
29
- "orderNumber" => order_number,
30
- "merchant" => {
31
- "@type" => "Organization",
32
- "name" => merchant_name
33
- }
34
- },
35
- "trackingUrl" => tracking_url,
36
- "potentialAction" => action&.as_json
37
- )
38
- end
39
-
40
- def build_delivery_address(**attrs)
41
- self.delivery_address = PostalAddress.new(**attrs)
42
- end
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,27 +0,0 @@
1
- require_relative 'base'
2
- require_relative 'postal_address'
3
-
4
- module Apps
5
- module Adapters
6
- module Gmail
7
- module Markup
8
- class Place < Base
9
-
10
- attr_accessor :name, :same_as, :address
11
-
12
- def as_json
13
- prune super.merge(
14
- "sameAs" => same_as,
15
- "name" => name,
16
- "address" => address&.as_json
17
- )
18
- end
19
-
20
- def build_address(**attrs)
21
- self.address = PostalAddress.new(**attrs)
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,26 +0,0 @@
1
- require_relative 'base'
2
-
3
- module Apps
4
- module Adapters
5
- module Gmail
6
- module Markup
7
- class PostalAddress < Base
8
-
9
- attr_accessor :name, :street, :locality, :region, :po_box, :postal_code, :country
10
-
11
- def as_json
12
- prune super.merge(
13
- "name" => name,
14
- "streetAddress" => street, # street address
15
- "addressLocality" => locality, # city
16
- "addressRegion" => region, # state (abbr)
17
- "postOfficeBoxNumber" => po_box,
18
- "postalCode" => postal_code, # zip code
19
- "addressCountry" => country
20
- )
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,27 +0,0 @@
1
- require_relative 'action'
2
-
3
- module Apps
4
- module Adapters
5
- module Gmail
6
- module Markup
7
- # See: https://developers.google.com/gmail/markup/reference/rsvp-action
8
- class RsvpAction < Action
9
-
10
- attr_accessor :response, :additional_number_of_guests, :bringing_kids, :bringing_other_people
11
-
12
- def as_json
13
- prune super.merge(
14
- "rsvpResponse" => response.downcase,
15
- "additionalNumberOfGuests" => additional_number_of_guests&.to_i,
16
- "bringingKids" => bringing_kids&.to_i,
17
- "bringingOtherPeople" => bringing_other_people&.to_i,
18
- # "comment" => {},
19
- # "event" => {},
20
- "attendance" => "http://schema.org/RsvpAttendance/#{response.capitalize}"
21
- )
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,22 +0,0 @@
1
- require_relative 'action'
2
-
3
- module Apps
4
- module Adapters
5
- module Gmail
6
- module Markup
7
- # See: https://developers.google.com/gmail/markup/reference/one-click-action
8
- # See: https://developers.google.com/gmail/markup/reference/types/SaveAction
9
- class SaveAction < Action
10
-
11
- attr_accessor :name
12
-
13
- def as_json
14
- prune super.merge(
15
- "name" => name
16
- )
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end