easy_mailchimp 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +12 -0
- data/Guardfile +70 -0
- data/bin/console +4 -3
- data/lib/easy_mailchimp/base.rb +6 -2
- data/lib/easy_mailchimp/configuration.rb +3 -1
- data/lib/easy_mailchimp/logger.rb +28 -0
- data/lib/easy_mailchimp/version.rb +1 -1
- data/lib/easy_mailchimp.rb +2 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aae1d6a158d999f6a24a4c9b7e0d7711557e1544
|
4
|
+
data.tar.gz: 2f3fb0a17a977ed11ce737fa59b8747ba18ba494
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e691a90eac2abb79e995dfbad54d449c3be05aae20448974d7c1ceb8ccd6601efdbada346f5099a1c0890bb3b7d96e91e09ef63a7964c439b5eb07b7ab1eded
|
7
|
+
data.tar.gz: 0c18f5d970a9c49de9b10938743937388025a4ce91386fc660b676d2854acce3c63c15ae273014bbda87b902ee8a769905a7e996b6108042373b87e68f6c47cc
|
data/Gemfile
CHANGED
@@ -2,3 +2,15 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in EasyMailchimp.gemspec
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
group :development, :test do
|
7
|
+
gem 'rb-inotify', require: false
|
8
|
+
gem 'rb-fsevent', require: false
|
9
|
+
gem 'rb-fchange', require: false
|
10
|
+
end
|
11
|
+
|
12
|
+
group :development do
|
13
|
+
gem 'pry'
|
14
|
+
gem 'guard'
|
15
|
+
gem 'guard-rspec', require: false
|
16
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
28
|
+
require "guard/rspec/dsl"
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
# Feel free to open issues for suggestions and improvements
|
32
|
+
|
33
|
+
# RSpec files
|
34
|
+
rspec = dsl.rspec
|
35
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
+
watch(rspec.spec_files)
|
38
|
+
|
39
|
+
# Ruby files
|
40
|
+
ruby = dsl.ruby
|
41
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
+
|
43
|
+
# Rails files
|
44
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
45
|
+
dsl.watch_spec_files_for(rails.app_files)
|
46
|
+
dsl.watch_spec_files_for(rails.views)
|
47
|
+
|
48
|
+
watch(rails.controllers) do |m|
|
49
|
+
[
|
50
|
+
rspec.spec.("routing/#{m[1]}_routing"),
|
51
|
+
rspec.spec.("controllers/#{m[1]}_controller"),
|
52
|
+
rspec.spec.("acceptance/#{m[1]}")
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
# Rails config changes
|
57
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
58
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
59
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
60
|
+
|
61
|
+
# Capybara features specs
|
62
|
+
watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
|
63
|
+
watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
|
64
|
+
|
65
|
+
# Turnip features and steps
|
66
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
67
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
68
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
69
|
+
end
|
70
|
+
end
|
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "bundler/setup"
|
4
|
-
require "
|
4
|
+
require "active_support/configurable"
|
5
|
+
require "easy_mailchimp"
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "EasyMailchimp"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require "
|
14
|
-
|
14
|
+
require "pry"
|
15
|
+
binding.pry
|
data/lib/easy_mailchimp/base.rb
CHANGED
@@ -2,6 +2,8 @@ module EasyMailchimp
|
|
2
2
|
class Base
|
3
3
|
def initialize
|
4
4
|
@config = ::EasyMailchimp.config
|
5
|
+
@logger = ::EasyMailchimp::Logger.new(@config.logger)
|
6
|
+
|
5
7
|
@gibbon = ::Gibbon::Request.new({
|
6
8
|
api_key: @config.api_key,
|
7
9
|
api_endpoint: endpoint,
|
@@ -9,6 +11,8 @@ module EasyMailchimp
|
|
9
11
|
})
|
10
12
|
end
|
11
13
|
|
14
|
+
attr_reader :logger
|
15
|
+
|
12
16
|
def create_member(list_id, info = {})
|
13
17
|
email = info[:email] || ''
|
14
18
|
first_name = info[:first_name] || ''
|
@@ -24,7 +28,7 @@ module EasyMailchimp
|
|
24
28
|
}
|
25
29
|
})
|
26
30
|
rescue ::Gibbon::MailChimpError => ex
|
27
|
-
|
31
|
+
logger.info("ERROR: #{ex.message} - #{ex.raw_body}", 'Mailchimp::Base#create_member')
|
28
32
|
raise
|
29
33
|
end
|
30
34
|
end
|
@@ -37,7 +41,7 @@ module EasyMailchimp
|
|
37
41
|
|
38
42
|
list_map.select { |k,v| k == list_id }.values.first
|
39
43
|
rescue => ex
|
40
|
-
|
44
|
+
logger.info("ERROR: #{ex.message}", 'Mailchimp::Base#get_list_name')
|
41
45
|
raise
|
42
46
|
end
|
43
47
|
|
@@ -11,10 +11,12 @@ module EasyMailchimp
|
|
11
11
|
|
12
12
|
config_accessor :api_endpoint,
|
13
13
|
:api_version,
|
14
|
-
:api_key
|
14
|
+
:api_key,
|
15
|
+
:logger
|
15
16
|
|
16
17
|
self.api_version = "3.0"
|
17
18
|
self.api_endpoint = "https://{{dc}}.api.mailchimp.com"
|
19
|
+
self.logger = ::Logger.new(STDOUT)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module EasyMailchimp
|
2
|
+
class Logger
|
3
|
+
def initialize(logger)
|
4
|
+
@logger = logger
|
5
|
+
end
|
6
|
+
|
7
|
+
attr_reader :logger
|
8
|
+
|
9
|
+
def info(message, tag = nil)
|
10
|
+
if defined?(::Rails) && defined?(::ActiveSupport::Logger)
|
11
|
+
if ::Rails.logger.class == ::ActiveSupport::Logger
|
12
|
+
|
13
|
+
if tag.present?
|
14
|
+
::Rails.logger.tagged(tag) { ::Rails.logger.debug message }
|
15
|
+
else
|
16
|
+
::Rails.logger.debug message
|
17
|
+
end
|
18
|
+
|
19
|
+
return
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
logger.debug message
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
data/lib/easy_mailchimp.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_mailchimp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael de Silva
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- ".travis.yml"
|
93
93
|
- EasyMailchimp.gemspec
|
94
94
|
- Gemfile
|
95
|
+
- Guardfile
|
95
96
|
- LICENSE.txt
|
96
97
|
- README.md
|
97
98
|
- Rakefile
|
@@ -100,6 +101,7 @@ files:
|
|
100
101
|
- lib/easy_mailchimp.rb
|
101
102
|
- lib/easy_mailchimp/base.rb
|
102
103
|
- lib/easy_mailchimp/configuration.rb
|
104
|
+
- lib/easy_mailchimp/logger.rb
|
103
105
|
- lib/easy_mailchimp/version.rb
|
104
106
|
homepage: https://github.com/bsodmike/easy_mailchimp
|
105
107
|
licenses:
|