to-arff 0.1.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 507fda68512fc420f96579514e00264c4e4ac0dd
4
- data.tar.gz: 21c267d6299d777d259c1fa55e9157e10103e38c
3
+ metadata.gz: 6e3569cf355dfe5e6d19f6616a99bfa7a734c848
4
+ data.tar.gz: 8253d90f77ab8d9745b0fcc35873f50410125008
5
5
  SHA512:
6
- metadata.gz: eaf66b84e11d9bb215ce2c30b1793117e22bbf2e822e91fc86c5a15bdf0fee4716e515baa96a3d5af7fd4a4a7e8d70f5801198227d7a721d1d112e0762f6b7bb
7
- data.tar.gz: 7a24e6157ce6bcb21b9f9fd2441bcb5742ada88cbc0c224ffc110806d71341e608a1182e37376932fdb49020da86f3ec7e4c86d1048ad1f091e03a43d9fc5b77
6
+ metadata.gz: 58d45ef0093abc7c780220868d6c6e7799ddacb122f2aad3d4d4c599f79170c171b9b136e9c1af911ba16c996d543cf15e3fe19acceed517d33b66c474255534
7
+ data.tar.gz: 0444fcf9b5580c49c1782cba7c1abedccef851e38b06174accc337f7aa3fcca6aeaffc4a2d828b13b47090706b1fa6f8279b98da6f33c9bb941a1fa4ad8753af
data/README.md CHANGED
@@ -45,52 +45,30 @@ Or install it yourself as:
45
45
 
46
46
  ###Convert from an SQLite Database
47
47
  #### By Specifying Column Types (Recommended)
48
- Use the convert() method and specify the column/attribute types as a json (or nested hash).
48
+ Its better to specify column types.
49
49
  ```ruby
50
50
  require 'to-arff'
51
- # Get the db file from https://github.com/dhrubomoy/to-arff/blob/master/spec/sample_db_files/sample2.db
52
- sample = ToARFF::SQLiteDB.new "/path/to/sample2.db"
51
+ # You can download the file from '/spec /sample_db_files/sample2.db'
52
+ sample = ToARFF::SQLiteDB.new "/path/to/sample_sqlite.db"
53
53
  # Attribute names and types must be valid
54
- # eg. { "table1": {"column11"=>"NUMERIC",
55
- # "column12"=>"STRING"
56
- # },
57
- # "table2": {"column21"=>"class {Iris-setosa,Iris-versicolor,Iris-virginica}",
58
- # "column22"=>"DATE \"yyyy-MM-dd HH:mm:ss\""
59
- # }
60
- # }
61
- # OR { "table1" => {"column11"=>"NUMERIC",
54
+ # eg. { "table1" => {"column11"=>"NUMERIC",
62
55
  # "column12"=>"STRING"
63
56
  # },
64
57
  # "table2" => {"column21"=>"class {Iris-setosa,Iris-versicolor,Iris-virginica}",
65
58
  # "column22"=>"DATE \"yyyy-MM-dd HH:mm:ss\""
66
59
  # }
67
- # }
68
- sample_column_types_param_json = {
69
- "albums": {
70
- "Albumid": "NUMERIC",
71
- "Title": "STRING"
72
- },
73
- "employees": {
74
- "EmployeeId": "NUMERIC",
75
- "LastName": "STRING",
76
- "City": "STRING",
77
- "HireDate": "DATE 'yyyy-MM-dd HH:mm:ss'"
78
- }
79
- }
80
- sample_column_types_param_hash = { "employees" => {"EmployeeId"=>"NUMERIC",
60
+ sample_column_types_param = { "employees" => {"EmployeeId"=>"NUMERIC",
81
61
  "LastName"=>"STRING",
82
62
  "City"=>"STRING",
83
63
  "HireDate"=>"DATE \"yyyy-MM-dd HH:mm:ss\""
84
64
  },
85
- "albums" => { "Albumid"=>"NUMERIC",
86
- "Title"=>"STRING"
87
- }
88
- }
89
- puts sample.convert column_types: sample_column_types_param_json
90
- #OR
91
- puts sample.convert column_types: sample_column_types_param_hash
65
+ "albums" => { "Albumid"=>"NUMERIC",
66
+ "Title"=>"STRING"
67
+ }
68
+ }
69
+ puts sample.convert column_types: sample_column_types_param
92
70
  ```
93
- Both will produce string similar to following:
71
+ We will get something similar to following:
94
72
  ```
95
73
  @RELATION employees
96
74
 
@@ -125,20 +103,12 @@ sample = ToARFF::SQLiteDB.new "/path/to/sample_sqlite.db"
125
103
  # { "table1" => ["column11", "column12",...],
126
104
  # "table2" => ["column21", "column22",...]
127
105
  # }
128
- # OR
129
- # { "table1": ["column11", "column12",...],
130
- # "table2": ["column21", "column22",...]
131
- # }
132
- sample_columns_json = { "albums": ["AlbumId", "Title", "ArtistId"],
133
- "employees": ["EmployeeId", "LastName", "FirstName", "Title"]
134
- }
135
- sample_columns_hash = { "albums" => ["AlbumId", "Title", "ArtistId"],
136
- "employees" => ["EmployeeId", "LastName", "FirstName", "Title"]
137
- }
138
- puts sample.convert columns: sample_columns_json
139
- puts sample.convert columns: sample_columns_hash
106
+ sample_columns = { "albums" => ["AlbumId", "Title", "ArtistId"],
107
+ "employees" => ["EmployeeId", "LastName", "FirstName", "Title"]
108
+ }
109
+ puts sample.convert columns: sample_columns
140
110
  ```
141
- Both json and hash parameters for `columns:` will return string similar to following:
111
+ We will get something similar:
142
112
  ```
143
113
  @RELATION albums
144
114
 
@@ -183,7 +153,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/dhrubo
183
153
  1. Fork it ( https://github.com/dhrubomoy/to-arff/fork )
184
154
  2. Create branch (`git checkout -b my-new-feature`)
185
155
  3. Make changes. Add test cases for your changes
186
- 4. Run `rake spec/` and make sure all the test passes
156
+ 4. Run `rspec spec/` and make sure all the test passes
187
157
  5. Commit your changes (`git commit -am 'Add some feature'`)
188
158
  6. Push to the branch (`git push origin my-new-feature`)
189
159
  7. Create new Pull Request
@@ -1,6 +1,5 @@
1
1
  require 'to-arff/version'
2
2
  require 'sqlite3'
3
- require 'json'
4
3
 
5
4
  module ToARFF
6
5
  RELATION_MARKER = '@RELATION'.freeze
@@ -192,14 +191,6 @@ module ToARFF
192
191
  end
193
192
  end
194
193
 
195
- def stringify_all_keys(hash)
196
- stringified_hash = {}
197
- hash.each do |k, v|
198
- stringified_hash[k.to_s] = v.is_a?(Hash) ? stringify_all_keys(v) : v
199
- end
200
- stringified_hash
201
- end
202
-
203
194
  def convert(options={})
204
195
  temp_tables = options.fetch(:tables, Array.new)
205
196
  temp_columns = options.fetch(:columns, Hash.new)
@@ -214,7 +205,7 @@ module ToARFF
214
205
  if valid_option_given(options)
215
206
  raise ArgumentError.new("Wrong parameter name \":#{options.keys.first}\"")
216
207
  else
217
- deal_with_valid_option(temp_tables, stringify_all_keys(temp_columns), stringify_all_keys(temp_column_types), res)
208
+ deal_with_valid_option(temp_tables, temp_columns, temp_column_types, res)
218
209
  end
219
210
  elsif param_count > 1
220
211
  raise ArgumentError.new("You can specify only one out of the three parameters: table, columns, column_types.")
@@ -1,3 +1,3 @@
1
1
  module ToARFF
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -23,5 +23,4 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'bundler', '~> 1.12'
24
24
  spec.add_development_dependency 'rake', '~> 11.2'
25
25
  spec.add_development_dependency 'sqlite3', '~> 1.3'
26
- spec.add_development_dependency 'json'
27
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to-arff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - dhrubo_moy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-31 00:00:00.000000000 Z
11
+ date: 2016-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
- - !ruby/object:Gem::Dependency
56
- name: json
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
55
  description:
70
56
  email:
71
57
  - dhrubo_moy@yahoo.com