workbook_rails 0.1.1 → 0.2.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.
- checksums.yaml +5 -5
- data/Gemfile +11 -7
- data/Gemfile.lock +206 -168
- data/README.md +24 -30
- data/Rakefile +5 -2
- data/lib/workbook_rails/action_controller.rb +5 -8
- data/lib/workbook_rails/engine.rb +8 -8
- data/lib/workbook_rails/template_handler.rb +5 -4
- data/lib/workbook_rails/version.rb +1 -1
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/controllers/home_controller.rb +0 -4
- data/spec/dummy/app/controllers/users_controller.rb +1 -1
- data/spec/dummy/app/mailers/notifier.rb +2 -2
- data/spec/dummy/config/routes.rb +0 -1
- data/spec/dummy/db/migrate/20120717192452_create_users.rb +1 -1
- data/spec/dummy/db/migrate/20121206210955_create_likes.rb +1 -1
- data/spec/dummy/db/schema.rb +19 -21
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +24 -0
- data/spec/dummy/log/test.log +15872 -7276
- data/spec/spec_helper.rb +9 -2
- data/spec/template_handler_spec.rb +2 -2
- data/spec/{test_3.2.sh → test_6.0.sh} +1 -1
- data/spec/{test_4.0.sh → test_7.0.sh} +1 -1
- data/spec/{test_4.1.sh → test_7.1.sh} +1 -1
- data/spec/workbook_mailer_spec.rb +1 -1
- data/spec/workbook_renderer_spec.rb +16 -10
- data/spec/workbook_request_spec.rb +35 -45
- metadata +31 -140
- /data/spec/{test_4.2.sh → test_6.1.sh} +0 -0
@@ -12,14 +12,14 @@ module WorkbookRails
|
|
12
12
|
initializer 'workbook_rails.action_controller' do
|
13
13
|
ActiveSupport.on_load :action_controller do
|
14
14
|
require 'workbook_rails/action_controller'
|
15
|
-
end
|
16
|
-
end
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
unless Mime[:xlsx]
|
17
|
+
Mime::Type.register "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", :xlsx
|
18
|
+
end
|
19
|
+
unless Mime[:xls]
|
20
|
+
Mime::Type.register "application/vnd.ms-excel", :xls
|
21
|
+
end
|
22
|
+
end
|
23
23
|
end
|
24
24
|
end
|
25
|
-
end
|
25
|
+
end
|
@@ -9,15 +9,16 @@ module WorkbookRails
|
|
9
9
|
when :xlsx then workbook.stream_xlsx
|
10
10
|
when :xls then
|
11
11
|
io = StringIO.new
|
12
|
-
workbook.
|
12
|
+
xls = workbook.is_a?(Spreadsheet::Workbook) ? workbook : workbook.to_xls
|
13
|
+
xls.write(io)
|
13
14
|
io.string
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
17
|
-
def self.call(template)
|
18
|
+
def self.call(template, source = nil)
|
18
19
|
"workbook = Workbook::Book.new;\n" +
|
19
|
-
|
20
|
-
|
20
|
+
(source || template.source) +
|
21
|
+
";\nWorkbookRails::TemplateHandler.workbook_to_string(workbook, lookup_context.formats.last);"
|
21
22
|
end
|
22
23
|
|
23
24
|
end
|
@@ -6,9 +6,9 @@ class Notifier < ActionMailer::Base
|
|
6
6
|
|
7
7
|
# normal syntax
|
8
8
|
xlsx = render_to_string handlers: [:wb], template: 'users/mailers/instructions', layout: false, formats: [:xlsx]
|
9
|
-
attachments["user_#{user.id}.xlsx"] = {mime_type: Mime
|
9
|
+
attachments["user_#{user.id}.xlsx"] = {mime_type: Mime[:xlsx], content: xlsx}
|
10
10
|
|
11
11
|
mail :to => user.email, :subject => 'Instructions'
|
12
12
|
end
|
13
13
|
|
14
|
-
end
|
14
|
+
end
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -12,6 +12,5 @@ Rails.application.routes.draw do
|
|
12
12
|
get "/withpartial(.:format)", :to => "home#withpartial", :as => :withpartial
|
13
13
|
get "/home/render_elsewhere(.:format)", :to => "home#render_elsewhere"
|
14
14
|
get "/render_elsewhere(.:format)", :to => "home#render_elsewhere"
|
15
|
-
get "/render_file_path(.:format)", :to => "home#render_file_path"
|
16
15
|
root to: "home#index"
|
17
16
|
end
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -1,32 +1,30 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# This file is auto-generated from the current state of the database. Instead
|
3
2
|
# of editing this file, please use the migrations feature of Active Record to
|
4
3
|
# incrementally modify your database, and then regenerate this schema definition.
|
5
4
|
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# from scratch.
|
10
|
-
#
|
5
|
+
# This file is the source Rails uses to define your schema when running `bin/rails
|
6
|
+
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
7
|
+
# be faster and is potentially less error prone than running all of your
|
8
|
+
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
+
# migrations use external dependencies or application code.
|
11
10
|
#
|
12
|
-
# It's strongly recommended
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
13
12
|
|
14
|
-
ActiveRecord::Schema.define(:
|
15
|
-
|
16
|
-
|
17
|
-
t.
|
18
|
-
t.
|
19
|
-
t.datetime "
|
20
|
-
t.datetime "updated_at"
|
13
|
+
ActiveRecord::Schema[7.0].define(version: 2012_12_06_210955) do
|
14
|
+
create_table "likes", force: :cascade do |t|
|
15
|
+
t.string "name"
|
16
|
+
t.integer "user_id"
|
17
|
+
t.datetime "created_at", precision: nil
|
18
|
+
t.datetime "updated_at", precision: nil
|
21
19
|
end
|
22
20
|
|
23
|
-
create_table "users", :
|
24
|
-
t.string
|
25
|
-
t.string
|
26
|
-
t.string
|
27
|
-
t.string
|
28
|
-
t.datetime "created_at"
|
29
|
-
t.datetime "updated_at"
|
21
|
+
create_table "users", force: :cascade do |t|
|
22
|
+
t.string "name"
|
23
|
+
t.string "last_name"
|
24
|
+
t.string "address"
|
25
|
+
t.string "email"
|
26
|
+
t.datetime "created_at", precision: nil
|
27
|
+
t.datetime "updated_at", precision: nil
|
30
28
|
end
|
31
29
|
|
32
30
|
end
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -0,0 +1,24 @@
|
|
1
|
+
[1m[35m (13.0ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)[0m
|
2
|
+
[1m[35m (10.5ms)[0m [1m[35mCREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)[0m
|
3
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.4ms)[0m [1m[34mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
4
|
+
Migrating to CreateUsers (20120717192452)
|
5
|
+
[1m[35m (0.1ms)[0m [1m[36mbegin transaction[0m
|
6
|
+
DEPRECATION WARNING: Directly inheriting from ActiveRecord::Migration is deprecated. Please specify the Rails release the migration was written for:
|
7
|
+
|
8
|
+
class CreateUsers < ActiveRecord::Migration[4.2] (called from load at /home/sergio/.rvm/gems/ruby-2.3.1/bin/rake:23)
|
9
|
+
[1m[35m (0.4ms)[0m [1m[35mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "last_name" varchar, "address" varchar, "email" varchar, "created_at" datetime, "updated_at" datetime)[0m
|
10
|
+
[1m[35mSQL (0.2ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES (?)[0m [["version", "20120717192452"]]
|
11
|
+
[1m[35m (10.0ms)[0m [1m[36mcommit transaction[0m
|
12
|
+
Migrating to CreateLikes (20121206210955)
|
13
|
+
[1m[35m (0.7ms)[0m [1m[36mbegin transaction[0m
|
14
|
+
DEPRECATION WARNING: Directly inheriting from ActiveRecord::Migration is deprecated. Please specify the Rails release the migration was written for:
|
15
|
+
|
16
|
+
class CreateLikes < ActiveRecord::Migration[4.2] (called from load at /home/sergio/.rvm/gems/ruby-2.3.1/bin/rake:23)
|
17
|
+
[1m[35m (0.3ms)[0m [1m[35mCREATE TABLE "likes" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "user_id" integer, "created_at" datetime, "updated_at" datetime)[0m
|
18
|
+
[1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES (?)[0m [["version", "20121206210955"]]
|
19
|
+
[1m[35m (11.0ms)[0m [1m[36mcommit transaction[0m
|
20
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.2ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", :environment], ["LIMIT", 1]]
|
21
|
+
[1m[35m (0.1ms)[0m [1m[36mbegin transaction[0m
|
22
|
+
[1m[35mSQL (0.3ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?)[0m [["key", "environment"], ["value", "development"], ["created_at", 2017-03-16 16:22:28 UTC], ["updated_at", 2017-03-16 16:22:28 UTC]]
|
23
|
+
[1m[35m (8.5ms)[0m [1m[36mcommit transaction[0m
|
24
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.5ms)[0m [1m[34mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|