apple-news 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +138 -0
- data/Rakefile +6 -0
- data/apple-news.gemspec +28 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/apple-news.rb +41 -0
- data/lib/apple-news/addition.rb +7 -0
- data/lib/apple-news/additions/base.rb +15 -0
- data/lib/apple-news/additions/link.rb +9 -0
- data/lib/apple-news/animation.rb +7 -0
- data/lib/apple-news/animations/appear.rb +7 -0
- data/lib/apple-news/animations/base.rb +17 -0
- data/lib/apple-news/animations/fade_in.rb +8 -0
- data/lib/apple-news/animations/move_in.rb +8 -0
- data/lib/apple-news/animations/scale_fade.rb +8 -0
- data/lib/apple-news/article.rb +33 -0
- data/lib/apple-news/behavior.rb +7 -0
- data/lib/apple-news/behaviors/background_motion.rb +7 -0
- data/lib/apple-news/behaviors/background_parallax.rb +7 -0
- data/lib/apple-news/behaviors/base.rb +15 -0
- data/lib/apple-news/behaviors/motion.rb +7 -0
- data/lib/apple-news/behaviors/parallax.rb +8 -0
- data/lib/apple-news/behaviors/springy.rb +7 -0
- data/lib/apple-news/channel.rb +40 -0
- data/lib/apple-news/component.rb +28 -0
- data/lib/apple-news/component_layout.rb +9 -0
- data/lib/apple-news/components/audio.rb +16 -0
- data/lib/apple-news/components/author.rb +8 -0
- data/lib/apple-news/components/banner_advertisement.rb +14 -0
- data/lib/apple-news/components/base.rb +17 -0
- data/lib/apple-news/components/body.rb +8 -0
- data/lib/apple-news/components/byline.rb +8 -0
- data/lib/apple-news/components/caption.rb +8 -0
- data/lib/apple-news/components/chapter.rb +10 -0
- data/lib/apple-news/components/container.rb +8 -0
- data/lib/apple-news/components/divider.rb +8 -0
- data/lib/apple-news/components/embed_web_video.rb +12 -0
- data/lib/apple-news/components/figure.rb +8 -0
- data/lib/apple-news/components/gallery.rb +8 -0
- data/lib/apple-news/components/header.rb +7 -0
- data/lib/apple-news/components/heading.rb +8 -0
- data/lib/apple-news/components/illustrator.rb +8 -0
- data/lib/apple-news/components/image.rb +14 -0
- data/lib/apple-news/components/instagram.rb +9 -0
- data/lib/apple-news/components/intro.rb +8 -0
- data/lib/apple-news/components/logo.rb +8 -0
- data/lib/apple-news/components/medium_rectangle_advertisement.rb +7 -0
- data/lib/apple-news/components/mosaic.rb +8 -0
- data/lib/apple-news/components/music.rb +8 -0
- data/lib/apple-news/components/photo.rb +8 -0
- data/lib/apple-news/components/photographer.rb +8 -0
- data/lib/apple-news/components/portrait.rb +8 -0
- data/lib/apple-news/components/pullquote.rb +8 -0
- data/lib/apple-news/components/quote.rb +8 -0
- data/lib/apple-news/components/scalable_image.rb +14 -0
- data/lib/apple-news/components/section.rb +8 -0
- data/lib/apple-news/components/text.rb +13 -0
- data/lib/apple-news/components/title.rb +8 -0
- data/lib/apple-news/components/tweet.rb +9 -0
- data/lib/apple-news/components/video.rb +12 -0
- data/lib/apple-news/configuration.rb +12 -0
- data/lib/apple-news/document.rb +22 -0
- data/lib/apple-news/document/attachments.rb +24 -0
- data/lib/apple-news/document/metadata.rb +43 -0
- data/lib/apple-news/document/persistence.rb +42 -0
- data/lib/apple-news/layout.rb +8 -0
- data/lib/apple-news/links.rb +19 -0
- data/lib/apple-news/metadata.rb +15 -0
- data/lib/apple-news/multipart_post_patch.rb +29 -0
- data/lib/apple-news/properties.rb +87 -0
- data/lib/apple-news/properties/advertising_layout.rb +7 -0
- data/lib/apple-news/properties/advertising_settings.rb +7 -0
- data/lib/apple-news/properties/anchor.rb +15 -0
- data/lib/apple-news/properties/base.rb +7 -0
- data/lib/apple-news/properties/caption_descriptor.rb +8 -0
- data/lib/apple-news/properties/color_stop.rb +8 -0
- data/lib/apple-news/properties/content_inset.rb +7 -0
- data/lib/apple-news/properties/gallery_item.rb +7 -0
- data/lib/apple-news/properties/margin.rb +7 -0
- data/lib/apple-news/properties/offset.rb +7 -0
- data/lib/apple-news/property.rb +7 -0
- data/lib/apple-news/request.rb +6 -0
- data/lib/apple-news/requests/get.rb +28 -0
- data/lib/apple-news/requests/post.rb +57 -0
- data/lib/apple-news/resource.rb +25 -0
- data/lib/apple-news/scene.rb +7 -0
- data/lib/apple-news/scenes/base.rb +15 -0
- data/lib/apple-news/scenes/fading_sticky_header.rb +8 -0
- data/lib/apple-news/scenes/parallax_scale_header.rb +7 -0
- data/lib/apple-news/section.rb +27 -0
- data/lib/apple-news/security.rb +46 -0
- data/lib/apple-news/style.rb +10 -0
- data/lib/apple-news/styles/base.rb +7 -0
- data/lib/apple-news/styles/border.rb +7 -0
- data/lib/apple-news/styles/component.rb +7 -0
- data/lib/apple-news/styles/component_text.rb +9 -0
- data/lib/apple-news/styles/document.rb +7 -0
- data/lib/apple-news/styles/drop_cap.rb +9 -0
- data/lib/apple-news/styles/fill.rb +11 -0
- data/lib/apple-news/styles/gradient_fill.rb +12 -0
- data/lib/apple-news/styles/image_fill.rb +11 -0
- data/lib/apple-news/styles/inline_text.rb +7 -0
- data/lib/apple-news/styles/linear_gradient_fill.rb +9 -0
- data/lib/apple-news/styles/shadow.rb +8 -0
- data/lib/apple-news/styles/stroke.rb +7 -0
- data/lib/apple-news/styles/text.rb +8 -0
- data/lib/apple-news/styles/text_stroke.rb +8 -0
- data/lib/apple-news/styles/video_fill.rb +12 -0
- data/lib/apple-news/version.rb +3 -0
- metadata +241 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
module AppleNews
|
2
|
+
class Channel
|
3
|
+
include Resource
|
4
|
+
include Links
|
5
|
+
|
6
|
+
attr_reader :id, :type, :name, :website, :links, :created_at, :modified_at,
|
7
|
+
:default_section
|
8
|
+
|
9
|
+
def self.current
|
10
|
+
self.new(AppleNews.config.channel_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(id, data = nil)
|
14
|
+
@id = id
|
15
|
+
@url = "/channels/#{id}"
|
16
|
+
|
17
|
+
data.nil? ? hydrate! : process_data(data)
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_section
|
21
|
+
Section.new(section_link_id('defaultSection'))
|
22
|
+
end
|
23
|
+
|
24
|
+
def sections
|
25
|
+
request = Request::Get.new("/channels/#{id}/sections")
|
26
|
+
resp = request.call
|
27
|
+
resp['data'].map do |section|
|
28
|
+
Section.new(section['id'], section)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def articles(params = {})
|
33
|
+
request = Request::Get.new("/channels/#{id}/articles")
|
34
|
+
resp = request.call(params)
|
35
|
+
resp['data'].map do |article|
|
36
|
+
Article.new(article['id'], article)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "apple-news/components/base"
|
2
|
+
require "apple-news/components/text"
|
3
|
+
require "apple-news/components/audio"
|
4
|
+
require "apple-news/components/image"
|
5
|
+
require "apple-news/components/scalable_image"
|
6
|
+
Dir["#{File.dirname(__FILE__)}/components/*.rb"].each { |path| require path }
|
7
|
+
|
8
|
+
module AppleNews
|
9
|
+
module Component
|
10
|
+
extend self
|
11
|
+
|
12
|
+
def factory(data)
|
13
|
+
components.each do |component|
|
14
|
+
if component.role == data[:role]
|
15
|
+
return component.new(data)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def components
|
23
|
+
@components ||= self.constants.
|
24
|
+
map { |const| self.const_get(const) }.
|
25
|
+
select { |const| const.name.demodulize != "Base" && const.is_a?(Class) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module AppleNews
|
2
|
+
class ComponentLayout
|
3
|
+
include Properties
|
4
|
+
|
5
|
+
optional_properties :column_span, :column_start, :content_inset, :horizontal_content_alignment,
|
6
|
+
:ignore_document_gutter, :ignore_document_margin, :margin,
|
7
|
+
:maximum_content_width, :minimum_height
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module AppleNews
|
2
|
+
module Component
|
3
|
+
module Audio
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
role "audio"
|
8
|
+
required_property :url
|
9
|
+
optional_properties :accessibility_caption, :caption, :explicit_content, :image_url
|
10
|
+
|
11
|
+
property_inflection :url, 'URL'
|
12
|
+
property_inflection :image_url, 'imageURL'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module AppleNews
|
2
|
+
module Component
|
3
|
+
class BannerAdvertisement < Base
|
4
|
+
role "banner_advertisement"
|
5
|
+
optional_property :banner_type, "any"
|
6
|
+
|
7
|
+
def valid?
|
8
|
+
super && [
|
9
|
+
'any', 'standard', 'double_height', 'large'
|
10
|
+
].include?(banner_type)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module AppleNews
|
2
|
+
module Component
|
3
|
+
class Base
|
4
|
+
include Properties
|
5
|
+
|
6
|
+
optional_properties :identifier, :layout, :style
|
7
|
+
|
8
|
+
def self.role(val = nil)
|
9
|
+
val.nil? ? _required_property_map[:role] : required_property(:role, val)
|
10
|
+
end
|
11
|
+
|
12
|
+
def role
|
13
|
+
self.class.role
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module AppleNews
|
2
|
+
module Component
|
3
|
+
class EmbedWebVideo < Base
|
4
|
+
role "embedwebvideo"
|
5
|
+
required_property :url
|
6
|
+
optional_properties :accessibility_caption, :aspect_ratio, :caption,
|
7
|
+
:explicit_content
|
8
|
+
|
9
|
+
property_inflection :url, 'URL'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module AppleNews
|
2
|
+
module Component
|
3
|
+
module Image
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
required_property :url
|
8
|
+
optional_properties :accessibility_caption, :caption, :explicit_content
|
9
|
+
|
10
|
+
property_inflection :url, 'URL'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module AppleNews
|
2
|
+
module Component
|
3
|
+
module ScalableImage
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
required_property :url
|
8
|
+
optional_properties :accessibility_caption, :caption, :explicit_content
|
9
|
+
|
10
|
+
property_inflection :url, 'URL'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|