datagrid 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,26 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+
9
+ gem "rails"
10
+
11
+
12
+
13
+ group :development do
14
+ gem "rake", "0.8.7"
15
+ gem "mocha"
16
+ gem "rspec", "2.6.0"
17
+ gem "bundler", "~> 1.0.0"
18
+ gem "jeweler", "~> 1.6.0"
19
+ gem "rcov", ">= 0"
20
+ gem "ruby-debug"
21
+ gem "sqlite3-ruby"
22
+ gem "fastercsv"
23
+ gem "nokogiri"
24
+ gem 'will_paginate', '2.3.15'
25
+
26
+ end
@@ -0,0 +1,111 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.7)
6
+ actionpack (= 3.0.7)
7
+ mail (~> 2.2.15)
8
+ actionpack (3.0.7)
9
+ activemodel (= 3.0.7)
10
+ activesupport (= 3.0.7)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.5.0)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.14)
16
+ rack-test (~> 0.5.7)
17
+ tzinfo (~> 0.3.23)
18
+ activemodel (3.0.7)
19
+ activesupport (= 3.0.7)
20
+ builder (~> 2.1.2)
21
+ i18n (~> 0.5.0)
22
+ activerecord (3.0.7)
23
+ activemodel (= 3.0.7)
24
+ activesupport (= 3.0.7)
25
+ arel (~> 2.0.2)
26
+ tzinfo (~> 0.3.23)
27
+ activeresource (3.0.7)
28
+ activemodel (= 3.0.7)
29
+ activesupport (= 3.0.7)
30
+ activesupport (3.0.7)
31
+ arel (2.0.10)
32
+ builder (2.1.2)
33
+ columnize (0.3.2)
34
+ diff-lcs (1.1.2)
35
+ erubis (2.6.6)
36
+ abstract (>= 1.0.0)
37
+ fastercsv (1.5.3)
38
+ git (1.2.5)
39
+ i18n (0.5.0)
40
+ jeweler (1.6.1)
41
+ bundler (~> 1.0.0)
42
+ git (>= 1.2.5)
43
+ rake
44
+ linecache (0.43)
45
+ mail (2.2.19)
46
+ activesupport (>= 2.3.6)
47
+ i18n (>= 0.4.0)
48
+ mime-types (~> 1.16)
49
+ treetop (~> 1.4.8)
50
+ mime-types (1.16)
51
+ mocha (0.9.12)
52
+ nokogiri (1.4.4)
53
+ polyglot (0.3.1)
54
+ rack (1.2.3)
55
+ rack-mount (0.6.14)
56
+ rack (>= 1.0.0)
57
+ rack-test (0.5.7)
58
+ rack (>= 1.0)
59
+ rails (3.0.7)
60
+ actionmailer (= 3.0.7)
61
+ actionpack (= 3.0.7)
62
+ activerecord (= 3.0.7)
63
+ activeresource (= 3.0.7)
64
+ activesupport (= 3.0.7)
65
+ bundler (~> 1.0)
66
+ railties (= 3.0.7)
67
+ railties (3.0.7)
68
+ actionpack (= 3.0.7)
69
+ activesupport (= 3.0.7)
70
+ rake (>= 0.8.7)
71
+ thor (~> 0.14.4)
72
+ rake (0.8.7)
73
+ rcov (0.9.9)
74
+ rspec (2.6.0)
75
+ rspec-core (~> 2.6.0)
76
+ rspec-expectations (~> 2.6.0)
77
+ rspec-mocks (~> 2.6.0)
78
+ rspec-core (2.6.0)
79
+ rspec-expectations (2.6.0)
80
+ diff-lcs (~> 1.1.2)
81
+ rspec-mocks (2.6.0)
82
+ ruby-debug (0.10.4)
83
+ columnize (>= 0.1)
84
+ ruby-debug-base (~> 0.10.4.0)
85
+ ruby-debug-base (0.10.4)
86
+ linecache (>= 0.3)
87
+ sqlite3 (1.3.3)
88
+ sqlite3-ruby (1.3.3)
89
+ sqlite3 (>= 1.3.3)
90
+ thor (0.14.6)
91
+ treetop (1.4.9)
92
+ polyglot (>= 0.3.1)
93
+ tzinfo (0.3.27)
94
+ will_paginate (2.3.15)
95
+
96
+ PLATFORMS
97
+ ruby
98
+
99
+ DEPENDENCIES
100
+ bundler (~> 1.0.0)
101
+ fastercsv
102
+ jeweler (~> 1.6.0)
103
+ mocha
104
+ nokogiri
105
+ rails
106
+ rake (= 0.8.7)
107
+ rcov
108
+ rspec (= 2.6.0)
109
+ ruby-debug
110
+ sqlite3-ruby
111
+ will_paginate (= 2.3.15)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Bogdan Gusiev
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ = datagrid
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to datagrid
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Bogdan Gusiev. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "datagrid"
18
+ gem.homepage = "http://github.com/bogdan/datagrid"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Ruby gem to create datagrids}
21
+ gem.description = %Q{This allows you to easily build datagrid aka data tables with sortable columns and filters}
22
+ gem.email = "agresso@gmail.com"
23
+ gem.authors = ["Bogdan Gusiev"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rake/rdoctask'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "datagrid #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
@@ -0,0 +1,88 @@
1
+ ## Datagrid
2
+
3
+ Ruby library that helps you to build and repsend table like data with:
4
+
5
+ * Filtering
6
+ * Sort order
7
+ * Exportort to CSV
8
+
9
+
10
+ ### Grid DSL
11
+
12
+ In order to create a report You need to define:
13
+
14
+ * scope of ActiveRecord objects to look through
15
+ * filters that will be used to filter data
16
+ * columns that should be displayed and sortable(if possible)
17
+
18
+
19
+ ``` ruby
20
+
21
+ class SimpleReport
22
+
23
+ include Datagrid
24
+
25
+
26
+ scope do
27
+ User.includes(:group)
28
+ end
29
+
30
+ filter(:category, :enum, :select => ["first", "second"])
31
+ filter(:disabled, :eboolean)
32
+ filter(:confirmed, :boolean)
33
+ integer_range_filter(:logins_count, :integer)
34
+ filter(:group_name) do |value|
35
+ self.joins(:group).where(:groups => {:name => value})
36
+ end
37
+
38
+ column(:group, :order => "groups.name") do |model|
39
+ group.name
40
+ end
41
+
42
+ column(:name)
43
+
44
+
45
+ end
46
+
47
+
48
+ report = SimpleReport.new(:group_id => 5, :from_logins_count => 1, :category => "first")
49
+ report.assets # => Array of User: SELECT * FROM users WHERE users.group_id = 5 AND users.logins_count >= 1 AND users.category = 'first'
50
+ report.header
51
+ report.rows
52
+ report.data
53
+
54
+ ```
55
+
56
+ ### Scope
57
+
58
+ Default scope of objects to filter and display.
59
+ In common case it is `ActiveRecord::Base` subclass with some generic scopes like in example above.
60
+
61
+ ### Filters
62
+
63
+ Each filter definition consists of:
64
+
65
+ * name of the filter
66
+ * type that will be used for value conversion
67
+ * conditions block that cegerates `ActiveRecord` scope
68
+ * additional options
69
+
70
+ Datagrid supports different type of filters including:
71
+
72
+ * text
73
+ * integer
74
+ * date
75
+ * boolean
76
+ * eboolean - the select of "yes", "no" and any
77
+ * enum
78
+
79
+ Read more about filters here:
80
+
81
+
82
+ ### Columns
83
+
84
+ Each column is represented by name and code block to calculate the value.
85
+ If no block given the value will be the result of column name method call on object defined in Scope.
86
+
87
+
88
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.3
@@ -0,0 +1,106 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{datagrid}
8
+ s.version = "0.0.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Bogdan Gusiev"]
12
+ s.date = %q{2011-06-02}
13
+ s.description = %q{This allows you to easily build datagrid aka data tables with sortable columns and filters}
14
+ s.email = %q{agresso@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "datagrid.gemspec",
29
+ "lib/datagrid.rb",
30
+ "lib/datagrid/columns.rb",
31
+ "lib/datagrid/columns/column.rb",
32
+ "lib/datagrid/core.rb",
33
+ "lib/datagrid/filters.rb",
34
+ "lib/datagrid/filters/base_filter.rb",
35
+ "lib/datagrid/filters/boolean_enum_filter.rb",
36
+ "lib/datagrid/filters/boolean_filter.rb",
37
+ "lib/datagrid/filters/composite_filters.rb",
38
+ "lib/datagrid/filters/date_filter.rb",
39
+ "lib/datagrid/filters/default_filter.rb",
40
+ "lib/datagrid/filters/enum_filter.rb",
41
+ "lib/datagrid/filters/filter_eval.rb",
42
+ "lib/datagrid/filters/integer_filter.rb",
43
+ "lib/datagrid/form_builder.rb",
44
+ "lib/datagrid/helper.rb",
45
+ "lib/datagrid/rspec.rb",
46
+ "spec/datagrid_spec.rb",
47
+ "spec/simple_report_spec.rb",
48
+ "spec/spec_helper.rb",
49
+ "tags"
50
+ ]
51
+ s.homepage = %q{http://github.com/bogdan/datagrid}
52
+ s.licenses = ["MIT"]
53
+ s.require_paths = ["lib"]
54
+ s.rubygems_version = %q{1.3.7}
55
+ s.summary = %q{Ruby gem to create datagrids}
56
+
57
+ if s.respond_to? :specification_version then
58
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
59
+ s.specification_version = 3
60
+
61
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
62
+ s.add_runtime_dependency(%q<rails>, [">= 0"])
63
+ s.add_development_dependency(%q<rake>, ["= 0.8.7"])
64
+ s.add_development_dependency(%q<mocha>, [">= 0"])
65
+ s.add_development_dependency(%q<rspec-rails>, ["= 2.6.0"])
66
+ s.add_development_dependency(%q<rspec>, ["= 2.6.0"])
67
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
68
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
69
+ s.add_development_dependency(%q<rcov>, [">= 0"])
70
+ s.add_development_dependency(%q<ruby-debug>, [">= 0"])
71
+ s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
72
+ s.add_development_dependency(%q<fastercsv>, [">= 0"])
73
+ s.add_development_dependency(%q<nokogiri>, [">= 0"])
74
+ s.add_development_dependency(%q<will_paginate>, ["= 2.3.15"])
75
+ else
76
+ s.add_dependency(%q<rails>, [">= 0"])
77
+ s.add_dependency(%q<rake>, ["= 0.8.7"])
78
+ s.add_dependency(%q<mocha>, [">= 0"])
79
+ s.add_dependency(%q<rspec-rails>, ["= 2.6.0"])
80
+ s.add_dependency(%q<rspec>, ["= 2.6.0"])
81
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
82
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
83
+ s.add_dependency(%q<rcov>, [">= 0"])
84
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
85
+ s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
86
+ s.add_dependency(%q<fastercsv>, [">= 0"])
87
+ s.add_dependency(%q<nokogiri>, [">= 0"])
88
+ s.add_dependency(%q<will_paginate>, ["= 2.3.15"])
89
+ end
90
+ else
91
+ s.add_dependency(%q<rails>, [">= 0"])
92
+ s.add_dependency(%q<rake>, ["= 0.8.7"])
93
+ s.add_dependency(%q<mocha>, [">= 0"])
94
+ s.add_dependency(%q<rspec-rails>, ["= 2.6.0"])
95
+ s.add_dependency(%q<rspec>, ["= 2.6.0"])
96
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
97
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
98
+ s.add_dependency(%q<rcov>, [">= 0"])
99
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
100
+ s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
101
+ s.add_dependency(%q<fastercsv>, [">= 0"])
102
+ s.add_dependency(%q<nokogiri>, [">= 0"])
103
+ s.add_dependency(%q<will_paginate>, ["= 2.3.15"])
104
+ end
105
+ end
106
+
@@ -0,0 +1,37 @@
1
+ require "datagrid/filters"
2
+ require "datagrid/columns"
3
+ require "datagrid/core"
4
+
5
+ require "datagrid/helper"
6
+ require "datagrid/form_builder"
7
+
8
+ module Datagrid
9
+
10
+ def self.included(base)
11
+ base.extend ClassMethods
12
+ base.class_eval do
13
+
14
+ include ::Datagrid::Core
15
+ include ::Datagrid::Filters
16
+ include ::Datagrid::Columns
17
+
18
+ end
19
+ base.send :include, InstanceMethods
20
+ end # self.included
21
+
22
+ module ClassMethods
23
+
24
+
25
+ end # ClassMethods
26
+
27
+ module InstanceMethods
28
+
29
+ end # InstanceMethods
30
+
31
+ class ConfigurationError < StandardError; end
32
+
33
+
34
+ end
35
+
36
+
37
+