launch_control 0.4.0 → 0.4.1

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: 862084a345e31444834f1be53cabc41e7c2ca9fa
4
- data.tar.gz: 97ba4842f3be6640dfc571c0bda30fbf177092d9
3
+ metadata.gz: e6ca5a72db16aac918a2604d405c7633cf386907
4
+ data.tar.gz: ca9f3df4166bc41e187786f3857f73499d4c03ee
5
5
  SHA512:
6
- metadata.gz: ea6f1112b7f95097cece49d81452ff1e5d731b1bcb15aa62e1c15b4bd5c87a7b545859cd7fda5723e86a323a348e8e415d48656ae06acb283b362102352e9390
7
- data.tar.gz: c5e0495a06647b62bb5a180f04476c419bc1cd030a64c7598a274d52f75961a25b6f197faf5db666aed169272696f6c99e75c1b9e0d7c08e1bd7234d78e47cc4
6
+ metadata.gz: 64f62077388716398fee4dbb881dcf1c29cc7038da4f6d23a083688491bacabf37fb321334d197b091fcfa35bc2b75d1b2246d7c5c74538203d9346afbbf0765
7
+ data.tar.gz: cefceac0ff5419c5c448fc4fc5b97f59f5517104c6abb953366797ecf273691538208fc5d4cb1564f57568a1e54007a01bb3efede087f10acaaa508032c312ce
@@ -35,5 +35,6 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency "rspec", '~> 3.2', ">= 3.2.0"
36
36
  spec.add_development_dependency "pry", '~> 0.9', ">= 0.9.12"
37
37
  spec.add_development_dependency "webmock"
38
+ spec.add_development_dependency "byebug"
38
39
  spec.add_development_dependency "simplecov", '~> 0.10', ">= 0.10.0"
39
40
  end
@@ -73,7 +73,7 @@ module LaunchControl
73
73
  end
74
74
 
75
75
  def valid?
76
- !!(@to && @subject && @template_id)
76
+ !!(@to && @template_id)
77
77
  end
78
78
 
79
79
  private
@@ -38,15 +38,18 @@ module LaunchControl
38
38
  default_email_contract.merge!(validations)
39
39
  end
40
40
 
41
+ def defaults
42
+ {}
43
+ end
44
+
41
45
  def merged_options(options)
42
- options
46
+ defaults.merge(options)
43
47
  end
44
48
 
45
- def deliver!(options)
46
- options = merged_options(options)
47
- launch = LaunchControl::Mailer.new(template, options)
49
+ def deliver!(options = {})
50
+ launch = LaunchControl::Mailer.new(template, merged_options(options))
48
51
  raise ContractFailure.new(error_string) unless valid?(options) && launch.valid?
49
- valid?(options) && launch.valid? && launch.deliver
52
+ launch.deliver
50
53
  end
51
54
 
52
55
  def deliver(options)
@@ -55,14 +58,15 @@ module LaunchControl
55
58
  end
56
59
 
57
60
  def default_email_contract
61
+ # Note that subject is not required as it can be set in Mandrill
58
62
  {
59
- to: lambda { |to| [Array,String,Hash].include?(to.class) },
60
- subject: 'string'
63
+ to: lambda { |to| [Array,String,Hash].include?(to.class) && to.present? }
61
64
  }
62
65
  end
63
66
 
64
- def valid?(options)
65
- validator = HashValidator.validate(options, merged_contract)
67
+ def valid?(options = {})
68
+ merged_options = merged_options(options)
69
+ validator = HashValidator.validate(merged_options, merged_contract)
66
70
  if validator.valid?
67
71
  true
68
72
  else
@@ -76,5 +80,9 @@ module LaunchControl
76
80
  "#{attr} #{message}"
77
81
  }.join(', ')
78
82
  end
83
+
84
+ def string_present?
85
+ lambda { |value| value.class == String && value.present? }
86
+ end
79
87
  end
80
88
  end
@@ -1,3 +1,3 @@
1
1
  module LaunchControl
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: launch_control
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Teague
@@ -146,6 +146,20 @@ dependencies:
146
146
  - - ">="
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
+ - !ruby/object:Gem::Dependency
150
+ name: byebug
151
+ requirement: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ type: :development
157
+ prerelease: false
158
+ version_requirements: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
149
163
  - !ruby/object:Gem::Dependency
150
164
  name: simplecov
151
165
  requirement: !ruby/object:Gem::Requirement