develapp-tardef 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cddf9ca825967c199ebf4723feb255ceee7a4fd
4
- data.tar.gz: e7fafc692f3c0c52b5ed2bd4b888b3b361811a03
3
+ metadata.gz: c31b137a9f1f4ce717a25eebf9acd24ef6b8ca01
4
+ data.tar.gz: 6196199c59c39e098b7fc9a1dc06a298e1775f74
5
5
  SHA512:
6
- metadata.gz: 47d61d20565d3daf785028b25cf72822ec331674d48ebfc64d424af151898bc99843def09de184a611276aa7a45826205526aba258f76704b82f4c375a31be59
7
- data.tar.gz: 48a5f30d5492c6cc276ee4f6b2f09572cbc9c59b1b9e6136665640cb65aee1beffe6629bb2bf7e69217a52fb33561e17fa97602107873f93b259d2a1c0376d8d
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
- File Format Description
18
- ===
19
- Coming soon...
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
@@ -1 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "test"
6
+ t.test_files = FileList['test/test*.rb']
7
+ t.verbose = false
8
+ end
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, Time.now.iso8601(0))
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"
@@ -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
- if hash["lists"]
13
- hash["lists"].each do |hsh|
14
- list = Tardef::List.new(nil, nil)
15
- list.load_hash(hsh)
16
- file.add_list(list)
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
@@ -26,4 +26,12 @@ module Tardef
26
26
  @due_at, @hidden, @tags = due_at, hidden, tags
27
27
  end
28
28
  end
29
+
30
+ class Extension < Base
31
+ attr_accessor :name, :data
32
+
33
+ def initialize(name, schema)
34
+ @name, @data = name, data
35
+ end
36
+ end
29
37
  end
@@ -1,4 +1,4 @@
1
1
  module Tardef
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  DEFAULT_SCHEMA = "http://develapp.moskitapp.com/tardef/schema/v1/tardef.yaml"
4
4
  end
@@ -32,7 +32,7 @@ mapping:
32
32
  sequence:
33
33
  - type: map
34
34
  mapping:
35
- "name" : { type: str, required: yes }
35
+ "name" : { type: str, required: yes, unique: yes }
36
36
  "schema": { type: str, required: yes }
37
37
  "target":
38
38
  type: str
@@ -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
@@ -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.2
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-30 00:00:00.000000000 Z
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