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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +11 -12
- data/app/models/catarse_monkeymail/mailchimp_api.rb +1 -1
- data/app/models/catarse_monkeymail/project_concern.rb +7 -3
- data/app/models/catarse_monkeymail/user_concern.rb +8 -2
- data/lib/catarse_monkeymail/configuration.rb +12 -0
- data/lib/catarse_monkeymail/version.rb +1 -1
- data/lib/catarse_monkeymail.rb +12 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1247a7a478711d37a17517dfd68216b55f04e751
|
4
|
+
data.tar.gz: b795876b793aeae70001dc286ec8dc61bbc6e578
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8158e6dba59214c16827806baed99271a0492f8837dba994979e6094c0489e678c63734a663b9292ffe69833f1a726ce8aadc2a1c4b1a5b891a7fee78c9763e
|
7
|
+
data.tar.gz: 4b6ff56672476ac42a9a085cbdef518fd5d746f39b7d39c2dfbb15c7a1cf727bb8ea8ebfc2bcca2e9df18b16fbc847cd59af5eba04e4220e36dab476c3e5bc09
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# CatarseMonkeymail
|
2
2
|
|
3
|
-
Mailchimp 2.0 integration for 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
|
-
|
17
|
+
#### Create a config/initializers/monkeymail.rb and put
|
18
18
|
|
19
|
-
|
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
|
-
|
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.
|
@@ -7,16 +7,20 @@ module CatarseMonkeymail::ProjectConcern
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def subscribe_owner_to_success_list
|
10
|
-
subscribe_to_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
|
14
|
+
subscribe_to_list monkey_settings.failed_projects_list
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
18
18
|
|
19
|
-
def
|
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
|
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
|
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
|
data/lib/catarse_monkeymail.rb
CHANGED
@@ -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.
|
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-
|
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
|