xls-file 0.1.0 → 0.2.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
  SHA256:
3
- metadata.gz: 06a00b7102da84c0d45e6cd96345cde337d776332750e7873945e85e299e30a1
4
- data.tar.gz: 01442f09ad5593a47868b4ef023aae4709c80bf89e43461ef42e3ecbfb852ceb
3
+ metadata.gz: 6e3041e4daeef202890f0af6afc5a165f0815e028a0665010b59a7dfdad9aad6
4
+ data.tar.gz: e78caa80f9bfded6cc741124eb3ab8776de35bb70d28e6909b3683c6d178539d
5
5
  SHA512:
6
- metadata.gz: ac349c23ed18fbb2bdf89caa2ae2d07ec51774e857bb01158ca6872525599c6b6356be225b5ca2a3da3966ea505823148b0fce4b8c66ffa133072c503cd992c5
7
- data.tar.gz: 386c5aac81e3459b4ed61ec81e0a469e67682513b3e730f060e2ac7560c26a8eae5a10b38c0697e5f29360a71bf3c68eea2200391553a3a033307cdab5efc69f
6
+ metadata.gz: eca5c6da9d83b599f99171f0b5a0c43c647f2f9de3c8493fc3c13a01dde8b4929a58988261a7792d468b50c9caa6514dc8d9dde90d7298d133310a7619e9d93d
7
+ data.tar.gz: 9a2655403dd1a636eb9812b60f37fb98937130b5becdd9b364bc860cc4327d1b5b1b28b038b1430d76f31815474a6bc3f08ef0eec57430282834e5256ca7d6cd
data/README.md CHANGED
@@ -33,9 +33,6 @@ file = Xls.generate_xls(data, headers).
33
33
 
34
34
  It will return newly generated file path, now its depends on you download with helper method (send_file) on controller or upload on any cloud.
35
35
 
36
- ## Request from all
37
- I am new in this and this Gem is in not fully completed yet still improving and learning something new so any suggestions and contributions are most welcome.
38
-
39
36
  ## License
40
37
 
41
38
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Xls
4
4
  module File
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
data/lib/xls/file.rb CHANGED
@@ -23,6 +23,27 @@ module Xls
23
23
  def self.formatted_excel_data(row)
24
24
  row.collect{|k, v| [v]}.flatten!
25
25
  end
26
+ def self.generate_csv(data, headers)
27
+ filename = "csv-file-#{Date.today.strftime('%dth %b %Y')}.csv"
28
+ path = "tmp/#{filename}"
29
+
30
+ CSV.open(path, "w", write_headers: true, headers: headers) do |csv|
31
+ unless data.is_a? Array
32
+ data = data.as_json
33
+ end
34
+
35
+ data.each do |row|
36
+ formatted_row = formatted_csv_data(row)
37
+ csv << formatted_row
38
+ end
39
+ end
40
+
41
+ return path
42
+ end
43
+
44
+ def self.formatted_csv_data(row)
45
+ row.collect { |k, v| v }
46
+ end
26
47
  def self.test
27
48
  puts "Cheers!! xls-file installed successfully"
28
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xls-file
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rajnish mishra
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-26 00:00:00.000000000 Z
11
+ date: 2025-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: caxlsx
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  - !ruby/object:Gem::Version
65
65
  version: '0'
66
66
  requirements: []
67
- rubygems_version: 3.4.1
67
+ rubygems_version: 3.2.22
68
68
  signing_key:
69
69
  specification_version: 4
70
70
  summary: Generate xls file with data and header