copy_csv 0.1.0 → 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
2
  SHA1:
3
- metadata.gz: 75e9f0db9f69da4f6a98d7a2095dab9b5d55f949
4
- data.tar.gz: 89c4e6212fd7834442b1b39b6ea5a64f341c64ef
3
+ metadata.gz: 05c8fd7fec59eb36302453b825ded8c7f2d386e5
4
+ data.tar.gz: b1941e33bb62c4644cc3503a44fa0dfb266d119e
5
5
  SHA512:
6
- metadata.gz: 209c2ab4f6d11ed8a163f7c8a8edd8357aaea9507dfed4d659b46b48a8257db3e302d1e8c879a1e0438fd761785864151750295b408a55f3c327403c3edbf58d
7
- data.tar.gz: 0ff454ba286750cd667b279976b76b1ddb8be915c5aed48b0b9b0c424fdfb5ef0c170e4f8d083c481e01c5bc3170ab2484ab91d93f4e0c6e68ee04672e7335a7
6
+ metadata.gz: 8902421ed37191cd383bc24f2bfe7fdb732dcc2790ff726b566b9b6009e387122c722fd0c863649fd6ddc75c87429f31bf6139ab512c0deb59b38bdf3367ce0a
7
+ data.tar.gz: f8010477bdefc5d105f9f842e90cd964a04794c05cd1c292b8b2dfa084d3b8bbe18aea36c3ba30e31b0875a427bf415d3152a138175b6cb79ab894c35f7b347d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- copy_csv (0.1.0)
4
+ copy_csv (1.0.0)
5
5
  activesupport (>= 5.0)
6
6
 
7
7
  GEM
@@ -45,4 +45,4 @@ DEPENDENCIES
45
45
  rspec (~> 3.0)
46
46
 
47
47
  BUNDLED WITH
48
- 1.16.2
48
+ 1.16.3
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
- # CopyCsv
1
+ # copy_csv
2
2
 
3
3
  A useful gem for converting an `ActiveRecord` Relation into a CSV formatted
4
4
  string.
5
5
 
6
+ [![Gem Version](https://badge.fury.io/rb/copy_csv.svg)](https://badge.fury.io/rb/copy_csv)
7
+
8
+ View it on [RubyGems](https://rubygems.org/gems/copy_csv)
9
+
6
10
  ## Basic Example
7
11
 
8
12
  There are a few users that have unsubscribed from your mailing list. You want
@@ -20,6 +24,9 @@ But someone else also wants to see the list, but in Excel. This is where
20
24
  File.open("unsubscribed_users.csv", "w") do |file|
21
25
  User.where(unsubscribed: true).copy_csv(file)
22
26
  end
27
+
28
+ # Alternatively, you can use `write_to_csv` to not have to deal with opening a file
29
+ User.where(unsubscribed: true).write_to_csv("unsubscribed_users.csv")
23
30
  ```
24
31
 
25
32
  `unsubscribed_users.csv` will now contain all of the Users that have
@@ -81,6 +88,10 @@ to use it in the rails console, your can just include it at will:
81
88
 
82
89
  And it can be used in that console session.
83
90
 
91
+ ## Documentation
92
+
93
+ View the [docs](https://www.rubydoc.info/gems/copy_csv/0.1.0).
94
+
84
95
  ## Development
85
96
 
86
97
  After checking out the repo, run `bin/setup` to install dependencies. Then, run
data/lib/copy_csv.rb CHANGED
@@ -11,8 +11,8 @@ module CopyCsv
11
11
  #
12
12
  # Example
13
13
  #
14
- # File.open("users.csv", "wb") do |file|
15
- # User.where(unsubscribed: false).copy_csv(io: file)
14
+ # File.open("unsubscribed_users.csv", "w") do |file|
15
+ # User.where(unsubscribed: false).copy_csv(file)
16
16
  # end
17
17
  #
18
18
  # Returns nil
@@ -30,5 +30,18 @@ module CopyCsv
30
30
 
31
31
  nil
32
32
  end
33
+
34
+ # Opens the file provided and writes the relation to it as a CSV.
35
+ #
36
+ # Example
37
+ #
38
+ # User.where(unsubscribed: false).write_to_csv("unsubscribed_users.csv")
39
+ #
40
+ # Returns nil
41
+ def write_to_csv(file_name, mode = "w")
42
+ File.open(file_name, mode) do |file|
43
+ all.copy_csv(file)
44
+ end
45
+ end
33
46
  end
34
47
  end
@@ -1,3 +1,3 @@
1
1
  module CopyCsv
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: copy_csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Stumbaugh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-15 00:00:00.000000000 Z
11
+ date: 2018-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler