woody-decorators 0.6.0 → 0.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d275dc5937f949ed6129bf9e7295faf1b192ba9
4
- data.tar.gz: bb7ffc9489967339489abd699d77b25d0914e112
3
+ metadata.gz: 04f77657db3d47be852273f0369290cc0e607923
4
+ data.tar.gz: e53ba600bbd0950d4ae84a1270e9c1ffba3cb53f
5
5
  SHA512:
6
- metadata.gz: 26b6966ba4cf172f6f27ff7cb1036761f27690b43a2905bb6c8d2d669195dce6da1093519115d01f4fb80c71734de51c3b0026641d17af02f6cb02d2bc7930da
7
- data.tar.gz: 81023fc0ec905c286d1499a89db98b00ddfe487baf721d53c983da312379f46e81dd8ab0e3b414fdaa38b78511d21f4c61e234f491547bc69b97658ee094b243
6
+ metadata.gz: 7e4ec5225e7f111a32d8e71d5e51bf6fd1f46f804ca20aa9c171c2fb73b74e7a8c6f8a6add2feb02ff321eedfdd267d009d859f1143b7df70783cb1a7927fe80
7
+ data.tar.gz: f5ed123f7717bc01c7e087303ba2f2e85f662decabd880eff57e949fdad9e26f151944d6962dccf87170d7e0dea5cd4f44ffa3623be88f53ceb44fd2f5a08a8e
@@ -1,5 +1,5 @@
1
1
  module Woody
2
2
  module Decorators
3
- VERSION = "0.6.0".freeze
3
+ VERSION = "0.7.0".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,86 @@
1
+ require "wes/data/api/brand"
2
+ require "wes/data/api/challenge"
3
+ require "wes/data/api/submission"
4
+ require "woody/decorators/base"
5
+ require "woody/decorators/video_transcoding_state"
6
+
7
+ module Woody
8
+ module Decorators
9
+ class Video < Base
10
+ def initialize(model, config)
11
+ @config = config
12
+ super(model)
13
+ end
14
+
15
+ def aspect_ratio
16
+ aspect_ratios.sample
17
+ end
18
+
19
+ def brand
20
+ @brand ||= Wes::Data::API::Brand.find(:id, challenge.brand_id)
21
+ end
22
+
23
+ def challenge
24
+ @challenge ||= Wes::Data::API::Challenge.find(
25
+ :id, submission.challenge_id
26
+ )
27
+ end
28
+
29
+ def gif
30
+ video_transcoding_state("gif").path(filename_hash)
31
+ end
32
+
33
+ def thumbnail
34
+ video_transcoding_state("gif").path(
35
+ filename_hash,
36
+ "thumbnail",
37
+ app_config["video_default_thumbnail"]
38
+ )
39
+ end
40
+
41
+ def processed?
42
+ type_processed?("gif") && type_processed?("mp4")
43
+ end
44
+
45
+ def url
46
+ video_transcoding_state("mp4").path(filename_hash)
47
+ end
48
+
49
+ private
50
+
51
+ def app_config
52
+ @app_config ||= @config.app
53
+ end
54
+
55
+ def aspect_ratios
56
+ [
57
+ "square",
58
+ "landscape_ar16-9",
59
+ "landscape_ar4-3",
60
+ "portrait_ar9-16",
61
+ "portrait_ar5-4"
62
+ ]
63
+ end
64
+
65
+ def filename_hash
66
+ @model.file_name.split(".").first
67
+ end
68
+
69
+ def submission
70
+ @submission ||= Wes::Data::API::Submission.find(
71
+ :id, @model.submission_id
72
+ )
73
+ end
74
+
75
+ def type_processed?(type)
76
+ video_transcoding_state(type).complete?
77
+ end
78
+
79
+ def video_transcoding_state(type)
80
+ VideoTranscodingState.new(
81
+ @model.transcoding_state(type), @config
82
+ )
83
+ end
84
+ end
85
+ end
86
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: woody-decorators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -136,6 +136,7 @@ files:
136
136
  - lib/woody/decorators/challenge.rb
137
137
  - lib/woody/decorators/creator_user.rb
138
138
  - lib/woody/decorators/submission.rb
139
+ - lib/woody/decorators/video.rb
139
140
  - lib/woody/decorators/video_transcoding_state.rb
140
141
  - woody-decorators.gemspec
141
142
  homepage: ''