mc 0.0.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.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Kale Davis
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ require File.join([File.dirname(__FILE__),'lib','mc','version.rb'])
2
+ spec = Gem::Specification.new do |s|
3
+ s.name = 'mc'
4
+ s.version = MC::VERSION
5
+ s.author = 'Kale Davis'
6
+ s.email = 'kale@kaledavis.com'
7
+ s.homepage = 'http://rubygems.org/gems/mc'
8
+ s.license = 'MIT'
9
+ s.platform = Gem::Platform::RUBY
10
+ s.summary = 'mc - the command line interface to MailChimp'
11
+ s.description = 'Access your MailChimp account via the command line using the api. Eep eep!'
12
+ s.files = `git ls-files`.split("\n")
13
+ s.test_files = `git ls-files -- {test,features}/*`.split("\n")
14
+ s.require_paths << 'lib'
15
+ s.bindir = 'bin'
16
+ s.executables = 'mc'
17
+ s.add_development_dependency('rake')
18
+ s.add_development_dependency('aruba')
19
+ s.add_runtime_dependency('gli','2.8.0')
20
+ s.add_runtime_dependency('gibbon','1.0.4')
21
+ s.add_runtime_dependency('filecache','1.0.0')
22
+ s.add_runtime_dependency('awesome_print','1.2.0')
23
+ s.add_runtime_dependency('table_print','1.4.0')
24
+ s.add_runtime_dependency('colorize','0.6.0')
25
+ end
@@ -0,0 +1,85 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+ require 'yaml'
4
+ require 'mc'
5
+ require_relative 'test_helper'
6
+
7
+ describe "MailChimp" do
8
+ before do
9
+ @mailchimp = MailChimp.new(config[:apikey])
10
+ @test_list_id = config[:test_list_id]
11
+ end
12
+
13
+ it "should be able to ping MailChimp" do
14
+ @mailchimp.ping.must_equal "Everything's Chimpy!"
15
+ end
16
+
17
+ it "should pass to method_missing" do
18
+ @mailchimp.lists_list.count.must_be :>, 0
19
+ end
20
+
21
+ it "should see updated results" do
22
+ email = get_random_email_address
23
+ #see how many subscribers the test list has
24
+ count = @mailchimp.lists_members({:id => @test_list_id})["total"].to_i
25
+ count.must_be :>=, 0
26
+
27
+ #add a new subscriber and make sure the count increases by one
28
+ @mailchimp.lists_subscribe(:id => @test_list_id, :email => {:email => email}, :double_optin => false)
29
+ new_count = @mailchimp.lists_members(:id => @test_list_id)["total"].to_i
30
+ new_count.must_equal count + 1
31
+
32
+ # remove subscriber to reset list
33
+ @mailchimp.lists_unsubscribe(:id => @test_list_id, :email => {:email => email}, :delete_member => true)
34
+ end
35
+ end
36
+
37
+ describe "MailChimpCached" do
38
+ before do
39
+ @mailchimp_cached = MailChimpCached.new(config[:apikey])
40
+ @test_list_id = config[:test_list_id]
41
+ clear_cached_dir
42
+ end
43
+
44
+ it "should not have a cached dir already" do
45
+ @mailchimp_cached.lists_list.count
46
+ File.exists?(cached_dir).must_equal true
47
+ clear_cached_dir
48
+ File.exists?(cached_dir).must_equal false
49
+ end
50
+
51
+ it "should be able to ping MailChimp" do
52
+ @mailchimp_cached.helper_ping['msg'].must_equal "Everything's Chimpy!"
53
+ end
54
+
55
+ it "should pass to method_missing" do
56
+ @mailchimp_cached.lists_list.count.must_be :>, 0
57
+ end
58
+
59
+ it "should create a cache dir" do
60
+ File.exists?(cached_dir).must_equal false
61
+
62
+ @mailchimp_cached.lists_list.count
63
+
64
+ File.exists?(cached_dir).must_equal true
65
+ end
66
+
67
+ it "should pull cached results when" do
68
+ clear_cached_dir
69
+ email = get_random_email_address
70
+
71
+ count = @mailchimp_cached.lists_members(:id => @test_list_id)["total"].to_i
72
+ count.must_be :>=, 0
73
+ @mailchimp_cached.lists_subscribe(:id => @test_list_id, :email => {:email => email}, :double_optin => false)
74
+ new_count = @mailchimp_cached.lists_members(:id => @test_list_id)["total"].to_i
75
+ new_count.must_equal count
76
+
77
+ clear_cached_dir
78
+
79
+ new_count = @mailchimp_cached.lists_members(:id => @test_list_id)["total"].to_i
80
+ new_count.must_equal count + 1
81
+
82
+ # remove subscriber to reset list
83
+ @mailchimp_cached.lists_unsubscribe(:id => @test_list_id, :email => {:email => email},:delete_member => true)
84
+ end
85
+ end
@@ -0,0 +1,24 @@
1
+ def config
2
+ config_file = ENV['HOME']+'/.mailchimp'
3
+ raise "Need config file to pull API key from." unless File.exists?(config_file)
4
+ config_hash = YAML.load(File.open(config_file))
5
+ config_hash[:test_list_id] = "ef4227fc80"
6
+
7
+ raise "Need API key for testing." unless config_hash.has_key? :apikey
8
+ raise "Need to define test list in test_helper.rb" unless config_hash.has_key? :test_list_id
9
+
10
+ return config_hash
11
+ end
12
+
13
+ def cached_dir
14
+ ENV['HOME']+'/.mailchimp-cache'
15
+ end
16
+
17
+ def clear_cached_dir
18
+ # delete cache dir
19
+ FileUtils.rm_rf(cached_dir)
20
+ end
21
+
22
+ def get_random_email_address
23
+ "test+#{rand(1000..9999)}@kaledavis.com"
24
+ end
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Kale Davis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: aruba
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: gli
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 2.8.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.8.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: gibbon
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.4
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.0.4
69
+ - !ruby/object:Gem::Dependency
70
+ name: filecache
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 1.0.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.0.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: awesome_print
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 1.2.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 1.2.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: table_print
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 1.4.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 1.4.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: colorize
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 0.6.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 0.6.0
125
+ description: Access your MailChimp account via the command line using the api. Eep
126
+ eep!
127
+ email: kale@kaledavis.com
128
+ executables:
129
+ - mc
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - .gitignore
134
+ - Gemfile
135
+ - README.md
136
+ - Rakefile
137
+ - bin/mc
138
+ - features/mc.feature
139
+ - features/step_definitions/mc_steps.rb
140
+ - features/support/env.rb
141
+ - lib/mc.rb
142
+ - lib/mc/commands.rb
143
+ - lib/mc/commands/campaigns.rb
144
+ - lib/mc/commands/ecomm.rb
145
+ - lib/mc/commands/export.rb
146
+ - lib/mc/commands/gallery.rb
147
+ - lib/mc/commands/helper.rb
148
+ - lib/mc/commands/lists.rb
149
+ - lib/mc/commands/reports.rb
150
+ - lib/mc/commands/search.rb
151
+ - lib/mc/commands/templates.rb
152
+ - lib/mc/commands/users.rb
153
+ - lib/mc/commands/vip.rb
154
+ - lib/mc/helper.rb
155
+ - lib/mc/mailchimp.rb
156
+ - lib/mc/mailchimp_cached.rb
157
+ - lib/mc/report.rb
158
+ - lib/mc/version.rb
159
+ - lib/mc/writer.rb
160
+ - license.txt
161
+ - mc.gemspec
162
+ - test/mc_test.rb
163
+ - test/test_helper.rb
164
+ homepage: http://rubygems.org/gems/mc
165
+ licenses:
166
+ - MIT
167
+ metadata: {}
168
+ post_install_message:
169
+ rdoc_options: []
170
+ require_paths:
171
+ - lib
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - '>='
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - '>='
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubyforge_project:
185
+ rubygems_version: 2.0.5
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: mc - the command line interface to MailChimp
189
+ test_files:
190
+ - features/mc.feature
191
+ - features/step_definitions/mc_steps.rb
192
+ - features/support/env.rb
193
+ - test/mc_test.rb
194
+ - test/test_helper.rb