develapp-tardef 0.0.2 → 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.
- checksums.yaml +4 -4
- data/README.md +15 -6
- data/Rakefile +7 -0
- data/bin/tardef +1 -1
- data/lib/tardef/base.rb +10 -20
- data/lib/tardef/connector/base.rb +12 -30
- data/lib/tardef/object.rb +8 -0
- data/lib/tardef/version.rb +1 -1
- data/schema/v1/tardef.yaml +1 -1
- data/test/test_library.rb +12 -0
- data/test/test_schema.rb +31 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c31b137a9f1f4ce717a25eebf9acd24ef6b8ca01
|
4
|
+
data.tar.gz: 6196199c59c39e098b7fc9a1dc06a298e1775f74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a08f9fb8c0fc94a39e089d222918f5e89ebaa5a020cee52bbfeb0f3b66979fc9ad12b3e6c321089ca9853a82e26b8b2c26859fdc3fd075cc4e6c8f42692a898f
|
7
|
+
data.tar.gz: 6ac56ab2b3ff64515f4a05debf129ce651c274e73cabd49ce4c89876fe8259a333f16a71adaf6cd865802718d47fd330ddfcac939aee3e5b2c1f1b9d512cf94b
|
data/README.md
CHANGED
@@ -1,19 +1,28 @@
|
|
1
1
|
About
|
2
|
-
|
2
|
+
-----
|
3
3
|
TARDEF is a format for saving and exchanging data for tasks and related data - like lists and tags - in an easy format. By default, YAML and JSON are supported as file formats by TARDEF, but any format that supports the same kind of structures as YAML / JSON could be used.
|
4
4
|
|
5
5
|
Advantages
|
6
|
-
|
6
|
+
----------
|
7
7
|
* Text based: Files can be read and written by humans and also supports versioning files using Git, SVN, etc.
|
8
8
|
* Extensions: Extensions can be used to add functionality to the TARDEF file that is not supported by the default format.
|
9
9
|
|
10
10
|
Usage
|
11
|
-
|
11
|
+
-----
|
12
12
|
The TARDEF repository contains a Ruby library that can be used for accessing the files. There are also schemas following the Kwalify (http://www.kuwata-lab.com/kwalify/) standard that can be used for validating TARDEF files. A ruby tool for doing so is also included.
|
13
13
|
|
14
14
|
The validator can be used by calling tardef_validate -f <file> -t <type>
|
15
15
|
|
16
16
|
An up-to-date documentation of the library can be found at http://rubydoc.info/github/DevelAppUG/tardef/master/frames.
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
|
18
|
+
Schemas
|
19
|
+
-------
|
20
|
+
There are several schemas available:
|
21
|
+
|
22
|
+
Base schema: http://develapp.moskitapp.com/tardef/schema/v1/tardef.yaml
|
23
|
+
|
24
|
+
Reminders extension: http://develapp.moskitapp.com/tardef/schema/v1/extension/reminder.yaml
|
25
|
+
|
26
|
+
Location extension: http://develapp.moskitapp.com/tardef/schema/v1/extension/location.yaml
|
27
|
+
|
28
|
+
Attachement extension: http://develapp.moskitapp.com/tardef/schema/v1/extension/attachement.yaml
|
data/Rakefile
CHANGED
data/bin/tardef
CHANGED
@@ -96,7 +96,7 @@ begin
|
|
96
96
|
raise "Output file must be given using -of <filename>" if output_file == ""
|
97
97
|
output_type = derive_type(output_file, output_type)
|
98
98
|
check_type(output_type)
|
99
|
-
obj = Tardef::File.new(output_file, Tardef::VERSION
|
99
|
+
obj = Tardef::File.new(output_file, Tardef::VERSION)
|
100
100
|
obj.schema = Tardef::DEFAULT_SCHEMA
|
101
101
|
write_file(output_file, output_type, obj)
|
102
102
|
puts "[SUCCESS] File generated"
|
data/lib/tardef/base.rb
CHANGED
@@ -7,11 +7,7 @@ module Tardef
|
|
7
7
|
def add_extension(extension)
|
8
8
|
@extensions << extension
|
9
9
|
end
|
10
|
-
|
11
|
-
def self.parse_date(datestring)
|
12
|
-
return DateTime.iso8601(datestring)
|
13
|
-
end
|
14
|
-
|
10
|
+
|
15
11
|
def to_hash
|
16
12
|
hash = {}
|
17
13
|
# Add all instance variables
|
@@ -54,19 +50,11 @@ module Tardef
|
|
54
50
|
end
|
55
51
|
end
|
56
52
|
|
57
|
-
class Extension < Base
|
58
|
-
attr_accessor :name, :data
|
59
|
-
|
60
|
-
def initialize(name, schema)
|
61
|
-
@name, @data = name, data
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
53
|
class File < Base
|
66
54
|
attr_accessor :filename, :title, :editor, :imports, :schema
|
67
55
|
attr_accessor :last_changed, :lists, :tags, :tasks, :extension_defs
|
68
56
|
|
69
|
-
def initialize(filename, protocol_version, last_changed, title = "", editor = "", imports = [], schema =
|
57
|
+
def initialize(filename, protocol_version, last_changed = Time.now.iso8601(0), title = "", editor = "", imports = [], schema = Tardef::DEFAULT_SCHEMA)
|
70
58
|
super()
|
71
59
|
@filename, @last_changed, @title = filename, last_changed, title
|
72
60
|
@editor, @lists, @tags, @tasks, @imports = editor, [], [], [], imports
|
@@ -84,12 +72,7 @@ module Tardef
|
|
84
72
|
def add_task(task)
|
85
73
|
@tasks << task
|
86
74
|
end
|
87
|
-
|
88
|
-
def hash_has_object?(list, uid)
|
89
|
-
list.each { |item| return true if item.uid == uid }
|
90
|
-
return false
|
91
|
-
end
|
92
|
-
|
75
|
+
|
93
76
|
def has_list?(uid)
|
94
77
|
hash_has_object?(@lists, uid)
|
95
78
|
end
|
@@ -122,5 +105,12 @@ module Tardef
|
|
122
105
|
end
|
123
106
|
return hash
|
124
107
|
end
|
108
|
+
|
109
|
+
private
|
110
|
+
def hash_has_object?(list, uid)
|
111
|
+
list.each { |item| return true if item.uid == uid }
|
112
|
+
return false
|
113
|
+
end
|
114
|
+
|
125
115
|
end
|
126
116
|
end
|
@@ -9,38 +9,20 @@ module Tardef::Connector
|
|
9
9
|
file.load_hash(hash["meta"])
|
10
10
|
file.filename = @filename
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
list, tag, task = Tardef::List, Tardef::Tag, Tardef::Task
|
13
|
+
extension = Tardef::Extension
|
14
|
+
entries = {"lists" => list, "tags" => tag, "tasks" => task,
|
15
|
+
"extensions" => extension}
|
16
|
+
|
17
|
+
entries.map do |key, value|
|
18
|
+
next unless hash[key]
|
19
|
+
hash[key].each do |hsh|
|
20
|
+
entry = value.new("", "", "")
|
21
|
+
entry.load_hash(hsh)
|
22
|
+
file << entry
|
17
23
|
end
|
18
24
|
end
|
19
|
-
|
20
|
-
if hash["tags"]
|
21
|
-
hash["tags"].each do |hsh|
|
22
|
-
tag = Tardef::Tag.new(nil, nil)
|
23
|
-
tag.load_hash(hsh)
|
24
|
-
file.add_tag(tag)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
if hash["tasks"]
|
29
|
-
hash["tasks"].each do |hsh|
|
30
|
-
task = Tardef::Task.new(nil, nil, nil)
|
31
|
-
task.load_hash(hsh)
|
32
|
-
file.add_task(task)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
if hash["extensions"]
|
37
|
-
hash["extensions"].each do |hsh|
|
38
|
-
ext = Tardef::Extension.new(nil, nil)
|
39
|
-
ext.load_hash(hsh)
|
40
|
-
file.add_extension(ext)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
25
|
+
|
44
26
|
file.schema = hash["schema"] if hash["schema"]
|
45
27
|
file
|
46
28
|
end
|
data/lib/tardef/object.rb
CHANGED
data/lib/tardef/version.rb
CHANGED
data/schema/v1/tardef.yaml
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'tardef'
|
3
|
+
|
4
|
+
class TestBaseFile < Test::Unit::TestCase
|
5
|
+
def testEmptyFileHasValidSyntax
|
6
|
+
file = Tardef::File.new(nil, nil)
|
7
|
+
validator = Tardef::Validator::Syntax.new(Tardef::DEFAULT_SCHEMA)
|
8
|
+
result = validator.validate(file)
|
9
|
+
|
10
|
+
assert_equal([], result)
|
11
|
+
end
|
12
|
+
end
|
data/test/test_schema.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'tardef'
|
3
|
+
|
4
|
+
class TestSchemas < Test::Unit::TestCase
|
5
|
+
def schemaValidation(file)
|
6
|
+
metavalidator = Kwalify::MetaValidator.instance
|
7
|
+
parser = Kwalify::Yaml::Parser.new(metavalidator)
|
8
|
+
parser.parse_file(file)
|
9
|
+
parser.errors
|
10
|
+
end
|
11
|
+
|
12
|
+
def testBaseSchema
|
13
|
+
errors = schemaValidation 'schema/v1/tardef.yaml'
|
14
|
+
assert_equal([], errors)
|
15
|
+
end
|
16
|
+
|
17
|
+
def testReminderSchema
|
18
|
+
errors = schemaValidation 'schema/v1/extension/reminder.yaml'
|
19
|
+
assert_equal([], errors)
|
20
|
+
end
|
21
|
+
|
22
|
+
def testLocationSchema
|
23
|
+
errors = schemaValidation 'schema/v1/extension/location.yaml'
|
24
|
+
assert_equal([], errors)
|
25
|
+
end
|
26
|
+
|
27
|
+
def testAttachementSchema
|
28
|
+
errors = schemaValidation 'schema/v1/extension/attachement.yaml'
|
29
|
+
assert_equal([], errors)
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: develapp-tardef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timo Puschkasch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06
|
11
|
+
date: 2013-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -125,6 +125,8 @@ files:
|
|
125
125
|
- schema/v1/extension/reminder.yaml
|
126
126
|
- schema/v1/tardef.yaml
|
127
127
|
- tardef.gemspec
|
128
|
+
- test/test_library.rb
|
129
|
+
- test/test_schema.rb
|
128
130
|
homepage: http://develapp.moskitapp.com/tardef
|
129
131
|
licenses:
|
130
132
|
- MIT
|
@@ -149,4 +151,6 @@ rubygems_version: 2.0.3
|
|
149
151
|
signing_key:
|
150
152
|
specification_version: 4
|
151
153
|
summary: Task and Related Data Exchange Format
|
152
|
-
test_files:
|
154
|
+
test_files:
|
155
|
+
- test/test_library.rb
|
156
|
+
- test/test_schema.rb
|