easy_mailchimp 0.1.3 → 0.1.4

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: 8fa2d9736751d7a99cb0141511ae0a97f5d2104e
4
- data.tar.gz: 0cd641514fa8ba849401d43c5df5e8e99e9d9d10
3
+ metadata.gz: aae1d6a158d999f6a24a4c9b7e0d7711557e1544
4
+ data.tar.gz: 2f3fb0a17a977ed11ce737fa59b8747ba18ba494
5
5
  SHA512:
6
- metadata.gz: 2799cb964cbf3c5ceeb20de4cbd73ae9ef3f201c7339107e4ab2a40b82a8b3d9462d345e181f5ea7deef6b8f92609bbb51a48029a32318ce75af86fd1d1d2d8b
7
- data.tar.gz: 07b78817b15e5ece9c5a392ab15378693828b022bfc0773b52db1df3e654df76e7076be487153e9fae88ecdcd2f82ba9adf795e96f80b8659cd855f823bd4bf6
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 "EasyMailchimp"
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 "irb"
14
- IRB.start
14
+ require "pry"
15
+ binding.pry
@@ -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
- Rails.logger.tagged('Mailchimp::Base#create_member') { Rails.logger.debug "ERROR: #{ex.message} - #{ex.raw_body}" }
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
- Rails.logger.tagged('Mailchimp::Base#get_list_name') { Rails.logger.debug "ERROR: #{ex.message}" }
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
+
@@ -1,3 +1,3 @@
1
1
  module EasyMailchimp
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -1,7 +1,9 @@
1
+ require "logger"
1
2
  require "gibbon"
2
3
  require "easy_mailchimp/version"
3
4
  require "easy_mailchimp/configuration"
4
5
 
5
6
  module EasyMailchimp
6
7
  autoload :Base, 'easy_mailchimp/base'
8
+ autoload :Logger, 'easy_mailchimp/logger'
7
9
  end
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.3
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: