woody-decorators 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4621116b3ad2e33b268c98c146dc3b138b0f73d5
4
- data.tar.gz: e5212ea5b8cb0912419ef4ee944421b4bcd090ed
3
+ metadata.gz: e1c5e2ae42088842a2ff966c2dbd7d332646466a
4
+ data.tar.gz: 6d0302ab48e5f7c9ffaca694fc087b8e4678ccef
5
5
  SHA512:
6
- metadata.gz: 75337929b944b69e856984a511b0effd6dd2a423faa10797ad5f6076ea4355937405f703c8ee1fac7e07fb113c43f9e8f1245bf0716f2bfba8d961e9f197b56f
7
- data.tar.gz: 6de295696e362347d39c307056046b1b3145c204b370bc175a25806f2d39a21f631b4a0da6b8893a130b39a5d850fc72de1ee502e354b15e7e54e87608e3db71
6
+ metadata.gz: 46d99c4def159a8735ccde82c82a0883ecd912259a58895677314f6f2856cac44ef5d074cb6d1cd5ea1bb0ae151a79722cac7e415497284c18d183890a4ce5a3
7
+ data.tar.gz: f22bfd676a924611d4c5bfd5a9cbeeaef02be68ea9f19d81244663909c506442d852ab38287efa428b8dff4e9b6134fe8f2d81e14a3a1b69a8cd7d5cba9c46ef
@@ -1,3 +1,4 @@
1
+ require "time_diff"
1
2
  require "wes/data/api/brand"
2
3
  require "wes/data/api/challenge"
3
4
  require "woody/decorators/base"
@@ -10,12 +11,25 @@ module Woody
10
11
  brand.name
11
12
  end
12
13
 
14
+ def concept_questions
15
+ questions.fetch("concept", {})
16
+ end
17
+
18
+ def draft?
19
+ status == "Draft"
20
+ end
21
+
22
+ def ended?
23
+ @model.status == "published" &&
24
+ DateTime.parse(@model.end_date) < DateTime.now
25
+ end
26
+
13
27
  def essentials_questions
14
28
  questions.fetch("essentials", {})
15
29
  end
16
30
 
17
- def concept_questions
18
- questions.fetch("concept", {})
31
+ def exist?
32
+ !@model.nil?
19
33
  end
20
34
 
21
35
  def reward_total
@@ -30,6 +44,10 @@ module Woody
30
44
  purchased_videos > 0 ? "Complete" : "Video Review"
31
45
  end
32
46
 
47
+ def time_left
48
+ Time.diff(DateTime.now, @model.end_date, "%d %H")[:diff]
49
+ end
50
+
33
51
  private
34
52
 
35
53
  def questions
@@ -1,4 +1,3 @@
1
- require "time_diff"
2
1
  require "wes/data/api/challenge"
3
2
  require "woody/decorators/base"
4
3
  require "woody/decorators/challenge"
@@ -11,20 +10,6 @@ module Woody
11
10
  Wes::Data::API::Challenge.find(:id, @model.challenge_id)
12
11
  )
13
12
  end
14
-
15
- def complete?
16
- @model.end_date < now
17
- end
18
-
19
- def time_left
20
- Time.diff(now, end_date, "%d %H")[:diff]
21
- end
22
-
23
- private
24
-
25
- def now
26
- @now ||= DateTime.now
27
- end
28
13
  end
29
14
  end
30
15
  end
@@ -1,3 +1,4 @@
1
+ require "wes/cloudkit"
1
2
  require "wes/data/api/brand"
2
3
  require "wes/data/api/challenge"
3
4
  require "wes/data/api/submission"
@@ -13,7 +14,7 @@ module Woody
13
14
  end
14
15
 
15
16
  def aspect_ratio
16
- aspect_ratios.sample
17
+ "landscape_ar16-9" # TODO
17
18
  end
18
19
 
19
20
  def brand
@@ -27,10 +28,12 @@ module Woody
27
28
  end
28
29
 
29
30
  def gif
31
+ return "https://i.imgur.com/jZCPUYx.gif" if dev?
30
32
  video_transcoding_state("gif").path(filename_hash)
31
33
  end
32
34
 
33
35
  def thumbnail
36
+ return "https://i.imgur.com/jZCPUYx.gif" if dev?
34
37
  video_transcoding_state("gif").path(
35
38
  filename_hash,
36
39
  "thumbnail",
@@ -39,10 +42,12 @@ module Woody
39
42
  end
40
43
 
41
44
  def processed?
45
+ return true if dev?
42
46
  type_processed?("gif") && type_processed?("mp4")
43
47
  end
44
48
 
45
49
  def url
50
+ return dev_url if dev?
46
51
  video_transcoding_state("mp4").path(filename_hash)
47
52
  end
48
53
 
@@ -52,6 +57,10 @@ module Woody
52
57
  @app_config ||= @config.app
53
58
  end
54
59
 
60
+ def aws_config
61
+ @aws_config ||= @config.aws
62
+ end
63
+
55
64
  def aspect_ratios
56
65
  [
57
66
  "square",
@@ -62,6 +71,17 @@ module Woody
62
71
  ]
63
72
  end
64
73
 
74
+ def dev?
75
+ Wes::Cloudkit.dev?
76
+ end
77
+
78
+ def dev_url
79
+ format(
80
+ "%s/%s/%s",
81
+ aws_config["s3_endpoint"], aws_config["s3_bucket"], @model.url_path
82
+ )
83
+ end
84
+
65
85
  def filename_hash
66
86
  @model.file_name.split(".").first
67
87
  end
@@ -13,7 +13,7 @@ module Woody
13
13
  end
14
14
 
15
15
  def path(filename, render_type = nil, default = "")
16
- type = render_type ? render_type : attributes.type
16
+ type = render_type ? render_type : @model.type
17
17
  suffix = format_suffix(type)
18
18
  complete? ? [s3_base, filename, suffix].join("/") : default
19
19
  end
@@ -1,5 +1,5 @@
1
1
  module Woody
2
2
  module Decorators
3
- VERSION = "0.8.0".freeze
3
+ VERSION = "0.9.0".freeze
4
4
  end
5
5
  end
@@ -25,5 +25,6 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_dependency "json"
27
27
  spec.add_dependency "time_diff", "~> 0"
28
+ spec.add_dependency "wes-cloudkit", "~> 3"
28
29
  spec.add_dependency "wes-data-api", "~> 5"
29
30
  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: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-18 00:00:00.000000000 Z
11
+ date: 2016-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: wes-cloudkit
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: wes-data-api
113
127
  requirement: !ruby/object:Gem::Requirement