develapp-tardef 0.0.1 → 0.0.2

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: c25ba53a04efb4aa4396b3510a48600faf67bc5b
4
- data.tar.gz: 2db69cf4bfee5c09da16091a9caef1e552baaf36
3
+ metadata.gz: 2cddf9ca825967c199ebf4723feb255ceee7a4fd
4
+ data.tar.gz: e7fafc692f3c0c52b5ed2bd4b888b3b361811a03
5
5
  SHA512:
6
- metadata.gz: 32acbdfdb908e15596f9b17e2371e09436d4c249c204148204957ba2ea2a18b327ed5b7c29a4741ad9e19523f3b2387c69558d13cb71068a3752d415f8335b15
7
- data.tar.gz: 96070238616ede59b1ed1a44dd6aeefd151c1704829b9471715890ebbc1dff217acbddb5c0bce7df61c55d89bc8aa3d7db7438570a33a53c87a1daffe21957b9
6
+ metadata.gz: 47d61d20565d3daf785028b25cf72822ec331674d48ebfc64d424af151898bc99843def09de184a611276aa7a45826205526aba258f76704b82f4c375a31be59
7
+ data.tar.gz: 48a5f30d5492c6cc276ee4f6b2f09572cbc9c59b1b9e6136665640cb65aee1beffe6629bb2bf7e69217a52fb33561e17fa97602107873f93b259d2a1c0376d8d
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- TARDEF - Task And Related Data Exchange Format
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
 
@@ -13,6 +13,7 @@ The TARDEF repository contains a Ruby library that can be used for accessing the
13
13
 
14
14
  The validator can be used by calling tardef_validate -f <file> -t <type>
15
15
 
16
+ An up-to-date documentation of the library can be found at http://rubydoc.info/github/DevelAppUG/tardef/master/frames.
16
17
  File Format Description
17
18
  ===
18
19
  Coming soon...
data/bin/tardef CHANGED
@@ -38,6 +38,7 @@ def write_file(file, type, obj)
38
38
  end
39
39
 
40
40
  def derive_type(file, type)
41
+ return "" if not file
41
42
  if type == ""
42
43
  if file.end_with?(".yaml")
43
44
  type = "yaml"
@@ -63,17 +64,11 @@ ARGV.each_with_index do |arg, index|
63
64
  end
64
65
  end
65
66
 
66
- if input_file == ""
67
- puts "[ERROR] Input file must be given using -if <filename>"
68
- exit
69
- end
70
-
71
- input_type = derive_type(input_file, input_type)
72
- output_type = derive_type(output_file, output_type)
73
- check_type(input_type)
74
-
75
67
  begin
76
68
  if command == "validate"
69
+ raise "Input file must be given using -if <filename>" if input_file == ""
70
+ input_type = derive_type(input_file, input_type)
71
+ check_type(input_type)
77
72
  obj = read_file(input_file, input_type)
78
73
  chain = Tardef::Validator::Chain.new
79
74
  chain.add_validator(Tardef::Validator::Links.new)
@@ -88,14 +83,23 @@ begin
88
83
  puts result
89
84
  end
90
85
  elsif command == "transform"
91
- if output_file == ""
92
- puts "[ERROR] Output file must be given using -of <filename>"
93
- exit
94
- end
86
+ raise "Input file must be given using -if <filename>" if input_file == ""
87
+ raise "Output file must be given using -of <filename>" if output_file == ""
88
+ input_type = derive_type(input_file, input_type)
89
+ output_type = derive_type(output_file, output_type)
90
+ check_type(input_type)
95
91
  check_type(output_type)
96
92
  obj = read_file(input_file, input_type)
97
93
  write_file(output_file, output_type, obj)
98
94
  puts "[SUCCESS] File transformed"
95
+ elsif command == "new"
96
+ raise "Output file must be given using -of <filename>" if output_file == ""
97
+ output_type = derive_type(output_file, output_type)
98
+ check_type(output_type)
99
+ obj = Tardef::File.new(output_file, Tardef::VERSION, Time.now.iso8601(0))
100
+ obj.schema = Tardef::DEFAULT_SCHEMA
101
+ write_file(output_file, output_type, obj)
102
+ puts "[SUCCESS] File generated"
99
103
  else
100
104
  raise "Command #{command} missing"
101
105
  end
@@ -1,13 +1,9 @@
1
1
  module Tardef::Connector
2
2
  class Base
3
3
  @filename = ""
4
- @can_read = true
5
- @can_write = true
6
-
7
4
  attr_accessor :filename
8
-
5
+
9
6
  def read
10
- raise "Connector is write-only" if not @can_write
11
7
  hash = read_file
12
8
  file = Tardef::File.new(nil, nil, nil)
13
9
  file.load_hash(hash["meta"])
@@ -50,7 +46,6 @@ module Tardef::Connector
50
46
  end
51
47
 
52
48
  def write(file_object)
53
- raise "Connector is read-only" if not @can_write
54
49
  hash = file_object.to_hash
55
50
  write_file(hash)
56
51
  end
@@ -2,9 +2,11 @@ require "open-uri"
2
2
  require "xmlsimple"
3
3
 
4
4
  module Tardef::Connector
5
- @can_read = false
6
-
7
5
  class XML < Base
6
+ def read
7
+ raise "Connector is write-only"
8
+ end
9
+
8
10
  def read_file
9
11
  file = open(@filename)
10
12
  XmlSimple.xml_in(file)
@@ -1,3 +1,4 @@
1
1
  module Tardef
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
+ DEFAULT_SCHEMA = "http://develapp.moskitapp.com/tardef/schema/v1/tardef.yaml"
3
4
  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.1
4
+ version: 0.0.2
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-28 00:00:00.000000000 Z
11
+ date: 2013-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler