resumetools 0.2.7.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.
- data/CHANGES +15 -0
- data/LICENSE +22 -0
- data/README.md +202 -0
- data/Rakefile +39 -0
- data/examples/sample.pdf +1532 -0
- data/examples/sample.resume +137 -0
- data/lib/fonts/Vera.ttf +0 -0
- data/lib/fonts/VeraBI.ttf +0 -0
- data/lib/fonts/VeraBd.ttf +0 -0
- data/lib/fonts/VeraIt.ttf +0 -0
- data/lib/resumetools.rb +37 -0
- data/lib/resumetools/grammars/resume.treetop +389 -0
- data/lib/resumetools/resume/export.rb +125 -0
- data/lib/resumetools/resume/json.rb +79 -0
- data/lib/resumetools/resume/pdf.rb +161 -0
- data/lib/resumetools/resume/plain_text.rb +143 -0
- data/lib/resumetools/resume/resume.rb +307 -0
- data/lib/resumetools/resume/text_reader.rb +107 -0
- data/lib/resumetools/version.rb +36 -0
- data/spec/grammar_spec.rb +93 -0
- data/spec/read_resume_spec.rb +61 -0
- data/spec/rendering_pdf_spec.rb +37 -0
- data/spec/resume_spec.rb +217 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +39 -0
- data/tasks/default.rake +1 -0
- data/tasks/gem.rake +80 -0
- data/tasks/package.rake +9 -0
- data/tasks/rdoc.rake +29 -0
- data/tasks/rspec.rake +16 -0
- metadata +155 -0
@@ -0,0 +1,93 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "spec_helper")
|
2
|
+
require "treetop"
|
3
|
+
|
4
|
+
Treetop.load File.join(File.dirname(__FILE__), "../lib/resumetools/grammars/resume.treetop")
|
5
|
+
|
6
|
+
describe "Resume Grammar" do
|
7
|
+
before(:all) do
|
8
|
+
resume_file = "sample.resume"
|
9
|
+
@parser = ResumeParser.new
|
10
|
+
@resume_txt = File.read(File.join(File.dirname(__FILE__), "../examples/#{resume_file}"))
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have a parser" do
|
14
|
+
@parser.should be_instance_of(ResumeParser)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "after parsing sample file" do
|
18
|
+
def elements_with_type(type)
|
19
|
+
@elements.reject { |e| e.data_type != type }
|
20
|
+
end
|
21
|
+
|
22
|
+
before(:all) do
|
23
|
+
@result = @parser.parse(@resume_txt)
|
24
|
+
@elements = @result.elements
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should parse our file" do
|
28
|
+
@result.should_not be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should have 29 items" do
|
32
|
+
elements_with_type(:item).length.should == 29
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should have 2 paragraphs" do
|
36
|
+
elements_with_type(:paragraph).length.should == 2
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have 7 sections" do
|
40
|
+
elements_with_type(:section).length.should == 7
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should have contact name" do
|
44
|
+
elements_with_type(:contact_name).length.should == 1
|
45
|
+
elements_with_type(:contact_name)[0].value.should == "Thomas B. Seeker"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should have contact telephone" do
|
49
|
+
elements_with_type(:contact_telephone).length.should == 1
|
50
|
+
elements_with_type(:contact_telephone)[0].value.should == "(410) 555-1212"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should have contact addresses" do
|
54
|
+
elements_with_type(:contact_address).length.should == 2
|
55
|
+
elements_with_type(:contact_address)[0].value.should == "1234 Northern Star Circle"
|
56
|
+
elements_with_type(:contact_address)[1].value.should == "Baltimore, MD 12345"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should have contact e-mail" do
|
60
|
+
elements_with_type(:contact_email).length.should == 1
|
61
|
+
elements_with_type(:contact_email)[0].value.should == "seeker@nettcom.com"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should have contact URL" do
|
65
|
+
elements_with_type(:contact_url).length.should == 1
|
66
|
+
elements_with_type(:contact_url)[0].value.should == "http://nettcom.com/tseeker"
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should have 5 periods" do
|
70
|
+
elements_with_type(:period).length.should == 5
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should have 5 period organizations" do
|
74
|
+
elements_with_type(:period_organization).length.should == 5
|
75
|
+
elements_with_type(:period_organization).map { |o| o.value }.should == [
|
76
|
+
"Computer Engineering Corporation",
|
77
|
+
"Business Consultants, Inc.",
|
78
|
+
"US Army Infantry",
|
79
|
+
"Air Force Institute of Technology (AFIT)",
|
80
|
+
"University of California, Los Angeles (UCLA)"
|
81
|
+
]
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should have 3 period locations" do
|
85
|
+
elements_with_type(:period_location).length.should == 3
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should have 3 period dates" do
|
89
|
+
elements_with_type(:period_dates).length.should == 3
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "spec_helper")
|
2
|
+
|
3
|
+
describe "Creating a resume from a text" do
|
4
|
+
before do
|
5
|
+
sample = File.join(File.dirname(__FILE__), '..', 'examples', 'sample.resume')
|
6
|
+
text = File.read(sample)
|
7
|
+
@resume = ResumeTools::Resume.from_text(text)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should create a resume" do
|
11
|
+
@resume.should be_instance_of(ResumeTools::Resume)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have the correct contact info" do
|
15
|
+
@resume.full_name.should == "Thomas B. Seeker"
|
16
|
+
@resume.address1.should == "1234 Northern Star Circle"
|
17
|
+
@resume.address2.should == "Baltimore, MD 12345"
|
18
|
+
@resume.telephone.should == "(410) 555-1212"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have 7 sections" do
|
22
|
+
@resume.should have(7).sections
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should have sections in order" do
|
26
|
+
@resume.sections.map { |s| s.title }.should == [
|
27
|
+
"Career Goal",
|
28
|
+
"Qualifications Summary",
|
29
|
+
"Technical Skills",
|
30
|
+
"Professional Experience",
|
31
|
+
"Education",
|
32
|
+
"Specialized Training",
|
33
|
+
"Certification, Honors, and Professional Affiliations"
|
34
|
+
]
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have a paragraph in the Career Goal section" do
|
38
|
+
@resume.sections[0].para.should_not be_blank
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should have a paragraph in the Qualifications Summary section" do
|
42
|
+
@resume.sections[1].para.should_not be_blank
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should have 4 items in the Technical Skills section" do
|
46
|
+
@resume.sections[2].should have(4).items
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should have 3 periods in the Professional Experience section" do
|
50
|
+
@resume.sections[3].should have(3).periods
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should have 3 items in the Systems Engineer period" do
|
54
|
+
@resume.sections[3].periods[0].should have(3).items
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should have proper dates" do
|
58
|
+
@resume.sections[3].periods[0].dtstart.should == "1993"
|
59
|
+
@resume.sections[3].periods[0].dtend.should == "Present"
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009 Virgil Dimaguila
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person
|
5
|
+
# obtaining a copy of this software and associated documentation
|
6
|
+
# files (the "Software"), to deal in the Software without
|
7
|
+
# restriction, including without limitation the rights to use,
|
8
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the
|
10
|
+
# Software is furnished to do so, subject to the following
|
11
|
+
# conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
#++
|
25
|
+
|
26
|
+
require File.join(File.dirname(__FILE__), "spec_helper")
|
27
|
+
|
28
|
+
describe "Rendering a Resume to PDF" do
|
29
|
+
before do
|
30
|
+
@resume = ResumeTools::Resume.new
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should render to PDF" do
|
34
|
+
result = @resume.render_pdf
|
35
|
+
result.should_not be_nil
|
36
|
+
end
|
37
|
+
end
|
data/spec/resume_spec.rb
ADDED
@@ -0,0 +1,217 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009 Virgil Dimaguila
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person
|
5
|
+
# obtaining a copy of this software and associated documentation
|
6
|
+
# files (the "Software"), to deal in the Software without
|
7
|
+
# restriction, including without limitation the rights to use,
|
8
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the
|
10
|
+
# Software is furnished to do so, subject to the following
|
11
|
+
# conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
#++
|
25
|
+
|
26
|
+
require File.join(File.dirname(__FILE__), "spec_helper")
|
27
|
+
|
28
|
+
|
29
|
+
def resume_attributes
|
30
|
+
{
|
31
|
+
:full_name => "Albert Einstein",
|
32
|
+
:url => "http://phys6.science.org/einstein",
|
33
|
+
:email => "albert.einstein@science.org",
|
34
|
+
:telephone => "(555) 123-4567",
|
35
|
+
:address1 => "221 Relativity Circle",
|
36
|
+
:address2 => "Princeton, NJ"
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def section_attributes
|
41
|
+
{ :title => "Objectives",
|
42
|
+
:para => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor." }
|
43
|
+
end
|
44
|
+
|
45
|
+
def period_attributes
|
46
|
+
{
|
47
|
+
:title => "Software Developer",
|
48
|
+
:location => "Toronto, ON",
|
49
|
+
:organization => "Roundysoft",
|
50
|
+
:dtstart => Date.new(2008, 6, 15),
|
51
|
+
:dtend => Date.new(2009, 4, 1)
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
def item_attributes
|
56
|
+
{ :text => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor." }
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
describe "Resume" do
|
61
|
+
before do
|
62
|
+
@attributes = resume_attributes
|
63
|
+
end
|
64
|
+
|
65
|
+
it "has initial properties after creation" do
|
66
|
+
@resume = ResumeTools::Resume.new
|
67
|
+
@resume.full_name.should be_blank
|
68
|
+
@resume.has_url?.should be_false
|
69
|
+
@resume.has_email?.should be_false
|
70
|
+
@resume.has_telephone?.should be_false
|
71
|
+
@resume.has_address1?.should be_false
|
72
|
+
@resume.has_address2?.should be_false
|
73
|
+
@resume.has_sections?.should be_false
|
74
|
+
end
|
75
|
+
|
76
|
+
it "is created with hash properties" do
|
77
|
+
@resume = ResumeTools::Resume.new(@attributes)
|
78
|
+
@resume.has_url?.should be_true
|
79
|
+
@resume.has_email?.should be_true
|
80
|
+
@resume.has_telephone?.should be_true
|
81
|
+
@resume.has_address1?.should be_true
|
82
|
+
@resume.has_address2?.should be_true
|
83
|
+
|
84
|
+
@resume.full_name.should == @attributes[:full_name]
|
85
|
+
@resume.url.should == @attributes[:url]
|
86
|
+
@resume.telephone.should == @attributes[:telephone]
|
87
|
+
@resume.address1.should == @attributes[:address1]
|
88
|
+
@resume.address2.should == @attributes[:address2]
|
89
|
+
@resume.should have(0).sections
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
describe "Section" do
|
96
|
+
before(:each) do
|
97
|
+
@resume = ResumeTools::Resume.new(resume_attributes)
|
98
|
+
@attributes = section_attributes
|
99
|
+
end
|
100
|
+
|
101
|
+
it "is created in resume" do
|
102
|
+
@resume.create_section do |s|
|
103
|
+
s.title = @attributes[:title]
|
104
|
+
s.para = @attributes[:para]
|
105
|
+
end
|
106
|
+
|
107
|
+
@resume.should have(1).sections
|
108
|
+
@resume.has_sections?.should be_true
|
109
|
+
section = @resume.sections[0]
|
110
|
+
section.title.should == @attributes[:title]
|
111
|
+
section.para.should == @attributes[:para]
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should have no items" do
|
115
|
+
section = ResumeTools::Section.new
|
116
|
+
section.should have(0).items
|
117
|
+
section.has_items?.should be_false
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should have no periods" do
|
121
|
+
section = ResumeTools::Section.new
|
122
|
+
section.has_periods?.should be_false
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
it "should be able to add items" do
|
127
|
+
section = ResumeTools::Section.new
|
128
|
+
section.create_item do |item|
|
129
|
+
item.text = "This is item A."
|
130
|
+
end
|
131
|
+
section.should have(1).items
|
132
|
+
section.add_item(ResumeTools::Item.new(:text => "This is item B."))
|
133
|
+
section.should have(2).items
|
134
|
+
section.items[0].text.should == "This is item A."
|
135
|
+
section.items[1].text.should == "This is item B."
|
136
|
+
section.has_items?.should be_true
|
137
|
+
end
|
138
|
+
|
139
|
+
it "is created in the right order" do
|
140
|
+
@resume.create_section do |s|
|
141
|
+
s.title = "First"
|
142
|
+
end
|
143
|
+
@resume.create_section do |s|
|
144
|
+
s.title = "Second"
|
145
|
+
end
|
146
|
+
|
147
|
+
@resume.sections[0].title.should == "First"
|
148
|
+
@resume.sections[1].title.should == "Second"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
describe "Period" do
|
154
|
+
before(:each) do
|
155
|
+
@resume = ResumeTools::Resume.new(resume_attributes)
|
156
|
+
@resume.create_section(section_attributes)
|
157
|
+
@section = @resume.sections[0]
|
158
|
+
@attributes = period_attributes
|
159
|
+
end
|
160
|
+
|
161
|
+
it "is created in a section" do
|
162
|
+
@section.create_period do |p|
|
163
|
+
p.title = @attributes[:title]
|
164
|
+
p.location = @attributes[:location]
|
165
|
+
p.organization = @attributes[:organization]
|
166
|
+
p.dtstart = @attributes[:dtstart]
|
167
|
+
p.dtend = @attributes[:dtend]
|
168
|
+
end
|
169
|
+
|
170
|
+
@section.should have(1).periods
|
171
|
+
period = @section.periods[0]
|
172
|
+
period.title.should == @attributes[:title]
|
173
|
+
period.location.should == @attributes[:location]
|
174
|
+
period.organization.should == @attributes[:organization]
|
175
|
+
period.dtstart.should == @attributes[:dtstart]
|
176
|
+
period.dtend.should == @attributes[:dtend]
|
177
|
+
end
|
178
|
+
|
179
|
+
it "is added in the right order" do
|
180
|
+
@section.create_period :title => "First"
|
181
|
+
@section.create_period :title => "Second"
|
182
|
+
|
183
|
+
@section.should have(2).periods
|
184
|
+
@section.periods[0].title.should == "First"
|
185
|
+
@section.periods[1].title.should == "Second"
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
describe "Item" do
|
191
|
+
before(:each) do
|
192
|
+
@resume = ResumeTools::Resume.new(resume_attributes)
|
193
|
+
@resume.create_section(section_attributes)
|
194
|
+
@resume.sections[0].create_period(period_attributes)
|
195
|
+
@period = @resume.sections[0].periods[0]
|
196
|
+
@attributes = item_attributes
|
197
|
+
end
|
198
|
+
|
199
|
+
it "is created in a period" do
|
200
|
+
@period.create_item do |i|
|
201
|
+
i.text = @attributes[:text]
|
202
|
+
end
|
203
|
+
|
204
|
+
@period.should have(1).items
|
205
|
+
item = @period.items[0]
|
206
|
+
item.text.should == @attributes[:text]
|
207
|
+
end
|
208
|
+
|
209
|
+
it "is addd in the right order" do
|
210
|
+
@period.create_item :text => "First"
|
211
|
+
@period.create_item :text => "Second"
|
212
|
+
|
213
|
+
@period.should have(2).items
|
214
|
+
@period.items[0].text.should == "First"
|
215
|
+
@period.items[1].text.should == "Second"
|
216
|
+
end
|
217
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009 Virgil Dimaguila
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person
|
5
|
+
# obtaining a copy of this software and associated documentation
|
6
|
+
# files (the "Software"), to deal in the Software without
|
7
|
+
# restriction, including without limitation the rights to use,
|
8
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the
|
10
|
+
# Software is furnished to do so, subject to the following
|
11
|
+
# conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
#++
|
25
|
+
|
26
|
+
spec_dir = File.expand_path(File.dirname(__FILE__))
|
27
|
+
lib_dir = File.expand_path(File.join(spec_dir, "../lib"))
|
28
|
+
|
29
|
+
$:.unshift(lib_dir)
|
30
|
+
$:.uniq!
|
31
|
+
|
32
|
+
require "rubygems"
|
33
|
+
require "resumetools"
|
34
|
+
|
35
|
+
|
36
|
+
# Simple blank string matcher
|
37
|
+
def be_blank
|
38
|
+
simple_matcher("a blank string") { |given| given.blank? }
|
39
|
+
end
|