comma 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/.gitignore +1 -0
  2. data/Appraisals +1 -0
  3. data/Gemfile.lock +9 -3
  4. data/README.markdown +6 -0
  5. data/comma.gemspec +4 -2
  6. data/gemfiles/active3.0.9.gemfile.lock +7 -1
  7. data/gemfiles/active3.1.1.gemfile.lock +5 -1
  8. data/gemfiles/active3.2.1.gemfile.lock +5 -1
  9. data/gemfiles/rails3.0.9.gemfile +1 -0
  10. data/gemfiles/rails3.0.9.gemfile.lock +13 -1
  11. data/gemfiles/rails3.1.1.gemfile +1 -0
  12. data/gemfiles/rails3.1.1.gemfile.lock +11 -1
  13. data/gemfiles/rails3.2.1.gemfile +1 -0
  14. data/gemfiles/rails3.2.1.gemfile.lock +11 -1
  15. data/lib/comma.rb +6 -2
  16. data/lib/comma/version.rb +1 -1
  17. data/spec/comma/{ar_spec.rb → rails/active_record_spec.rb} +1 -1
  18. data/spec/controllers/users_controller_spec.rb +127 -0
  19. data/spec/non_rails_app/ruby_classes.rb +31 -0
  20. data/spec/rails_app/Rakefile +7 -0
  21. data/spec/rails_app/app/controllers/application_controller.rb +2 -0
  22. data/spec/rails_app/app/controllers/users_controller.rb +17 -0
  23. data/spec/rails_app/app/helpers/application_helper.rb +3 -0
  24. data/spec/rails_app/app/models/post.rb +10 -0
  25. data/spec/rails_app/app/models/user.rb +16 -0
  26. data/spec/rails_app/app/views/layouts/application.html.erb +12 -0
  27. data/spec/rails_app/app/views/users/index.html.erb +1 -0
  28. data/spec/rails_app/config.ru +4 -0
  29. data/spec/rails_app/config/application.rb +42 -0
  30. data/spec/rails_app/config/boot.rb +8 -0
  31. data/spec/rails_app/config/database.yml +18 -0
  32. data/spec/rails_app/config/environment.rb +5 -0
  33. data/spec/rails_app/config/environments/development.rb +20 -0
  34. data/spec/rails_app/config/environments/production.rb +35 -0
  35. data/spec/rails_app/config/environments/test.rb +33 -0
  36. data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  37. data/spec/rails_app/config/initializers/inflections.rb +2 -0
  38. data/spec/rails_app/config/initializers/secret_token.rb +2 -0
  39. data/spec/rails_app/config/routes.rb +8 -0
  40. data/spec/rails_app/db/development.sqlite3 +0 -0
  41. data/spec/rails_app/db/migrate/20120224085510_create_tables.rb +24 -0
  42. data/spec/rails_app/db/schema.rb +32 -0
  43. data/spec/rails_app/public/404.html +26 -0
  44. data/spec/rails_app/public/422.html +26 -0
  45. data/spec/rails_app/public/500.html +26 -0
  46. data/spec/rails_app/public/favicon.ico +0 -0
  47. data/spec/rails_app/script/rails +6 -0
  48. data/spec/spec_helper.rb +31 -28
  49. metadata +89 -20
  50. data/spec/support/database.yml +0 -4
data/.gitignore CHANGED
@@ -2,3 +2,4 @@ pkg/*
2
2
  .*.swp
3
3
  *~
4
4
  .bundle
5
+ spec/rails_app/log
data/Appraisals CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  appraise "rails#{ clean_number }" do
5
5
  gem "rails", version_number
6
+ gem "rspec-rails"
6
7
  end
7
8
 
8
9
  appraise "active#{ clean_number }" do
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- comma (3.0.0)
4
+ comma (3.0.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -10,7 +10,8 @@ GEM
10
10
  bundler
11
11
  rake
12
12
  diff-lcs (1.1.3)
13
- rake (0.9.2)
13
+ multi_json (1.0.4)
14
+ rake (0.9.2.2)
14
15
  rspec (2.8.0)
15
16
  rspec-core (~> 2.8.0)
16
17
  rspec-expectations (~> 2.8.0)
@@ -19,6 +20,10 @@ GEM
19
20
  rspec-expectations (2.8.0)
20
21
  diff-lcs (~> 1.1.2)
21
22
  rspec-mocks (2.8.0)
23
+ simplecov (0.5.4)
24
+ multi_json (~> 1.0.3)
25
+ simplecov-html (~> 0.5.3)
26
+ simplecov-html (0.5.3)
22
27
  sqlite3 (1.3.5)
23
28
 
24
29
  PLATFORMS
@@ -27,6 +32,7 @@ PLATFORMS
27
32
  DEPENDENCIES
28
33
  appraisal (~> 0.4.1)
29
34
  comma!
30
- rake (= 0.9.2)
35
+ rake (~> 0.9.2)
31
36
  rspec (~> 2.8.0)
37
+ simplecov
32
38
  sqlite3 (~> 1.3.4)
@@ -305,3 +305,9 @@ bundle exec rake appraisals spec
305
305
 
306
306
  ```
307
307
 
308
+ When rebuilding for a new rails version, to test across controller and the stack itself, a fake rails app must be generated :
309
+
310
+ ```
311
+ rails plugin new rails_app --full --dummy-path=spec/dummy --skip-bundle --skip-gemspec --skip-test-unit --skip-sprockets --skip-javascript --skip-gemfile --skip-git
312
+ ```
313
+
@@ -18,9 +18,11 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_development_dependency(%q<rake>, ["0.9.2"])
21
+ s.add_development_dependency(%q<rake>, ["~> 0.9.2"])
22
22
  s.add_development_dependency('sqlite3', '~> 1.3.4')
23
- s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
24
23
  s.add_development_dependency(%q<appraisal>, ["~> 0.4.1"])
25
24
 
25
+ s.add_development_dependency('rspec', '~> 2.8.0')
26
+ s.add_development_dependency 'simplecov'
27
+
26
28
  end
@@ -23,6 +23,7 @@ GEM
23
23
  builder (2.1.2)
24
24
  diff-lcs (1.1.3)
25
25
  i18n (0.5.0)
26
+ multi_json (1.0.4)
26
27
  rake (0.9.2)
27
28
  rspec (2.8.0)
28
29
  rspec-core (~> 2.8.0)
@@ -32,6 +33,10 @@ GEM
32
33
  rspec-expectations (2.8.0)
33
34
  diff-lcs (~> 1.1.2)
34
35
  rspec-mocks (2.8.0)
36
+ simplecov (0.5.4)
37
+ multi_json (~> 1.0.3)
38
+ simplecov-html (~> 0.5.3)
39
+ simplecov-html (0.5.3)
35
40
  sqlite3 (1.3.5)
36
41
  tzinfo (0.3.31)
37
42
 
@@ -43,6 +48,7 @@ DEPENDENCIES
43
48
  activesupport (= 3.0.9)
44
49
  appraisal (~> 0.4.1)
45
50
  comma!
46
- rake (= 0.9.2)
51
+ rake (~> 0.9.2)
47
52
  rspec (~> 2.8.0)
53
+ simplecov
48
54
  sqlite3 (~> 1.3.4)
@@ -34,6 +34,9 @@ GEM
34
34
  rspec-expectations (2.8.0)
35
35
  diff-lcs (~> 1.1.2)
36
36
  rspec-mocks (2.8.0)
37
+ simplecov (0.4.2)
38
+ simplecov-html (~> 0.4.4)
39
+ simplecov-html (0.4.5)
37
40
  sqlite3 (1.3.5)
38
41
  tzinfo (0.3.31)
39
42
 
@@ -45,6 +48,7 @@ DEPENDENCIES
45
48
  activesupport (= 3.1.1)
46
49
  appraisal (~> 0.4.1)
47
50
  comma!
48
- rake (= 0.9.2)
51
+ rake (~> 0.9.2)
49
52
  rspec (~> 2.8.0)
53
+ simplecov
50
54
  sqlite3 (~> 1.3.4)
@@ -34,6 +34,9 @@ GEM
34
34
  rspec-expectations (2.8.0)
35
35
  diff-lcs (~> 1.1.2)
36
36
  rspec-mocks (2.8.0)
37
+ simplecov (0.4.2)
38
+ simplecov-html (~> 0.4.4)
39
+ simplecov-html (0.4.5)
37
40
  sqlite3 (1.3.5)
38
41
  tzinfo (0.3.31)
39
42
 
@@ -45,6 +48,7 @@ DEPENDENCIES
45
48
  activesupport (~> 3.2.1)
46
49
  appraisal (~> 0.4.1)
47
50
  comma!
48
- rake (= 0.9.2)
51
+ rake (~> 0.9.2)
49
52
  rspec (~> 2.8.0)
53
+ simplecov
50
54
  sqlite3 (~> 1.3.4)
@@ -3,5 +3,6 @@
3
3
  source "http://rubygems.org"
4
4
 
5
5
  gem "rails", "3.0.9"
6
+ gem "rspec-rails"
6
7
 
7
8
  gemspec :path=>"../"
@@ -49,6 +49,7 @@ GEM
49
49
  mime-types (~> 1.16)
50
50
  treetop (~> 1.4.8)
51
51
  mime-types (1.17.2)
52
+ multi_json (1.0.4)
52
53
  polyglot (0.3.3)
53
54
  rack (1.2.5)
54
55
  rack-mount (0.6.14)
@@ -80,6 +81,15 @@ GEM
80
81
  rspec-expectations (2.8.0)
81
82
  diff-lcs (~> 1.1.2)
82
83
  rspec-mocks (2.8.0)
84
+ rspec-rails (2.8.1)
85
+ actionpack (>= 3.0)
86
+ activesupport (>= 3.0)
87
+ railties (>= 3.0)
88
+ rspec (~> 2.8.0)
89
+ simplecov (0.5.4)
90
+ multi_json (~> 1.0.3)
91
+ simplecov-html (~> 0.5.3)
92
+ simplecov-html (0.5.3)
83
93
  sqlite3 (1.3.5)
84
94
  thor (0.14.6)
85
95
  treetop (1.4.10)
@@ -94,6 +104,8 @@ DEPENDENCIES
94
104
  appraisal (~> 0.4.1)
95
105
  comma!
96
106
  rails (= 3.0.9)
97
- rake (= 0.9.2)
107
+ rake (~> 0.9.2)
98
108
  rspec (~> 2.8.0)
109
+ rspec-rails
110
+ simplecov
99
111
  sqlite3 (~> 1.3.4)
@@ -3,5 +3,6 @@
3
3
  source "http://rubygems.org"
4
4
 
5
5
  gem "rails", "3.1.1"
6
+ gem "rspec-rails"
6
7
 
7
8
  gemspec :path=>"../"
@@ -86,6 +86,14 @@ GEM
86
86
  rspec-expectations (2.8.0)
87
87
  diff-lcs (~> 1.1.2)
88
88
  rspec-mocks (2.8.0)
89
+ rspec-rails (2.8.1)
90
+ actionpack (>= 3.0)
91
+ activesupport (>= 3.0)
92
+ railties (>= 3.0)
93
+ rspec (~> 2.8.0)
94
+ simplecov (0.4.2)
95
+ simplecov-html (~> 0.4.4)
96
+ simplecov-html (0.4.5)
89
97
  sprockets (2.0.3)
90
98
  hike (~> 1.2)
91
99
  rack (~> 1.0)
@@ -105,6 +113,8 @@ DEPENDENCIES
105
113
  appraisal (~> 0.4.1)
106
114
  comma!
107
115
  rails (= 3.1.1)
108
- rake (= 0.9.2)
116
+ rake (~> 0.9.2)
109
117
  rspec (~> 2.8.0)
118
+ rspec-rails
119
+ simplecov
110
120
  sqlite3 (~> 1.3.4)
@@ -3,5 +3,6 @@
3
3
  source "http://rubygems.org"
4
4
 
5
5
  gem "rails", "~>3.2.1"
6
+ gem "rspec-rails"
6
7
 
7
8
  gemspec :path=>"../"
@@ -84,6 +84,14 @@ GEM
84
84
  rspec-expectations (2.8.0)
85
85
  diff-lcs (~> 1.1.2)
86
86
  rspec-mocks (2.8.0)
87
+ rspec-rails (2.8.1)
88
+ actionpack (>= 3.0)
89
+ activesupport (>= 3.0)
90
+ railties (>= 3.0)
91
+ rspec (~> 2.8.0)
92
+ simplecov (0.4.2)
93
+ simplecov-html (~> 0.4.4)
94
+ simplecov-html (0.4.5)
87
95
  sprockets (2.1.2)
88
96
  hike (~> 1.2)
89
97
  rack (~> 1.0)
@@ -103,6 +111,8 @@ DEPENDENCIES
103
111
  appraisal (~> 0.4.1)
104
112
  comma!
105
113
  rails (~> 3.2.1)
106
- rake (= 0.9.2)
114
+ rake (~> 0.9.2)
107
115
  rspec (~> 2.8.0)
116
+ rspec-rails
117
+ simplecov
108
118
  sqlite3 (~> 1.3.4)
@@ -11,6 +11,7 @@ if defined? Rails and (Rails.version.split('.').map(&:to_i).first < 3)
11
11
  end
12
12
 
13
13
  require 'active_support/core_ext/class/attribute'
14
+ require 'active_support/core_ext/module/delegation'
14
15
  require 'comma/relation' if defined?(ActiveRecord::Relation)
15
16
 
16
17
  require 'comma/extractors'
@@ -21,7 +22,10 @@ require 'comma/object'
21
22
  #Load into Rails controllers
22
23
  if defined?(ActionController::Renderers) && ActionController::Renderers.respond_to?(:add)
23
24
  ActionController::Renderers.add :csv do |obj, options|
24
- filename = options[:filename] || 'data'
25
- send_data obj.to_comma, :type => Mime::CSV, :disposition => "attachment; filename=#{filename}.csv"
25
+ filename = options[:filename] || 'data'
26
+ #Capture any CSV optional settings passed to comma
27
+ csv_options = options.slice(*CSV_HANDLER::DEFAULT_OPTIONS.merge(:write_headers => nil).keys)
28
+
29
+ send_data obj.to_comma(csv_options), :type => Mime::CSV, :disposition => "attachment; filename=#{filename}.csv"
26
30
  end
27
31
  end
@@ -1,3 +1,3 @@
1
1
  module Comma
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Comma, 'generating CSV from an ActiveRecord object' do
4
4
 
@@ -0,0 +1,127 @@
1
+ require 'spec_helper'
2
+
3
+ if defined?(ActionController) && defined?(Rails)
4
+
5
+ describe UsersController do
6
+
7
+ describe "rails setup" do
8
+
9
+ it 'should capture the CSV renderer provided by Rails' do
10
+ mock_users = [mock_model(User), mock_model(User)]
11
+ User.stub!(:all).and_return(mock_users)
12
+
13
+ mock_users.should_receive(:to_comma).once
14
+
15
+ get :index, :format => :csv
16
+ end
17
+
18
+ end
19
+
20
+ describe "controller" do
21
+ before(:each) do
22
+ @user_1 = User.create!(:first_name => 'Fred', :last_name => 'Flintstone')
23
+ @user_2 = User.create!(:first_name => 'Wilma', :last_name => 'Flintstone')
24
+ end
25
+
26
+ it 'should not affect html requested' do
27
+ get :index
28
+
29
+ response.status.should == 200
30
+ response.content_type.should == 'text/html'
31
+ response.body.should == 'Users!'
32
+ end
33
+
34
+ it "should return a csv when requested" do
35
+ get :index, :format => :csv
36
+
37
+ response.status.should == 200
38
+ response.content_type.should == 'text/csv'
39
+ response.header["Content-Disposition"].should include('filename=data.csv')
40
+
41
+ expected_content =<<-CSV.gsub(/^\s+/,'')
42
+ First name,Last name,Name
43
+ Fred,Flintstone,Fred Flintstone
44
+ Wilma,Flintstone,Wilma Flintstone
45
+ CSV
46
+
47
+ response.body.should == expected_content
48
+ end
49
+
50
+ describe 'with custom options' do
51
+
52
+ it 'should allow a filename to be set' do
53
+ get :with_custom_options, :format => :csv, :custom_options => { :filename => 'my_custom_name' }
54
+
55
+ response.status.should == 200
56
+ response.content_type.should == 'text/csv'
57
+ response.header["Content-Disposition"].should include('filename=my_custom_name.csv')
58
+ end
59
+
60
+ describe 'headers' do
61
+
62
+ it 'should allow toggling on' do
63
+ get :with_custom_options, :format => :csv, :custom_options => { :write_headers => 'true' }
64
+
65
+ response.status.should == 200
66
+ response.content_type.should == 'text/csv'
67
+
68
+ expected_content =<<-CSV.gsub(/^\s+/,'')
69
+ First name,Last name,Name
70
+ Fred,Flintstone,Fred Flintstone
71
+ Wilma,Flintstone,Wilma Flintstone
72
+ CSV
73
+
74
+ response.body.should == expected_content
75
+ end
76
+
77
+ it 'should allow toggling off' do
78
+ get :with_custom_options, :format => :csv, :custom_options => {:write_headers => false}
79
+
80
+ response.status.should == 200
81
+ response.content_type.should == 'text/csv'
82
+
83
+ expected_content =<<-CSV.gsub(/^\s+/,'')
84
+ Fred,Flintstone,Fred Flintstone
85
+ Wilma,Flintstone,Wilma Flintstone
86
+ CSV
87
+
88
+ response.body.should == expected_content
89
+ end
90
+
91
+ end
92
+
93
+ it 'should allow forcing of quotes' do
94
+ get :with_custom_options, :format => :csv, :custom_options => { :force_quotes => true }
95
+
96
+ response.status.should == 200
97
+ response.content_type.should == 'text/csv'
98
+
99
+ expected_content =<<-CSV.gsub(/^\s+/,'')
100
+ "First name","Last name","Name"
101
+ "Fred","Flintstone","Fred Flintstone"
102
+ "Wilma","Flintstone","Wilma Flintstone"
103
+ CSV
104
+
105
+ response.body.should == expected_content
106
+ end
107
+
108
+ it 'should allow combinations of options' do
109
+ get :with_custom_options, :format => :csv, :custom_options => { :write_headers => false, :force_quotes => true, :col_sep => '||', :row_sep => "ENDOFLINE\n" }
110
+
111
+ response.status.should == 200
112
+ response.content_type.should == 'text/csv'
113
+
114
+ expected_content =<<-CSV.gsub(/^\s+/,'')
115
+ "Fred"||"Flintstone"||"Fred Flintstone"ENDOFLINE
116
+ "Wilma"||"Flintstone"||"Wilma Flintstone"ENDOFLINE
117
+ CSV
118
+
119
+ response.body.should == expected_content
120
+ end
121
+
122
+ end
123
+
124
+ end
125
+
126
+ end
127
+ end
@@ -0,0 +1,31 @@
1
+ class Book
2
+ attr_accessor :name, :description, :isbn
3
+
4
+ def initialize(name, description, isbn)
5
+ @name, @description, @isbn = name, description, isbn
6
+ end
7
+
8
+ comma do
9
+ name 'Title'
10
+ description
11
+
12
+ isbn :authority => :issuer
13
+ isbn :number_10 => 'ISBN-10'
14
+ isbn :number_13 => 'ISBN-13'
15
+ end
16
+
17
+ comma :brief do
18
+ name
19
+ description
20
+ end
21
+ end
22
+
23
+ class Isbn
24
+ attr_accessor :number_10, :number_13
25
+
26
+ def initialize(isbn_10, isbn_13)
27
+ @number_10, @number_13 = isbn_10, isbn_13
28
+ end
29
+
30
+ def authority; 'ISBN'; end
31
+ end
@@ -0,0 +1,7 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+ require 'rake'
6
+
7
+ RailsApp::Application.load_tasks
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
@@ -0,0 +1,17 @@
1
+ class UsersController < ApplicationController
2
+ def index
3
+ respond_to do |format|
4
+ format.html { render :text => 'Users!' }
5
+ format.csv { render :csv => User.all }
6
+ end
7
+ end
8
+
9
+ def with_custom_options
10
+ render_options = {:csv => User.all}.update(params[:custom_options].symbolize_keys)
11
+
12
+ respond_to do |format|
13
+ format.csv { render render_options }
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,3 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end
@@ -0,0 +1,10 @@
1
+ class Post < ActiveRecord::Base
2
+
3
+ comma do
4
+ title
5
+ description
6
+
7
+ user :full_name
8
+ end
9
+
10
+ end
@@ -0,0 +1,16 @@
1
+ class User < ActiveRecord::Base
2
+ comma do
3
+ first_name
4
+ last_name
5
+ full_name "Name"
6
+ end
7
+
8
+ comma :brief do
9
+ first_name
10
+ last_name
11
+ end
12
+
13
+ def full_name
14
+ "#{first_name} #{last_name}".strip
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html>
4
+ <head>
5
+ <title>Comma Test App</title>
6
+ </head>
7
+ <body>
8
+ <div id="container">
9
+ <%= yield %>
10
+ </div>
11
+ </body>
12
+ </html>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run RailsApp::Application
@@ -0,0 +1,42 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ # If you have a Gemfile, require the gems listed there, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(:default, Rails.env) if defined?(Bundler)
8
+
9
+ module RailsApp
10
+ class Application < Rails::Application
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ # -- all .rb files in that directory are automatically loaded.
14
+
15
+ # Custom directories with classes and modules you want to be autoloadable.
16
+ # config.autoload_paths += %W(#{config.root}/extras)
17
+
18
+ # Only load the plugins named here, in the order given (default is alphabetical).
19
+ # :all can be used as a placeholder for all plugins not explicitly named.
20
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
21
+
22
+ # Activate observers that should always be running.
23
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
24
+
25
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
26
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
27
+ # config.time_zone = 'Central Time (US & Canada)'
28
+
29
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
30
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
31
+ # config.i18n.default_locale = :de
32
+
33
+ # JavaScript files you want as :defaults (application.js is always included).
34
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
35
+
36
+ # Configure the default encoding used in templates for Ruby 1.9.
37
+ config.encoding = "utf-8"
38
+
39
+ # Configure sensitive parameters which will be filtered from the log file.
40
+ config.filter_parameters += [:password]
41
+ end
42
+ end
@@ -0,0 +1,8 @@
1
+ unless defined?(DEVISE_ORM)
2
+ DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym
3
+ end
4
+
5
+ require 'rubygems'
6
+ require 'bundler/setup'
7
+
8
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,18 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3-ruby (not necessary on OS X Leopard)
3
+ development:
4
+ adapter: sqlite3
5
+ database: db/development.sqlite3
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as "test" will be erased and
10
+ # re-generated from your development database when you run "rake".
11
+ # Do not set this db to the same as development or production.
12
+ test:
13
+ adapter: sqlite3
14
+ database: ":memory:"
15
+
16
+ production:
17
+ adapter: sqlite3
18
+ database: ":memory:"
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ RailsApp::Application.initialize!
@@ -0,0 +1,20 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the webserver when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ config.active_support.deprecation = :log
20
+ end
@@ -0,0 +1,35 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # The production environment is meant for finished, "live" apps.
5
+ # Code is not reloaded between requests
6
+ config.cache_classes = true
7
+
8
+ # Full error reports are disabled and caching is turned on
9
+ config.consider_all_requests_local = false
10
+ config.action_controller.perform_caching = true
11
+
12
+ # See everything in the log (default is :info)
13
+ # config.log_level = :debug
14
+
15
+ # Use a different logger for distributed setups
16
+ # config.logger = SyslogLogger.new
17
+
18
+ # Use a different cache store in production
19
+ # config.cache_store = :mem_cache_store
20
+
21
+ # Disable Rails's static asset server
22
+ # In production, Apache or nginx will already do this
23
+ config.serve_static_assets = false
24
+
25
+ # Enable serving of images, stylesheets, and javascripts from an asset server
26
+ # config.action_controller.asset_host = "http://assets.example.com"
27
+
28
+ # Disable delivery errors, bad email addresses will be ignored
29
+ # config.action_mailer.raise_delivery_errors = false
30
+
31
+ # Enable threaded mode
32
+ # config.threadsafe!
33
+
34
+ config.active_support.deprecation = :log
35
+ end
@@ -0,0 +1,33 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Disable request forgery protection in test environment
18
+ config.action_controller.allow_forgery_protection = false
19
+
20
+ # Tell Action Mailer not to deliver emails to the real world.
21
+ # The :test delivery method accumulates sent emails in the
22
+ # ActionMailer::Base.deliveries array.
23
+ config.action_mailer.delivery_method = :test
24
+
25
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
26
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
27
+ # like if you have constraints or database-specific column types
28
+ # config.active_record.schema_format = :sql
29
+
30
+ config.action_dispatch.show_exceptions = false
31
+
32
+ config.active_support.deprecation = :stderr
33
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,2 @@
1
+ ActiveSupport::Inflector.inflections do |inflect|
2
+ end
@@ -0,0 +1,2 @@
1
+ Rails.application.config.secret_token = 'ea942c41850d502f2c8283e26bdc57829f471bb18224ddff0a192c4f32cdf6cb5aa0d82b3a7a7adbeb640c4b06f3aa1cd5f098162d8240f669b39d6b49680571'
2
+ Rails.application.config.session_store :cookie_store, :key => "_my_app"
@@ -0,0 +1,8 @@
1
+ Rails.application.routes.draw do
2
+ # Resources for testing
3
+ resources :users, :only => [:index]
4
+
5
+ match "with_custom_options", :to => "users#with_custom_options"
6
+
7
+ root :to => "users#index"
8
+ end
@@ -0,0 +1,24 @@
1
+
2
+ class CreateTables < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :users do |t|
5
+ t.string :first_name
6
+ t.string :last_name
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ create_table :posts do |t|
12
+ t.references :user
13
+ t.string :title
14
+ t.string :description
15
+
16
+ t.timestamps
17
+ end
18
+ end
19
+
20
+ def self.down
21
+ drop_table :posts
22
+ drop_table :users
23
+ end
24
+ end
@@ -0,0 +1,32 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended to check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(:version => 20120224085510) do
14
+
15
+ create_table "posts", :force => true do |t|
16
+ t.string "title"
17
+ t.string "description", :limit => 128
18
+ t.integer "user_id"
19
+
20
+ t.datetime "created_at"
21
+ t.datetime "updated_at"
22
+ end
23
+
24
+ create_table "users", :force => true do |t|
25
+ t.string "first_name"
26
+ t.string "last_name"
27
+
28
+ t.datetime "created_at"
29
+ t.datetime "updated_at"
30
+ end
31
+
32
+ end
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -1,44 +1,47 @@
1
1
  require 'rubygems'
2
2
  require 'rspec'
3
- require 'active_record'
3
+ require 'simplecov'
4
4
 
5
- ActiveRecord::ActiveRecordError # http://tinyurl.com/24f84gf
5
+ SimpleCov.start do
6
+ add_filter "spec"
7
+ use_merging true
8
+ merge_timeout 600
9
+ end
6
10
 
7
- $:.unshift(File.dirname(__FILE__) + '/../lib')
11
+ begin
12
+ #Conditionally load rails app for controller tests if rspec-rails gem is installed
13
+ require "rails_app/config/environment"
14
+ require 'rspec/rails'
15
+ ENV["RAILS_ENV"] = "test"
8
16
 
9
- config = YAML::load(IO.read(File.dirname(__FILE__) + '/support/database.yml'))
10
- ActiveRecord::Base.establish_connection(config['test'])
17
+ SimpleCov.command_name 'rspec:with_rails'
11
18
 
12
- require 'comma'
19
+ # Requires supporting ruby files with custom matchers and macros, etc,
20
+ # in spec/support/ and its subdirectories.
21
+ Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|file| require file }
13
22
 
14
- class Book
15
- attr_accessor :name, :description, :isbn
23
+ load_schema = lambda {
24
+ load "#{Rails.root.to_s}/db/schema.rb" # use db agnostic schema by default
25
+ # ActiveRecord::Migrator.up('db/migrate') # use migrations
26
+ }
27
+ silence_stream(STDOUT, &load_schema)
16
28
 
17
- def initialize(name, description, isbn)
18
- @name, @description, @isbn = name, description, isbn
29
+ RSpec.configure do |config|
30
+ config.use_transactional_fixtures = true
19
31
  end
20
32
 
21
- comma do
22
- name 'Title'
23
- description
33
+ rescue LoadError => e
34
+ # Normal tests : Basic active record + support only calls
35
+ SimpleCov.command_name 'rspec:without_rails'
24
36
 
25
- isbn :authority => :issuer
26
- isbn :number_10 => 'ISBN-10'
27
- isbn :number_13 => 'ISBN-13'
28
- end
37
+ require 'active_record'
29
38
 
30
- comma :brief do
31
- name
32
- description
33
- end
39
+ config = YAML::load(IO.read(File.dirname(__FILE__) + '/rails_app/config/database.yml'))
40
+ ActiveRecord::Base.establish_connection(config['test'])
34
41
  end
35
42
 
36
- class Isbn
37
- attr_accessor :number_10, :number_13
43
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
38
44
 
39
- def initialize(isbn_10, isbn_13)
40
- @number_10, @number_13 = isbn_10, isbn_13
41
- end
45
+ require 'comma'
42
46
 
43
- def authority; 'ISBN'; end
44
- end
47
+ require File.expand_path('../../spec/non_rails_app/ruby_classes' , __FILE__)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comma
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,22 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-02-19 00:00:00.000000000Z
13
+ date: 2012-02-26 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
17
- requirement: &70126322915060 !ruby/object:Gem::Requirement
17
+ requirement: &70233068053000 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
- - - =
20
+ - - ~>
21
21
  - !ruby/object:Gem::Version
22
22
  version: 0.9.2
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *70126322915060
25
+ version_requirements: *70233068053000
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: sqlite3
28
- requirement: &70126322913740 !ruby/object:Gem::Requirement
28
+ requirement: &70233068052360 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,21 @@ dependencies:
33
33
  version: 1.3.4
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *70126322913740
36
+ version_requirements: *70233068052360
37
+ - !ruby/object:Gem::Dependency
38
+ name: appraisal
39
+ requirement: &70233068051800 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 0.4.1
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *70233068051800
37
48
  - !ruby/object:Gem::Dependency
38
49
  name: rspec
39
- requirement: &70126322912840 !ruby/object:Gem::Requirement
50
+ requirement: &70233068051240 !ruby/object:Gem::Requirement
40
51
  none: false
41
52
  requirements:
42
53
  - - ~>
@@ -44,18 +55,18 @@ dependencies:
44
55
  version: 2.8.0
45
56
  type: :development
46
57
  prerelease: false
47
- version_requirements: *70126322912840
58
+ version_requirements: *70233068051240
48
59
  - !ruby/object:Gem::Dependency
49
- name: appraisal
50
- requirement: &70126322911980 !ruby/object:Gem::Requirement
60
+ name: simplecov
61
+ requirement: &70233068050740 !ruby/object:Gem::Requirement
51
62
  none: false
52
63
  requirements:
53
- - - ~>
64
+ - - ! '>='
54
65
  - !ruby/object:Gem::Version
55
- version: 0.4.1
66
+ version: '0'
56
67
  type: :development
57
68
  prerelease: false
58
- version_requirements: *70126322911980
69
+ version_requirements: *70233068050740
59
70
  description: Ruby Comma Seperated Values generation library
60
71
  email:
61
72
  - crafterm@redartisan.com
@@ -97,12 +108,41 @@ files:
97
108
  - lib/comma/object.rb
98
109
  - lib/comma/relation.rb
99
110
  - lib/comma/version.rb
100
- - spec/comma/ar_spec.rb
101
111
  - spec/comma/comma_spec.rb
102
112
  - spec/comma/extractors_spec.rb
113
+ - spec/comma/rails/active_record_spec.rb
114
+ - spec/controllers/users_controller_spec.rb
115
+ - spec/non_rails_app/ruby_classes.rb
116
+ - spec/rails_app/Rakefile
117
+ - spec/rails_app/app/controllers/application_controller.rb
118
+ - spec/rails_app/app/controllers/users_controller.rb
119
+ - spec/rails_app/app/helpers/application_helper.rb
120
+ - spec/rails_app/app/models/post.rb
121
+ - spec/rails_app/app/models/user.rb
122
+ - spec/rails_app/app/views/layouts/application.html.erb
123
+ - spec/rails_app/app/views/users/index.html.erb
124
+ - spec/rails_app/config.ru
125
+ - spec/rails_app/config/application.rb
126
+ - spec/rails_app/config/boot.rb
127
+ - spec/rails_app/config/database.yml
128
+ - spec/rails_app/config/environment.rb
129
+ - spec/rails_app/config/environments/development.rb
130
+ - spec/rails_app/config/environments/production.rb
131
+ - spec/rails_app/config/environments/test.rb
132
+ - spec/rails_app/config/initializers/backtrace_silencers.rb
133
+ - spec/rails_app/config/initializers/inflections.rb
134
+ - spec/rails_app/config/initializers/secret_token.rb
135
+ - spec/rails_app/config/routes.rb
136
+ - spec/rails_app/db/development.sqlite3
137
+ - spec/rails_app/db/migrate/20120224085510_create_tables.rb
138
+ - spec/rails_app/db/schema.rb
139
+ - spec/rails_app/public/404.html
140
+ - spec/rails_app/public/422.html
141
+ - spec/rails_app/public/500.html
142
+ - spec/rails_app/public/favicon.ico
143
+ - spec/rails_app/script/rails
103
144
  - spec/spec.opts
104
145
  - spec/spec_helper.rb
105
- - spec/support/database.yml
106
146
  homepage: http://github.com/crafterm/comma
107
147
  licenses: []
108
148
  post_install_message:
@@ -117,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
157
  version: '0'
118
158
  segments:
119
159
  - 0
120
- hash: 4325782371584984549
160
+ hash: -3572797252536909493
121
161
  required_rubygems_version: !ruby/object:Gem::Requirement
122
162
  none: false
123
163
  requirements:
@@ -126,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
166
  version: '0'
127
167
  segments:
128
168
  - 0
129
- hash: 4325782371584984549
169
+ hash: -3572797252536909493
130
170
  requirements: []
131
171
  rubyforge_project: comma
132
172
  rubygems_version: 1.8.10
@@ -134,9 +174,38 @@ signing_key:
134
174
  specification_version: 3
135
175
  summary: Ruby Comma Seperated Values generation library
136
176
  test_files:
137
- - spec/comma/ar_spec.rb
138
177
  - spec/comma/comma_spec.rb
139
178
  - spec/comma/extractors_spec.rb
179
+ - spec/comma/rails/active_record_spec.rb
180
+ - spec/controllers/users_controller_spec.rb
181
+ - spec/non_rails_app/ruby_classes.rb
182
+ - spec/rails_app/Rakefile
183
+ - spec/rails_app/app/controllers/application_controller.rb
184
+ - spec/rails_app/app/controllers/users_controller.rb
185
+ - spec/rails_app/app/helpers/application_helper.rb
186
+ - spec/rails_app/app/models/post.rb
187
+ - spec/rails_app/app/models/user.rb
188
+ - spec/rails_app/app/views/layouts/application.html.erb
189
+ - spec/rails_app/app/views/users/index.html.erb
190
+ - spec/rails_app/config.ru
191
+ - spec/rails_app/config/application.rb
192
+ - spec/rails_app/config/boot.rb
193
+ - spec/rails_app/config/database.yml
194
+ - spec/rails_app/config/environment.rb
195
+ - spec/rails_app/config/environments/development.rb
196
+ - spec/rails_app/config/environments/production.rb
197
+ - spec/rails_app/config/environments/test.rb
198
+ - spec/rails_app/config/initializers/backtrace_silencers.rb
199
+ - spec/rails_app/config/initializers/inflections.rb
200
+ - spec/rails_app/config/initializers/secret_token.rb
201
+ - spec/rails_app/config/routes.rb
202
+ - spec/rails_app/db/development.sqlite3
203
+ - spec/rails_app/db/migrate/20120224085510_create_tables.rb
204
+ - spec/rails_app/db/schema.rb
205
+ - spec/rails_app/public/404.html
206
+ - spec/rails_app/public/422.html
207
+ - spec/rails_app/public/500.html
208
+ - spec/rails_app/public/favicon.ico
209
+ - spec/rails_app/script/rails
140
210
  - spec/spec.opts
141
211
  - spec/spec_helper.rb
142
- - spec/support/database.yml
@@ -1,4 +0,0 @@
1
- test:
2
- adapter: sqlite3
3
- database: ":memory:"
4
-