sie 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -0
- data/README.md +113 -3
- data/lib/sie/document/renderer.rb +2 -0
- data/lib/sie/version.rb +1 -1
- metadata +15 -16
- data/script/ci/support/env +0 -6
- data/script/ci/tests.sh +0 -5
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Sie
|
2
2
|
|
3
|
+
[![Build Status](https://secure.travis-ci.org/barsoom/sie.png)](http://travis-ci.org/barsoom/sie)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/barsoom/sie.png)](https://codeclimate.com/github/barsoom/sie)
|
5
|
+
|
6
|
+
|
3
7
|
## Installation
|
4
8
|
|
5
9
|
Add this line to your application's Gemfile:
|
@@ -14,6 +18,115 @@ Or install it yourself as:
|
|
14
18
|
|
15
19
|
$ gem install sie
|
16
20
|
|
21
|
+
## Generating a SIE file
|
22
|
+
|
23
|
+
To generate a SIE document you define a class that responds to the methods below. Try it out! Copy and paste this example into a ruby file and run it.
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require "date"
|
27
|
+
|
28
|
+
class YourDataSource
|
29
|
+
def program
|
30
|
+
"Your app"
|
31
|
+
end
|
32
|
+
|
33
|
+
def program_version
|
34
|
+
"1.0"
|
35
|
+
end
|
36
|
+
|
37
|
+
def generated_on
|
38
|
+
Date.today
|
39
|
+
end
|
40
|
+
|
41
|
+
def from_date
|
42
|
+
Date.today
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_date
|
46
|
+
Date.today
|
47
|
+
end
|
48
|
+
|
49
|
+
def company_name
|
50
|
+
"Your company"
|
51
|
+
end
|
52
|
+
|
53
|
+
def financial_year_start_month
|
54
|
+
1
|
55
|
+
end
|
56
|
+
|
57
|
+
def accounts
|
58
|
+
[
|
59
|
+
{ number: 1500, description: "Customer ledger" }
|
60
|
+
]
|
61
|
+
end
|
62
|
+
|
63
|
+
def balance_account_numbers
|
64
|
+
[ "1500", "2400" ]
|
65
|
+
end
|
66
|
+
|
67
|
+
def closing_account_numbers
|
68
|
+
[ "3100" ]
|
69
|
+
end
|
70
|
+
|
71
|
+
# Used to calculate balance before (and on) the given date for an account.
|
72
|
+
def balance_before(account_number, date)
|
73
|
+
# ActiveRecord example:
|
74
|
+
# VoucherLine.where('booked_on <= ?', date).
|
75
|
+
# where(account_number: account_number).sum(:amount)
|
76
|
+
|
77
|
+
0
|
78
|
+
end
|
79
|
+
|
80
|
+
# Used to load voucher data in batches so that you don't need to load all of
|
81
|
+
# it into memory at once.
|
82
|
+
def each_voucher(&block)
|
83
|
+
[
|
84
|
+
{
|
85
|
+
creditor: false, type: :invoice, number: 1,
|
86
|
+
booked_on: Date.today, description: "Invoice 1",
|
87
|
+
voucher_lines: [
|
88
|
+
{
|
89
|
+
account_number: "1500", amount: 512.0,
|
90
|
+
booked_on: Date.today, description: "Item 1"
|
91
|
+
},
|
92
|
+
{
|
93
|
+
account_number: "3100", amount: -512.0,
|
94
|
+
booked_on: Date.today, description: "Item 1"
|
95
|
+
},
|
96
|
+
]
|
97
|
+
}
|
98
|
+
].each(&block)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
data_source = YourDataSource.new
|
103
|
+
|
104
|
+
require "sie"
|
105
|
+
doc = Sie::Document.new(data_source)
|
106
|
+
puts doc.render
|
107
|
+
```
|
108
|
+
|
109
|
+
For more info, see the specs.
|
110
|
+
|
111
|
+
## Parsing a SIE file
|
112
|
+
|
113
|
+
You can parse sie data from anything that responds to `each_line` like a file or a string.
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
File.open("path/to/file.se") do |f|
|
117
|
+
parser = Sie::Parser.new
|
118
|
+
sie_file = parser.parse(f)
|
119
|
+
|
120
|
+
# The company name
|
121
|
+
puts sie_file.entries_with_label("fnamn").first.attributes["foretagsnamn"]
|
122
|
+
|
123
|
+
# The first account number
|
124
|
+
puts sie_file.entries_with_label("konto").first.attributes["kontonr"]
|
125
|
+
end
|
126
|
+
```
|
127
|
+
|
128
|
+
For more info, see the specs.
|
129
|
+
|
17
130
|
## Developing
|
18
131
|
|
19
132
|
First time setup:
|
@@ -28,9 +141,6 @@ Getting the latest code and gems:
|
|
28
141
|
|
29
142
|
script/refresh
|
30
143
|
|
31
|
-
## Usage
|
32
|
-
|
33
|
-
|
34
144
|
## Contributing
|
35
145
|
|
36
146
|
1. Fork it
|
data/lib/sie/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: attr_extras
|
16
|
-
requirement: &
|
16
|
+
requirement: &70219540379320 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70219540379320
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &70219540378900 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70219540378900
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70219540378400 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '1.3'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70219540378400
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &70219540377980 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70219540377980
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &70219540377520 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70219540377520
|
69
69
|
description: SIE parser and generator
|
70
70
|
email:
|
71
71
|
- all@barsoom.se
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- .gitignore
|
77
77
|
- .rspec
|
78
78
|
- .rvmrc
|
79
|
+
- .travis.yml
|
79
80
|
- Gemfile
|
80
81
|
- README.md
|
81
82
|
- Rakefile
|
@@ -94,8 +95,6 @@ files:
|
|
94
95
|
- lib/sie/parser/tokenizer/token.rb
|
95
96
|
- lib/sie/version.rb
|
96
97
|
- script/bootstrap
|
97
|
-
- script/ci/support/env
|
98
|
-
- script/ci/tests.sh
|
99
98
|
- script/refresh
|
100
99
|
- script/turbux_rspec
|
101
100
|
- sie.gemspec
|
@@ -123,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
122
|
version: '0'
|
124
123
|
segments:
|
125
124
|
- 0
|
126
|
-
hash:
|
125
|
+
hash: -4086731428764887794
|
127
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
127
|
none: false
|
129
128
|
requirements:
|
@@ -132,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
131
|
version: '0'
|
133
132
|
segments:
|
134
133
|
- 0
|
135
|
-
hash:
|
134
|
+
hash: -4086731428764887794
|
136
135
|
requirements: []
|
137
136
|
rubyforge_project:
|
138
137
|
rubygems_version: 1.8.6
|
data/script/ci/support/env
DELETED