the_merger 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.org +26 -23
- data/lib/the_merger/version.rb +1 -1
- data/lib/the_merger.rb +1 -1
- data/spec/internal/db/schema.rb +1 -0
- data/spec/lib/the_merger_spec.rb +9 -3
- metadata +4 -4
data/README.org
CHANGED
@@ -15,46 +15,48 @@ There is a demo app here: https://github.com/map7/mailout
|
|
15
15
|
|
16
16
|
Add this line to your application's Gemfile:
|
17
17
|
|
18
|
-
|
18
|
+
: gem 'the_merger'
|
19
19
|
|
20
20
|
And then execute:
|
21
21
|
|
22
|
-
|
22
|
+
: bundle
|
23
23
|
|
24
24
|
Or install it yourself as:
|
25
25
|
|
26
|
-
|
26
|
+
: gem install the_merger
|
27
27
|
|
28
28
|
** Configure
|
29
29
|
|
30
|
-
When using TheMerger in a controller you have to add the following line to the top
|
30
|
+
When using TheMerger in a controller you have to add the following line to the top. EG: the default would be the users controller as you are doing the mail merge there.
|
31
31
|
|
32
|
-
|
32
|
+
: include TheMerger
|
33
33
|
|
34
34
|
Create a yaml file in your config directory called 'the_merger.yml' with something like this
|
35
35
|
|
36
|
-
|
37
|
-
|
36
|
+
: ---
|
37
|
+
: merge_model: "Client"
|
38
38
|
|
39
39
|
|
40
40
|
To use the javascript included in this gem put the following in your application.js
|
41
41
|
|
42
|
-
|
42
|
+
: //= require the_merger/application
|
43
43
|
|
44
44
|
|
45
45
|
Where you need to insert fields (I usually create a 'letters' table) put the following in the form, just above the text_area.
|
46
46
|
|
47
|
-
|
47
|
+
: <%= field_selection %>
|
48
|
+
|
49
|
+
Give the text_area you want to interact with the class 'mail_merge_body' so that the insert button knows where to insert the field selected.
|
48
50
|
|
49
51
|
|
50
52
|
** Usage
|
51
53
|
|
52
54
|
Currently it's just one method and this is how you pass it information
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
: TheMerger.mail_merge(
|
57
|
+
: from: "from@example.com",
|
58
|
+
: subject: "update_listing",
|
59
|
+
: body: "Dear [firstname] [lastname], Please update your listing, from Mick")
|
58
60
|
|
59
61
|
|
60
62
|
** Contributing
|
@@ -66,13 +68,14 @@ Currently it's just one method and this is how you pass it information
|
|
66
68
|
5. Create new Pull Request
|
67
69
|
|
68
70
|
** Tasks
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
71
|
+
- [X] Get all users from the users table
|
72
|
+
- [X] Mail merge and output to the screen
|
73
|
+
- [X] Make the table a variable
|
74
|
+
- [X] Create a method to get all fields from the selected table.
|
75
|
+
- [X] Create a helper method to have a dropdown of fields
|
76
|
+
- [X] Turn this into an engine so that I can include asset pipeline javascript.
|
77
|
+
- [X] Get the Email all button to work
|
78
|
+
- [ ] Write tests
|
79
|
+
- [ ] Schedule repetitive mail outs
|
80
|
+
- [ ] Make compatible with tinymce
|
81
|
+
|
data/lib/the_merger/version.rb
CHANGED
data/lib/the_merger.rb
CHANGED
data/spec/internal/db/schema.rb
CHANGED
data/spec/lib/the_merger_spec.rb
CHANGED
@@ -2,13 +2,13 @@ require 'spec_helper'
|
|
2
2
|
include TheMerger
|
3
3
|
|
4
4
|
class User < ActiveRecord::Base
|
5
|
-
attr_accessible :email, :firstname, :lastname
|
5
|
+
attr_accessible :email, :firstname, :lastname, :age
|
6
6
|
end
|
7
7
|
|
8
8
|
describe TheMerger do
|
9
9
|
|
10
10
|
before do
|
11
|
-
@user = User.create(firstname: "Michael", lastname: "Pope", email: "map7777@gmail.com")
|
11
|
+
@user = User.create(firstname: "Michael", lastname: "Pope", email: "map7777@gmail.com", age: 99)
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "#merge_fields" do
|
@@ -18,6 +18,12 @@ describe TheMerger do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
context "body includes a number" do
|
22
|
+
it "replaces [age] with 99" do
|
23
|
+
merge_fields("Are you over [age] years old?",@user).should eq("Are you over 99 years old?")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
21
27
|
context "body is set to Dear [firstname] [lastname], [address]" do
|
22
28
|
it "replaces fields which exist in the model" do
|
23
29
|
merge_fields("Dear [firstname] [lastname], [address]",@user).should eq("Dear Michael Pope, [address]")
|
@@ -27,7 +33,7 @@ describe TheMerger do
|
|
27
33
|
|
28
34
|
describe "#fields" do
|
29
35
|
it "returns fields for the model excluding created_at, updated_at & id" do
|
30
|
-
fields.should eq(%w[firstname lastname email])
|
36
|
+
fields.should eq(%w[firstname lastname email age])
|
31
37
|
end
|
32
38
|
end
|
33
39
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_merger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-04 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Mail merge a table of fields into a standard letter
|
15
15
|
email:
|
@@ -53,7 +53,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version: '0'
|
54
54
|
segments:
|
55
55
|
- 0
|
56
|
-
hash:
|
56
|
+
hash: -1055697086999734969
|
57
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
58
|
none: false
|
59
59
|
requirements:
|
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
62
|
version: '0'
|
63
63
|
segments:
|
64
64
|
- 0
|
65
|
-
hash:
|
65
|
+
hash: -1055697086999734969
|
66
66
|
requirements: []
|
67
67
|
rubyforge_project:
|
68
68
|
rubygems_version: 1.8.23
|