catarse_monkeymail 0.1.0 → 0.1.2

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: b8c10b2d656c25d1a87740a6a1db89f0626edcc5
4
- data.tar.gz: 5c8c04851d06667855487dd077dd94c44855c3b8
3
+ metadata.gz: 1247a7a478711d37a17517dfd68216b55f04e751
4
+ data.tar.gz: b795876b793aeae70001dc286ec8dc61bbc6e578
5
5
  SHA512:
6
- metadata.gz: c9b053d4cc053855fe2fc62d2b0234574af004d29c9c1abf7523fdc75f9abc3e939619ebaa57bba3651148a11ced6e23517149bff89f555bdf625d23502d59ce
7
- data.tar.gz: 61dd7f826f713639ca2f6119861c882fcf216b2898dff898d87d3319f1d7d3bf470e8ce1a10d20376692ee23b4f77147951f6e3ecb8ebd92d2ba90c833284878
6
+ metadata.gz: c8158e6dba59214c16827806baed99271a0492f8837dba994979e6094c0489e678c63734a663b9292ffe69833f1a726ce8aadc2a1c4b1a5b891a7fee78c9763e
7
+ data.tar.gz: 4b6ff56672476ac42a9a085cbdef518fd5d746f39b7d39c2dfbb15c7a1cf727bb8ea8ebfc2bcca2e9df18b16fbc847cd59af5eba04e4220e36dab476c3e5bc09
data/Gemfile.lock CHANGED
@@ -28,7 +28,7 @@ GIT
28
28
  PATH
29
29
  remote: .
30
30
  specs:
31
- catarse_monkeymail (0.1.0)
31
+ catarse_monkeymail (0.1.1)
32
32
  mailchimp-api (~> 2.0.4)
33
33
  rails (~> 4.0.3)
34
34
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # CatarseMonkeymail
2
2
 
3
- Mailchimp 2.0 integration for Catarse[http://github.com/catarse/catarse]
3
+ Mailchimp 2.0 integration for [Catarse](http://github.com/catarse/catarse)
4
4
 
5
5
 
6
6
  ## Installation
@@ -14,24 +14,23 @@ or
14
14
  `gem install catarse_monkeymail`
15
15
 
16
16
 
17
- You need to have a Mailchimp API KEY and a List ID configured:
17
+ #### Create a config/initializers/monkeymail.rb and put
18
18
 
19
- `CatarseSettings[:mailchimp_api_key] = 'YOUR_API_KEY'`
19
+ ~~~
20
+ CatarseMonkeymail.configure do |config|
21
+ config.mailchimp_api_key = 'YOUR_API_KEY'
22
+ config.mailchimp_list_id = 'YOUR_NEWSLETTER_LIST_ID'
23
+ config.mailchimp_successful_projects_list = 'YOUR_PROJECT_SUCCESSFUL_LIST_ID'
24
+ config.mailchimp_failed_projects_list = 'YOUR_PROJECT_FAILED_LIST_ID'
25
+ end
26
+ ~~~
20
27
 
21
- `CatarseSettings[:mailchimp_list_id] = 'YOUR_NEWSLETTER_LIST_ID'`
28
+ by default we use the `::CatarseSettings` class
22
29
 
23
30
 
24
- ### If you want to use the project mailchimp integration (when project is failed or successful we add the project owner to a separated list) you need to:
25
-
26
31
  #### Add into config/application.rb
27
32
 
28
33
  `config.active_record.observers = 'CatarseMonkeymail::MonkeyProjectObserver'`
29
34
 
30
- #### Add theses configurations:
31
-
32
- `CatarseSettings[:mailchimp_successful_projects_list] = 'YOUR_PROJECT_SUCCESSFUL_LIST_ID'`
33
-
34
- `CatarseSettings[:mailchimp_failed_projects_list] = 'YOUR_PROJECT_FAILED_LIST_ID'`
35
-
36
35
 
37
36
  This project rocks and uses MIT-LICENSE.
@@ -3,7 +3,7 @@ require 'mailchimp'
3
3
  module CatarseMonkeymail
4
4
  class MailchimpApi
5
5
  def self.start
6
- @mailchimp ||= ::Mailchimp::API.new(::CatarseSettings[:mailchimp_api_key])
6
+ @mailchimp ||= ::Mailchimp::API.new(::CatarseMonkeymail.configuration.api_key)
7
7
  end
8
8
  end
9
9
  end
@@ -7,16 +7,20 @@ module CatarseMonkeymail::ProjectConcern
7
7
  end
8
8
 
9
9
  def subscribe_owner_to_success_list
10
- subscribe_to_list ::CatarseSettings[:mailchimp_successful_projects_list]
10
+ subscribe_to_list monkey_settings.successful_projects_list
11
11
  end
12
12
 
13
13
  def subscribe_owner_to_failed_list
14
- subscribe_to_list ::CatarseSettings[:mailchimp_failed_projects_list]
14
+ subscribe_to_list monkey_settings.failed_projects_list
15
15
  end
16
16
 
17
17
  private
18
18
 
19
- def subscribe_to_list list_id
19
+ def monkey_settings
20
+ ::CatarseMonkeymail.configuration
21
+ end
22
+
23
+ def subscribe_to_list(list_id)
20
24
  mailchimp.lists.subscribe list_id, { email: self.user.email }, subscriber_args
21
25
  end
22
26
 
@@ -23,11 +23,17 @@ module CatarseMonkeymail::UserConcern
23
23
  end
24
24
 
25
25
  def subscribe_to_newsletter_list
26
- mailchimp.lists.subscribe ::CatarseSettings[:mailchimp_list_id], { email: self.email }, { name: self.name }
26
+ mailchimp.lists.subscribe monkey_settings.list_id, { email: self.email }, { name: self.name }
27
27
  end
28
28
 
29
29
  def unsubscribe_from_newsletter_list email_arg = self.email
30
- mailchimp.lists.unsubscribe ::CatarseMonkeymail[:mailchimp_list_id], { email: email_arg }
30
+ mailchimp.lists.unsubscribe monkey_settings.list_id, { email: email_arg }
31
+ end
32
+
33
+ private
34
+
35
+ def monkey_settings
36
+ ::CatarseMonkeymail.configuration
31
37
  end
32
38
 
33
39
  end
@@ -0,0 +1,12 @@
1
+ module CatarseMonkeymail
2
+ class Configuration
3
+ attr_accessor :api_key, :list_id, :successful_projects_list, :failed_projects_list
4
+
5
+ def inititalizer
6
+ @api_key = ''
7
+ @list_id = ''
8
+ @successful_projects_list = ''
9
+ @failed_projects_list = ''
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module CatarseMonkeymail
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,4 +1,16 @@
1
1
  require "catarse_monkeymail/engine"
2
+ require "catarse_monkeymail/configuration"
2
3
 
3
4
  module CatarseMonkeymail
5
+ class << self
6
+ attr_writer :configuration
7
+ end
8
+
9
+ def self.configuration
10
+ @configuration ||= Configuration.new
11
+ end
12
+
13
+ def self.configure
14
+ yield(configuration)
15
+ end
4
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: catarse_monkeymail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antônio Roberto Silva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-29 00:00:00.000000000 Z
11
+ date: 2014-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -77,6 +77,7 @@ files:
77
77
  - catarse_monkeymail.gemspec
78
78
  - config/routes.rb
79
79
  - lib/catarse_monkeymail.rb
80
+ - lib/catarse_monkeymail/configuration.rb
80
81
  - lib/catarse_monkeymail/engine.rb
81
82
  - lib/catarse_monkeymail/version.rb
82
83
  - lib/tasks/catarse_monkeymail_tasks.rake