doctag 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +13 -0
- data/.travis.yml +5 -0
- data/Gemfile +2 -0
- data/LICENSE +22 -0
- data/README.md +58 -0
- data/Rakefile +8 -0
- data/doctag.gemspec +25 -0
- data/lib/doc_tag.rb +19 -0
- data/lib/doc_tag/version.rb +3 -0
- data/lib/doctag.rb +1 -0
- data/spec/doctag_spec.rb +31 -0
- data/spec/spec_helper.rb +9 -0
- metadata +161 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012-2013 Georg Leciejewski
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following 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 OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Doctag Ruby Lib
|
2
|
+
|
3
|
+
[](https://travis-ci.org/docTag/doctag_rb)
|
4
|
+
|
5
|
+
Handle Doctag documents.
|
6
|
+
|
7
|
+
This is work in progress ...
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'doctag'
|
14
|
+
|
15
|
+
Or install with:
|
16
|
+
|
17
|
+
$ gem install doctag
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Initialize class structure
|
22
|
+
|
23
|
+
require 'doctag'
|
24
|
+
DocTag.init
|
25
|
+
|
26
|
+
Play with docs
|
27
|
+
|
28
|
+
doc = DocTag::Document.new doctype: 'invoice'
|
29
|
+
doc.number = '123'
|
30
|
+
doc.valid?
|
31
|
+
|
32
|
+
Play with related classes
|
33
|
+
|
34
|
+
tax = DocTag::Tax.new
|
35
|
+
tax.name = 'MwSt'
|
36
|
+
tax.rate = 19
|
37
|
+
tax.amount = 10
|
38
|
+
doc.tax = tax
|
39
|
+
|
40
|
+
TODO .. add 5 lines of ruby :-)
|
41
|
+
|
42
|
+
doc = DocTag::Document.from_json(json_string)
|
43
|
+
doc.to_json
|
44
|
+
|
45
|
+
doc = Document.new {params-hash}
|
46
|
+
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create new Pull Request
|
55
|
+
|
56
|
+
## Copyright
|
57
|
+
|
58
|
+
MIT License 2012-2013 Georg Leciejewski
|
data/Rakefile
ADDED
data/doctag.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/doc_tag/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ['Georg Leciejewski']
|
6
|
+
gem.email = ['gl@salesking.eu']
|
7
|
+
gem.description = %q{DocTag Ruby library}
|
8
|
+
gem.summary = %q{Create classes from doctag markup }
|
9
|
+
gem.homepage = 'https://github.com/docTag/doctag_rb'
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = 'doctag'
|
15
|
+
gem.require_paths = ['lib']
|
16
|
+
gem.version = DocTag::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'json_schema_tools'
|
19
|
+
gem.add_dependency 'doctag_json_schema'
|
20
|
+
gem.add_dependency 'activesupport'
|
21
|
+
|
22
|
+
gem.add_development_dependency 'rake'
|
23
|
+
gem.add_development_dependency 'simplecov'
|
24
|
+
gem.add_development_dependency 'rspec'
|
25
|
+
end
|
data/lib/doc_tag.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'json_schema_tools'
|
2
|
+
require 'doctag_json_schema'
|
3
|
+
|
4
|
+
module DocTag
|
5
|
+
class << self
|
6
|
+
# initialize class structure from json schema
|
7
|
+
# @example
|
8
|
+
# DocTag.init
|
9
|
+
# doc = DocTag::Document.new
|
10
|
+
# doc.number = '4711'
|
11
|
+
# doc.valid?
|
12
|
+
def init
|
13
|
+
reader = SchemaTools::Reader.new
|
14
|
+
SchemaTools::KlassFactory.build namespace: DocTag,
|
15
|
+
reader: reader,
|
16
|
+
path: DocTag::Schema.path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/doctag.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'doc_tag'
|
data/spec/doctag_spec.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DocTag do
|
4
|
+
SchemaTools.schema_path = DocTag::Schema.path
|
5
|
+
before :all do
|
6
|
+
@schemata = SchemaTools::Reader.read_all
|
7
|
+
end
|
8
|
+
context 'class creation' do
|
9
|
+
it 'should init all classes' do
|
10
|
+
DocTag.init
|
11
|
+
@schemata.each do |schema|
|
12
|
+
klass = schema['name'].classify
|
13
|
+
DocTag.const_defined?(klass).should be_true
|
14
|
+
DocTag.const_get(klass).new
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should with params' do
|
19
|
+
DocTag.init
|
20
|
+
DocTag::Document.new number: '4711'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should validate' do
|
24
|
+
DocTag.init
|
25
|
+
doc = DocTag::Document.new number: '4711'
|
26
|
+
doc.valid?
|
27
|
+
doc.errors.full_messages.should be_present
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: doctag
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Georg Leciejewski
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: json_schema_tools
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
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: doctag_json_schema
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
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: activesupport
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: simplecov
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: DocTag Ruby library
|
111
|
+
email:
|
112
|
+
- gl@salesking.eu
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- .gitignore
|
118
|
+
- .travis.yml
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- doctag.gemspec
|
124
|
+
- lib/doc_tag.rb
|
125
|
+
- lib/doc_tag/version.rb
|
126
|
+
- lib/doctag.rb
|
127
|
+
- spec/doctag_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
homepage: https://github.com/docTag/doctag_rb
|
130
|
+
licenses: []
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
137
|
+
requirements:
|
138
|
+
- - ! '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
segments:
|
142
|
+
- 0
|
143
|
+
hash: -4349915045813507382
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
segments:
|
151
|
+
- 0
|
152
|
+
hash: -4349915045813507382
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 1.8.24
|
156
|
+
signing_key:
|
157
|
+
specification_version: 3
|
158
|
+
summary: Create classes from doctag markup
|
159
|
+
test_files:
|
160
|
+
- spec/doctag_spec.rb
|
161
|
+
- spec/spec_helper.rb
|