blythedunham-ar_dumper 1.2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +77 -0
  3. data/Rakefile +76 -0
  4. data/db/migrate/generic_schema.rb +31 -0
  5. data/init.rb +3 -0
  6. data/lib/ar_dumper.rb +5 -0
  7. data/lib/ar_dumper_active_record.rb +31 -0
  8. data/lib/ar_dumper_base.rb +505 -0
  9. data/lib/ar_dumper_controller.rb +52 -0
  10. data/lib/xml_serializer_dumper_support.rb +49 -0
  11. data/test/ar_dumper_controller_test.rb +10 -0
  12. data/test/ar_dumper_test.rb +101 -0
  13. data/test/data/expected_results/all_books.csv +10 -0
  14. data/test/data/expected_results/all_books.xml +93 -0
  15. data/test/data/expected_results/all_books.yml +90 -0
  16. data/test/data/expected_results/except_title_and_author.csv +10 -0
  17. data/test/data/expected_results/except_title_and_author.xml +75 -0
  18. data/test/data/expected_results/except_title_and_author.yml +72 -0
  19. data/test/data/expected_results/only_title_and_author.csv +10 -0
  20. data/test/data/expected_results/only_title_and_author.xml +39 -0
  21. data/test/data/expected_results/only_title_and_author.yml +36 -0
  22. data/test/data/expected_results/proc.csv +3 -0
  23. data/test/data/expected_results/proc.xml +11 -0
  24. data/test/data/expected_results/proc.yml +8 -0
  25. data/test/data/expected_results/second_book.csv +2 -0
  26. data/test/data/expected_results/second_book.xml +13 -0
  27. data/test/data/expected_results/second_book.yml +10 -0
  28. data/test/data/expected_results/topic_name.csv +10 -0
  29. data/test/data/expected_results/topic_name.xml +48 -0
  30. data/test/data/expected_results/topic_name.yml +45 -0
  31. data/test/fixtures/books.yml +65 -0
  32. data/test/fixtures/topics.yml +5 -0
  33. data/test/models/book.rb +8 -0
  34. data/test/models/topic.rb +13 -0
  35. data/test/run.rb +38 -0
  36. data/test/test_helper.rb +60 -0
  37. metadata +96 -0
@@ -0,0 +1,60 @@
1
+
2
+ dir = File.dirname(__FILE__)
3
+ require dir + '/run'
4
+ require dir +'/../init'
5
+
6
+ result_dir = File.join(dir, 'data', 'results')
7
+ FileUtils.mkdir_p(result_dir)
8
+ ArDumper.dumper_file_path = result_dir
9
+
10
+ puts "Using Rails version: #{ActiveRecord::VERSION::STRING}"
11
+
12
+ if ActiveRecord::VERSION::STRING < '2.3.1'
13
+
14
+ TestCaseSuperClass = Test::Unit::TestCase
15
+ class Test::Unit::TestCase #:nodoc:
16
+ self.use_transactional_fixtures = true
17
+ self.use_instantiated_fixtures = false
18
+
19
+ def assert_queries(num = 1)
20
+ $queries_executed = []
21
+ yield
22
+ ensure
23
+ %w{ BEGIN COMMIT }.each { |x| $queries_executed.delete(x) }
24
+ assert_equal num, $queries_executed.size, "#{$queries_executed.size} instead of #{num} queries were executed.#{$queries_executed.size == 0 ? '' : "\nQueries:\n#{$queries_executed.join("\n")}"}"
25
+ end
26
+
27
+ end
28
+
29
+ Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
30
+ else
31
+
32
+
33
+
34
+ TestCaseSuperClass = ActiveRecord::TestCase
35
+ require 'active_record/test_case'
36
+ class ActiveRecord::TestCase #:nodoc:
37
+ include ActiveRecord::TestFixtures
38
+ self.use_transactional_fixtures = true
39
+ self.use_instantiated_fixtures = false
40
+ self.fixtures :all
41
+ end
42
+ ActiveRecord::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
43
+ end
44
+
45
+ #ActiveRecord::Base.connection.class.class_eval do
46
+ # IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /SHOW FIELDS/]
47
+
48
+ # def execute_with_query_record(sql, name = nil, &block)
49
+ # $queries_executed ||= []
50
+ # $queries_executed << sql unless IGNORED_SQL.any? { |r| sql =~ r }
51
+ # execute_without_query_record(sql, name, &block)
52
+ # end
53
+
54
+ # alias_method_chain :execute, :query_record
55
+ #end
56
+
57
+ class TestCaseSuperClass
58
+ def logger; ActiveRecord::Base.logger; end
59
+ def self.logger; ActiveRecord::Base.logger; end
60
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blythedunham-ar_dumper
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Blythe Dunham
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-10 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: blythe@snowgiraffe.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ files:
25
+ - README.rdoc
26
+ - LICENSE
27
+ - Rakefile
28
+ - init.rb
29
+ - db/migrate
30
+ - db/migrate/generic_schema.rb
31
+ - lib/ar_dumper.rb
32
+ - lib/ar_dumper_active_record.rb
33
+ - lib/ar_dumper_base.rb
34
+ - lib/ar_dumper_controller.rb
35
+ - lib/xml_serializer_dumper_support.rb
36
+ - test/ar_dumper_controller_test.rb
37
+ - test/ar_dumper_test.rb
38
+ - test/data
39
+ - test/data/expected_results
40
+ - test/data/expected_results/all_books.csv
41
+ - test/data/expected_results/all_books.xml
42
+ - test/data/expected_results/all_books.yml
43
+ - test/data/expected_results/except_title_and_author.csv
44
+ - test/data/expected_results/except_title_and_author.xml
45
+ - test/data/expected_results/except_title_and_author.yml
46
+ - test/data/expected_results/only_title_and_author.csv
47
+ - test/data/expected_results/only_title_and_author.xml
48
+ - test/data/expected_results/only_title_and_author.yml
49
+ - test/data/expected_results/proc.csv
50
+ - test/data/expected_results/proc.xml
51
+ - test/data/expected_results/proc.yml
52
+ - test/data/expected_results/second_book.csv
53
+ - test/data/expected_results/second_book.xml
54
+ - test/data/expected_results/second_book.yml
55
+ - test/data/expected_results/topic_name.csv
56
+ - test/data/expected_results/topic_name.xml
57
+ - test/data/expected_results/topic_name.yml
58
+ - test/fixtures
59
+ - test/fixtures/books.yml
60
+ - test/fixtures/topics.yml
61
+ - test/models
62
+ - test/models/book.rb
63
+ - test/models/topic.rb
64
+ - test/run.rb
65
+ - test/test_helper.rb
66
+ has_rdoc: false
67
+ homepage: http://github.com/blythedunham/ar_dumper
68
+ licenses:
69
+ post_install_message:
70
+ rdoc_options:
71
+ - --line-numbers
72
+ - --inline-source
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ version:
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: "0"
86
+ version:
87
+ requirements: []
88
+
89
+ rubyforge_project: ar_dumper
90
+ rubygems_version: 1.3.5
91
+ signing_key:
92
+ specification_version: 3
93
+ summary: Extends ActiveRecord to export volume records to a file, string, or temp file in csv, yaml, or xml formats
94
+ test_files:
95
+ - test/ar_dumper_controller_test.rb
96
+ - test/ar_dumper_test.rb