csv_json_converter 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: bb1717587cef433b03f7926fe88567ef3fc16b7a1a2a963881cd0750550b7d77
4
- data.tar.gz: 44169ae334d3df842aa410260e4dcc7880fab765d1d2d84709b78af5e3d28f16
3
+ metadata.gz: 6228b84cfe7878661d694b60dba84af9d48f55c1a81cd964829d3a8eea78a39c
4
+ data.tar.gz: ff55c26aa989850f9c1f3d407d434387aabc9d3ba0063d5512e9ade3e1b1c120
5
5
  SHA512:
6
- metadata.gz: b8e3ddacda3672913642fed427eb42c3127e5dd0bc6efb5d52e59b03927086b6b3bdba5121a146094bda2a57c779d2907a74542f5cf71d9166a5e3cc6650252e
7
- data.tar.gz: e9f5be03e570d64b791e4fa756f3da345593206416b1117e8d4c2bf1be76aac93810be35978bfa94752fc71d50f79bcb899258457b2eacb848d691b0a23418c7
6
+ metadata.gz: c8c640903d18eacdeeb9da4a4dd48bc326f25b66d54049281d57a2a175ac2c1c8ad92746e7ec32cf4e087919f9c741b73876b2665ac1c7606a644098b014e217
7
+ data.tar.gz: c3cfa34d23a6429d35a3efa2f0ce0f92fa6fcbd0202141e7524396421608d101a0bb635981a1555c237d44c0d4150392aa7670b680d82d74666936cb547c4717
data/README.md CHANGED
@@ -13,8 +13,8 @@
13
13
  - [:busts_in_silhouette: Authors ](#-authors-)
14
14
  - [:handshake: Contributing ](#-contributing-)
15
15
  - [:star:️ Show your support ](#️-show-your-support-)
16
- # :book: json_or_ruby_to_csv <a name="about-project"></a>
17
- This gem converts data from a variety of sources into a comma-separated value (CSV) format. The gem can convert arrays of JSON objects, arrays of hashes, arrays of ActionController params, simple hashes, or ActiveRecord relations and objects. The CSV format is a common way to store data in a tabular format. It is often used for data exchange between different applications.
16
+ # :book: csv_json_convert <a name="about-project"></a>
17
+ This gem converts a csv string to json object.
18
18
  ## Installation <a name="tech-stack"></a>
19
19
  Add the following code to you Gemfile
20
20
  ```
@@ -32,25 +32,21 @@ If you want to convert `csv string`, to json you can use `to_json` method from `
32
32
 
33
33
  <i>For example </i>
34
34
  ```ruby
35
- #```
35
+
36
36
  require 'csv_json_converter'
37
37
 
38
38
  data_csv='file;text;number;hex
39
39
  test18.csv;CMkABfAGXvmSFV;9892576;jz40cbafbec8d6f92e93d22ea6ef5b'
40
40
 
41
- json_data = CsvJsonCoverter::Csv.to_json(data_csv)
41
+ json_data = CsvJsonCoverter.to_json(data_csv)
42
42
 
43
43
  print json_data
44
- #{ "file": "test18.csv",
45
- # "text": "CMkABfAGXvmSFV",
46
- # "number": 9892576,
47
- # "hex": "jz40cbafbec8d6f92e93d22ea6ef5b"
48
- #}
49
- #```
44
+
50
45
  ```
51
46
 
52
47
  **The output looks like below**
53
- ```{ "file": "test18.csv",
48
+ ```
49
+ { "file": "test18.csv",
54
50
  "text": "CMkABfAGXvmSFV",
55
51
  "number": 9892576,
56
52
  "hex": "jz40cbafbec8d6f92e93d22ea6ef5b"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CsvJsonConverter
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -6,16 +6,13 @@ require_relative "csv_json_converter/version"
6
6
  module CsvJsonConverter
7
7
  class Error < StandardError; end
8
8
  # Your code goes here...
9
- class Csv
10
- def self.to_json(input, separator=',')
11
- for_csv = CSV.parse(input,:col_sep => separator,headers: true, header_converters: :symbol)
12
- # treat first row as headers if the caller didn't provide them
13
- arr_to_json = for_csv.map(&:to_h).to_json
14
-
15
- arr_to_json
9
+ def self.to_json(input, separator=',')
10
+ for_csv = CSV.parse(input,:col_sep => separator,headers: true, header_converters: :symbol)
11
+ # treat first row as headers if the caller didn't provide them
12
+ arr_to_json = for_csv.map(&:to_h).to_json
13
+
14
+ arr_to_json
15
+
16
16
 
17
-
18
- end
19
-
20
17
  end
21
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv_json_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - alexoid1