crusade 0.8.0 → 0.8.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: e7c9ad5a87057eb2d7f67cf5f7b8678781957c45
4
- data.tar.gz: 52767d108623c74a0e39f0a2e241041dfabb4278
3
+ metadata.gz: 7fecf82740f5e248c140475ca842ec747f1452de
4
+ data.tar.gz: 800d6e400a446abeb6fba9a92d21338027c8bffb
5
5
  SHA512:
6
- metadata.gz: ba9d3401ce6992572c5fe4ae464614926cce9c51097eeea67c0660bbd591f78b091a8ced2890b2e3355c63ece5a9ee5907f3448793a3bd2931b90e0d8d21c037
7
- data.tar.gz: e65bb8f57d097a97c1870df8a28de1e0d3bf518113603321884e971f5d0b9072346fd1fe4770599c0dcb42595d6fa116b80dbe60e7be8361c19385d88e9ac64f
6
+ metadata.gz: 9bb0290d7c104ff7fa1d15587fa8c5ba4293876f397ac8252046615ae89ea0ff837495276ed18134142c49bd4b69de0c14f94e2917a68d1300ca5558c4356997
7
+ data.tar.gz: efc9b2061001c5f1958cbf446d082ce694910ac1853e7f09b26c1271dab46960376d97f274e427f67443ca77677261fd12314f8a9620a511e0073c302852c46d
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in crusade.gemspec
4
- gemspec
4
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- crusade (0.8.0)
4
+ crusade (0.8.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -36,6 +36,7 @@ module Crusade
36
36
  private
37
37
 
38
38
  def register_plugin plugin
39
+ require "crusade/#{plugin}"
39
40
  self.class.send(:attr_accessor, plugin)
40
41
  config = load_plugin_configuration plugin
41
42
  self.send("#{plugin}=", configuration_class_for(plugin).new(config))
@@ -0,0 +1,12 @@
1
+ module Crusade
2
+ class Notification
3
+ attr_accessor :title, :body, :action, :url_args, :device_token
4
+
5
+ def initialize(attrs = {} )
6
+ self.title = attrs.fetch(:title) { nil }
7
+ self.body = attrs.fetch(:body) { nil }
8
+ self.action = attrs.fetch(:action) { nil }
9
+ self.url_args = attrs.fetch(:url_args) { [] }
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,44 @@
1
+ require 'crusade/notification'
2
+
3
+ module Crusade
4
+ class NotificationBuilder
5
+
6
+ def initialize
7
+ self.notification = Crusade::Notification.new
8
+ end
9
+
10
+ def build
11
+ notification
12
+ end
13
+
14
+ def with_title(title)
15
+ notification.title = title
16
+ self
17
+ end
18
+
19
+ def with_body(body)
20
+ notification.body = body
21
+ self
22
+ end
23
+
24
+ def with_action(action)
25
+ notification.action = action
26
+ self
27
+ end
28
+
29
+ def with_url_args(url_args)
30
+ notification.url_args = url_args
31
+ self
32
+ end
33
+
34
+ def with_device_token(device_token)
35
+ notification.device_token = device_token
36
+ self
37
+ end
38
+
39
+ private
40
+
41
+ attr_accessor :notification
42
+
43
+ end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module Crusade
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
@@ -0,0 +1,4 @@
1
+ module Crusade::APNS
2
+ class Configuration < OpenStruct
3
+ end
4
+ end
@@ -3,11 +3,6 @@ require File.expand_path '../../test_helper.rb', __FILE__
3
3
  require 'crusade/configuration'
4
4
  require 'ostruct'
5
5
 
6
- module Crusade::APNS
7
- class Configuration < OpenStruct
8
- end
9
- end
10
-
11
6
  describe Crusade do
12
7
 
13
8
  describe 'config' do
@@ -0,0 +1,76 @@
1
+ require File.expand_path '../../test_helper.rb', __FILE__
2
+
3
+ require 'crusade/notification_builder'
4
+
5
+ describe Crusade::NotificationBuilder do
6
+ let(:described_class) { Crusade::NotificationBuilder }
7
+ subject { described_class.new }
8
+
9
+ describe 'build' do
10
+ it' creates a notification' do
11
+ notification = subject.build
12
+
13
+ notification.is_a?(Crusade::Notification).must_be_true
14
+ end
15
+ end
16
+
17
+ describe 'with_title' do
18
+ it 'returns the builder' do
19
+ subject.with_title('test').must_be_same_as subject
20
+ end
21
+
22
+ it 'sets the title of the notification' do
23
+ notif = subject.with_title('test').build
24
+
25
+ notif.title.must_equal 'test'
26
+ end
27
+ end
28
+
29
+ describe 'with_body' do
30
+ it 'returns the builder' do
31
+ subject.with_body('test').must_be_same_as subject
32
+ end
33
+
34
+ it 'sets the body of the notification' do
35
+ notif = subject.with_body('test').build
36
+
37
+ notif.body.must_equal 'test'
38
+ end
39
+ end
40
+
41
+ describe 'with_action' do
42
+ it 'returns the builder' do
43
+ subject.with_action('test').must_be_same_as subject
44
+ end
45
+
46
+ it 'sets the action of the notification' do
47
+ notif = subject.with_action('test').build
48
+
49
+ notif.action.must_equal 'test'
50
+ end
51
+ end
52
+
53
+ describe 'with_url_args' do
54
+ it 'returns the builder' do
55
+ subject.with_url_args('test').must_be_same_as subject
56
+ end
57
+
58
+ it 'sets the url_args of the notification' do
59
+ notif = subject.with_url_args(['test']).build
60
+
61
+ notif.url_args.must_equal ['test']
62
+ end
63
+ end
64
+
65
+ describe 'with_device_token' do
66
+ it 'returns the builder' do
67
+ subject.with_device_token('test').must_be_same_as subject
68
+ end
69
+
70
+ it 'sets the url_args of the notification' do
71
+ notif = subject.with_device_token('test').build
72
+
73
+ notif.device_token.must_equal 'test'
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,52 @@
1
+ require File.expand_path '../../test_helper.rb', __FILE__
2
+
3
+ require 'crusade/notification'
4
+
5
+ require 'json'
6
+
7
+ describe Crusade::Notification do
8
+ let(:described_class) { Crusade::Notification }
9
+
10
+ let(:attrs) do
11
+ {
12
+ title: 'the title',
13
+ body: 'the body',
14
+ action: 'submit',
15
+ url_args: ['a'],
16
+ device_token: '1234a'
17
+ }
18
+ end
19
+
20
+ describe 'initialize' do
21
+ subject { described_class.new }
22
+
23
+ it 'initializes the title' do
24
+ subject.title.must_be_nil
25
+ end
26
+
27
+ it 'initializes the body' do
28
+ subject.body.must_be_nil
29
+ end
30
+
31
+ it 'initializes the action' do
32
+ subject.action.must_be_nil
33
+ end
34
+
35
+ it 'initializes the url_args' do
36
+ subject.url_args.must_equal []
37
+ end
38
+
39
+ it 'initializes the device_token' do
40
+ subject.device_token.must_be_nil
41
+ end
42
+
43
+ describe 'with a hash' do
44
+ subject { described_class.new attrs }
45
+
46
+ it { subject.title.must_equal 'the title' }
47
+ it { subject.body.must_equal 'the body' }
48
+ it { subject.action.must_equal 'submit' }
49
+ it { subject.url_args.must_equal ['a'] }
50
+ end
51
+ end
52
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crusade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rouchy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-22 00:00:00.000000000 Z
11
+ date: 2013-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,13 +112,18 @@ files:
112
112
  - lib/crusade.rb
113
113
  - lib/crusade/configuration.rb
114
114
  - lib/crusade/logger.rb
115
+ - lib/crusade/notification.rb
116
+ - lib/crusade/notification_builder.rb
115
117
  - lib/crusade/null_logger.rb
116
118
  - lib/crusade/version.rb
117
119
  - test/fixtures/config.yml
120
+ - test/support/crusade/apns.rb
118
121
  - test/support/fake_logger.rb
119
122
  - test/test_helper.rb
120
123
  - test/unit/configuration_test.rb
121
124
  - test/unit/logger_test.rb
125
+ - test/unit/notification_builder_test.rb
126
+ - test/unit/notification_test.rb
122
127
  - test/unit/null_logger_test.rb
123
128
  homepage: ''
124
129
  licenses:
@@ -146,8 +151,11 @@ specification_version: 4
146
151
  summary: push some notification through APNS
147
152
  test_files:
148
153
  - test/fixtures/config.yml
154
+ - test/support/crusade/apns.rb
149
155
  - test/support/fake_logger.rb
150
156
  - test/test_helper.rb
151
157
  - test/unit/configuration_test.rb
152
158
  - test/unit/logger_test.rb
159
+ - test/unit/notification_builder_test.rb
160
+ - test/unit/notification_test.rb
153
161
  - test/unit/null_logger_test.rb