datatables_server_side 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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31a4853d6bfe98af8964ad2f2e7bdd2972b51af8
4
- data.tar.gz: 946ce45d877d215ab60272f0609d3b20002f183b
3
+ metadata.gz: ebbd5204046ad46a8809cf2de1d20141d9346233
4
+ data.tar.gz: af01a6f4ea3d5a2bf719971f0384dc29be440c5f
5
5
  SHA512:
6
- metadata.gz: 1c6e0b9e7409dcf1f113df3992c3562f871daa822efc6d02d93bae71f0464990af46cd41a3d2a1e0db649af6bc8cda20a31fd3164a35579d7fe44ce0428597d3
7
- data.tar.gz: 5eef3e1a135ffd37720fc835e590fde37728c602a63a9a06adef4e72f0e61e6d73a2f7694a6324c0a56f8a3ae8ca66f54853becaeacb20ae5bbbe4d2b711f89f
6
+ metadata.gz: 9babccb2b6239ebf1ce37a3cffc61a09c314a12b0f0a160b523aea0c40062fff9859b8393ba517e40e0c2771846fec0766f93ff30dbd33453d6f6cb95d23b4cc
7
+ data.tar.gz: ef70c59bf78f508d578d1671532ffeaee84163374cb623f83520749c8a463cf0ce57780be582a8c04410ccaa3e37564c3d28fabbc71fab28c9247b94868eb9aa
data/.gitignore CHANGED
File without changes
data/Gemfile CHANGED
File without changes
File without changes
data/README.md CHANGED
File without changes
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = DatatablesServerSide::VERSION
9
9
  spec.authors = ['Layon Ferreira']
10
10
  spec.email = ['layon@live.com.pt']
11
- spec.summary = %q{Simple gem that helps the creation of json datatables json responses.}
12
- spec.description = %q{Simple gem that helps the creation of json datatables json responses.}
11
+ spec.summary = %q{Simple gem that helps the creation of datatables json responses.}
12
+ spec.description = %q{Simple gem that helps the creation of datatables json responses.}
13
13
  spec.homepage = 'https://github.com/layonferreira/datatables_server_side'
14
14
  spec.license = 'MIT'
15
15
 
File without changes
@@ -1,3 +1,3 @@
1
1
  module DatatablesServerSide
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,12 +1,12 @@
1
- require 'thor/group'
2
- module DatatablesServerSide
3
- module Generators
4
- class DatatableGenerator < Rails::Generators::Base
5
- source_root File.expand_path("../../templates", __FILE__)
6
- argument :table_name, :type => :string
7
- def generate_datatable
8
- template "generic_datatable.rb","app/datatables/#{table_name.underscore}_datatable.rb"
9
- end
10
- end
11
- end
1
+ require 'thor/group'
2
+ module DatatablesServerSide
3
+ module Generators
4
+ class DatatableGenerator < Rails::Generators::Base
5
+ source_root File.expand_path("../../templates", __FILE__)
6
+ argument :table_name, :type => :string
7
+ def generate_datatable
8
+ template "generic_datatable.rb","app/datatables/#{table_name.underscore}_datatable.rb"
9
+ end
10
+ end
11
+ end
12
12
  end
@@ -1,11 +1,11 @@
1
- require 'thor/group'
2
- module DatatablesServerSide
3
- module Generators
4
- class InstallerGenerator < Rails::Generators::Base
5
- source_root File.expand_path("../../templates", __FILE__)
6
- def generate_installer
7
- empty_directory 'app/datatables'
8
- end
9
- end
10
- end
1
+ require 'thor/group'
2
+ module DatatablesServerSide
3
+ module Generators
4
+ class InstallerGenerator < Rails::Generators::Base
5
+ source_root File.expand_path("../../templates", __FILE__)
6
+ def generate_installer
7
+ empty_directory 'app/datatables'
8
+ end
9
+ end
10
+ end
11
11
  end
@@ -1,37 +1,37 @@
1
- class <%= table_name.camelize %>Datatable < DatatablesServerSide::Datatables
2
- #You can delegate paths to the @view context, example
3
- #delegate :model_path, :delete_model_path, :edit_model_path, to: :@view
4
-
5
- # the json response that will be returned
6
- def as_json(options = {})
7
- {
8
- sEcho: params[:sEcho].to_i,
9
- iTotalRecords: <%= table_name.camelize.singularize %>.count,
10
- iTotalDisplayRecords: records.length,
11
- aaData: safe_attributes(data)
12
- }
13
- end
14
-
15
- private
16
-
17
- # returns the data object, it should contain the object that datatable will parse, example
18
- # def data
19
- # records.map do |example|
20
- # [
21
- # example.id,
22
- # example.name,
23
- # example.description,
24
- # ]
25
- # end
26
-
27
- def data
28
- # TODO ADD your code here
29
- end
30
-
31
- #this method is responsible for connect with model, here you should add your filters.
32
- def fetch_records
33
- <%= table_name.underscore %> = <%= table_name.camelize.singularize %>.all
34
- <%= table_name.underscore %>
35
- end
36
-
1
+ class <%= table_name.camelize %>Datatable < DatatablesServerSide::Datatables
2
+ #You can delegate paths to the @view context, example
3
+ #delegate :model_path, :delete_model_path, :edit_model_path, to: :@view
4
+
5
+ # the json response that will be returned
6
+ def as_json(options = {})
7
+ {
8
+ sEcho: params[:sEcho].to_i,
9
+ iTotalRecords: <%= table_name.camelize.singularize %>.count,
10
+ iTotalDisplayRecords: records.length,
11
+ aaData: safe_attributes(data)
12
+ }
13
+ end
14
+
15
+ private
16
+
17
+ # returns the data object, it should contain the object that datatable will parse, example
18
+ # def data
19
+ # records.map do |example|
20
+ # [
21
+ # example.id,
22
+ # example.name,
23
+ # example.description,
24
+ # ]
25
+ # end
26
+
27
+ def data
28
+ # TODO ADD your code here
29
+ end
30
+
31
+ #this method is responsible for connect with model, here you should add your filters.
32
+ def fetch_records
33
+ <%= table_name.underscore %> = <%= table_name.camelize.singularize %>.all
34
+ <%= table_name.underscore %>
35
+ end
36
+
37
37
  end
@@ -1,20 +1,20 @@
1
- require 'generator_spec'
2
- require 'generators/datatables_server_side/datatable_generator'
3
- describe DatatablesServerSide::Generators::DatatableGenerator, type: :generator do
4
- destination File.expand_path("../tmp", File.dirname(__FILE__))
5
- arguments %w(TestOfGenerator)
6
- before(:all) do
7
- prepare_destination
8
- run_generator
9
- end
10
- it 'creates a file with the correct name' do
11
- run_generator
12
- assert_file 'app/datatables/test_of_generator_datatable.rb'
13
- end
14
-
15
- it 'creates a file with correct class' do
16
- run_generator
17
- assert_file 'app/datatables/test_of_generator_datatable.rb',/class TestOfGeneratorDatatable < DatatablesServerSide::Datatables/
18
- end
19
-
20
- end
1
+ require 'generator_spec'
2
+ require 'generators/datatables_server_side/datatable_generator'
3
+ describe DatatablesServerSide::Generators::DatatableGenerator, type: :generator do
4
+ destination File.expand_path("../tmp", File.dirname(__FILE__))
5
+ arguments %w(TestOfGenerator)
6
+ before(:all) do
7
+ prepare_destination
8
+ run_generator
9
+ end
10
+ it 'creates a file with the correct name' do
11
+ run_generator
12
+ assert_file 'app/datatables/test_of_generator_datatable.rb'
13
+ end
14
+
15
+ it 'creates a file with correct class' do
16
+ run_generator
17
+ assert_file 'app/datatables/test_of_generator_datatable.rb',/class TestOfGeneratorDatatable < DatatablesServerSide::Datatables/
18
+ end
19
+
20
+ end
@@ -1,70 +1,70 @@
1
- require 'datatables_server_side'
2
- describe DatatablesServerSide::Datatables do
3
- def getTable
4
- context = double(:render => "some content...", :link_to => "<a href='www.somewhere.com'>somewhere</a>") #TODO improve this stub
5
- DatatablesServerSide::Datatables.new(context)
6
- end
7
-
8
- # checks each element inside array to be html_safe
9
- def is_all_values_safe?(data)
10
- is_valid=true
11
- data.each do |array_value|
12
- if array_value.class==Array
13
- is_valid= is_valid && is_all_values_safe?(array_value)
14
- elsif array_value.class!=NilClass
15
- is_valid= is_valid && array_value.html_safe?
16
- end
17
- end
18
- return is_valid
19
- end
20
-
21
- def get_dummy_data
22
- array_of_text = Array.new
23
- data=Array.new
24
- array_of_text[0]="teste"
25
- array_of_text[1]="teste"
26
- array_of_text[2]="<a>teste</a>"
27
- data[0]="teste"
28
- data[1]=array_of_text
29
- data
30
- end
31
-
32
- it 'initializes' do
33
- my_table=getTable
34
- my_table.class.should eq(DatatablesServerSide::Datatables)
35
- end
36
-
37
-
38
- it 'protects records with html safe' do
39
- my_table=getTable
40
- safe_records=my_table.send(:safe_attributes, get_dummy_data)
41
- is_all_values_safe?(safe_records).should eq true
42
- end
43
-
44
-
45
- it 'gets the correct page' do
46
- my_table=getTable
47
- my_table.stub(:per_page){10}
48
- my_table.stub(:params){{iDisplayStart: nil}}
49
- my_table.send(:page).should eq 1
50
- my_table.stub(:params){{iDisplayStart: 2}}
51
- my_table.send(:page).should eq 1
52
- my_table.stub(:params){{iDisplayStart: 10}}
53
- my_table.send(:page).should eq 2
54
- end
55
-
56
-
57
- it 'have default per page of 10' do
58
- my_table=getTable
59
- my_table.stub(:params){{iDisplayLength: nil}}
60
- my_table.send(:per_page).should eq 10
61
- end
62
-
63
-
64
- it 'have default sor direction of asc' do
65
- my_table=getTable
66
- my_table.stub(:params){{sSortDir_0: nil}}
67
- my_table.send(:sort_direction).should eq 'asc'
68
- end
69
-
70
- end
1
+ require 'datatables_server_side'
2
+ describe DatatablesServerSide::Datatables do
3
+ def dummy_table
4
+ context = double(:render => "some content...", :link_to => "<a href='www.somewhere.com'>somewhere</a>") #TODO improve this stub
5
+ DatatablesServerSide::Datatables.new(context)
6
+ end
7
+
8
+ # checks each element inside array to be html_safe
9
+ def are_elements_safe?(data)
10
+ is_valid=true
11
+ data.each do |array_value|
12
+ if array_value.class==Array
13
+ is_valid= is_valid && are_elements_safe?(array_value)
14
+ elsif array_value.class!=NilClass
15
+ is_valid= is_valid && array_value.html_safe?
16
+ end
17
+ end
18
+ return is_valid
19
+ end
20
+
21
+ def dummy_data
22
+ array_of_text = Array.new
23
+ data=Array.new
24
+ array_of_text[0]="teste"
25
+ array_of_text[1]="teste"
26
+ array_of_text[2]="<a>teste</a>"
27
+ data[0]="teste"
28
+ data[1]=array_of_text
29
+ data
30
+ end
31
+
32
+ it 'initializes' do
33
+ my_table=dummy_table
34
+ my_table.class.should eq(DatatablesServerSide::Datatables)
35
+ end
36
+
37
+
38
+ it 'protects records with html safe' do
39
+ my_table=dummy_table
40
+ safe_records=my_table.send(:safe_attributes, dummy_data)
41
+ are_elements_safe?(safe_records).should eq true
42
+ end
43
+
44
+
45
+ it 'gets the correct page' do
46
+ my_table=dummy_table
47
+ my_table.stub(:per_page){10}
48
+ my_table.stub(:params){{iDisplayStart: nil}}
49
+ my_table.send(:page).should eq 1
50
+ my_table.stub(:params){{iDisplayStart: 2}}
51
+ my_table.send(:page).should eq 1
52
+ my_table.stub(:params){{iDisplayStart: 10}}
53
+ my_table.send(:page).should eq 2
54
+ end
55
+
56
+
57
+ it 'have default per page of 10' do
58
+ my_table=dummy_table
59
+ my_table.stub(:params){{iDisplayLength: nil}}
60
+ my_table.send(:per_page).should eq 10
61
+ end
62
+
63
+
64
+ it 'have default sor direction of asc' do
65
+ my_table=dummy_table
66
+ my_table.stub(:params){{sSortDir_0: nil}}
67
+ my_table.send(:sort_direction).should eq 'asc'
68
+ end
69
+
70
+ end
@@ -1,15 +1,15 @@
1
- require 'generator_spec'
2
- require 'generators/datatables_server_side/installer_generator'
3
- describe DatatablesServerSide::Generators::InstallerGenerator, type: :generator do
4
- destination File.expand_path("../tmp", File.dirname(__FILE__))
5
- before(:all) do
6
- prepare_destination
7
- run_generator
8
- end
9
- it 'creates the empty directory' do
10
- run_generator
11
- assert_directory 'app/datatables'
12
- end
13
-
14
- end
15
-
1
+ require 'generator_spec'
2
+ require 'generators/datatables_server_side/installer_generator'
3
+ describe DatatablesServerSide::Generators::InstallerGenerator, type: :generator do
4
+ destination File.expand_path("../tmp", File.dirname(__FILE__))
5
+ before(:all) do
6
+ prepare_destination
7
+ run_generator
8
+ end
9
+ it 'creates the empty directory' do
10
+ run_generator
11
+ assert_directory 'app/datatables'
12
+ end
13
+
14
+ end
15
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datatables_server_side
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
  - Layon Ferreira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-17 00:00:00.000000000 Z
11
+ date: 2015-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -114,7 +114,7 @@ dependencies:
114
114
  - - "<"
115
115
  - !ruby/object:Gem::Version
116
116
  version: '5'
117
- description: Simple gem that helps the creation of json datatables json responses.
117
+ description: Simple gem that helps the creation of datatables json responses.
118
118
  email:
119
119
  - layon@live.com.pt
120
120
  executables: []
@@ -122,16 +122,6 @@ extensions: []
122
122
  extra_rdoc_files: []
123
123
  files:
124
124
  - ".gitignore"
125
- - ".idea/.name"
126
- - ".idea/.rakeTasks"
127
- - ".idea/datatable_server_side.iml"
128
- - ".idea/dictionaries/Layon.xml"
129
- - ".idea/encodings.xml"
130
- - ".idea/misc.xml"
131
- - ".idea/modules.xml"
132
- - ".idea/scopes/scope_settings.xml"
133
- - ".idea/vcs.xml"
134
- - ".idea/workspace.xml"
135
125
  - Gemfile
136
126
  - LICENSE.txt
137
127
  - README.md
@@ -168,7 +158,7 @@ rubyforge_project:
168
158
  rubygems_version: 2.2.2
169
159
  signing_key:
170
160
  specification_version: 4
171
- summary: Simple gem that helps the creation of json datatables json responses.
161
+ summary: Simple gem that helps the creation of datatables json responses.
172
162
  test_files:
173
163
  - spec/datatable_generator_spec.rb
174
164
  - spec/datatables_spec.rb
@@ -1 +0,0 @@
1
- datatable_server_side
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Settings><!--This file was automatically generated by Ruby plugin.
3
- You are allowed to:
4
- 1. Remove rake task
5
- 2. Add existing rake tasks
6
- To add existing rake tasks automatically delete this file and reload the project.
7
- --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
@@ -1,45 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="RUBY_MODULE" version="4">
3
- <component name="FacetManager">
4
- <facet type="gem" name="Ruby Gem">
5
- <configuration>
6
- <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$/../datatable_server_side" />
7
- <option name="GEM_APP_TEST_PATH" value="" />
8
- <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/../datatable_server_side/lib" />
9
- </configuration>
10
- </facet>
11
- </component>
12
- <component name="NewModuleRootManager">
13
- <content url="file://$MODULE_DIR$" />
14
- <orderEntry type="inheritedJdk" />
15
- <orderEntry type="sourceFolder" forTests="false" />
16
- <orderEntry type="library" scope="PROVIDED" name="actionpack (v4.2.0, Remote:ruby-2.1.2-p95) [gem]" level="application" />
17
- <orderEntry type="library" scope="PROVIDED" name="actionview (v4.2.0, Remote:ruby-2.1.2-p95) [gem]" level="application" />
18
- <orderEntry type="library" scope="PROVIDED" name="activesupport (v4.2.0, Remote:ruby-2.1.2-p95) [gem]" level="application" />
19
- <orderEntry type="library" scope="PROVIDED" name="builder (v3.2.2, Remote:ruby-2.1.2-p95) [gem]" level="application" />
20
- <orderEntry type="library" scope="PROVIDED" name="bundler (v1.7.2, Remote:ruby-2.1.2-p95) [gem]" level="application" />
21
- <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, Remote:ruby-2.1.2-p95) [gem]" level="application" />
22
- <orderEntry type="library" scope="PROVIDED" name="erubis (v2.7.0, Remote:ruby-2.1.2-p95) [gem]" level="application" />
23
- <orderEntry type="library" scope="PROVIDED" name="generator_spec (v0.9.3, Remote:ruby-2.1.2-p95) [gem]" level="application" />
24
- <orderEntry type="library" scope="PROVIDED" name="i18n (v0.7.0, Remote:ruby-2.1.2-p95) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="json (v1.8.2, Remote:ruby-2.1.2-p95) [gem]" level="application" />
26
- <orderEntry type="library" scope="PROVIDED" name="loofah (v2.0.1, Remote:ruby-2.1.2-p95) [gem]" level="application" />
27
- <orderEntry type="library" scope="PROVIDED" name="mini_portile (v0.6.2, Remote:ruby-2.1.2-p95) [gem]" level="application" />
28
- <orderEntry type="library" scope="PROVIDED" name="minitest (v5.5.1, Remote:ruby-2.1.2-p95) [gem]" level="application" />
29
- <orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.6.5, Remote:ruby-2.1.2-p95) [gem]" level="application" />
30
- <orderEntry type="library" scope="PROVIDED" name="rack (v1.6.0, Remote:ruby-2.1.2-p95) [gem]" level="application" />
31
- <orderEntry type="library" scope="PROVIDED" name="rack-test (v0.6.3, Remote:ruby-2.1.2-p95) [gem]" level="application" />
32
- <orderEntry type="library" scope="PROVIDED" name="rails-deprecated_sanitizer (v1.0.3, Remote:ruby-2.1.2-p95) [gem]" level="application" />
33
- <orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v1.0.5, Remote:ruby-2.1.2-p95) [gem]" level="application" />
34
- <orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.0.1, Remote:ruby-2.1.2-p95) [gem]" level="application" />
35
- <orderEntry type="library" scope="PROVIDED" name="railties (v4.2.0, Remote:ruby-2.1.2-p95) [gem]" level="application" />
36
- <orderEntry type="library" scope="PROVIDED" name="rake (v10.4.2, Remote:ruby-2.1.2-p95) [gem]" level="application" />
37
- <orderEntry type="library" scope="PROVIDED" name="rspec (v2.99.0, Remote:ruby-2.1.2-p95) [gem]" level="application" />
38
- <orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.99.2, Remote:ruby-2.1.2-p95) [gem]" level="application" />
39
- <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.99.2, Remote:ruby-2.1.2-p95) [gem]" level="application" />
40
- <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v2.99.2, Remote:ruby-2.1.2-p95) [gem]" level="application" />
41
- <orderEntry type="library" scope="PROVIDED" name="thor (v0.19.1, Remote:ruby-2.1.2-p95) [gem]" level="application" />
42
- <orderEntry type="library" scope="PROVIDED" name="thread_safe (v0.3.4, Remote:ruby-2.1.2-p95) [gem]" level="application" />
43
- <orderEntry type="library" scope="PROVIDED" name="tzinfo (v1.2.2, Remote:ruby-2.1.2-p95) [gem]" level="application" />
44
- </component>
45
- </module>