virgild-resumetools 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,213 @@
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
+ { :name => "Physicist Resume",
31
+ :title => "Physicist - 30+ yrs experience",
32
+ :full_name => "Albert Einstein",
33
+ :url => "http://phys6.science.org/einstein",
34
+ :email => "albert.einstein@science.org",
35
+ :telephone => "(555) 123-4567",
36
+ :address1 => "221 Relativity Circle",
37
+ :address2 => "Princeton, NJ"
38
+ }
39
+ end
40
+
41
+ def section_attributes
42
+ { :title => "Objectives",
43
+ :para => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor." }
44
+ end
45
+
46
+ def period_attributes
47
+ {
48
+ :title => "Software Developer",
49
+ :location => "Toronto, ON",
50
+ :organization => "Roundysoft",
51
+ :dtstart => Date.new(2008, 6, 15),
52
+ :dtend => Date.new(2009, 4, 1)
53
+ }
54
+ end
55
+
56
+ def item_attributes
57
+ { :text => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor." }
58
+ end
59
+
60
+
61
+ describe "Resume" do
62
+ before do
63
+ @attributes = resume_attributes
64
+ end
65
+
66
+ it "has initial properties after creation" do
67
+ @resume = ResumeTools::Resume.new
68
+ @resume.name.should == "Unnamed Resume"
69
+ @resume.title.should be_blank
70
+ @resume.full_name.should be_blank
71
+ @resume.has_url?.should be_false
72
+ @resume.has_email?.should be_false
73
+ @resume.has_telephone?.should be_false
74
+ @resume.has_address1?.should be_false
75
+ @resume.has_address2?.should be_false
76
+ @resume.should have(0).sections
77
+ end
78
+
79
+ it "is created with hash properties" do
80
+ @resume = ResumeTools::Resume.new(@attributes)
81
+ @resume.has_url?.should be_true
82
+ @resume.has_email?.should be_true
83
+ @resume.has_telephone?.should be_true
84
+ @resume.has_address1?.should be_true
85
+ @resume.has_address2?.should be_true
86
+
87
+ @resume.name.should == @attributes[:name]
88
+ @resume.title.should == @attributes[:title]
89
+ @resume.full_name.should == @attributes[:full_name]
90
+ @resume.url.should == @attributes[:url]
91
+ @resume.telephone.should == @attributes[:telephone]
92
+ @resume.address1.should == @attributes[:address1]
93
+ @resume.address2.should == @attributes[:address2]
94
+ @resume.should have(0).sections
95
+ end
96
+
97
+ end
98
+
99
+
100
+ describe "Section" do
101
+ before(:each) do
102
+ @resume = ResumeTools::Resume.new(resume_attributes)
103
+ @attributes = section_attributes
104
+ end
105
+
106
+ it "is created in resume" do
107
+ @resume.create_section do |s|
108
+ s.title = @attributes[:title]
109
+ s.para = @attributes[:para]
110
+ end
111
+
112
+ @resume.should have(1).sections
113
+ section = @resume.sections[0]
114
+ section.title.should == @attributes[:title]
115
+ section.para.should == @attributes[:para]
116
+ end
117
+
118
+ it "should have no items" do
119
+ section = ResumeTools::Section.new
120
+ section.should have(0).items
121
+ end
122
+
123
+ it "should be able to add items" do
124
+ section = ResumeTools::Section.new
125
+ section.create_item do |item|
126
+ item.text = "This is item A."
127
+ end
128
+ section.should have(1).items
129
+ section.add_item(ResumeTools::Item.new(:text => "This is item B."))
130
+ section.should have(2).items
131
+ section.items[0].text.should == "This is item A."
132
+ section.items[1].text.should == "This is item B."
133
+ end
134
+
135
+ it "is created in the right order" do
136
+ @resume.create_section do |s|
137
+ s.title = "First"
138
+ end
139
+ @resume.create_section do |s|
140
+ s.title = "Second"
141
+ end
142
+
143
+ @resume.sections[0].title.should == "First"
144
+ @resume.sections[1].title.should == "Second"
145
+ end
146
+ end
147
+
148
+
149
+ describe "Period" do
150
+ before(:each) do
151
+ @resume = ResumeTools::Resume.new(resume_attributes)
152
+ @resume.create_section(section_attributes)
153
+ @section = @resume.sections[0]
154
+ @attributes = period_attributes
155
+ end
156
+
157
+ it "is created in a section" do
158
+ @section.create_period do |p|
159
+ p.title = @attributes[:title]
160
+ p.location = @attributes[:location]
161
+ p.organization = @attributes[:organization]
162
+ p.dtstart = @attributes[:dtstart]
163
+ p.dtend = @attributes[:dtend]
164
+ end
165
+
166
+ @section.should have(1).periods
167
+ period = @section.periods[0]
168
+ period.title.should == @attributes[:title]
169
+ period.location.should == @attributes[:location]
170
+ period.organization.should == @attributes[:organization]
171
+ period.dtstart.should == @attributes[:dtstart]
172
+ period.dtend.should == @attributes[:dtend]
173
+ end
174
+
175
+ it "is added in the right order" do
176
+ @section.create_period :title => "First"
177
+ @section.create_period :title => "Second"
178
+
179
+ @section.should have(2).periods
180
+ @section.periods[0].title.should == "First"
181
+ @section.periods[1].title.should == "Second"
182
+ end
183
+ end
184
+
185
+
186
+ describe "Item" do
187
+ before(:each) do
188
+ @resume = ResumeTools::Resume.new(resume_attributes)
189
+ @resume.create_section(section_attributes)
190
+ @resume.sections[0].create_period(period_attributes)
191
+ @period = @resume.sections[0].periods[0]
192
+ @attributes = item_attributes
193
+ end
194
+
195
+ it "is created in a period" do
196
+ @period.create_item do |i|
197
+ i.text = @attributes[:text]
198
+ end
199
+
200
+ @period.should have(1).items
201
+ item = @period.items[0]
202
+ item.text.should == @attributes[:text]
203
+ end
204
+
205
+ it "is addd in the right order" do
206
+ @period.create_item :text => "First"
207
+ @period.create_item :text => "Second"
208
+
209
+ @period.should have(2).items
210
+ @period.items[0].text.should == "First"
211
+ @period.items[1].text.should == "Second"
212
+ end
213
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format=specdocs
@@ -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
@@ -0,0 +1 @@
1
+ task :default => :spec
data/tasks/gem.rake ADDED
@@ -0,0 +1,77 @@
1
+ require "rake/gempackagetask"
2
+
3
+ namespace :gem do
4
+ GEM_SPEC = Gem::Specification.new do |s|
5
+ unless s.respond_to?(:add_development_dependency)
6
+ puts "The gem spec requires a newer version of RubyGems."
7
+ exit(1)
8
+ end
9
+
10
+ s.name = PKG_NAME
11
+ s.version = PKG_VERSION
12
+ s.summary = PKG_SUMMARY
13
+ s.description = PKG_DESCRIPTION
14
+
15
+ s.files = PKG_FILES.to_a
16
+
17
+ s.has_rdoc = true
18
+
19
+ s.required_ruby_version = ">= 1.8.6"
20
+
21
+ s.add_development_dependency("rake", ">= 0.8.7")
22
+ s.add_development_dependency("rspec", ">= 1.2.8")
23
+
24
+ s.add_runtime_dependency("extlib")
25
+ s.add_runtime_dependency("prawn", ">= 0.5.0")
26
+ s.add_runtime_dependency("treetop", ">= 1.3.0")
27
+
28
+ s.require_path = "lib"
29
+
30
+ s.author = "Virgil Dimaguila"
31
+ s.email = "virgil@roundysoft.com"
32
+ s.homepage = "http://virgild.github.com/resumetools"
33
+ end
34
+
35
+ Rake::GemPackageTask.new(GEM_SPEC) do |p|
36
+ p.gem_spec = GEM_SPEC
37
+ p.need_tar = true
38
+ p.need_zip = true
39
+ end
40
+
41
+ desc "Generate gemspec file"
42
+ task :gemspec do
43
+ File.open(File.join(File.dirname(__FILE__), '..', 'resumetools.gemspec'), "w") do |f|
44
+ f.write(GEM_SPEC.to_ruby)
45
+ end
46
+ end
47
+
48
+ desc "Show information about the gem"
49
+ task :debug do
50
+ puts GEM_SPEC.to_ruby
51
+ end
52
+
53
+ desc "Install the gem"
54
+ task :install => ["clobber", "gem:package"] do
55
+ sh "#{SUDO} gem install --local pkg/#{GEM_SPEC.full_name}"
56
+ end
57
+
58
+ desc "Uninstall the gem"
59
+ task :uninstall do
60
+ installed_list = Gem.source_index.find_name(PKG_NAME)
61
+ if installed_list &&
62
+ (installed_list.collect { |s| s.version.to_s}.include?(PKG_VERSION))
63
+ sh(
64
+ "#{SUDO} gem uninstall --version '#{PKG_VERSION}' " +
65
+ "--ignore-dependencies --executables #{PKG_NAME}"
66
+ )
67
+ end
68
+ end
69
+
70
+ desc "Reinstall the gem"
71
+ task :reinstall => [:uninstall, :install]
72
+ end
73
+
74
+ desc "Alias to gem:package"
75
+ task "gem" => "gem:package"
76
+
77
+ task "clobber" => ["gem:clobber_package"]
@@ -0,0 +1,9 @@
1
+ namespace :package do
2
+ desc "Clean Mac OS X extended file attributes"
3
+ task :clean_attributes do
4
+ `for i in $(ls -Rl@ | grep '^\t' | awk '{print $1}' | sort -u); do
5
+ find . | xargs xattr -d $i 2>/dev/null;
6
+ done
7
+ `
8
+ end
9
+ end
data/tasks/rdoc.rake ADDED
@@ -0,0 +1,29 @@
1
+ require "rake/rdoctask"
2
+
3
+ namespace :doc do
4
+ desc "Generate RDoc documentation"
5
+ Rake::RDocTask.new do |rdoc|
6
+ rdoc.rdoc_dir = "doc"
7
+ rdoc.title = "#{PKG_NAME}-#{PKG_VERSION} Documentation"
8
+ rdoc.options << "--line-numbers" << "--inline-source" <<
9
+ "--accessor" << "cattr_accessor=object" << "--charset" << "utf-8"
10
+ rdoc.template = "#{ENV["template"]}.rb" if ENV["template"]
11
+ rdoc.rdoc_files.include("README", "CHANGES", "LICENSE")
12
+ rdoc.rdoc_files.include("lib/**/*.rb")
13
+ end
14
+
15
+ desc "Generate ri locally for testing"
16
+ task :ri do
17
+ sh "rdoc --ri -o ri ."
18
+ end
19
+
20
+ desc "Remove ri products"
21
+ task :clobber_ri do
22
+ rm_r "ri" rescue nil
23
+ end
24
+ end
25
+
26
+ desc "Alias to doc:rdoc"
27
+ task "doc" => "doc:rdoc"
28
+
29
+ task "clobber" => ["doc:clobber_rdoc", "doc:clobber_ri"]
data/tasks/rspec.rake ADDED
@@ -0,0 +1,16 @@
1
+ namespace :spec do
2
+ desc "Run all specs"
3
+ Spec::Rake::SpecTask.new(:normal) do |t|
4
+ t.spec_files = FileList['spec/**/*_spec.rb']
5
+ t.spec_opts = ["--colour", "--format", "specdoc"]
6
+ end
7
+
8
+ desc "Run specs with rcov"
9
+ Spec::Rake::SpecTask.new(:rcov) do |t|
10
+ t.spec_files = FileList['spec/**/*_spec.rb']
11
+ t.spec_opts = ["--colour", "--format", "specdoc"]
12
+ t.rcov = true
13
+ end
14
+ end
15
+
16
+ task :spec => "spec:normal"
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: virgild-resumetools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Virgil Dimaguila
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-11 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rake
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.8.7
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.8
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: extlib
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: prawn
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 0.5.0
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: treetop
57
+ type: :runtime
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 1.3.0
64
+ version:
65
+ description: Resume generation and writing tools
66
+ email: virgil@roundysoft.com
67
+ executables: []
68
+
69
+ extensions: []
70
+
71
+ extra_rdoc_files: []
72
+
73
+ files:
74
+ - examples/sample.pdf
75
+ - examples/sample.resume
76
+ - lib/grammars
77
+ - lib/grammars/resume.treetop
78
+ - lib/resume
79
+ - lib/resume/pdf.rb
80
+ - lib/resume/resume.rb
81
+ - lib/resume/text_reader.rb
82
+ - lib/resumetools
83
+ - lib/resumetools/version.rb
84
+ - lib/resumetools.rb
85
+ - spec/grammar_spec.rb
86
+ - spec/read_resume_spec.rb
87
+ - spec/rendering_pdf_spec.rb
88
+ - spec/resume_spec.rb
89
+ - spec/spec.opts
90
+ - spec/spec_helper.rb
91
+ - tasks/default.rake
92
+ - tasks/gem.rake
93
+ - tasks/package.rake
94
+ - tasks/rdoc.rake
95
+ - tasks/rspec.rake
96
+ - CHANGES
97
+ - LICENSE
98
+ - Rakefile
99
+ - README.md
100
+ has_rdoc: false
101
+ homepage: http://virgild.github.com/resumetools
102
+ licenses:
103
+ post_install_message:
104
+ rdoc_options: []
105
+
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 1.8.6
113
+ version:
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: "0"
119
+ version:
120
+ requirements: []
121
+
122
+ rubyforge_project:
123
+ rubygems_version: 1.3.5
124
+ signing_key:
125
+ specification_version: 3
126
+ summary: Resume generation and writing tools
127
+ test_files: []
128
+