woody-decorators 4.1.1 → 4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ad92d64bff6a18c1a831b9c9e87e3af7ed00c1f
4
- data.tar.gz: 47734f3cdefa1dce0f621660be2fea7306c3de9d
3
+ metadata.gz: 1fc09a74ca4f0feee5447dde1332e39d2d16a852
4
+ data.tar.gz: d35a90590e2bbf6b110d564199e934dbeac3133a
5
5
  SHA512:
6
- metadata.gz: 640a2a309fbb4645e66b502f977ba3ce9aabfed20cc8c88e4966cbea0418841df027f4e8c1ea1f997b840aa2ce2b19fe8414a27e78f51c4a843867d4d9577f62
7
- data.tar.gz: 33dbe21b1bf96f37963920bdc2b5e79e3f7cde3ee71604c95fa581c2f575fc36343a14df9688905c71ad6ffa4599c01c971d8a3edd3f0a74b8d9a00d8a7fb76a
6
+ metadata.gz: 6533571e535ab88201ef18a34af152cd5432558ecfa988ead13eb2c579cbe760d3008314bd2d56600fa779fbe136a7e9833fb986920b1387060d59f7deeaae35
7
+ data.tar.gz: 60f3a495ef16536c6e574f101131a959ba706ab57104e5c2376f0d6ea2b825590414b3b4f86963aeb1df33b56a9975295aa4ddfd37b495b99c67d6e95b41dcd5
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
@@ -1,5 +1,5 @@
1
1
  module Woody
2
2
  module Decorators
3
- VERSION = "4.1.1".freeze
3
+ VERSION = '4.2.0'.freeze
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
- require "woody/decorators/base"
2
- require "woody/decorators/challenge"
1
+ require 'woody/decorators/base'
2
+ require 'woody/decorators/challenge'
3
3
 
4
4
  module Woody
5
5
  module Decorators
@@ -1,10 +1,10 @@
1
- require "woody/decorators/user"
1
+ require 'woody/decorators/user'
2
2
 
3
3
  module Woody
4
4
  module Decorators
5
5
  class BrandUser < User
6
6
  def avatar
7
- super("brands")
7
+ super('brands')
8
8
  end
9
9
  end
10
10
  end
@@ -1,8 +1,8 @@
1
- require "time_diff"
2
- require "wes/data/api/brand"
3
- require "wes/data/api/challenge"
4
- require "woody/decorators/base"
5
- require "woody/decorators/challenge_question"
1
+ require 'time_diff'
2
+ require 'wes/data/api/brand'
3
+ require 'wes/data/api/challenge'
4
+ require 'woody/decorators/base'
5
+ require 'woody/decorators/challenge_question'
6
6
 
7
7
  module Woody
8
8
  module Decorators
@@ -17,20 +17,20 @@ module Woody
17
17
  end
18
18
 
19
19
  def concept_questions
20
- questions.fetch("concept") { {} }
20
+ questions.fetch('concept') { {} }
21
21
  end
22
22
 
23
23
  def draft?
24
- status == "Draft"
24
+ status == 'Draft'
25
25
  end
26
26
 
27
27
  def ended?
28
- @model.status == "published" &&
28
+ @model.status == 'published' &&
29
29
  DateTime.parse(@model.end_date) < DateTime.now
30
30
  end
31
31
 
32
32
  def essentials_questions
33
- questions.fetch("essentials") { {} }
33
+ questions.fetch('essentials') { {} }
34
34
  end
35
35
 
36
36
  def exist?
@@ -43,10 +43,8 @@ module Woody
43
43
 
44
44
  def image_url
45
45
  format(
46
- "%s/%s/brands/campaign_image/%s",
47
- @config.s3_domain,
48
- @config.public_s3_bucket,
49
- @model.short_hash
46
+ '%s/%s/brands/campaign_image/%s',
47
+ @config.s3_domain, @config.public_s3_bucket, @model.short_hash
50
48
  )
51
49
  end
52
50
 
@@ -57,33 +55,42 @@ module Woody
57
55
  end
58
56
 
59
57
  def status
60
- return "Draft" if @model.status == "draft"
61
- return "Live" if DateTime.parse(@model.end_date) > DateTime.now
62
- purchased_videos > 0 ? "Complete" : "Video Review"
58
+ return 'Draft' if @model.status == 'draft'
59
+ return 'Live' if DateTime.parse(@model.end_date) > DateTime.now
60
+ purchased_videos > 0 ? 'Complete' : 'Video Review'
63
61
  end
64
62
 
65
63
  def time_left
66
- Time.diff(DateTime.now, @model.end_date, "%d %H")[:diff]
64
+ Time.diff(DateTime.now, @model.end_date, '%d %H')[:diff]
65
+ end
66
+
67
+ def title(truncate: false)
68
+ return @model.title unless @model.title.size >= 15 && truncate
69
+ truncate(@model.title, 12)
67
70
  end
68
71
 
69
72
  def public?
70
- @model.type == "public"
73
+ @model.type == 'public'
71
74
  end
72
75
 
73
76
  private
74
77
 
78
+ def brand
79
+ @brand ||= Wes::Data::API::Brand.find(:id, @model.brand_id)
80
+ end
81
+
82
+ def purchased_videos
83
+ @purchased_videos ||= @model.videos(state: 'purchased').size
84
+ end
85
+
75
86
  def questions
76
87
  @questions ||= Wes::Data::API::Challenge.questions.map do |question|
77
88
  ChallengeQuestion.new(question, @model.answers)
78
89
  end.group_by(&:section)
79
90
  end
80
91
 
81
- def brand
82
- @brand ||= Wes::Data::API::Brand.find(:id, @model.brand_id)
83
- end
84
-
85
- def purchased_videos
86
- @purchased_videos ||= @model.videos(state: "purchased").size
92
+ def truncate(s, i)
93
+ format('%s...', s[0..i])
87
94
  end
88
95
  end
89
96
  end
@@ -1,4 +1,4 @@
1
- require "woody/decorators/base"
1
+ require 'woody/decorators/base'
2
2
 
3
3
  module Woody
4
4
  module Decorators
@@ -10,7 +10,7 @@ module Woody
10
10
 
11
11
  def answer
12
12
  answer_item = answer_for_question(@model.id)
13
- answer_item ? answer_item.answer : ""
13
+ answer_item ? answer_item.answer : ''
14
14
  end
15
15
 
16
16
  def answered?
@@ -18,15 +18,15 @@ module Woody
18
18
  end
19
19
 
20
20
  def text_type?
21
- @model.type == "text"
21
+ @model.type == 'text'
22
22
  end
23
23
 
24
24
  def textarea_type?
25
- @model.type == "textarea"
25
+ @model.type == 'textarea'
26
26
  end
27
27
 
28
28
  def number_type?
29
- @model.type == "number"
29
+ @model.type == 'number'
30
30
  end
31
31
 
32
32
  private
@@ -1,4 +1,4 @@
1
- require "woody/decorators/base"
1
+ require 'woody/decorators/base'
2
2
 
3
3
  module Woody
4
4
  module Decorators
@@ -8,8 +8,8 @@ module Woody
8
8
  super(model)
9
9
  end
10
10
 
11
- def image_src(type = "png")
12
- [s3_base, suffix(type)].join("/")
11
+ def image_src(type = 'png')
12
+ [s3_base, suffix(type)].join('/')
13
13
  end
14
14
 
15
15
  private
@@ -20,10 +20,10 @@ module Woody
20
20
 
21
21
  def s3_base
22
22
  [
23
- app_config["s3_domain"],
24
- app_config["public_s3_bucket"],
25
- "creator/collectives"
26
- ].join("/")
23
+ app_config['s3_domain'],
24
+ app_config['public_s3_bucket'],
25
+ 'creator/collectives'
26
+ ].join('/')
27
27
  end
28
28
 
29
29
  def suffix(type)
@@ -1,10 +1,10 @@
1
- require "woody/decorators/user"
1
+ require 'woody/decorators/user'
2
2
 
3
3
  module Woody
4
4
  module Decorators
5
5
  class CreatorUser < User
6
6
  def avatar
7
- super("creator")
7
+ super('creator')
8
8
  end
9
9
 
10
10
  def location
@@ -12,7 +12,7 @@ module Woody
12
12
  end
13
13
 
14
14
  def portfolio_url
15
- format("/u/%s", @model.portfolio_username)
15
+ format('/u/%s', @model.portfolio_username)
16
16
  end
17
17
 
18
18
  protected
@@ -8,13 +8,13 @@ module Woody
8
8
  end
9
9
 
10
10
  def class_name
11
- return format_class_name("landscape", "16-9") unless valid_dimensions
11
+ return format_class_name('landscape', '16-9') unless valid_dimensions
12
12
 
13
13
  case ratio
14
- when "1:1"
15
- "square"
16
- when "16:9", "4:3", "9:16", "4:5"
17
- format(CLASS_NAME_FORMAT, orientation, ratio("-"))
14
+ when '1:1'
15
+ 'square'
16
+ when '16:9', '4:3', '9:16', '4:5'
17
+ format(CLASS_NAME_FORMAT, orientation, ratio('-'))
18
18
  else
19
19
  format(CLASS_NAME_FORMAT, orientation, default_ratio)
20
20
  end
@@ -22,18 +22,18 @@ module Woody
22
22
 
23
23
  private
24
24
 
25
- CLASS_NAME_FORMAT = "%s_ar%s".freeze
25
+ CLASS_NAME_FORMAT = '%s_ar%s'.freeze
26
26
 
27
27
  def format_class_name(orientation, ratio)
28
28
  format(CLASS_NAME_FORMAT, orientation, ratio)
29
29
  end
30
30
 
31
31
  def default_ratio
32
- orientation == "landscape" ? "16-9" : "9-16"
32
+ orientation == 'landscape' ? '16-9' : '9-16'
33
33
  end
34
34
 
35
- def ratio(delimiter = ":")
36
- format("%d%s%d", ratio_width, delimiter, ratio_height)
35
+ def ratio(delimiter = ':')
36
+ format('%d%s%d', ratio_width, delimiter, ratio_height)
37
37
  end
38
38
 
39
39
  def gcd
@@ -49,7 +49,7 @@ module Woody
49
49
  end
50
50
 
51
51
  def orientation
52
- @width > @height ? "landscape" : "portrait"
52
+ @width > @height ? 'landscape' : 'portrait'
53
53
  end
54
54
 
55
55
  def valid_dimensions
@@ -1,6 +1,6 @@
1
- require "wes/data/api/challenge"
2
- require "woody/decorators/base"
3
- require "woody/decorators/challenge"
1
+ require 'wes/data/api/challenge'
2
+ require 'woody/decorators/base'
3
+ require 'woody/decorators/challenge'
4
4
 
5
5
  module Woody
6
6
  module Decorators
@@ -1,4 +1,4 @@
1
- require "woody/decorators/base"
1
+ require 'woody/decorators/base'
2
2
 
3
3
  module Woody
4
4
  module Decorators
@@ -10,7 +10,7 @@ module Woody
10
10
 
11
11
  def avatar(platform)
12
12
  invalid_platform(platform) unless %w(creator brands).include?(platform)
13
- return user_avatar(platform) if platform == "brands"
13
+ return user_avatar(platform) if platform == 'brands'
14
14
  @model.onboarded ? user_avatar(platform) : default_avatar(platform)
15
15
  end
16
16
 
@@ -23,7 +23,7 @@ module Woody
23
23
  end
24
24
 
25
25
  def full_name
26
- [first_name, last_name].join(" ")
26
+ [first_name, last_name].join(' ')
27
27
  end
28
28
 
29
29
  def id
@@ -39,7 +39,7 @@ module Woody
39
39
  def default_avatar(platform)
40
40
  r = rand(1..default_avatars)
41
41
  format(
42
- "%s/%s/%s/avatars/00%d.png",
42
+ '%s/%s/%s/avatars/00%d.png',
43
43
  @config.s3_domain, @config.public_s3_bucket, platform, r
44
44
  )
45
45
  end
@@ -53,7 +53,7 @@ module Woody
53
53
 
54
54
  def user_avatar(platform)
55
55
  format(
56
- "%s/%s/%s/avatars/%s.png",
56
+ '%s/%s/%s/avatars/%s.png',
57
57
  @config.s3_domain, @config.public_s3_bucket, platform, id
58
58
  )
59
59
  end
@@ -1,11 +1,11 @@
1
- require "wes/cloudkit"
2
- require "wes/data/api/brand"
3
- require "wes/data/api/challenge"
4
- require "wes/data/api/submission"
5
- require "wes/data/api/creator_user"
6
- require "woody/decorators/base"
7
- require "woody/decorators/video_transcoding_state"
8
- require "woody/decorators/helper/aspect_ratio"
1
+ require 'wes/cloudkit'
2
+ require 'wes/data/api/brand'
3
+ require 'wes/data/api/challenge'
4
+ require 'wes/data/api/submission'
5
+ require 'wes/data/api/creator_user'
6
+ require 'woody/decorators/base'
7
+ require 'woody/decorators/video_transcoding_state'
8
+ require 'woody/decorators/helper/aspect_ratio'
9
9
 
10
10
  module Woody
11
11
  module Decorators
@@ -35,14 +35,13 @@ module Woody
35
35
 
36
36
  def creator
37
37
  @creator ||= @creator_model ? @creator_model : Wes::Data::API::CreatorUser.find(
38
- :id,
39
- submission.user_id
38
+ :id, submission.user_id
40
39
  )
41
40
  end
42
41
 
43
42
  def gif
44
- return "https://i.imgur.com/jZCPUYx.gif" if dev?
45
- video_transcoding_state("gif").path(
43
+ return 'https://i.imgur.com/jZCPUYx.gif' if dev?
44
+ video_transcoding_state('gif').path(
46
45
  filename_hash,
47
46
  nil,
48
47
  processing_image
@@ -50,31 +49,31 @@ module Woody
50
49
  end
51
50
 
52
51
  def thumbnail
53
- return "https://i.imgur.com/jZCPUYx.gif" if dev?
54
- video_transcoding_state("gif").path(
52
+ return 'https://i.imgur.com/jZCPUYx.gif' if dev?
53
+ video_transcoding_state('gif').path(
55
54
  filename_hash,
56
- "thumbnail",
55
+ 'thumbnail',
57
56
  processing_image
58
57
  )
59
58
  end
60
59
 
61
60
  def processed?
62
61
  return true if dev?
63
- type_processed?("gif") && type_processed?("mp4")
62
+ type_processed?('gif') && type_processed?('mp4')
64
63
  end
65
64
 
66
65
  def url
67
66
  return dev_url if dev?
68
- video_transcoding_state("mp4").path(filename_hash)
67
+ video_transcoding_state('mp4').path(filename_hash)
69
68
  end
70
69
 
71
70
  private
72
71
 
73
72
  def processing_image
74
- format(
75
- "%s/%s/shared/video_processing/%s.jpg",
76
- app_config["s3_domain"],
77
- app_config["public_s3_bucket"],
73
+ format(
74
+ '%s/%s/shared/video_processing/%s.jpg',
75
+ app_config['s3_domain'],
76
+ app_config['public_s3_bucket'],
78
77
  rand(1...5)
79
78
  )
80
79
  end
@@ -93,15 +92,15 @@ module Woody
93
92
 
94
93
  def dev_url
95
94
  format(
96
- "%s/%s/%s",
97
- app_config["s3_domain"],
98
- app_config["private_s3_bucket"],
95
+ '%s/%s/%s',
96
+ app_config['s3_domain'],
97
+ app_config['private_s3_bucket'],
99
98
  @model.current_version.url_path
100
99
  )
101
100
  end
102
101
 
103
102
  def filename_hash
104
- @model.current_version.file_name.split(".").first
103
+ @model.current_version.file_name.split('.').first
105
104
  end
106
105
 
107
106
  def submission
@@ -1,4 +1,4 @@
1
- require "woody/decorators/base"
1
+ require 'woody/decorators/base'
2
2
 
3
3
  module Woody
4
4
  module Decorators
@@ -9,13 +9,13 @@ module Woody
9
9
  end
10
10
 
11
11
  def complete?
12
- @model.state == "complete"
12
+ @model.state == 'complete'
13
13
  end
14
14
 
15
- def path(filename, render_type = nil, default = "")
15
+ def path(filename, render_type = nil, default = '')
16
16
  type = render_type ? render_type : @model.type
17
17
  suffix = format_suffix(type)
18
- complete? ? [s3_base, filename, suffix].join("/") : default
18
+ complete? ? [s3_base, filename, suffix].join('/') : default
19
19
  end
20
20
 
21
21
  private
@@ -30,19 +30,19 @@ module Woody
30
30
 
31
31
  def format_suffix(type)
32
32
  case type
33
- when "gif", "mp4"
33
+ when 'gif', 'mp4'
34
34
  "#{etc_config['output_suffix']}.#{type}"
35
- when "thumbnail"
35
+ when 'thumbnail'
36
36
  "#{etc_config['output_suffix']}_00001.png"
37
37
  end
38
38
  end
39
39
 
40
40
  def s3_base
41
41
  [
42
- app_config["s3_domain"],
43
- app_config["public_s3_bucket"],
44
- etc_config["base_prefix"]
45
- ].join("/")
42
+ app_config['s3_domain'],
43
+ app_config['public_s3_bucket'],
44
+ etc_config['base_prefix']
45
+ ].join('/')
46
46
  end
47
47
  end
48
48
  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: 4.1.1
4
+ version: 4.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-29 00:00:00.000000000 Z
11
+ date: 2016-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler