json_csv 0.0.7 → 1.0.0

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
- SHA1:
3
- metadata.gz: '0043834553b3243296e8b2b55c6806721b82673c'
4
- data.tar.gz: 857ab74bc2b9f95ffb0f5d9d47ba520f8ba0a17f
2
+ SHA256:
3
+ metadata.gz: 7dc36a6c25ffa37eae4a51c7d373763c3958eb10341f2659acbbf70c7f1f6cdf
4
+ data.tar.gz: de793cb71e127d0518cca18a1fc5c4f31d0d595df51f23abb0c79c02394b4435
5
5
  SHA512:
6
- metadata.gz: 427f4714f7b6999c798bef38b8e80bef3f0fe5033b31909e4a3aa064aee79e407e5f5957a207dfaa55d9d389b7da763d813c053ce184f3dd8bc97c0b38ead32a
7
- data.tar.gz: cdf0311ca31c8c830f22daf426f18e2a36f77cb5ebc47ebdc97ceaf8eeecea1bf1b88f2dec60dd2155e4f6d94c17ccfa5aded6cb64efe9b399d1aaf27beb5738
6
+ metadata.gz: abffea2f7c780e093a052e3d558526f5e1d93c4492a36de3e3d0a1d38eaa81be4f81ccd929352bd630b6a7db4e8b9141dc76d70a0f8a4986c5a6b1b9a1cf3316
7
+ data.tar.gz: d791b8465efb81add9160dc3f2d04a1772c3762c3cc88467d456820123153fb80df7c3f02dd2071ea8e4acd518e9fc87323b0d05cc77da927cd9bf871ddcdace
data/README.md CHANGED
@@ -13,9 +13,26 @@ gem install json_csv
13
13
  ```ruby
14
14
  require 'json_csv'
15
15
 
16
- TODO: Provide usage examples
16
+ path_to_output_csv_file = '/path/to/file.csv'
17
+
18
+ # Write json-like hash objects to a csv file
19
+
20
+ JsonCsv.create_csv_for_json_records(path_to_output_csv_file) do |csv_builder|
21
+ digital_objects_for_batch_export(batch_export) do |digital_object|
22
+ csv_builder.add({...json-like hash...})
23
+ end
24
+ end
25
+
26
+ # Read csv back into json-like hash objects
27
+
28
+ JsonCsv.csv_file_to_hierarchical_json_hash(csv_file.path) do |json_hash_for_row, csv_row_number|
29
+ puts "Row: #{csv_row_number}" # prints out 2 the first time, then 3, etc.
30
+ puts "Object: #{json_hash_for_row}" # prints out a hierarchical json object, created from the csv row
31
+ end
17
32
  ```
18
33
 
34
+ See specs for advanced usage.
35
+
19
36
  ### Running Tests (for developers):
20
37
 
21
38
  Tests are great and we should run them. Here's how:
@@ -21,7 +21,7 @@ module JsonCsv
21
21
  # because it only keeps one row in memory at a time.
22
22
  # Sample usage: csv_file_to_hierarchical_json_hash(path_to_csv, field_casting_rules = {}, strip_value_whitespace = true) do |row_json_hash, row_number|
23
23
  def csv_file_to_hierarchical_json_hash(path_to_csv, field_casting_rules = {}, strip_value_whitespace = true)
24
- i = 1 # start with row 1 because this corresponds to the first row of 0-indexed CSV data
24
+ i = 2 # start with row 2 because this corresponds to the SECOND row of 1-indexed CSV data (where headers are row 1)
25
25
  CSV.foreach(path_to_csv, headers: true, header_converters: lambda { |header|
26
26
  header.strip # remove leading and trailing header whitespace
27
27
  }) do |row_data_hash|
@@ -1,6 +1,6 @@
1
1
  module JsonCsv
2
2
 
3
- VERSION = '0.0.7'.freeze
3
+ VERSION = '1.0.0'.freeze
4
4
 
5
5
  def self.version
6
6
  VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric O'Hanlon
@@ -114,8 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
- rubyforge_project:
118
- rubygems_version: 2.6.14
117
+ rubygems_version: 3.0.8
119
118
  signing_key:
120
119
  specification_version: 4
121
120
  summary: A library for converting json to csv...and back!