table2csv 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ODc5ODQwMGEwZTZjN2Q3NDc0MmZhMmY1NDBkYTM3YzgwYTI0NjI2NQ==
5
- data.tar.gz: !binary |-
6
- MzJiNGMwYWMyNjdjYzU0MDcyN2I5OWI3YzI0ODc4MzNiNjc1OTBmMg==
2
+ SHA1:
3
+ metadata.gz: ecc9aded4b8cb6bff1656b50e83b3dc530b555fd
4
+ data.tar.gz: 07c7a40cdd98287b5e8d937c1657c6c0c085f40a
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YjJmNmQ2ZWY4YmNjZmU0NDEyOTEzYjJjNjhjNGIyOTM5NGI5MmYxMTNjZWU5
10
- YTkwOTdkZTg5MTE5ZDg1ODQ5YjNjZmE3MzIxNzdkYzNkNzA0ZDdmNDdmMWYw
11
- YzljNTE3MjAzYmU0ODFiMjcwNDA4YmNkNGUwZGQ0ODUwOTllZDk=
12
- data.tar.gz: !binary |-
13
- MTdkOWMyZjdlMjZjNTRhZTgyYzE2YmY4ZTFkNDIxNjYwYjBmNGRkNWE3M2Mw
14
- N2NmMDY3OTdiZWRiNzdhNzE1ZjEwYmI0MjQ3OTc1ODRkMjAxYmZjMTk1MGVj
15
- ZDIyNWM0YzI5MzM2NWQ0MjAzZmJhYjFkOGQxNjc3OTQ3MjllOTY=
6
+ metadata.gz: eeb831eaacd8cd0a7f4cbbc5381883bf4532fa57c7a1676450ff66be3fd2fce004cee79f095152e2cf35dda887e8d869205aa1097f5c32131b92db8d1851146b
7
+ data.tar.gz: ee6d5385df03a1fa4bcfe2467c6ef55b3bda43a91d39cd7af0d78c9c684c23b402809e533c3fcb8aee5fba6c040b5a4a77b5265addb40a16c05e2b2c646fcef6
data/README.md CHANGED
@@ -31,6 +31,10 @@ Use the table_export_tag helper like any other regular tag helper next to your t
31
31
 
32
32
  <%= table_export_tag %>
33
33
 
34
+ In order to select a particular table use id of the table as follows
35
+
36
+ <%= table_export_tag('id of the table') %>
37
+
34
38
 
35
39
  ## Contributing
36
40
 
@@ -1,7 +1,11 @@
1
- //= require jquery.tableToCSV
1
+ //= require jquery.tableToCSV.min
2
2
 
3
3
  $(document).ready(function(){
4
- $("#export").click(function(){
5
- $("table").tableToCSV();
6
- });
7
- });
4
+ $("#export").click(function(){
5
+ var id = $("#export").data('id')
6
+ if(id != undefined && id!= '')
7
+ $("table"+"#"+id).tableToCSV();
8
+ else
9
+ $("table").tableToCSV();
10
+ });
11
+ });
@@ -1,5 +1,6 @@
1
1
  module TableToCsvHelper
2
- def table_export_tag
3
- content_tag(:button,"Export",id: "export", "data-export" =>"export")
4
- end
5
- end
2
+ def table_export_tag(id='')
3
+ content_tag(:button,"Export",id: "export", "data-export" =>"export", "data-id" => id)
4
+ end
5
+ end
6
+
@@ -1,3 +1,3 @@
1
1
  module Table2csv
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1 @@
1
+ jQuery.fn.tableToCSV=function(){var t=function(t){return t=t.replace(/"/g,'\\"').replace(/'/g,"\\'"),'"'+t+'"'};$(this).each(function(){var e=($(this),$(this).find("caption").text()),n=[],i=[];$(this).find("tr").each(function(){var e=[];$(this).find("th").each(function(){var e=t($(this).text());n.push(e)}),$(this).find("td").each(function(){var n=t($(this).text());e.push(n)}),e=e.join(","),i.push(e)}),n=n.join(","),i=i.join("\n");var c=n+i,a="data:text/csv;charset=utf-8,"+encodeURIComponent(c),o=document.createElement("a");o.href=a;var h=(new Date).getTime();o.download=""==e?h+".csv":e+"-"+h+".csv",document.body.appendChild(o),o.click(),document.body.removeChild(o)})};
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table2csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ethiraj
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-10 00:00:00.000000000 Z
11
+ date: 2015-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  description: Export a html table into csv file
@@ -45,7 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - .gitignore
48
+ - ".gitignore"
49
49
  - CODE_OF_CONDUCT.md
50
50
  - Gemfile
51
51
  - LICENSE.txt
@@ -58,7 +58,7 @@ files:
58
58
  - lib/table2csv.rb
59
59
  - lib/table2csv/version.rb
60
60
  - table2csv.gemspec
61
- - vendor/assets/javascripts/jquery.tableToCSV.js
61
+ - vendor/assets/javascripts/jquery.tableToCSV.min.js
62
62
  homepage: https://github.com/ethirajsrinivasan/table2csv
63
63
  licenses:
64
64
  - MIT
@@ -70,12 +70,12 @@ require_paths:
70
70
  - lib
71
71
  required_ruby_version: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - ! '>='
78
+ - - ">="
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  requirements: []
@@ -1,45 +0,0 @@
1
- jQuery.fn.tableToCSV = function() {
2
-
3
- var clean_text = function(text){
4
- text = text.replace(/"/g, '\\"').replace(/'/g, "\\'");
5
- return '"'+text+'"';
6
- };
7
-
8
- $(this).each(function(){
9
- var table = $(this);
10
- var caption = $(this).find('caption').text();
11
- var title = [];
12
- var rows = [];
13
-
14
- $(this).find('tr').each(function(){
15
- var data = [];
16
- $(this).find('th').each(function(){
17
- var text = clean_text($(this).text());
18
- title.push(text);
19
- });
20
- $(this).find('td').each(function(){
21
- var text = clean_text($(this).text());
22
- data.push(text);
23
- });
24
- data = data.join(",");
25
- rows.push(data);
26
- });
27
- title = title.join(",");
28
- rows = rows.join("\n");
29
-
30
- var csv = title + rows;
31
- var uri = 'data:text/csv;charset=utf-8,' + encodeURIComponent(csv);
32
- var download_link = document.createElement('a');
33
- download_link.href = uri;
34
- var ts = new Date().getTime();
35
- if(caption==""){
36
- download_link.download = ts+".csv";
37
- } else {
38
- download_link.download = caption+"-"+ts+".csv";
39
- }
40
- document.body.appendChild(download_link);
41
- download_link.click();
42
- document.body.removeChild(download_link);
43
- });
44
-
45
- };