farmingengineers 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+ gem 'ruport'
3
+ gem 'ruport-util'
@@ -0,0 +1,35 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ color (1.4.1)
5
+ fastercsv (1.5.3)
6
+ hoe (2.6.2)
7
+ rake (>= 0.8.7)
8
+ rubyforge (>= 2.0.4)
9
+ json_pure (1.4.6)
10
+ mailfactory (1.4.0)
11
+ mime-types (>= 1.13.1)
12
+ mime-types (1.16)
13
+ pdf-writer (1.1.8)
14
+ color (>= 1.4.0)
15
+ transaction-simple (~> 1.3)
16
+ rake (0.8.7)
17
+ rubyforge (2.0.4)
18
+ json_pure (>= 1.1.7)
19
+ rubyzip (0.9.4)
20
+ ruport (1.6.3)
21
+ fastercsv
22
+ pdf-writer (= 1.1.8)
23
+ ruport-util (0.14.0)
24
+ mailfactory (>= 1.2.3)
25
+ rubyzip (>= 0.9.1)
26
+ ruport (>= 1.6.0)
27
+ transaction-simple (1.4.0)
28
+ hoe (>= 1.1.7)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ ruport
35
+ ruport-util
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Matt Burke
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,17 @@
1
+ = invoices-x
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Matt Burke. See LICENSE for details.
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "farmingengineers"
8
+ gem.summary = %Q{Stuff that's useful to the farming engineers.}
9
+ gem.description = %Q{Invoice generators, etc.}
10
+ gem.email = "mr.matt.burke@gmail.com"
11
+ gem.homepage = "http://github.com/spraints/farmingengineers"
12
+ gem.authors = ["Matt Burke"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_development_dependency "yard", ">= 0"
15
+ gem.add_dependency 'ruport', '>= 1.6.3'
16
+ gem.add_dependency 'ruport-util', '>= 0.14.0'
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
+ end
23
+
24
+ require 'spec/rake/spectask'
25
+ Spec::Rake::SpecTask.new(:spec) do |spec|
26
+ spec.libs << 'lib' << 'spec'
27
+ spec.spec_files = FileList['spec/**/*_spec.rb']
28
+ end
29
+
30
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
31
+ spec.libs << 'lib' << 'spec'
32
+ spec.pattern = 'spec/**/*_spec.rb'
33
+ spec.rcov = true
34
+ end
35
+
36
+ task :spec => :check_dependencies
37
+
38
+ task :default => :spec
39
+
40
+ begin
41
+ require 'yard'
42
+ YARD::Rake::YardocTask.new
43
+ rescue LoadError
44
+ task :yardoc do
45
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
46
+ end
47
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1,73 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{farmingengineers}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Matt Burke"]
12
+ s.date = %q{2010-10-16}
13
+ s.description = %q{Invoice generators, etc.}
14
+ s.email = %q{mr.matt.burke@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "farmingengineers.gemspec",
29
+ "invoice.rb",
30
+ "lib/egg_csa_invoice.rb",
31
+ "lib/farming_engineers.rb",
32
+ "lib/farming_engineers/invoices.rb",
33
+ "lib/farming_engineers/invoices/.eggs.rb.swp",
34
+ "lib/farming_engineers/invoices/common.rb",
35
+ "lib/farming_engineers/invoices/eggs.rb",
36
+ "lib/instance_eval_attr.rb",
37
+ "spec/egg_csa_invoices.rb",
38
+ "spec/spec.opts",
39
+ "spec/spec_helper.rb"
40
+ ]
41
+ s.homepage = %q{http://github.com/spraints/farmingengineers}
42
+ s.rdoc_options = ["--charset=UTF-8"]
43
+ s.require_paths = ["lib"]
44
+ s.rubygems_version = %q{1.3.7}
45
+ s.summary = %q{Stuff that's useful to the farming engineers.}
46
+ s.test_files = [
47
+ "spec/egg_csa_invoices.rb",
48
+ "spec/spec_helper.rb"
49
+ ]
50
+
51
+ if s.respond_to? :specification_version then
52
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
53
+ s.specification_version = 3
54
+
55
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
57
+ s.add_development_dependency(%q<yard>, [">= 0"])
58
+ s.add_runtime_dependency(%q<ruport>, [">= 1.6.3"])
59
+ s.add_runtime_dependency(%q<ruport-util>, [">= 0.14.0"])
60
+ else
61
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
62
+ s.add_dependency(%q<yard>, [">= 0"])
63
+ s.add_dependency(%q<ruport>, [">= 1.6.3"])
64
+ s.add_dependency(%q<ruport-util>, [">= 0.14.0"])
65
+ end
66
+ else
67
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
68
+ s.add_dependency(%q<yard>, [">= 0"])
69
+ s.add_dependency(%q<ruport>, [">= 1.6.3"])
70
+ s.add_dependency(%q<ruport-util>, [">= 0.14.0"])
71
+ end
72
+ end
73
+
@@ -0,0 +1,11 @@
1
+ require 'rubygems' ; require 'bundler/setup'
2
+ $: << 'lib'
3
+ require 'egg_csa_invoice'
4
+
5
+
6
+ egg_csa_invoice do
7
+ customer 'Sample customer'
8
+ address ['123 Street', 'City, IN', '317-xxx-xxxx']
9
+ deposit '8/1/2010', 50
10
+ deliver '10/11/2010', 4
11
+ end
@@ -0,0 +1,42 @@
1
+ require 'ruport'
2
+ require 'ruport/util'
3
+ require 'farming_engineers'
4
+
5
+ $invoice_count = 0
6
+ def egg_csa_invoice(&block)
7
+ invoice = FarmingEngineers::Invoices::Eggs::Invoice.new
8
+ invoice.instance_eval(&block)
9
+
10
+ history_table = Table(:date, :description, :quantity, :total, :balance) do |t|
11
+ balance = 0
12
+ invoice.history.each do |line|
13
+ balance += line.total
14
+ t << [line.date, line.description, line.quantity, line.total, balance]
15
+ end
16
+ end
17
+
18
+ history_table.rename_columns(
19
+ :date => 'Date',
20
+ :description => 'Description',
21
+ :quantity => 'Quantity',
22
+ :total => 'Total',
23
+ :balance => 'Balance'
24
+ )
25
+
26
+ invoice_id = "#{Date.today.strftime('%Y%m%d')}-#{$invoice_count += 1}"
27
+ invoice_file = "invoice-#{invoice_id}.pdf"
28
+
29
+ Ruport::Controller::Invoice.render :pdf, :file => invoice_file do |i|
30
+ i.data = history_table
31
+ i.options do |o|
32
+ o.company_info = "the farming engineers\nPO Box 1031\nWestfield, IN 46074"
33
+ o.customer_info = "#{invoice.customer}\n#{invoice.address.join("\n")}"
34
+ o.comments = "#{invoice.notes}"
35
+ o.order_info = "Invoice #{invoice_id}"
36
+ o.title = "Egg delivery"
37
+ o.body_width = 480
38
+ o.comments_font_size = 12
39
+ o.title_font_size = 10
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ module FarmingEngineers
2
+ autoload :Invoices, 'farming_engineers/invoices'
3
+ end
@@ -0,0 +1,5 @@
1
+ module FarmingEngineers ; module Invoices
2
+ autoload :Reports, 'farming_engineers/invoices/reports'
3
+ autoload :Common, 'farming_engineers/invoices/common'
4
+ autoload :Eggs, 'farming_engineers/invoices/eggs'
5
+ end ; end
@@ -0,0 +1,30 @@
1
+ require 'instance_eval_attr'
2
+
3
+ module FarmingEngineers ; module Invoices ; module Common
4
+ class Invoice
5
+ extend InstanceEvalAttr
6
+ instance_eval_attr :customer, :address, :notes
7
+
8
+ attr_reader :history
9
+
10
+ def method_missing(method, *args)
11
+ history.send(method, *args)
12
+ end
13
+ end
14
+
15
+ class History < Array
16
+ def deposit date, amount
17
+ push Deposit.new(date, amount)
18
+ end
19
+ end
20
+ class HistoryItem
21
+ attr_reader :date, :description, :quantity, :total
22
+ end
23
+ class Deposit < HistoryItem
24
+ def initialize(date, amount)
25
+ @date = date
26
+ @description = 'Deposit'
27
+ @total = -amount
28
+ end
29
+ end
30
+ end ; end ; end
@@ -0,0 +1,31 @@
1
+
2
+ module FarmingEngineers ; module Invoices ; module Eggs
3
+ class Invoice < Common::Invoice
4
+ def initialize
5
+ @history = History.new
6
+ end
7
+ end
8
+
9
+ class History < Common::History
10
+ def deliver date, dozens
11
+ push Delivery.new(date, dozens)
12
+ end
13
+ end
14
+
15
+ class Delivery < Common::HistoryItem
16
+ def initialize(date, dozens)
17
+ @date = date
18
+ @description = 'Delivery'
19
+ @quantity = dozens
20
+ end
21
+ def total
22
+ if @quantity < 8
23
+ @quantity * 5
24
+ elsif @quantity < 12
25
+ @quantity * 4.50
26
+ else
27
+ @quantity * 4
28
+ end
29
+ end
30
+ end
31
+ end ; end ; end
@@ -0,0 +1,14 @@
1
+ module InstanceEvalAttr
2
+ def instance_eval_attr(*names)
3
+ names.each do |name|
4
+ varname= "@#{name}"
5
+ define_method name do |*args|
6
+ instance_variable_set(varname, args.first) unless args.empty?
7
+ instance_variable_get(varname)
8
+ end
9
+ define_method "#{name}=" do |val|
10
+ instance_variable_set(varname, val)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "egg_csa_invoices" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'invoices-x'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: farmingengineers
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 1
10
+ version: 0.1.1
11
+ platform: ruby
12
+ authors:
13
+ - Matt Burke
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-16 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 1
32
+ - 2
33
+ - 9
34
+ version: 1.2.9
35
+ type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: yard
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: ruport
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 9
60
+ segments:
61
+ - 1
62
+ - 6
63
+ - 3
64
+ version: 1.6.3
65
+ type: :runtime
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ name: ruport-util
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 39
76
+ segments:
77
+ - 0
78
+ - 14
79
+ - 0
80
+ version: 0.14.0
81
+ type: :runtime
82
+ version_requirements: *id004
83
+ description: Invoice generators, etc.
84
+ email: mr.matt.burke@gmail.com
85
+ executables: []
86
+
87
+ extensions: []
88
+
89
+ extra_rdoc_files:
90
+ - LICENSE
91
+ - README.rdoc
92
+ files:
93
+ - .document
94
+ - .gitignore
95
+ - Gemfile
96
+ - Gemfile.lock
97
+ - LICENSE
98
+ - README.rdoc
99
+ - Rakefile
100
+ - VERSION
101
+ - farmingengineers.gemspec
102
+ - invoice.rb
103
+ - lib/egg_csa_invoice.rb
104
+ - lib/farming_engineers.rb
105
+ - lib/farming_engineers/invoices.rb
106
+ - lib/farming_engineers/invoices/.eggs.rb.swp
107
+ - lib/farming_engineers/invoices/common.rb
108
+ - lib/farming_engineers/invoices/eggs.rb
109
+ - lib/instance_eval_attr.rb
110
+ - spec/egg_csa_invoices.rb
111
+ - spec/spec.opts
112
+ - spec/spec_helper.rb
113
+ has_rdoc: true
114
+ homepage: http://github.com/spraints/farmingengineers
115
+ licenses: []
116
+
117
+ post_install_message:
118
+ rdoc_options:
119
+ - --charset=UTF-8
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ hash: 3
128
+ segments:
129
+ - 0
130
+ version: "0"
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ hash: 3
137
+ segments:
138
+ - 0
139
+ version: "0"
140
+ requirements: []
141
+
142
+ rubyforge_project:
143
+ rubygems_version: 1.3.7
144
+ signing_key:
145
+ specification_version: 3
146
+ summary: Stuff that's useful to the farming engineers.
147
+ test_files:
148
+ - spec/egg_csa_invoices.rb
149
+ - spec/spec_helper.rb