Permalink
Browse files

Init

  • Loading branch information...
0 parents commit 5e3f5b7f794ae0187be3c2bd93fdd84146c61027 @bogdan committed Jun 13, 2011
@@ -0,0 +1,5 @@
+lib/**/*.rb
+bin/*
+-
+features/**/*.feature
+LICENSE.txt
@@ -0,0 +1,7 @@
+.bundle
+coverage
+rdoc
+.yardoc
+spec.log
+pkg
+
1 .rspec
@@ -0,0 +1 @@
+--color
26 Gemfile
@@ -0,0 +1,26 @@
+source "http://rubygems.org"
+# Add dependencies required to use your gem here.
+# Example:
+# gem "activesupport", ">= 2.3.5"
+
+# Add dependencies to develop your gem here.
+# Include everything needed to run rake, tests, features, etc.
+
+gem "rails"
+
+
+
+group :development do
+ gem "rake", "0.8.7"
+ gem "mocha"
+ gem "rspec", "2.6.0"
+ gem "bundler", "~> 1.0.0"
+ gem "jeweler", "~> 1.6.0"
+ gem "rcov", ">= 0"
+ gem "ruby-debug"
+ gem "sqlite3-ruby"
+ gem "fastercsv"
+ gem "nokogiri"
+ gem 'will_paginate', '2.3.15'
+
+end
@@ -0,0 +1,111 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ abstract (1.0.0)
+ actionmailer (3.0.7)
+ actionpack (= 3.0.7)
+ mail (~> 2.2.15)
+ actionpack (3.0.7)
+ activemodel (= 3.0.7)
+ activesupport (= 3.0.7)
+ builder (~> 2.1.2)
+ erubis (~> 2.6.6)
+ i18n (~> 0.5.0)
+ rack (~> 1.2.1)
+ rack-mount (~> 0.6.14)
+ rack-test (~> 0.5.7)
+ tzinfo (~> 0.3.23)
+ activemodel (3.0.7)
+ activesupport (= 3.0.7)
+ builder (~> 2.1.2)
+ i18n (~> 0.5.0)
+ activerecord (3.0.7)
+ activemodel (= 3.0.7)
+ activesupport (= 3.0.7)
+ arel (~> 2.0.2)
+ tzinfo (~> 0.3.23)
+ activeresource (3.0.7)
+ activemodel (= 3.0.7)
+ activesupport (= 3.0.7)
+ activesupport (3.0.7)
+ arel (2.0.10)
+ builder (2.1.2)
+ columnize (0.3.2)
+ diff-lcs (1.1.2)
+ erubis (2.6.6)
+ abstract (>= 1.0.0)
+ fastercsv (1.5.3)
+ git (1.2.5)
+ i18n (0.5.0)
+ jeweler (1.6.1)
+ bundler (~> 1.0.0)
+ git (>= 1.2.5)
+ rake
+ linecache (0.43)
+ mail (2.2.19)
+ activesupport (>= 2.3.6)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ mocha (0.9.12)
+ nokogiri (1.4.4)
+ polyglot (0.3.1)
+ rack (1.2.3)
+ rack-mount (0.6.14)
+ rack (>= 1.0.0)
+ rack-test (0.5.7)
+ rack (>= 1.0)
+ rails (3.0.7)
+ actionmailer (= 3.0.7)
+ actionpack (= 3.0.7)
+ activerecord (= 3.0.7)
+ activeresource (= 3.0.7)
+ activesupport (= 3.0.7)
+ bundler (~> 1.0)
+ railties (= 3.0.7)
+ railties (3.0.7)
+ actionpack (= 3.0.7)
+ activesupport (= 3.0.7)
+ rake (>= 0.8.7)
+ thor (~> 0.14.4)
+ rake (0.8.7)
+ rcov (0.9.9)
+ rspec (2.6.0)
+ rspec-core (~> 2.6.0)
+ rspec-expectations (~> 2.6.0)
+ rspec-mocks (~> 2.6.0)
+ rspec-core (2.6.0)
+ rspec-expectations (2.6.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.6.0)
+ ruby-debug (0.10.4)
+ columnize (>= 0.1)
+ ruby-debug-base (~> 0.10.4.0)
+ ruby-debug-base (0.10.4)
+ linecache (>= 0.3)
+ sqlite3 (1.3.3)
+ sqlite3-ruby (1.3.3)
+ sqlite3 (>= 1.3.3)
+ thor (0.14.6)
+ treetop (1.4.9)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.27)
+ will_paginate (2.3.15)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ bundler (~> 1.0.0)
+ fastercsv
+ jeweler (~> 1.6.0)
+ mocha
+ nokogiri
+ rails
+ rake (= 0.8.7)
+ rcov
+ rspec (= 2.6.0)
+ ruby-debug
+ sqlite3-ruby
+ will_paginate (= 2.3.15)
@@ -0,0 +1,20 @@
+Copyright (c) 2011 Bogdan Gusiev
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
+= datagrid
+
+Description goes here.
+
+== Contributing to datagrid
+
+* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
+* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
+* Fork the project
+* Start a feature/bugfix branch
+* Commit and push until you are happy with your contribution
+* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
+* 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.
+
+== Copyright
+
+Copyright (c) 2011 Bogdan Gusiev. See LICENSE.txt for
+further details.
+
@@ -0,0 +1,49 @@
+# encoding: utf-8
+
+require 'rubygems'
+require 'bundler'
+begin
+ Bundler.setup(:default, :development)
+rescue Bundler::BundlerError => e
+ $stderr.puts e.message
+ $stderr.puts "Run `bundle install` to install missing gems"
+ exit e.status_code
+end
+require 'rake'
+
+require 'jeweler'
+Jeweler::Tasks.new do |gem|
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
+ gem.name = "datagrid"
+ gem.homepage = "http://github.com/bogdan/datagrid"
+ gem.license = "MIT"
+ gem.summary = %Q{Ruby gem to create datagrids}
+ gem.description = %Q{This allows you to easily build datagrid aka data tables with sortable columns and filters}
+ gem.email = "agresso@gmail.com"
+ gem.authors = ["Bogdan Gusiev"]
+ # dependencies defined in Gemfile
+end
+Jeweler::RubygemsDotOrgTasks.new
+
+require 'rspec/core'
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new(:spec) do |spec|
+ spec.pattern = FileList['spec/**/*_spec.rb']
+end
+
+RSpec::Core::RakeTask.new(:rcov) do |spec|
+ spec.pattern = 'spec/**/*_spec.rb'
+ spec.rcov = true
+end
+
+task :default => :spec
+
+require 'rake/rdoctask'
+Rake::RDocTask.new do |rdoc|
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
+
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "datagrid #{version}"
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
@@ -0,0 +1,88 @@
+## Datagrid
+
+Ruby library that helps you to build and repsend table like data with:
+
+* Filtering
+* Sort order
+* Exportort to CSV
+
+
+### Grid DSL
+
+In order to create a report You need to define:
+
+* scope of ActiveRecord objects to look through
+* filters that will be used to filter data
+* columns that should be displayed and sortable(if possible)
+
+
+``` ruby
+
+class SimpleReport
+
+ include Datagrid
+
+
+ scope do
+ User.includes(:group)
+ end
+
+ filter(:category, :enum, :select => ["first", "second"])
+ filter(:disabled, :eboolean)
+ filter(:confirmed, :boolean)
+ integer_range_filter(:logins_count, :integer)
+ filter(:group_name) do |value|
+ self.joins(:group).where(:groups => {:name => value})
+ end
+
+ column(:group, :order => "groups.name") do |model|
+ group.name
+ end
+
+ column(:name)
+
+
+end
+
+
+report = SimpleReport.new(:group_id => 5, :from_logins_count => 1, :category => "first")
+report.assets # => Array of User: SELECT * FROM users WHERE users.group_id = 5 AND users.logins_count >= 1 AND users.category = 'first'
+report.header
+report.rows
+report.data
+
+```
+
+### Scope
+
+Default scope of objects to filter and display.
+In common case it is `ActiveRecord::Base` subclass with some generic scopes like in example above.
+
+### Filters
+
+Each filter definition consists of:
+
+* name of the filter
+* type that will be used for value conversion
+* conditions block that cegerates `ActiveRecord` scope
+* additional options
+
+Datagrid supports different type of filters including:
+
+* text
+* integer
+* date
+* boolean
+* eboolean - the select of "yes", "no" and any
+* enum
+
+Read more about filters here:
+
+
+### Columns
+
+Each column is represented by name and code block to calculate the value.
+If no block given the value will be the result of column name method call on object defined in Scope.
+
+
+
@@ -0,0 +1 @@
+0.0.3
Oops, something went wrong.

0 comments on commit 5e3f5b7

Please sign in to comment.