acts_as_exportable 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.DS_Store +0 -0
- data/.document +5 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +20 -0
- data/MIT-LICENSE +20 -0
- data/README.md +43 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/acts_as_exportable.gemspec +84 -0
- data/app/.DS_Store +0 -0
- data/app/controllers/.DS_Store +0 -0
- data/app/controllers/acts_as_exportable/export_controller.rb +14 -0
- data/app/views/.DS_Store +0 -0
- data/app/views/acts_as_exportable/export/index.html.erb +8 -0
- data/config/routes.rb +11 -0
- data/lib/acts_as_exportable/exporter.rb +57 -0
- data/lib/acts_as_exportable/view_helper.rb +27 -0
- data/lib/acts_as_exportable.rb +12 -0
- data/lib/engine.rb +30 -0
- data/lib/rails/generators/cheese/cheese_generator.rb +75 -0
- data/lib/rails/generators/cheese/templates/initializer.rb +8 -0
- data/lib/rails/generators/cheese/templates/migration.rb +9 -0
- data/lib/rails/generators/cheese/templates/schema.rb +11 -0
- data/lib/rails/railties/tasks.rake +8 -0
- data/rails/init.rb +4 -0
- data/tasks/acts_as_exportable_tasks.rake +8 -0
- data/test/acts_as_exportable_test.rb +8 -0
- data/test/helper.rb +18 -0
- data/test/test_acts_as_exportable.rb +7 -0
- data/test/test_helper.rb +3 -0
- metadata +152 -0
data/.DS_Store
ADDED
Binary file
|
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
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
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.5.2"
|
12
|
+
gem "rcov", ">= 0"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.5.2)
|
6
|
+
bundler (~> 1.0.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
rake (0.9.2)
|
10
|
+
rcov (0.9.9)
|
11
|
+
shoulda (2.11.3)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
ruby
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
bundler (~> 1.0.0)
|
18
|
+
jeweler (~> 1.5.2)
|
19
|
+
rcov
|
20
|
+
shoulda
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 [name of plugin creator]
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
ActsAsExportable
|
2
|
+
================
|
3
|
+
|
4
|
+
Rails 2.3 plugin that exports ActiveRecord table data into a csv.
|
5
|
+
|
6
|
+
Important:
|
7
|
+
|
8
|
+
Rails 2.3 only
|
9
|
+
Requires the FasterCsv gem
|
10
|
+
|
11
|
+
Install
|
12
|
+
=======
|
13
|
+
|
14
|
+
script/plugin install git://github.com/rossnelson/acts_as_exportable.git
|
15
|
+
|
16
|
+
Example
|
17
|
+
=======
|
18
|
+
|
19
|
+
To get started, just specify an ActiveRecord class as `acts_as_exportable`
|
20
|
+
This will add all the Object's attributes to the CSV
|
21
|
+
|
22
|
+
class Contact < ActiveRecord::Base
|
23
|
+
acts_as_exportable
|
24
|
+
end
|
25
|
+
|
26
|
+
You can also specify the attributes to be included
|
27
|
+
|
28
|
+
class Contact < ActiveRecord::Base
|
29
|
+
acts_as_exportable :name, :email, :comment
|
30
|
+
end
|
31
|
+
|
32
|
+
At this point the class will be given the "build_csv" class method.
|
33
|
+
|
34
|
+
Contact.build_csv
|
35
|
+
|
36
|
+
As a convenience a view helper has also been provided.
|
37
|
+
|
38
|
+
link_to_export("Link Text", "ClassName", :html_options => {})
|
39
|
+
|
40
|
+
This will return a link for downloading the CSV
|
41
|
+
|
42
|
+
|
43
|
+
Copyright (c) 2011 Ross Nelson, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "acts_as_exportable"
|
16
|
+
gem.homepage = "http://github.com/rossnelson/acts_as_exportable"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Export ActiveRecord Data to csv}
|
19
|
+
gem.description = %Q{Export ActiveRecord data as a csv.}
|
20
|
+
gem.email = "axcess1@me.com"
|
21
|
+
gem.authors = ["rossnelson"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
Rake::TestTask.new(:test) do |test|
|
31
|
+
test.libs << 'lib' << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'rcov/rcovtask'
|
37
|
+
Rcov::RcovTask.new do |test|
|
38
|
+
test.libs << 'test'
|
39
|
+
test.pattern = 'test/**/test_*.rb'
|
40
|
+
test.verbose = true
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "acts_as_exportable #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
@@ -0,0 +1,84 @@
|
|
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{acts_as_exportable}
|
8
|
+
s.version = "0.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["rossnelson"]
|
12
|
+
s.date = %q{2011-08-06}
|
13
|
+
s.description = %q{Export ActiveRecord data as a csv.}
|
14
|
+
s.email = %q{axcess1@me.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".DS_Store",
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"MIT-LICENSE",
|
24
|
+
"README.md",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"acts_as_exportable.gemspec",
|
28
|
+
"app/.DS_Store",
|
29
|
+
"app/controllers/.DS_Store",
|
30
|
+
"app/controllers/acts_as_exportable/export_controller.rb",
|
31
|
+
"app/views/.DS_Store",
|
32
|
+
"app/views/acts_as_exportable/export/index.html.erb",
|
33
|
+
"config/routes.rb",
|
34
|
+
"lib/acts_as_exportable.rb",
|
35
|
+
"lib/acts_as_exportable/exporter.rb",
|
36
|
+
"lib/acts_as_exportable/view_helper.rb",
|
37
|
+
"lib/engine.rb",
|
38
|
+
"lib/rails/generators/cheese/cheese_generator.rb",
|
39
|
+
"lib/rails/generators/cheese/templates/initializer.rb",
|
40
|
+
"lib/rails/generators/cheese/templates/migration.rb",
|
41
|
+
"lib/rails/generators/cheese/templates/schema.rb",
|
42
|
+
"lib/rails/railties/tasks.rake",
|
43
|
+
"rails/init.rb",
|
44
|
+
"tasks/acts_as_exportable_tasks.rake",
|
45
|
+
"test/acts_as_exportable_test.rb",
|
46
|
+
"test/helper.rb",
|
47
|
+
"test/test_acts_as_exportable.rb",
|
48
|
+
"test/test_helper.rb"
|
49
|
+
]
|
50
|
+
s.homepage = %q{http://github.com/rossnelson/acts_as_exportable}
|
51
|
+
s.licenses = ["MIT"]
|
52
|
+
s.require_paths = ["lib"]
|
53
|
+
s.rubygems_version = %q{1.3.7}
|
54
|
+
s.summary = %q{Export ActiveRecord Data to csv}
|
55
|
+
s.test_files = [
|
56
|
+
"test/acts_as_exportable_test.rb",
|
57
|
+
"test/helper.rb",
|
58
|
+
"test/test_acts_as_exportable.rb",
|
59
|
+
"test/test_helper.rb"
|
60
|
+
]
|
61
|
+
|
62
|
+
if s.respond_to? :specification_version then
|
63
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
64
|
+
s.specification_version = 3
|
65
|
+
|
66
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
67
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
68
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
69
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
70
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
71
|
+
else
|
72
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
73
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
74
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
75
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
76
|
+
end
|
77
|
+
else
|
78
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
79
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
80
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
81
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
data/app/.DS_Store
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module ActsAsExportable
|
2
|
+
class ExportController < ApplicationController
|
3
|
+
|
4
|
+
def index
|
5
|
+
@metaclass = params[:class_name].constantize
|
6
|
+
@csv_string = @metaclass.build_csv
|
7
|
+
send_data(@csv_string,
|
8
|
+
:type => 'text/csv; charset=utf-8; header=present',
|
9
|
+
:filename => "All#{params[:class_name].pluralize}#{Date.today}.csv"
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
data/app/views/.DS_Store
ADDED
Binary file
|
data/config/routes.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Rails.application.routes.draw do |map|
|
2
|
+
|
3
|
+
mount_at = ActsAsExportable::Engine.config.mount_at
|
4
|
+
|
5
|
+
match mount_at => 'acts_as_exportable/export#index'
|
6
|
+
|
7
|
+
map.resources :export, :only => [ :index ],
|
8
|
+
:controller => "acts_as_exportable/export",
|
9
|
+
:path_prefix => mount_at
|
10
|
+
|
11
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module ActsAsExportable
|
2
|
+
module Exporter
|
3
|
+
def self.included(base) # :nodoc:
|
4
|
+
base.extend ClassMethods
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
##
|
9
|
+
# Make a model a exportable. This allows a Class to export all its
|
10
|
+
# data.
|
11
|
+
#
|
12
|
+
# Example:
|
13
|
+
# class Contact < ActiveRecord::Base
|
14
|
+
# acts_as_exportable
|
15
|
+
# end
|
16
|
+
def acts_as_exportable(*args)
|
17
|
+
|
18
|
+
cattr_accessor :csv_library
|
19
|
+
|
20
|
+
if RUBY_VERSION >= "1.9"
|
21
|
+
self.csv_library = CSV
|
22
|
+
else
|
23
|
+
self.csv_library = FasterCSV
|
24
|
+
end
|
25
|
+
|
26
|
+
cattr_accessor :exported_attrs
|
27
|
+
self.exported_attrs = args
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# Find all the records and build a CSV string
|
32
|
+
#
|
33
|
+
# Contact.build_csv
|
34
|
+
def build_csv
|
35
|
+
list = self.all(:order => "created_at DESC")
|
36
|
+
csv_string = csv_library.generate do |csv|
|
37
|
+
csv << included_columns
|
38
|
+
list.each do |item|
|
39
|
+
csv << included_columns.map{ |a| item[a.to_sym]}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Determine whether to include all attributes or just those
|
46
|
+
# specified.
|
47
|
+
#
|
48
|
+
def included_columns
|
49
|
+
if exported_attrs.blank?
|
50
|
+
self.column_names
|
51
|
+
else
|
52
|
+
exported_attrs
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ActsAsExportable
|
2
|
+
module ViewHelper
|
3
|
+
include ActionDispatch::Routing::UrlFor
|
4
|
+
include ActionView::Helpers::TagHelper
|
5
|
+
|
6
|
+
##
|
7
|
+
# Download csv Link
|
8
|
+
#
|
9
|
+
# Link_to_export "Link Text", "Contact", :id => "contact-button"
|
10
|
+
# <a href="export/index?class_name=Contact" id="contact-button">Link Text</a>
|
11
|
+
#
|
12
|
+
def link_to_export(*args)
|
13
|
+
name = args[0]
|
14
|
+
class_name = args[1]
|
15
|
+
options = args[1] || {}
|
16
|
+
html_options = args[2]
|
17
|
+
url = "export?class_name=#{class_name}"
|
18
|
+
|
19
|
+
html_options = convert_options_to_data_attributes(options, html_options)
|
20
|
+
tag_options = tag_options(html_options)
|
21
|
+
|
22
|
+
href_attr = "href=\"#{url}\""
|
23
|
+
|
24
|
+
"<a #{href_attr}#{tag_options}>#{html_escape(name || url)}</a>".html_safe
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'acts_as_exportable/exporter'
|
2
|
+
require 'acts_as_exportable/view_helper'
|
3
|
+
require 'csv' if RUBY_VERSION >= "1.9"
|
4
|
+
require 'engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
|
5
|
+
|
6
|
+
if defined?(ActiveRecord::Base)
|
7
|
+
ActiveRecord::Base.send :include, ActsAsExportable::Exporter
|
8
|
+
end
|
9
|
+
|
10
|
+
if defined?(ActionView::Base)
|
11
|
+
ActionView::Base.send :include, ActsAsExportable::ViewHelper
|
12
|
+
end
|
data/lib/engine.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'acts_as_exportable'
|
2
|
+
require 'rails'
|
3
|
+
# require 'action_controller'
|
4
|
+
|
5
|
+
|
6
|
+
module ActsAsExportable
|
7
|
+
class Engine < Rails::Engine
|
8
|
+
|
9
|
+
# Config defaults
|
10
|
+
config.widget_factory_name = "default factory name"
|
11
|
+
config.mount_at = '/'
|
12
|
+
|
13
|
+
# Load rake tasks
|
14
|
+
rake_tasks do
|
15
|
+
load File.join(File.dirname(__FILE__), 'rails/railties/tasks.rake')
|
16
|
+
end
|
17
|
+
|
18
|
+
# Check the gem config
|
19
|
+
initializer "check config" do |app|
|
20
|
+
|
21
|
+
# make sure mount_at ends with trailing slash
|
22
|
+
config.mount_at += '/' unless config.mount_at.last == '/'
|
23
|
+
end
|
24
|
+
|
25
|
+
initializer "static assets" do |app|
|
26
|
+
app.middleware.use ::ActionDispatch::Static, "#{root}/public"
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
class CheeseGenerator < Rails::Generators::Base
|
5
|
+
include Rails::Generators::Migration
|
6
|
+
|
7
|
+
def self.source_root
|
8
|
+
File.join(File.dirname(__FILE__), 'templates')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.next_migration_number(dirname) #:nodoc:
|
12
|
+
if ActiveRecord::Base.timestamped_migrations
|
13
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
14
|
+
else
|
15
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# Every method that is declared below will be automatically executed when the generator is run
|
21
|
+
|
22
|
+
def create_migration_file
|
23
|
+
f = File.open File.join(File.dirname(__FILE__), 'templates', 'schema.rb')
|
24
|
+
schema = f.read; f.close
|
25
|
+
|
26
|
+
schema.gsub!(/ActiveRecord::Schema.*\n/, '')
|
27
|
+
schema.gsub!(/^end\n*$/, '')
|
28
|
+
|
29
|
+
f = File.open File.join(File.dirname(__FILE__), 'templates', 'migration.rb')
|
30
|
+
migration = f.read; f.close
|
31
|
+
migration.gsub!(/SCHEMA_AUTO_INSERTED_HERE/, schema)
|
32
|
+
|
33
|
+
tmp = File.open "tmp/~migration_ready.rb", "w"
|
34
|
+
tmp.write migration
|
35
|
+
tmp.close
|
36
|
+
|
37
|
+
migration_template '../../../tmp/~migration_ready.rb',
|
38
|
+
'db/migrate/create_cheese_tables.rb'
|
39
|
+
remove_file 'tmp/~migration_ready.rb'
|
40
|
+
end
|
41
|
+
|
42
|
+
def copy_initializer_file
|
43
|
+
copy_file 'initializer.rb', 'config/initializers/cheese.rb'
|
44
|
+
end
|
45
|
+
|
46
|
+
def update_application_template
|
47
|
+
f = File.open "app/views/layouts/application.html.erb"
|
48
|
+
layout = f.read; f.close
|
49
|
+
|
50
|
+
if layout =~ /<%=[ ]+yield[ ]+%>/
|
51
|
+
print " \e[1m\e[34mquestion\e[0m Your layouts/application.html.erb layout currently has the line <%= yield %>. This gem needs to change this line to <%= content_for?(:content) ? yield(:content) : yield %> to support its nested layouts. This change should not affect any of your existing layouts or views. Is this okay? [y/n] "
|
52
|
+
begin
|
53
|
+
answer = gets.chomp
|
54
|
+
end while not answer =~ /[yn]/i
|
55
|
+
|
56
|
+
if answer =~ /y/i
|
57
|
+
|
58
|
+
layout.gsub!(/<%=[ ]+yield[ ]+%>/, '<%= content_for?(:content) ? yield(:content) : yield %>')
|
59
|
+
|
60
|
+
tmp = File.open "tmp/~application.html.erb", "w"
|
61
|
+
tmp.write layout; tmp.close
|
62
|
+
|
63
|
+
remove_file 'app/views/layouts/application.html.erb'
|
64
|
+
copy_file '../../../tmp/~application.html.erb',
|
65
|
+
'app/views/layouts/application.html.erb'
|
66
|
+
remove_file 'tmp/~application.html.erb'
|
67
|
+
end
|
68
|
+
elsif layout =~ /<%=[ ]+content_for\?\(:content\) \? yield\(:content\) : yield[ ]+%>/
|
69
|
+
puts " \e[1m\e[33mskipping\e[0m layouts/application.html.erb modification is already done."
|
70
|
+
else
|
71
|
+
puts " \e[1m\e[31mconflict\e[0m The gem is confused by your layouts/application.html.erb. It does not contain the default line <%= yield %>, you may need to make manual changes to get this gem's nested layouts working. Visit ###### for details."
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
data/rails/init.rb
ADDED
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'acts_as_exportable'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: acts_as_exportable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 0.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- rossnelson
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-08-06 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: shoulda
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
prerelease: false
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 1
|
42
|
+
- 0
|
43
|
+
- 0
|
44
|
+
version: 1.0.0
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: jeweler
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 1
|
57
|
+
- 5
|
58
|
+
- 2
|
59
|
+
version: 1.5.2
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rcov
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
type: :development
|
74
|
+
prerelease: false
|
75
|
+
version_requirements: *id004
|
76
|
+
description: Export ActiveRecord data as a csv.
|
77
|
+
email: axcess1@me.com
|
78
|
+
executables: []
|
79
|
+
|
80
|
+
extensions: []
|
81
|
+
|
82
|
+
extra_rdoc_files:
|
83
|
+
- README.md
|
84
|
+
files:
|
85
|
+
- .DS_Store
|
86
|
+
- .document
|
87
|
+
- Gemfile
|
88
|
+
- Gemfile.lock
|
89
|
+
- MIT-LICENSE
|
90
|
+
- README.md
|
91
|
+
- Rakefile
|
92
|
+
- VERSION
|
93
|
+
- acts_as_exportable.gemspec
|
94
|
+
- app/.DS_Store
|
95
|
+
- app/controllers/.DS_Store
|
96
|
+
- app/controllers/acts_as_exportable/export_controller.rb
|
97
|
+
- app/views/.DS_Store
|
98
|
+
- app/views/acts_as_exportable/export/index.html.erb
|
99
|
+
- config/routes.rb
|
100
|
+
- lib/acts_as_exportable.rb
|
101
|
+
- lib/acts_as_exportable/exporter.rb
|
102
|
+
- lib/acts_as_exportable/view_helper.rb
|
103
|
+
- lib/engine.rb
|
104
|
+
- lib/rails/generators/cheese/cheese_generator.rb
|
105
|
+
- lib/rails/generators/cheese/templates/initializer.rb
|
106
|
+
- lib/rails/generators/cheese/templates/migration.rb
|
107
|
+
- lib/rails/generators/cheese/templates/schema.rb
|
108
|
+
- lib/rails/railties/tasks.rake
|
109
|
+
- rails/init.rb
|
110
|
+
- tasks/acts_as_exportable_tasks.rake
|
111
|
+
- test/acts_as_exportable_test.rb
|
112
|
+
- test/helper.rb
|
113
|
+
- test/test_acts_as_exportable.rb
|
114
|
+
- test/test_helper.rb
|
115
|
+
has_rdoc: true
|
116
|
+
homepage: http://github.com/rossnelson/acts_as_exportable
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
hash: 1512869050250062956
|
130
|
+
segments:
|
131
|
+
- 0
|
132
|
+
version: "0"
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
none: false
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
segments:
|
139
|
+
- 0
|
140
|
+
version: "0"
|
141
|
+
requirements: []
|
142
|
+
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 1.3.7
|
145
|
+
signing_key:
|
146
|
+
specification_version: 3
|
147
|
+
summary: Export ActiveRecord Data to csv
|
148
|
+
test_files:
|
149
|
+
- test/acts_as_exportable_test.rb
|
150
|
+
- test/helper.rb
|
151
|
+
- test/test_acts_as_exportable.rb
|
152
|
+
- test/test_helper.rb
|