woody-decorators 2.1.0 → 2.2.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 +4 -4
- data/lib/woody/decorators.rb +1 -1
- data/lib/woody/decorators/helper/aspect_ratio.rb +61 -0
- data/lib/woody/decorators/video.rb +5 -11
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 998199005ed2235da9f97f8f5effc60329e83ca0
|
|
4
|
+
data.tar.gz: d11091f950adbde26fea150ba849503110ceef14
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e5dc61f0ee15bce38a8c247e00e8a555191407eb7774a17d6a77f3a40ca31b309d6b37b6691d3b4f1d90bd4f9472acb5bcd9e7eb4a4cd76da9ff15a2d25b27a2
|
|
7
|
+
data.tar.gz: 7c64a2c998ab09f282a54cec281085427485572360ddd956e545d86f9a14bb9c913da24fc32d25844ffe15a0e656a985b06a33f59d3f8c37fcbf65bc9817e4de
|
data/lib/woody/decorators.rb
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
module Woody
|
|
2
|
+
module Decorators
|
|
3
|
+
module Helper
|
|
4
|
+
class AspectRatio
|
|
5
|
+
def initialize(height, width)
|
|
6
|
+
@height = height
|
|
7
|
+
@width = width
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def class_name
|
|
11
|
+
return format_class_name("landscape", "16-9") unless valid_dimensions
|
|
12
|
+
|
|
13
|
+
case ratio
|
|
14
|
+
when "1:1"
|
|
15
|
+
"square"
|
|
16
|
+
when "16:9", "4:3", "9:16", "5:4"
|
|
17
|
+
format(CLASS_NAME_FORMAT, orientation, ratio("-"))
|
|
18
|
+
else
|
|
19
|
+
format(CLASS_NAME_FORMAT, orientation, default_ratio)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
CLASS_NAME_FORMAT = "%s_ar%s".freeze
|
|
26
|
+
|
|
27
|
+
def format_class_name(orientation, ratio)
|
|
28
|
+
format(CLASS_NAME_FORMAT, orientation, ratio)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def default_ratio
|
|
32
|
+
orientation == "landscape" ? "16-9" : "9-16"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def ratio(delimiter = ":")
|
|
36
|
+
format("%d%s%d", ratio_width, delimiter, ratio_height)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def gcd
|
|
40
|
+
@height.gcd(@width)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def ratio_width
|
|
44
|
+
@width / gcd
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def ratio_height
|
|
48
|
+
@height / gcd
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def orientation
|
|
52
|
+
@width > @height ? "landscape" : "portrait"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def valid_dimensions
|
|
56
|
+
!@width.nil? && !@height.nil?
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -4,6 +4,7 @@ require "wes/data/api/challenge"
|
|
|
4
4
|
require "wes/data/api/submission"
|
|
5
5
|
require "woody/decorators/base"
|
|
6
6
|
require "woody/decorators/video_transcoding_state"
|
|
7
|
+
require "woody/decorators/helper/aspect_ratio"
|
|
7
8
|
|
|
8
9
|
module Woody
|
|
9
10
|
module Decorators
|
|
@@ -14,7 +15,10 @@ module Woody
|
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
def aspect_ratio
|
|
17
|
-
|
|
18
|
+
@aspect_ratio ||= Helper::AspectRatio.new(
|
|
19
|
+
@model.height,
|
|
20
|
+
@model.width
|
|
21
|
+
).class_name
|
|
18
22
|
end
|
|
19
23
|
|
|
20
24
|
def brand
|
|
@@ -61,16 +65,6 @@ module Woody
|
|
|
61
65
|
@aws_config ||= @config.aws
|
|
62
66
|
end
|
|
63
67
|
|
|
64
|
-
def aspect_ratios
|
|
65
|
-
[
|
|
66
|
-
"square",
|
|
67
|
-
"landscape_ar16-9",
|
|
68
|
-
"landscape_ar4-3",
|
|
69
|
-
"portrait_ar9-16",
|
|
70
|
-
"portrait_ar5-4"
|
|
71
|
-
]
|
|
72
|
-
end
|
|
73
|
-
|
|
74
68
|
def dev?
|
|
75
69
|
Wes::Cloudkit.dev?
|
|
76
70
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: woody-decorators
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ''
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-06-
|
|
11
|
+
date: 2016-06-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -152,6 +152,7 @@ files:
|
|
|
152
152
|
- lib/woody/decorators/challenge_question.rb
|
|
153
153
|
- lib/woody/decorators/collective.rb
|
|
154
154
|
- lib/woody/decorators/creator_user.rb
|
|
155
|
+
- lib/woody/decorators/helper/aspect_ratio.rb
|
|
155
156
|
- lib/woody/decorators/submission.rb
|
|
156
157
|
- lib/woody/decorators/user.rb
|
|
157
158
|
- lib/woody/decorators/video.rb
|