zadok 0.4.4 → 0.4.5

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: a8ca6fd921b6f60fa1483f0eb91b2749a31240c7f658745a58efdb4a735204d2
4
- data.tar.gz: 14c937d6f5c459a3747f68ecdb9c39b0466ac6495931cfb621aabfd6cb6856cd
3
+ metadata.gz: 7f90c17326ec414128552f0de6cf254b1199b0ce24e6afb2f8966831175e8774
4
+ data.tar.gz: fb012cd6e048b94c49eb3e30a1fba25ec07690781bb069a80b89efff33851076
5
5
  SHA512:
6
- metadata.gz: ada0bf4e16c8906aefb836d45c9d360f1e921cccfbb6e403a2c2aebb860709434550e12530f64ab953625f60b3425c05f176653cf0b25849a9555fc9c645039d
7
- data.tar.gz: 583fb73d682bae7291d493bb4a13c1ff76ec8e238b6d8345bb50c1cf8c1b90bc452a76e83979c9a4e1888a8ed40231a5c420a431db831c196801e495997e4dcf
6
+ metadata.gz: 385741acdf468d8cccc0edd0e442af34fd8493b001d82f8e2e87069914193ff872a31b6cab0151cd81b28f9e96afe5bb7cd5be0dda366cf7955ee5e2ddbbc722
7
+ data.tar.gz: '097a367c4560b620c1bc479c715c10d30f5c0c1f5c89f9f451db4a09de34b2d1f95a777c357fad73e222771b147717415a8c1847ab63c0d684568f3ec91d0dc9'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zadok (0.4.4)
4
+ zadok (0.4.5)
5
5
  bootstrap (~> 4.0)
6
6
  bundler-audit (~> 0.6)
7
7
  cancancan (~> 2.1)
@@ -142,7 +142,7 @@ GEM
142
142
  powerpack (0.1.1)
143
143
  puma (3.11.2)
144
144
  rack (2.0.4)
145
- rack-test (0.8.2)
145
+ rack-test (0.8.3)
146
146
  rack (>= 1.0, < 3)
147
147
  rails (5.1.5)
148
148
  actioncable (= 5.1.5)
@@ -12,12 +12,24 @@ class ZadokController < ApplicationController
12
12
  helper_method :show_attributes
13
13
 
14
14
  def index
15
- filter_and_paginate_resources!
16
- render "zadok/index"
15
+ respond_to do |format|
16
+ format.csv { send_data(generate_csv) }
17
+ format.html do
18
+ filter_and_paginate_resources!
19
+ render "zadok/index"
20
+ end
21
+ format.json { render json: resources, root: false }
22
+ format.xml { render xml: resources, root: false }
23
+ end
17
24
  end
18
25
 
19
26
  def show
20
- render [controller_name, "show"].join("/")
27
+ respond_to do |format|
28
+ format.html { render [controller_name, "show"].join("/") }
29
+ format.json { render json: resource, root: false }
30
+ format.xml { render xml: resource, root: false }
31
+ end
32
+
21
33
  end
22
34
 
23
35
  def new
@@ -125,7 +137,7 @@ class ZadokController < ApplicationController
125
137
  end
126
138
 
127
139
  def resources
128
- @resources ||= send("@#{controller_name}")
140
+ raise "resources method not implemented"
129
141
  end
130
142
 
131
143
  def filter_and_paginate_resources!
@@ -133,7 +145,7 @@ class ZadokController < ApplicationController
133
145
  end
134
146
 
135
147
  def resource
136
- @resource ||= send("@#{controller_name.singularize}")
148
+ raise "resource method not implemented"
137
149
  end
138
150
 
139
151
  def show_attributes
@@ -151,4 +163,14 @@ class ZadokController < ApplicationController
151
163
  def edit_attributes
152
164
  raise "edit_attributes method not implemented"
153
165
  end
166
+
167
+ def generate_csv
168
+ CSV.generate(headers: true, col_sep: t("zadok.csv.col_sep")) do |csv|
169
+ csv << resource_class.attribute_names
170
+
171
+ resources.each do |resource|
172
+ csv << resource_class.attribute_names.map { |attr| resource.send(attr) }
173
+ end
174
+ end
175
+ end
154
176
  end
data/lib/zadok/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zadok
4
- VERSION = "0.4.4"
4
+ VERSION = "0.4.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zadok
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leon Hooijer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-26 00:00:00.000000000 Z
11
+ date: 2018-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap