format_data_converter 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,2 +1,17 @@
1
- fdc
2
- =========
1
+ Format Data Converter
2
+ =====================
3
+
4
+ Because, if you work with many data formats, you need gems specifically for each of the types you're working with, Format Data Converter comes to help you, autodetecting the input type from a number of known types (JSON, XML, CSV, Hash, Activerecord) and converting it to the type required in your application (currently supporting JSON, XML, CSV, Excel and Hash and working on YAML).
5
+
6
+ To install, run:
7
+
8
+ gem install format_data_converter -v '0.9.0'
9
+
10
+ To convert, you need to run:
11
+
12
+ FDC.detect_and_to_*FORMAT*, where format may be csv, json, hash_symbols (puts symbols instead of strings), hash, xml, xls.
13
+
14
+ As this is a beta version, there are still improvements to be made. Feel free to expand the code and make it better!
15
+
16
+ Hope this gem helps you when you work with multiple data types.
17
+
@@ -86,8 +86,7 @@ class Converter
86
86
  sxml << name_parent[n] << ">"
87
87
  end
88
88
  elsif (s[i] == "}")
89
- sxml << "</"
90
- print name_parent
89
+ sxml << "</"
91
90
  sxml << name_parent[n]
92
91
  n = n-1
93
92
  sxml << ">"
@@ -22,30 +22,33 @@ class Hasher
22
22
 
23
23
  def self.from_xml s
24
24
  shash = ""
25
- arbre = []
26
25
  for i in 0..s.length-2
27
- if (s[i] == ">")
26
+ if (s[i] == ">")
28
27
  if (s[i+1] == "<")
29
- if (s[i+2] != "/") then shash << '"=>['
28
+ if (s[i+2] != "/")
29
+ saux = s.clone
30
+ if (s[saux.index(">", i+2)+2 .. saux.index(">", i+2)+3] == "</") then shash << '"=>['
31
+ else shash<< ","
32
+ end
30
33
  end
31
34
  else shash << '"=>'
32
- saux = s.clone
33
- shash << saux.slice(i+1..(saux.index("<", i+2)-1))
35
+ saux = s.clone
36
+ shash << '"' << saux.slice(i+1..(saux.index("<", i+2)-1)) << '"'
34
37
  end
35
- elsif (s[i] == "<")
36
- if (s[i+1] == "/")
38
+ elsif (s[i] == "<")
39
+ if (s[i+1] == "/")
40
+ saux = s.clone
41
+ if (s[saux.index(">", i+1)+1 .. saux.index(">", i+1)+2] == "</") then shash << '}]'
42
+ else shash << '}'
43
+ end
44
+ else shash << '{"'
37
45
  saux = s.clone
38
- if (s[saux.index(">", i+1)+1 .. saux.index(">", i+1)+2] == "</") then shash << '}]'
39
- else shash << '}'
40
- end
41
- else shash << '{"'
42
- saux = s.clone
43
- shash << saux.slice(i+1..(saux.index(">", i+2)-1))
46
+ shash << saux.slice(i+1..(saux.index(">", i+2)-1))
44
47
  end
45
48
  end
46
49
  end
47
50
  shash
48
- end
51
+ end
49
52
 
50
53
  def self.from_json s
51
54
  s.gsub(":","=>")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: format_data_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: