atpay_buttons 1.0.0

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,102 @@
1
+ <!-- yahoo template with no wrap -->
2
+
3
+ <style>
4
+ a.not_yahoo {display:inline; display: inline !important;font-size: 20px !important;}
5
+ a.not_yahoosm {display:inline; display: inline !important;font-size: 12px !important;}
6
+
7
+ a.not_yahoo[fix] {display:inline; display: inline !important;font-size: 20px !important;}
8
+ a.not_yahoosm[fix] {display:inline; display: inline !important;font-size: 12px !important;}
9
+ a.yahoo[fix] {display:none; display: none !important;font-size: 0px !important;}
10
+ </style>
11
+
12
+ <center>
13
+ <a border='0' class='yahoo' fix='email' href='{{yahoo_url}}' style='text-underline:none;'>
14
+ <table border='0' cellpadding='0' cellspacing='0' style='background-color:{{color}};'>
15
+ <tr class='main'>
16
+ <td class='main' style='padding:3px 5px 5px 5px;' width='145'>
17
+ <table>
18
+ <tr>
19
+ <td>
20
+ <a class='yahoo' fix='email' href='{{yahoo_url}}' style='color:#ffffff; text-decoration:none; border:none; display:inline;'>
21
+ <img src='{{image}}' style='margin-left: 5px; margin-right:10px; margin-top:8px;'>
22
+ </a>
23
+ </td>
24
+ <td>
25
+ <table border='0' cellpadding='0' cellspacing='0' style='float:left; margin:0; margin-left:5px;'>
26
+ <tr>
27
+ <td style='font-size: 11px; color: #ffffff; font-family: Tahoma; text-align:center; padding:0; margin:0;'>
28
+ {{title}}
29
+ </td>
30
+ </tr>
31
+ <tr>
32
+ <td>
33
+ <table border='0' cellpadding='0' cellspacing='0' style='margin:0; padding:0;'>
34
+ <tr>
35
+ <td style='padding:0; margin:0; font-size: 20px; color: #ffffff; font-family: Tahoma; vertical-align:top; line-height:25px;' valign='top'>
36
+ <a class='yahoo' fix='email' href='{{yahoo_url}}' style='color:#ffffff; text-decoration:none; border:none; display:inline;'>
37
+ {{dollar}}
38
+ </a>
39
+ </td>
40
+ <td style='padding:0; margin:0; font-size:14px; text-decoration:underline;padding-left:2px; color: #ffffff; font-family: Tahoma; vertical-align:top;' valign='top'>
41
+ <a class='yahoosm' fix='email' href='{{yahoo_url}}' style='color:#ffffff; text-decoration:none; border:none; display:inline;'>
42
+ {{cents}}
43
+ </a>
44
+ </td>
45
+ </tr>
46
+ </table>
47
+ </td>
48
+ </tr>
49
+ </table>
50
+ </td>
51
+ </tr>
52
+ </table>
53
+ </td>
54
+ </tr>
55
+ </table>
56
+ </a>
57
+ <a border='0' class='not_yahoo' fix='email' href='{{url}}' style='text-underline:none; display:none; font-size:0px; text-indent:-9999999;'>
58
+ <table border='0' cellpadding='0' cellspacing='0' style='background-color:#6dbe45;'>
59
+ <tr class='main'>
60
+ <td class='main' style='padding:3px 5px 5px 5px;' width='145'>
61
+ <table>
62
+ <tr>
63
+ <td>
64
+ <a class='not_yahoo' href='{{url}}' style='color:#ffffff; text-decoration:none; border:none;'>
65
+ <img src='{{image}}' style='margin-left: 5px; margin-right:10px; margin-top:8px;'>
66
+ </a>
67
+ </td>
68
+ <td>
69
+ <table border='0' cellpadding='0' cellspacing='0' style='float:left; margin:0; margin-left:5px;'>
70
+ <tr>
71
+ <td style='font-size: 11px; color: #ffffff; font-family: Tahoma; text-align:center; padding:0; margin:0;'>
72
+ {{title}}
73
+ </td>
74
+ </tr>
75
+ <tr>
76
+ <td>
77
+ <table border='0' cellpadding='0' cellspacing='0' style='margin:0; padding:0;'>
78
+ <tr>
79
+ <td style='padding:0; margin:0; font-size: 20px; color: #ffffff; font-family: Tahoma; vertical-align:top; line-height:25px;' valign='top'>
80
+ <a class='not_yahoo' fix='email' href='{{url}}' style='color:#ffffff; text-decoration:none; border:none;'>
81
+ {{dollar}}
82
+ </a>
83
+ </td>
84
+ <td style='padding:0; margin:0; font-size:14px; text-decoration:underline;padding-left:2px; color: #ffffff; font-family: Tahoma; vertical-align:top;' valign='top'>
85
+ <a class='not_yahoosm' fix='email' href='{{url}}' style='color:#ffffff; text-decoration:none; border:none;'>
86
+ {{cents}}
87
+ </a>
88
+ </td>
89
+ </tr>
90
+ </table>
91
+ </td>
92
+ </tr>
93
+ </table>
94
+ </td>
95
+ </tr>
96
+ </table>
97
+ </td>
98
+ </tr>
99
+ </table>
100
+ </a>
101
+ </center>
102
+
@@ -0,0 +1,5 @@
1
+ require 'atpay_tokens'
2
+ require 'bigdecimal'
3
+
4
+ require_relative 'atpay/button/template'
5
+ require_relative 'atpay/button/generator'
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe "atpay_buttons" do
4
+ let(:session) { mock }
5
+ let(:file_info) { 'test_data.txt' }
6
+ let(:public_key) { '06zK82iu9NUUMmDiZsEvoUH25tbIE6R3R+zPnDK8YGQ=' }
7
+ let(:private_key) { 'plBs9X+Zvr65z6iCa0oLNdAEGYZ85Dzf74Qy1yPTris=' }
8
+ let(:options) { {partner_id: 1, public_key: public_key, private_key: private_key, amount: '12', env: :sandbox, user_data: 'aaaaaaaa'} }
9
+ let(:cli_input) { "bin/atpay_buttons --amount 5.0 -p #{private_key} -u #{public_key} -r #{options[:partner_id]} -s subject -i imageurl -c color -t title -w false -e sandbox -n #{file_info}" }
10
+ let(:cli_output) {`#{cli_input}`}
11
+
12
+ describe "button creation" do
13
+ it "creates a string based on passed in parameters" do
14
+ refute_empty(cli_output)
15
+ cli_output.must_be_instance_of String
16
+ end
17
+
18
+ it "contains button identifier text" do
19
+ cli_output.must_include 'mailto'
20
+ end
21
+
22
+ it "generates valid usage information" do
23
+ assert_match(/--help, -h: Show this message/,`bin/atpay_buttons -h`)
24
+ end
25
+
26
+ #it "displays a message if the input file is missing" do
27
+ # cli_output = `atpay-button-generator -n missing.txt`
28
+ # assert_match(/Error: file or url for option '-n' cannot be opened: No such file or directory/, cli_output)
29
+ #end
30
+ end
31
+ end
@@ -0,0 +1 @@
1
+ Default
@@ -0,0 +1 @@
1
+ Mailto Body
@@ -0,0 +1 @@
1
+ Default Wrap
@@ -0,0 +1 @@
1
+ Yahoo Wrap
@@ -0,0 +1 @@
1
+ Yahoo
@@ -0,0 +1,86 @@
1
+ require 'spec_helper'
2
+
3
+ describe AtPay::Button::Generator do
4
+ let(:session) { mock }
5
+ let(:public_key) { '06zK82iu9NUUMmDiZsEvoUH25tbIE6R3R+zPnDK8YGQ=' }
6
+ let(:private_key) { 'plBs9X+Zvr65z6iCa0oLNdAEGYZ85Dzf74Qy1yPTris=' }
7
+ let(:options) { {partner_id: 1, public_key: public_key, private_key: private_key, amount: '12', env: :sandbox, user_data: 'aaaaaaaa'} }
8
+ let(:subject) { AtPay::Button::Generator.new options }
9
+
10
+ describe "#new" do
11
+ it "adds the provided options to the defaults" do
12
+ subject.instance_eval{ @options }.keys.sort.must_equal [:amount, :partner_id, :public_key, :private_key, :env, :template, :title, :type, :group, :user_data].sort
13
+ end
14
+ end
15
+
16
+ describe "#token" do
17
+ before do
18
+ @dummy_key = mock
19
+ session.expects(:security_key).returns(@dummy_key)
20
+ AtPay::Session.stubs(:new).returns(session)
21
+ end
22
+
23
+ it "builds an @Pay token" do
24
+ @dummy_key.expects :email_token
25
+
26
+ subject.token(:card, '3838383')
27
+ end
28
+ end
29
+
30
+ describe "#template" do
31
+ it "instantiates the template for the given email" do
32
+ AtPay::Button::Template.expects(:new).with(any_parameters) { |options| options[:email] == 'bob@bob' }
33
+
34
+ subject.template 'bob@bob'
35
+ end
36
+ end
37
+
38
+ describe "#to_html" do
39
+ it "renders the template with the given token" do
40
+ AtPay::Button::Template.any_instance.expects(:render).with(token: 'token', email: 'bob@bob')
41
+
42
+ subject.to_html 'token', 'bob@bob'
43
+ end
44
+ end
45
+
46
+ describe "#generate" do
47
+ before do
48
+ @dummy_key = mock
49
+ @dummy_key.expects(:email_token).returns('token')
50
+ AtPay::Button::Template.any_instance.expects(:render).returns('button')
51
+ session.expects(:security_key).returns(@dummy_key)
52
+ AtPay::Session.stubs(:new).returns(session)
53
+ end
54
+
55
+ it "builds an html button when given only the email" do
56
+ subject.generate(email: 'bob@bob').must_equal 'button'
57
+ end
58
+
59
+ it "builds an html button when given the email and source" do
60
+ subject.generate(email: 'bob@bob', source: '3838383').must_equal 'button'
61
+ end
62
+
63
+ it "builds an html button when given the email, source and type" do
64
+ subject.generate(email: 'bob@bob', source: '38383838', type: :card).must_equal 'button'
65
+ end
66
+ end
67
+
68
+ describe "#build" do
69
+ before do
70
+ AtPay::Button::Generator.any_instance.stubs(:generate).returns('button')
71
+ AtPay::Session.stubs(:new).returns(session)
72
+ end
73
+
74
+ it "builds a collection of buttons" do
75
+ subject.build({ 'bob@bob' => 'card', 'sue@sue' => 'card' }).must_equal [['bob@bob', 'button'], ['sue@sue', 'button']]
76
+ end
77
+
78
+ it "builds a single button" do
79
+ subject.build({ 'bob@bob' => 'card' }).must_equal [['bob@bob', 'button']]
80
+ end
81
+
82
+ it "builds a button when only given an email" do
83
+ subject.build(['bob@bob']).must_equal [['bob@bob', 'button']]
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,18 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'pry'
5
+ require File.dirname(__FILE__) + '/../lib/atpay_buttons'
6
+
7
+ # require 'minitest'
8
+ require 'minitest/autorun'
9
+
10
+ require 'mocha/setup'
11
+
12
+ # See http://www.jetbrains.com/ruby/webhelp/minitest.html
13
+ if ENV["RM_INFO"] || ENV["TEAMCITY_VERSION"]
14
+ require 'active_support'
15
+ require 'minitest/reporters'
16
+ MiniTest::Reporters.use! MiniTest::Reporters::RubyMineReporter.new
17
+ end
18
+
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe AtPay::Button::Template do
4
+ let(:session) { mock }
5
+ let(:options) { {destination: "Partner Name", email: 'bob@example.com', amount: 20, templates: "spec/fixtures/templates" } }
6
+ let(:subject) { AtPay::Button::Template.new options }
7
+ let(:subject_class) { AtPay::Button::Template }
8
+
9
+ describe "#new" do
10
+ it "adds the provided options to the defaults" do
11
+ subject.instance_eval{ @options }.keys.sort.must_equal [:subject, :title, :color, :image, :processor, :destination, :templates, :email, :amount, :wrap].sort
12
+ end
13
+ end
14
+
15
+ describe "#render" do
16
+ it "renders yahoo specific templates for yahoo providers" do
17
+ %w(test@yahoo.com test@ymail.com test@rocketmail.com).each do |email|
18
+ subject.instance_eval {
19
+ @options[:email] = email
20
+ }
21
+
22
+ subject.render.strip.must_equal "Yahoo"
23
+ end
24
+ end
25
+
26
+ it "renders wrapped version of yahoo template for yahoo providers" do
27
+ %w(test@yahoo.com test@ymail.com test@rocketmail.com).each do |email|
28
+ subject.instance_eval {
29
+ @options[:email] = email
30
+ @options[:wrap] = true
31
+ }
32
+
33
+ subject.render.strip.must_equal "Yahoo Wrap"
34
+ end
35
+ end
36
+
37
+ it "renders default template for all other providers" do
38
+ subject.instance_eval {
39
+ @options[:email] = "test@atpay.com"
40
+ }
41
+
42
+ subject.render.strip.must_equal "Default"
43
+ end
44
+
45
+ it "renders wrapped version of default template for other providers" do
46
+ subject.instance_eval {
47
+ @options[:email] = "test@atpay.com"
48
+ @options[:wrap] = true
49
+ }
50
+
51
+ subject.render.strip.must_equal "Default Wrap"
52
+ end
53
+ end
54
+
55
+ # Integration style tests
56
+ describe "#templates" do
57
+ let(:options) { {destination: "Partner Name", amount: 20 } }
58
+
59
+ it "should render with all known template types" do
60
+ %w(test@hotmail.com test@yahoo.com test@atpay.com).each do |email|
61
+ subject.instance_eval { @options[:email] = email }
62
+ subject.render
63
+ end
64
+ end
65
+ end
66
+ end
data/test_data.txt ADDED
@@ -0,0 +1,3 @@
1
+ test1@example.com, vT43Rfdd45g
2
+ test2@example.com, iT43Rfdd51g
3
+ test3@example.com, bTsdRfdd48g
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: atpay_buttons
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Thomas Pastinsky
8
+ - Glen Holcomb
9
+ - James Kassemi
10
+ - Isaiah Baca
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2013-08-02 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '1.3'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ - !ruby/object:Gem::Dependency
45
+ name: atpay_tokens
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ - !ruby/object:Gem::Dependency
59
+ name: liquid
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ description: Atpay button generator
73
+ email:
74
+ - dev@atpay.com
75
+ executables:
76
+ - atpay_buttons
77
+ extensions: []
78
+ extra_rdoc_files: []
79
+ files:
80
+ - .gitignore
81
+ - Gemfile
82
+ - README.md
83
+ - Rakefile
84
+ - atpay_buttons.gemspec
85
+ - bin/atpay_buttons
86
+ - circle.yml
87
+ - imgs/sample_button.png
88
+ - lib/atpay/button/generator.rb
89
+ - lib/atpay/button/template.rb
90
+ - lib/atpay/button/templates/default.liquid
91
+ - lib/atpay/button/templates/mailto_body.liquid
92
+ - lib/atpay/button/templates/wrap_default.liquid
93
+ - lib/atpay/button/templates/wrap_yahoo.liquid
94
+ - lib/atpay/button/templates/yahoo.liquid
95
+ - lib/atpay_buttons.rb
96
+ - spec/command_line_spec.rb
97
+ - spec/fixtures/templates/default.liquid
98
+ - spec/fixtures/templates/mailto_body.liquid
99
+ - spec/fixtures/templates/wrap_default.liquid
100
+ - spec/fixtures/templates/wrap_yahoo.liquid
101
+ - spec/fixtures/templates/yahoo.liquid
102
+ - spec/generator_spec.rb
103
+ - spec/spec_helper.rb
104
+ - spec/template_spec.rb
105
+ - test_data.txt
106
+ homepage: http://atpay.com
107
+ licenses: []
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.0.2
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Command line tool and Ruby library for generating @Pay 2 click email buttons
129
+ test_files:
130
+ - spec/command_line_spec.rb
131
+ - spec/fixtures/templates/default.liquid
132
+ - spec/fixtures/templates/mailto_body.liquid
133
+ - spec/fixtures/templates/wrap_default.liquid
134
+ - spec/fixtures/templates/wrap_yahoo.liquid
135
+ - spec/fixtures/templates/yahoo.liquid
136
+ - spec/generator_spec.rb
137
+ - spec/spec_helper.rb
138
+ - spec/template_spec.rb