gnucash-invoice 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NTM0ZmFmZmJhNzA5ZDU5OTk3YmViZTBmY2I4ZDQ5MWQ0OTlmYjZkZg==
5
- data.tar.gz: !binary |-
6
- MjkxM2RmZThlM2YyZDYxMDZlNWU3MmViMTZhY2RjODk2NjcxNDNlNw==
2
+ SHA1:
3
+ metadata.gz: 6805f32b727e0fa30dc0956701570949a8d9a7cd
4
+ data.tar.gz: aad080f28dd9ff8cffbda343c5c4dbe6d176f533
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZDk1MzI3OWI2MTU1N2U4YWIzNDBhNmM0MDk2YjA4OTAzMDUxNGE5Njg3Mjlj
10
- NzVjYjgxYjI1ODg4Nzc0NDEwYTE0MTQ4ZTliMzhhOTQzZGFjMjUxZTVjYzcx
11
- NjAxNjhmMmVlNTc4ODE5ODQ5OWUwNDQ3YWJhODY3MzE1MWEzMmI=
12
- data.tar.gz: !binary |-
13
- NGRkOGY0Mzc3MWQwZTRiMTdmYTM0MzUyYjJmMjViMTZiOWM2MjBlOTE3NjA2
14
- MTJhZjQwZmZiZDc2NjdkYjg4NmE0NjhjMmQxYTgyNmZlOWQwZmEwY2RkYTdi
15
- ZWYwNzY3MmU2NzkxMzA1ODM2MWNjZWU1N2ZlOTA4ODRmZTBhNDk=
6
+ metadata.gz: 7100d3d30cb33e12e52a9612a92d2d8fb9104c3eef271c1e409d1678cf406e2df2329eaaa111e76108aaec638370df27fac514597ca5c653fab80fd5bfb8cdd1
7
+ data.tar.gz: 736304526efb62cda0f97e15c9f559cf7269316fd05f79552edd0695fbd23e7adc254035c3e3fe226190ce6ba87396fc5b6cf1add2865d2d48567523899d7bcf
@@ -6,7 +6,7 @@ require 'sprockets'
6
6
  module GnuCash
7
7
  class Invoice
8
8
  class Printer
9
- def initialize invoice_id, templates = "templates"
9
+ def initialize invoice_id, templates
10
10
  @invoice = Invoice.find(invoice_id)
11
11
  @templates = GnuCash.root.join(templates)
12
12
  end
@@ -1,54 +1,66 @@
1
1
  # stdlib
2
- require 'ostruct'
3
- require 'optparse'
4
- require 'pathname'
5
-
2
+ require "optparse"
6
3
 
7
4
  module GnuCash
8
5
  class Invoice
9
6
  module Runner
10
- class InvalidArguments < StandardError; end
7
+ class << self
8
+ def run(argv)
9
+ options = parse argv
11
10
 
11
+ unless options[:db]
12
+ puts "ERROR: No database selected"
13
+ exit 1
14
+ end
12
15
 
13
- def self.run argv
14
- options = parse argv
16
+ GnuCash.connect! options[:db]
15
17
 
16
- GnuCash.connect! options.dbpath
18
+ if options[:invoice_id]
19
+ # Print out invoice
20
+ puts Printer.new(options[:invoice_id], options[:template]).render
21
+ exit 0
22
+ end
17
23
 
18
- # Print out invoice
19
- unless argv.empty?
20
- puts Printer.new(options.invoice_id, options.template_path).render
21
- exit
24
+ # Show known invoices
25
+ Invoice.all.each { |invoice| puts invoice }
26
+ exit 0
27
+ rescue Sequel::DatabaseConnectionError
28
+ puts "ERROR: Can't connect to database: #{options[:db].inspect}"
29
+ exit 2
30
+ rescue => e
31
+ puts "ERROR: #{e}"
32
+ exit 3
22
33
  end
23
34
 
24
- # Show known invoices
25
- Invoice.all.each do |invoice|
26
- puts invoice
27
- end
28
- end
35
+ protected
29
36
 
37
+ def parse(argv)
38
+ options = { :template => "templates" }
30
39
 
31
- protected
40
+ OptionParser.new do |opts|
41
+ opts.on("--dbpath [DATABASE]",
42
+ "SQLite database path") do |path|
43
+ puts "WARNING: --dbpath is deprecated use --db-path instead"
44
+ options[:db] = path
45
+ end
32
46
 
47
+ opts.on("-d", "--db-path [DATABASE]",
48
+ "SQLite database path") do |path|
49
+ options[:db] = path
50
+ end
33
51
 
34
- def self.parse argv
35
- options = OpenStruct.new
52
+ opts.on("-t", "--template [TEMPLATE]",
53
+ "Template directory path") do |path|
54
+ options[:template] = path
55
+ end
36
56
 
37
- OptionParser.new do |opts|
38
- opts.on('-d', '--dbpath [DATABASE]', 'SQLite database path') do |path|
39
- options.dbpath = Pathname.new path
40
- end
41
- opts.on('-t', '--template [TEMPLATE]', 'Template directory path') do |path|
42
- options.template_path = Pathname.new path
57
+ opts.parse! argv
43
58
  end
44
- end.parse! argv
45
59
 
46
- raise InvalidArguments, "No database selected" unless options.dbpath
47
- raise InvalidArguments, "Can't find specified database" unless options.dbpath.exist?
60
+ options[:invoice_id] = argv.first
48
61
 
49
- options.invoice_id = argv.first
50
-
51
- options
62
+ options
63
+ end
52
64
  end
53
65
  end
54
66
  end
@@ -1,5 +1,5 @@
1
1
  module GnuCash
2
2
  class Invoice
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gnucash-invoice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksey
@@ -10,90 +10,90 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-11-11 00:00:00.000000000 Z
13
+ date: 2014-11-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sequel
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ~>
19
+ - - "~>"
20
20
  - !ruby/object:Gem::Version
21
21
  version: '3.41'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ~>
26
+ - - "~>"
27
27
  - !ruby/object:Gem::Version
28
28
  version: '3.41'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: slim
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - ~>
33
+ - - "~>"
34
34
  - !ruby/object:Gem::Version
35
35
  version: '1.3'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - ~>
40
+ - - "~>"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '1.3'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: sass
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ~>
47
+ - - "~>"
48
48
  - !ruby/object:Gem::Version
49
49
  version: '3.2'
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - ~>
54
+ - - "~>"
55
55
  - !ruby/object:Gem::Version
56
56
  version: '3.2'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: sprockets
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ~>
61
+ - - "~>"
62
62
  - !ruby/object:Gem::Version
63
63
  version: '2.8'
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ~>
68
+ - - "~>"
69
69
  - !ruby/object:Gem::Version
70
70
  version: '2.8'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: sqlite3
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ! '>='
75
+ - - ">="
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - ! '>='
82
+ - - ">="
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: rake
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - ! '>='
89
+ - - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - ! '>='
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  description: GnuCash invoice printer for human beings.
@@ -104,7 +104,7 @@ executables:
104
104
  extensions: []
105
105
  extra_rdoc_files: []
106
106
  files:
107
- - .gitignore
107
+ - ".gitignore"
108
108
  - COPYING
109
109
  - Gemfile
110
110
  - LICENSE
@@ -136,19 +136,18 @@ require_paths:
136
136
  - lib
137
137
  required_ruby_version: !ruby/object:Gem::Requirement
138
138
  requirements:
139
- - - ! '>='
139
+ - - ">="
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  requirements:
144
- - - ! '>='
144
+ - - ">="
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0'
147
147
  requirements: []
148
148
  rubyforge_project:
149
- rubygems_version: 2.1.8
149
+ rubygems_version: 2.4.1
150
150
  signing_key:
151
151
  specification_version: 4
152
- summary: gnucash-invoice-0.1.3
152
+ summary: gnucash-invoice-0.1.4
153
153
  test_files: []
154
- has_rdoc: