doctag_json_schema 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ pkg/
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ gemfile:
5
+ - Gemfile
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # DocTag JSON Schema
2
+ [![Build Status](https://secure.travis-ci.org/docTag/doctag_json_schema.png?branch=master)](http://travis-ci.org/docTag/doctag_json_schema)
3
+
4
+ This is the formal description of the docTag(working title) document exchange
5
+ format. With docTag we(see Supporters) aim to simplify the exchange of documents
6
+ e.g. invoices, between services.
7
+
8
+ Our goal is to provide a small common subset of objects and fields, which can
9
+ be extended by everybody. As a starting point we tackle invoice documents.
10
+
11
+ ## About JSON Schema
12
+
13
+ [JSON-Schema](json-schema.org) is formal way to describe JSON structures.
14
+
15
+ > JSON Schema provides a contract for what JSON data is required for a given
16
+ application and how to interact with it. JSON Schema is intended to define
17
+ validation, documentation, hyperlink navigation, and interaction control of JSON
18
+ data.
19
+ Quoted: http://tools.ietf.org/html/draft-zyp-json-schema-03
20
+
21
+ Compared to its evil twin: XML Schema (WSDL), json-schema is lightweight, easier
22
+ to read(also for humans) and to parse.
23
+
24
+ ## Other formats
25
+
26
+ The idea to exchange documents in a structured, machine readable format isn't
27
+ new. We could not find any existing solution which could fit small businesses
28
+ needs and where easy to implement.
29
+
30
+ Formats like [EDI](http://en.wikipedia.org/wiki/Electronic_Data_Interchange#See_also)
31
+ and it's xml-based subsets rather fit big enterprises and are way too bloated.
32
+
33
+ ## Test
34
+
35
+ A tiny test-suite in /test ensures that all schema files contain valid json.
36
+ The test are run after each commit by travis-ci(see batch above)
37
+
38
+ To run the test locally you need ruby. First install the ruby-gem dependencies
39
+ and then run it:
40
+
41
+ bundle install
42
+ rake spec
43
+
44
+
45
+ ## Initiative Supporters a-z
46
+
47
+ * Billomat
48
+ * CentralStation CRM
49
+ * Doctape
50
+ * Easybill
51
+ * FastBill
52
+ * Fileee
53
+ * FreeFibu
54
+ * Fortrabbit
55
+ * Mein Tagwerk
56
+ * Salesking
57
+ * Smarchive
58
+ * Skippr
59
+
60
+ ## License
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec'
4
+ require 'rspec/core/rake_task'
5
+
6
+ desc 'Run specs'
7
+ RSpec::Core::RakeTask.new
8
+ task :default => :spec
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'doc_tag/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.version = DocTag::Schema::VERSION
7
+ s.date = %q{2013-01-01}
8
+ s.name = %q{doctag_json_schema}
9
+ s.summary = 'DocTag API - JSON Schema'
10
+ s.description = %q{This is the formal description of the docTag document exchange format. With docTag we(see Supporters) aim to simplify the exchange of documents e.g. invoices, between services. Ruby users can use this gem with utility methods to load and test the schema files.}
11
+ s.authors = ['Georg Leciejewski']
12
+ s.email = %q{gl@salesking.eu}
13
+ s.homepage = %q{https://github.com/docTag/doctag_json_schema}
14
+ s.extra_rdoc_files = ['README.md']
15
+ s.executables = nil
16
+ s.files = `git ls-files`.split("\n").reject{|i| i[/^docs\//] }
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+
19
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
20
+ s.require_paths = ['lib']
21
+
22
+ s.add_development_dependency 'rspec'
23
+ s.add_development_dependency 'json_schema_tools'
24
+ s.add_development_dependency 'rake', '>= 0.9.2'
25
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+ module DocTag
3
+ class Schema
4
+ # Get the path to schema files. So it can be used f.ex. with
5
+ # gem json_schema_tools
6
+ def self.path
7
+ File.expand_path( '../../schema', File.dirname(__FILE__))
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ module DocTag
2
+ class Schema
3
+ # gem version
4
+ VERSION='1.0.0'
5
+ end
6
+ end
@@ -0,0 +1 @@
1
+ require 'doc_tag/schema'
@@ -0,0 +1,39 @@
1
+ { "type":"object",
2
+ "title": "address",
3
+ "description": "An address of a contact for a document",
4
+ "properties":{
5
+ "name":{
6
+ "description": "tax name",
7
+ "type":"string",
8
+ "required": true
9
+ },
10
+ "contact":{
11
+ "description": "contact name",
12
+ "type":"string"
13
+ },
14
+ "street":{
15
+ "description": "street name",
16
+ "type":"string"
17
+ },
18
+ "zip_code":{
19
+ "description": "ZIP code",
20
+ "type":"string"
21
+ },
22
+ "city":{
23
+ "description": "City",
24
+ "type":"string"
25
+ },
26
+ "state":{
27
+ "description": "State",
28
+ "type":"string"
29
+ },
30
+ "country":{
31
+ "description": "Country code ISO 3166-1",
32
+ "type":"string"
33
+ },
34
+ "tax_number":{
35
+ "description": "Tax number",
36
+ "type":"string"
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,16 @@
1
+ { "type":"object",
2
+ "title": "amount",
3
+ "description": "Gross and net total values for a total",
4
+ "properties":{
5
+ "gross":{
6
+ "description": "Gross total",
7
+ "type":"number",
8
+ "required": true
9
+ },
10
+ "net":{
11
+ "description": "Net total",
12
+ "type":"number",
13
+ "required": true
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,22 @@
1
+ { "type":"object",
2
+ "title": "amount",
3
+ "description": "Gross and net total values for a total",
4
+ "properties":{
5
+ "date":{
6
+ "description": "Date the discount expires. ISO-8601 format: YYYY-MM-DD",
7
+ "format":"date",
8
+ "type":"string",
9
+ "required": true
10
+ },
11
+ "rate":{
12
+ "description": "Discount percent value",
13
+ "type":"string",
14
+ "required": true
15
+ },
16
+ "amount":{
17
+ "description": "Discounted value",
18
+ "type":"number",
19
+ "required": true
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,95 @@
1
+ { "type":"object",
2
+ "title": "Document",
3
+ "description": "A document of the defined doctype",
4
+ "properties":{
5
+ "doctype":{
6
+ "description": "Type of the document",
7
+ "type":"string",
8
+ "required": true,
9
+ "enum": ["invoice", "offer"]
10
+ },
11
+ "doctag_version":{
12
+ "description": "Doctag Version used e.g.: 1.0.0",
13
+ "type":"string",
14
+ "required": true
15
+ },
16
+ "id":{
17
+ "description": "Unique ID",
18
+ "type":"string",
19
+ "required": true
20
+ },
21
+ "number":{
22
+ "description": "Unique number",
23
+ "type":"string"
24
+ },
25
+ "customer_number":{
26
+ "description": "Unique number of the contact related to this doc",
27
+ "type":"string"
28
+ },
29
+ "date":{
30
+ "description": "Date the document is issued. ISO-8601 format: YYYY-MM-DD",
31
+ "format":"date",
32
+ "type":"string",
33
+ "required": true
34
+ },
35
+ "delivery_date":{
36
+ "description": "Date ?? delivered. ISO-8601 format: YYYY-MM-DD",
37
+ "format":"date",
38
+ "type":"string",
39
+ "required": true
40
+ },
41
+ "due_date":{
42
+ "description": "Date the invoice is due. ISO-8601 format: YYYY-MM-DD",
43
+ "format":"date",
44
+ "type":"string"
45
+ },
46
+ "discount_date":{
47
+ "description": "Date until which a cash discount can be applied. ISO-8601 format: YYYY-MM-DD",
48
+ "format":"date",
49
+ "type":"string"
50
+ },
51
+ "intro":{
52
+ "description": "Intro text",
53
+ "type":"string"
54
+ },
55
+ "note":{
56
+ "description": "Notes text",
57
+ "type":"string"
58
+ },
59
+ "items":{
60
+ "description": "Line items for the document. The order matters.",
61
+ "type":"array",
62
+ "properties":{"$ref":"./item.json#properties"}
63
+ },
64
+ "sender":{
65
+ "description": "Document issuer",
66
+ "type":"object",
67
+ "properties":{"$ref":"./address.json#properties"}
68
+ },
69
+ "recipient":{
70
+ "description": "Document receiver",
71
+ "type":"object",
72
+ "properties":{"$ref":"./address.json#properties"}
73
+ },
74
+ "currency": {
75
+ "description": "ISO 4217 Currency Code",
76
+ "maxLength": 3,
77
+ "type":"string",
78
+ "required": true
79
+ },
80
+ "total":{
81
+ "description": "Gross and net total for all line items",
82
+ "type":"object",
83
+ "properties":{"$ref":"./amount.json#properties"}
84
+ },
85
+ "taxes":{
86
+ "description": "All taxes applied to all items",
87
+ "type":"array",
88
+ "properties":{"$ref":"./tax.json#properties"}
89
+ },
90
+ "discounts":{
91
+ "type":"array",
92
+ "properties":{"$ref":"./discount.json#properties"}
93
+ }
94
+ }
95
+ }
data/schema/item.json ADDED
@@ -0,0 +1,41 @@
1
+ { "type":"object",
2
+ "title": "item",
3
+ "description": "An item belonging to a document",
4
+ "properties":{
5
+ "title":{
6
+ "description": "Product name or item title",
7
+ "type":"string",
8
+ "required": true
9
+ },
10
+ "description":{
11
+ "description": "Item or product description",
12
+ "type":"string"
13
+ },
14
+ "unit":{
15
+ "description": "Unit name",
16
+ "type":"string"
17
+ },
18
+ "quantity":{
19
+ "description": "Quantity for this item",
20
+ "type":"number",
21
+ "required": true
22
+ },
23
+ "unit_price":{
24
+ "description": "Single price for one item",
25
+ "type":"array",
26
+ "properties":{"$ref":"./amount.json#properties"},
27
+ "required": true
28
+ },
29
+ "total":{
30
+ "description": "Totals net and gross prices for the item",
31
+ "type":"object",
32
+ "properties":{"$ref":"./amount.json#properties"},
33
+ "required": true
34
+ },
35
+ "taxes":{
36
+ "description": "Taxes applied to the item",
37
+ "type":"array",
38
+ "properties":{"$ref":"./tax.json#properties"}
39
+ }
40
+ }
41
+ }
data/schema/tax.json ADDED
@@ -0,0 +1,21 @@
1
+ { "type":"object",
2
+ "title": "tax",
3
+ "description": "An tax for an item of a document",
4
+ "properties":{
5
+ "name":{
6
+ "description": "tax name",
7
+ "type":"string",
8
+ "required": true
9
+ },
10
+ "rate":{
11
+ "description": "Tax rate in percent",
12
+ "type":"number",
13
+ "required": true
14
+ },
15
+ "amount":{
16
+ "description": "Tax total",
17
+ "type":"number",
18
+ "required": true
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe DocTag::Schema do
4
+
5
+ context 'path' do
6
+ it 'should provide path to schema files' do
7
+ DocTag::Schema.path.should == File.expand_path( File.join('../schema'), File.dirname(__FILE__))
8
+ end
9
+ end
10
+
11
+ context 'read schemata' do
12
+
13
+ it 'should read all json files' do
14
+ SchemaTools.schema_path = DocTag::Schema.path
15
+ SchemaTools::Reader.read_all
16
+ SchemaTools::Reader.registry.should_not be_empty
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+ $:.unshift(File.dirname(__FILE__))
3
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+
5
+ require 'rspec'
6
+ require 'json_schema_tools'
7
+ require 'doctag_json_schema'
8
+
9
+ RSpec.configure do |config|
10
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: doctag_json_schema
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Georg Leciejewski
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: json_schema_tools
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.2
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.2
62
+ description: This is the formal description of the docTag document exchange format.
63
+ With docTag we(see Supporters) aim to simplify the exchange of documents e.g. invoices,
64
+ between services. Ruby users can use this gem with utility methods to load and test
65
+ the schema files.
66
+ email: gl@salesking.eu
67
+ executables: []
68
+ extensions: []
69
+ extra_rdoc_files:
70
+ - README.md
71
+ files:
72
+ - .gitignore
73
+ - .travis.yml
74
+ - Gemfile
75
+ - README.md
76
+ - Rakefile
77
+ - doctag_json_schema.gemspec
78
+ - lib/doc_tag/schema.rb
79
+ - lib/doc_tag/version.rb
80
+ - lib/doctag_json_schema.rb
81
+ - schema/address.json
82
+ - schema/amount.json
83
+ - schema/discount.json
84
+ - schema/document.json
85
+ - schema/item.json
86
+ - schema/tax.json
87
+ - spec/doctag_schema_spec.rb
88
+ - spec/spec_helper.rb
89
+ homepage: https://github.com/docTag/doctag_json_schema
90
+ licenses: []
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ segments:
102
+ - 0
103
+ hash: -181409995259960853
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 1.8.24
113
+ signing_key:
114
+ specification_version: 3
115
+ summary: DocTag API - JSON Schema
116
+ test_files: []