woody-decorators 1.4.1 → 2.0.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: a8cb244d781bfa1025da6fdc3bd6af5bb1f58ce8
4
- data.tar.gz: 485f1d4a6a2e7e54dbe70996f8a8219a7b5315f7
3
+ metadata.gz: 96f41a3deba0d2e3b2b596713003fbfdca6f13d5
4
+ data.tar.gz: 5bc6fd4b221b075a661a86cddef0b05875b87fea
5
5
  SHA512:
6
- metadata.gz: 8a8ee42cfd3a9bd4a29ca4af1a2cc44f34b65e1899a1a2d582e5dba0d1abffaadc11d00119907fd27cca9c522918343478bbd53004f23d720444fbd7d0fc16e3
7
- data.tar.gz: 445ebe77e427e6a8018ee985ae9a315be1cca0b9a99148648ff0ceddb43f1b4df6f77f8959865d73470128171b2dc9a1d20896cae3c307c1bcae5dbc114b8381
6
+ metadata.gz: 1b5d1bc5d6eb74bc24c7dd679534c3a2b6e3599bf7ad0e341708e7a27652938f2038fce7d143b23a720b3f3d67bde6153eb506a6298daefba8f646a3aa68aae9
7
+ data.tar.gz: 3fb7ca4ffa4143704b38836fdb08fba48e29a4c32522b655be025e83a01a7b1030cd9cd6508f3c8b31123969ba861157cca7d83c4db52aaf3120cdcd6702a354
@@ -4,11 +4,7 @@ module Woody
4
4
  module Decorators
5
5
  class BrandUser < User
6
6
  def avatar
7
- default_avatar
8
- end
9
-
10
- def default_avatars
11
- 1
7
+ super("brands")
12
8
  end
13
9
  end
14
10
  end
@@ -12,7 +12,7 @@ module Woody
12
12
  end
13
13
 
14
14
  def concept_questions
15
- questions.fetch("concept", {})
15
+ questions.fetch("concept") { {} }
16
16
  end
17
17
 
18
18
  def draft?
@@ -25,7 +25,7 @@ module Woody
25
25
  end
26
26
 
27
27
  def essentials_questions
28
- questions.fetch("essentials", {})
28
+ questions.fetch("essentials") { {} }
29
29
  end
30
30
 
31
31
  def exist?
@@ -57,9 +57,7 @@ module Woody
57
57
  def questions
58
58
  @questions ||= Wes::Data::API::Challenge.questions.map do |question|
59
59
  ChallengeQuestion.new(question, @model.answers)
60
- end.group_by do |question|
61
- question.section
62
- end
60
+ end.group_by(&:section)
63
61
  end
64
62
 
65
63
  def brand
@@ -4,8 +4,8 @@ module Woody
4
4
  module Decorators
5
5
  class ChallengeQuestion < Base
6
6
  def initialize(model, answers)
7
- super(model)
8
7
  @answers = answers
8
+ super(model)
9
9
  end
10
10
 
11
11
  def answer
@@ -13,8 +13,8 @@ module Woody
13
13
  answer_item ? answer_item.answer : ""
14
14
  end
15
15
 
16
- def has_answer?
17
- answer_for_question(@model.id)
16
+ def answered?
17
+ answer_for_question(@model.id).nil? ? false : true
18
18
  end
19
19
 
20
20
  def text_type?
@@ -3,8 +3,8 @@ require "woody/decorators/user"
3
3
  module Woody
4
4
  module Decorators
5
5
  class CreatorUser < User
6
- def default_avatars
7
- 5
6
+ def avatar
7
+ super("creator")
8
8
  end
9
9
 
10
10
  def location
@@ -14,6 +14,12 @@ module Woody
14
14
  def portfolio_url
15
15
  format("/u/%s", @model.portfolio_username)
16
16
  end
17
+
18
+ protected
19
+
20
+ def default_avatars
21
+ 5
22
+ end
17
23
  end
18
24
  end
19
25
  end
@@ -8,8 +8,10 @@ module Woody
8
8
  super(model)
9
9
  end
10
10
 
11
- def avatar
12
- @model.onboarded ? user_avatar : default_avatar
11
+ def avatar(platform)
12
+ invalid_platform(platform) unless %w(creator brands).include?(platform)
13
+ return user_avatar(platform) if platform == "brands"
14
+ @model.onboarded ? user_avatar(platform) : default_avatar(platform)
13
15
  end
14
16
 
15
17
  def exist?
@@ -34,18 +36,25 @@ module Woody
34
36
 
35
37
  private
36
38
 
37
- def default_avatar
39
+ def default_avatar(platform)
38
40
  r = rand(1..default_avatars)
39
41
  format(
40
- "%s/%s/%s/00%d.png",
41
- @config.s3_domain, @config.public_s3_bucket, @config.s3_avatar_path, r
42
+ "%s/%s/%s/avatars/00%d.png",
43
+ @config.s3_domain, @config.public_s3_bucket, platform, r
42
44
  )
43
45
  end
44
46
 
45
- def user_avatar
47
+ def invalid_platform(platform)
48
+ raise(
49
+ ArgumentError,
50
+ "'#{platform}' is not a supported platform"
51
+ )
52
+ end
53
+
54
+ def user_avatar(platform)
46
55
  format(
47
- "%s/%s/%s/%s.png",
48
- @config.s3_domain, @config.public_s3_bucket, @config.s3_avatar_path, id
56
+ "%s/%s/%s/avatars/%s.png",
57
+ @config.s3_domain, @config.public_s3_bucket, platform, id
49
58
  )
50
59
  end
51
60
  end
@@ -78,7 +78,9 @@ module Woody
78
78
  def dev_url
79
79
  format(
80
80
  "%s/%s/%s",
81
- app_config["s3_domain"], app_config["private_s3_bucket"], @model.url_path
81
+ app_config["s3_domain"],
82
+ app_config["private_s3_bucket"],
83
+ @model.url_path
82
84
  )
83
85
  end
84
86
 
@@ -1,5 +1,5 @@
1
1
  module Woody
2
2
  module Decorators
3
- VERSION = "1.4.1".freeze
3
+ VERSION = "2.0.0".freeze
4
4
  end
5
5
  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: 1.4.1
4
+ version: 2.0.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-20 00:00:00.000000000 Z
11
+ date: 2016-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler