csv_shaper 1.1.0 → 1.1.1

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: ebfdda4a218f9cf86f42c9158f3ea0baa77de655
4
- data.tar.gz: 7cc018cfafa1d59ae8589f087f71e9556c960e8f
3
+ metadata.gz: 76a5437adbc2bf71d5c1938a2bb6e7086ef944dd
4
+ data.tar.gz: 5530c88d1eb91af5f4193ab26d82de35e33d5ee9
5
5
  SHA512:
6
- metadata.gz: 644876cb037fa67e9f7bb79bd84880e74aac4b1b75143427f687db9ce794a5c75ae2f7b7d4323631792fb07618c579294ff42e2538af96fb5cd88994fa62040b
7
- data.tar.gz: e71f61f64dedb5785e01ac9037d75f9e093ffed3b36238006da5f9d2a0c5466a8d9fc35918615284b53701b38537d5c1ab5b67489aafc7880c0475687f91f2a6
6
+ metadata.gz: 3364d9d38707acfa5dc0b07e1113a9e65ad808219da8ae15eb9952f7f3d6936f55919b33563be521531394d91698879402cde5416a20706a41892ab4d3b7dc4e
7
+ data.tar.gz: 77a1096fec7de79cdb3fe474bd1e8b303017daae68285014e9e21117bfc368faf30f0dbd83e4693e13f52bdb0dd4974c1cbce7a5899bd6eb45f6ace4aa19f18b
@@ -4,8 +4,12 @@ module CsvShaper
4
4
  class Shaper
5
5
  attr_reader :header, :rows
6
6
 
7
- class << self
8
- attr_accessor :config
7
+ def self.config
8
+ @config ||= Config.new
9
+ end
10
+
11
+ def self.config=(new_config)
12
+ @config = new_config
9
13
  end
10
14
 
11
15
  def initialize(options = {})
@@ -1,3 +1,3 @@
1
1
  module CsvShaper
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
data/spec/config_spec.rb CHANGED
@@ -13,6 +13,20 @@ describe CsvShaper::Config do
13
13
  expect(config.options).to eq({ write_headers: false, col_sep: "\t", header_inflector: :titleize })
14
14
  end
15
15
 
16
+ it "does not require setting up the config before generating a CSV file" do
17
+ shaper = CsvShaper::Shaper.new do |csv|
18
+ csv.headers :name, :age, :gender
19
+
20
+ csv.row do |csv|
21
+ csv.cell :name, 'Paul'
22
+ csv.cell :age, '27'
23
+ csv.cell :gender, 'Male'
24
+ end
25
+ end
26
+
27
+ expect(shaper.to_csv).to eq "Name,Age,Gender\nPaul,27,Male\n"
28
+ end
29
+
16
30
  it "should exclude the headers if specified" do
17
31
  CsvShaper::Shaper.config = config
18
32
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv_shaper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Springett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-02 00:00:00.000000000 Z
11
+ date: 2014-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport