caracal-rails 1.0.2 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2eb4b9d05daec06006dadbf3957e46737654baee0f4c0a5df8acae982c1ada61
4
- data.tar.gz: 719cbefd24e98d26d09260fcd67ee61edf1f598f20964e303bf89cf3359a0a88
3
+ metadata.gz: a1f20228fa4a74595fc007ff0d9ec6d84d271135dfdaac535c7ad7c1fc5039f8
4
+ data.tar.gz: 0206e6242135c9c4ace8c20c272bd4ff5f40dcc9b78dbcc407e7758cbc552a61
5
5
  SHA512:
6
- metadata.gz: 7672ad6d880149a24fe49690d0d0ea6229f5313d3605d7a6bb137ef00cefd810a068864e641a0910a526598823f9998d00031f05931fc8d7399f8816ad1a93e4
7
- data.tar.gz: f34463c65d18523be6652fc6f6bf17e1bd026e64b7e5fb8532fddcafa850dba472eb864d408b7771bf8f7c017e4c250e8388503c6590e1c38d9aa1ceec56acbc
6
+ metadata.gz: d35b7b86b5550e65a84a44d0a4ad1832b633547bc0590c8d8f63d4826ccf8568ad922d4fd10e9f8a33e933ac925ccf6890797c0f27a4292d2f29ebc46e0a998e
7
+ data.tar.gz: 690165c748ab92ec13ef194dcb881ccb0dcea2839f14cc6c28d3b1af6dac749869f12fc97be5efdb21ec535bd36c63776f57ca260bcba27fd6f77d1f15e338c0
@@ -0,0 +1,33 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ test:
13
+ name: Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }}
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ # Rails 7.2 requires Ruby >= 3.1; Rails 8.x requires Ruby >= 3.2,
19
+ # so these are paired explicitly rather than crossed.
20
+ include:
21
+ - { ruby: '3.1', rails: '~> 7.1.0' }
22
+ - { ruby: '3.2', rails: '~> 7.2.0' }
23
+ - { ruby: '3.3', rails: '~> 8.0.0' }
24
+ - { ruby: '3.4', rails: '~> 8.1.0' }
25
+ env:
26
+ RAILS_VERSION: ${{ matrix.rails }}
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+ - uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby }}
32
+ bundler-cache: true
33
+ - run: bundle exec rspec
data/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ #### v1.0.3
2
+
3
+ * Security
4
+ * The template handler no longer interpolates the template path into generated Ruby source. A path containing a single quote closed the string literal, so the remainder was compiled as code by Rails; an ordinary apostrophe in a directory name raised a `SyntaxError` instead. The path is now escaped with `String#inspect`. (@dlauer)
5
+
6
+ * Bug Fixes
7
+ * Corrected five outdated examples in the README, each confirmed against caracal 1.5.0: `font` and `style` take a hash or block rather than a string, `cell_style` uses `:background` rather than `:background_color`, `br` is not a document level command, and `strong` is not a command at all. (reported by @Alan-M-Thomaz)
8
+
9
+ * Enhancements
10
+ * Added continuous integration across Ruby 3.1 to 3.4 and Rails 7.1 to 8.1. (@dlauer)
11
+ * Relaxed the bundler development dependency, which made `bundle install` impossible on current bundler, and raised rspec-rails so the suite runs on modern Rails. (@dlauer)
12
+ * Replaced Appraisal, whose configuration referenced a local checkout and covered only Rails 3.2 to 4.1, with a `RAILS_VERSION` environment variable read by the Gemfile. (@dlauer)
13
+ * Raised the rails floor to `>= 6.0`, matching the two argument template handler signature this gem ships. (@dlauer)
14
+ * Modernised the dummy application used by the suite: it now loads only the railties it needs rather than `rails/all`, which required ActiveRecord and sqlite3 for a gem that uses neither. (@dlauer)
15
+
16
+
17
+ #### v1.0.2
18
+
19
+ * Bug Fixes
20
+ * Added the second parameter to the template handler, which Rails 6 requires. (@emp823)
21
+
22
+
23
+ *Releases before v1.0.2 predate this changelog; see the git history for details.*
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ # lets CI test against specific Rails versions
6
+ gem 'rails', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Trade Informatics, Inc
1
+ Copyright (c) 2014 Urvin LLC
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Caracal-Rails
2
2
 
3
- [Caracal](https://github.com/trade-informatics/caracal) is a ruby library for dynamically creating professional-quality Microsoft Word documents.
3
+ [Caracal](https://github.com/urvin-compliance/caracal) is a ruby library for dynamically creating professional-quality Microsoft Word documents.
4
4
 
5
5
  Caracal-Rails is a drop in solution for registering the Microsoft Word mime type and for establishing a template handler in Rails for the :docx format. All caracal documents are rendered with an explicit block passing a reference to the Caracal::Document object named `docx`.
6
6
 
7
- Please see the [caracal-example](https://github.com/trade-informatics/caracal-example) repository for
7
+ Please see the [caracal-example](https://github.com/urvin-compliance/caracal-example) repository for
8
8
  a working demonstration of the library's capabilities.
9
9
 
10
10
  ## Installation
@@ -42,9 +42,11 @@ Specify the format `docx` in your route:
42
42
 
43
43
  Inside your view, simply issue Caracal commands on the document object:
44
44
 
45
- docx.font 'Droid Serif'
45
+ docx.font name: 'Droid Serif'
46
46
 
47
- docx.style 'special' do
47
+ docx.style do
48
+ id 'special'
49
+ name 'Special'
48
50
  font 'Droid Serif'
49
51
  italic true
50
52
  size 16
@@ -61,28 +63,27 @@ Inside your view, simply issue Caracal commands on the document object:
61
63
  text ' in the middle.'
62
64
  end
63
65
  docx.img image_url('https://www.example.com/logo.png'), width: 300, height: 200, align: 'right'
64
- docx.br
65
66
  docx.table client.tablular_data, border_size: 4 do
66
- cell_style rows[0], background_color: '3366cc', color: 'ffffff', bold: true
67
+ cell_style rows[0], background: '3366cc', color: 'ffffff', bold: true
67
68
  end
68
69
  docx.page
69
70
  docx.p 'This is an bulleted list.'
70
71
  docx.ul do
71
72
  li do
72
- strong 'Item 1'
73
- text 'More text'
73
+ text 'Item 1', bold: true
74
+ text ' More text'
74
75
  end
75
76
  li 'Item 2'
76
77
  end
77
78
  end
78
79
 
79
80
 
80
- *See the [Caracal](https://github.com/trade-informatics/caracal) library for more details.*
81
+ *See the [Caracal](https://github.com/urvin-compliance/caracal) library for more details.*
81
82
 
82
83
 
83
84
  ## Contributing
84
85
 
85
- 1. Fork it ( https://github.com/trade-informatics/caracal-rails/fork )
86
+ 1. Fork it ( https://github.com/urvin-compliance/caracal-rails/fork )
86
87
  2. Create your feature branch (`git checkout -b my-new-feature`)
87
88
  3. Commit your changes (`git commit -am 'Add some feature'`)
88
89
  4. Push to the branch (`git push origin my-new-feature`)
@@ -101,6 +102,6 @@ A tip of the hat to the wonderful PDF generation libraries [Prawn](https://githu
101
102
 
102
103
  ## License
103
104
 
104
- Copyright (c) 2014 Trade Informatics, Inc
105
+ Copyright (c) 2014 Urvin LLC
105
106
 
106
- [MIT License](https://github.com/trade-informatics/caracal-rails/blob/master/LICENSE.txt)
107
+ [MIT License](https://github.com/urvin-compliance/caracal-rails/blob/master/LICENSE.txt)
@@ -6,22 +6,26 @@ require 'caracal/rails/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'caracal-rails'
8
8
  spec.version = Caracal::Rails::VERSION
9
- spec.authors = ['Trade Informatics', 'John Dugan']
10
- spec.email = ['jpdugan@gmail.com']
9
+ spec.authors = ['Urvin LLC', 'Dave Lauer']
10
+ spec.email = ['dave@plia.com']
11
11
  spec.summary = %q{ Caracal::Rails makes using Caracal in Rails a no-brainer. }
12
12
  spec.description = %q{ Caracal::Rails takes care of registering Microsoft Word output with Rails. Essentially, this involves registering the mime type, establishing a template handler for .docx formats, and establishing sane defaults for generating professional quality Word documents. }
13
- spec.homepage = 'https://github.com/ibpinc/caracal-rails'
13
+ spec.homepage = 'https://github.com/urvin-compliance/caracal-rails'
14
14
  spec.license = 'MIT'
15
15
 
16
+ spec.metadata = {
17
+ 'source_code_uri' => 'https://github.com/urvin-compliance/caracal-rails',
18
+ 'bug_tracker_uri' => 'https://github.com/urvin-compliance/caracal-rails/issues'
19
+ }
20
+
16
21
  spec.files = `git ls-files -z`.split("\x0")
17
22
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
23
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
24
  spec.require_paths = ['lib']
20
25
 
21
26
  spec.add_dependency 'caracal', '~> 1.0'
22
- spec.add_dependency 'rails', '>= 3.2'
27
+ spec.add_dependency 'rails', '>= 6.0'
23
28
 
24
- spec.add_development_dependency 'appraisal', '~> 1.0'
25
- spec.add_development_dependency 'bundler', '~> 1.6'
26
- spec.add_development_dependency 'rspec-rails', '~> 3.0'
29
+ spec.add_development_dependency 'bundler', '>= 1.6'
30
+ spec.add_development_dependency 'rspec-rails', '>= 6.0'
27
31
  end
@@ -3,7 +3,7 @@ module Caracal
3
3
  class TemplateHandler
4
4
 
5
5
  def self.call(template, source = nil)
6
- "Tilt.new('#{ template.identifier }').render(self)"
6
+ "Tilt.new(#{ template.identifier.inspect }).render(self)"
7
7
  end
8
8
 
9
9
  end
@@ -1,5 +1,5 @@
1
1
  module Caracal
2
2
  module Rails
3
- VERSION = '1.0.2'
3
+ VERSION = '1.0.3'
4
4
  end
5
5
  end
@@ -1,6 +1,8 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
- require 'rails/all'
3
+ require 'rails'
4
+ require 'action_controller/railtie'
5
+ require 'action_view/railtie'
4
6
 
5
7
  # Require the gems listed in Gemfile, including any gems
6
8
  # you've limited to :test, :development, or :production.
@@ -5,7 +5,7 @@ Dummy::Application.configure do
5
5
  # test suite. You never need to work with it otherwise. Remember that
6
6
  # your test database is "scratch space" for the test suite and is wiped
7
7
  # and recreated between test runs. Don't rely on the data there!
8
- config.cache_classes = true
8
+ config.enable_reloading = false
9
9
 
10
10
  # Do not eager load code on boot. This avoids loading your whole application
11
11
  # just for the purpose of running a single test. If you are using a tool that
@@ -13,15 +13,15 @@ Dummy::Application.configure do
13
13
  config.eager_load = false
14
14
 
15
15
  # Configure static asset server for tests with Cache-Control for performance.
16
- config.serve_static_assets = true
17
- config.static_cache_control = 'public, max-age=3600'
16
+ config.public_file_server.enabled = true
17
+ config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
18
18
 
19
19
  # Show full error reports and disable caching.
20
20
  config.consider_all_requests_local = true
21
21
  config.action_controller.perform_caching = false
22
22
 
23
23
  # Raise exceptions instead of rendering exception templates.
24
- config.action_dispatch.show_exceptions = false
24
+ config.action_dispatch.show_exceptions = :none
25
25
 
26
26
  # Disable request forgery protection in test environment.
27
27
  config.action_controller.allow_forgery_protection = false
@@ -29,7 +29,6 @@ Dummy::Application.configure do
29
29
  # Tell Action Mailer not to deliver emails to the real world.
30
30
  # The :test delivery method accumulates sent emails in the
31
31
  # ActionMailer::Base.deliveries array.
32
- config.action_mailer.delivery_method = :test
33
32
 
34
33
  # Print deprecation notices to the stderr.
35
34
  config.active_support.deprecation = :stderr
@@ -12,8 +12,28 @@ describe Caracal::Rails::TemplateHandler do
12
12
  describe '#call' do
13
13
  let(:template) { double('template', identifier: 'show.docx.caracal') }
14
14
  let(:actual) { Caracal::Rails::TemplateHandler.call(template) }
15
-
16
- it { expect(actual).to eq "Tilt.new('show.docx.caracal').render(self)" }
15
+
16
+ it { expect(actual).to eq %q{Tilt.new("show.docx.caracal").render(self)} }
17
+
18
+ describe 'when the path contains a quote' do
19
+ let(:template) { double('template', identifier: %q{/views/o'brien/show.docx.caracal}) }
20
+
21
+ it 'escapes it rather than breaking out of the string' do
22
+ expect(actual).to eq %q{Tilt.new("/views/o'brien/show.docx.caracal").render(self)}
23
+ end
24
+
25
+ it 'produces source that still parses as ruby' do
26
+ expect { RubyVM::InstructionSequence.compile(actual) }.not_to raise_error
27
+ end
28
+ end
29
+
30
+ describe 'when the path is hostile' do
31
+ let(:template) { double('template', identifier: %q{/tmp/x'); system('id'); ('}) }
32
+
33
+ it 'keeps the whole path inside the string literal' do
34
+ expect(actual).to eq %q{Tilt.new("/tmp/x'); system('id'); ('").render(self)}
35
+ end
36
+ end
17
37
  end
18
38
 
19
39
  end
@@ -49,8 +49,12 @@ describe Caracal::Rails::Railtie do
49
49
 
50
50
  # .handler_for_extension
51
51
  describe '#handler_for_extension' do
52
+ # The railtie registers the handler inside ActiveSupport.on_load(:action_view),
53
+ # which fires when ActionView::Base is first loaded rather than during boot.
54
+ before { ActionView::Base.empty }
55
+
52
56
  let(:actual) { ActionView::Template.handler_for_extension(:caracal) }
53
-
57
+
54
58
  it { expect(actual).to eq Caracal::Rails::TemplateHandler }
55
59
  end
56
60
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caracal-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
- - Trade Informatics
8
- - John Dugan
9
- autorequire:
7
+ - Urvin LLC
8
+ - Dave Lauer
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-07-15 00:00:00.000000000 Z
12
+ date: 2026-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: caracal
@@ -31,76 +31,60 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: '3.2'
34
+ version: '6.0'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: '3.2'
42
- - !ruby/object:Gem::Dependency
43
- name: appraisal
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '1.0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '1.0'
41
+ version: '6.0'
56
42
  - !ruby/object:Gem::Dependency
57
43
  name: bundler
58
44
  requirement: !ruby/object:Gem::Requirement
59
45
  requirements:
60
- - - "~>"
46
+ - - ">="
61
47
  - !ruby/object:Gem::Version
62
48
  version: '1.6'
63
49
  type: :development
64
50
  prerelease: false
65
51
  version_requirements: !ruby/object:Gem::Requirement
66
52
  requirements:
67
- - - "~>"
53
+ - - ">="
68
54
  - !ruby/object:Gem::Version
69
55
  version: '1.6'
70
56
  - !ruby/object:Gem::Dependency
71
57
  name: rspec-rails
72
58
  requirement: !ruby/object:Gem::Requirement
73
59
  requirements:
74
- - - "~>"
60
+ - - ">="
75
61
  - !ruby/object:Gem::Version
76
- version: '3.0'
62
+ version: '6.0'
77
63
  type: :development
78
64
  prerelease: false
79
65
  version_requirements: !ruby/object:Gem::Requirement
80
66
  requirements:
81
- - - "~>"
67
+ - - ">="
82
68
  - !ruby/object:Gem::Version
83
- version: '3.0'
69
+ version: '6.0'
84
70
  description: " Caracal::Rails takes care of registering Microsoft Word output with
85
71
  Rails. Essentially, this involves registering the mime type, establishing a template
86
72
  handler for .docx formats, and establishing sane defaults for generating professional
87
73
  quality Word documents. "
88
74
  email:
89
- - jpdugan@gmail.com
75
+ - dave@plia.com
90
76
  executables: []
91
77
  extensions: []
92
78
  extra_rdoc_files: []
93
79
  files:
80
+ - ".github/workflows/ci.yml"
94
81
  - ".gitignore"
95
- - Appraisals
82
+ - CHANGELOG.md
96
83
  - Gemfile
97
84
  - LICENSE.txt
98
85
  - README.md
99
86
  - Rakefile
100
87
  - caracal-rails.gemspec
101
- - gemfiles/rails_3.2.gemfile
102
- - gemfiles/rails_4.0.gemfile
103
- - gemfiles/rails_4.1.gemfile
104
88
  - lib/caracal-rails.rb
105
89
  - lib/caracal/rails/template_handler.rb
106
90
  - lib/caracal/rails/version.rb
@@ -148,11 +132,13 @@ files:
148
132
  - spec/lib/caracal/rails/template_handler_spec.rb
149
133
  - spec/lib/caracal/rails/version.rb
150
134
  - spec/spec_helper.rb
151
- homepage: https://github.com/ibpinc/caracal-rails
135
+ homepage: https://github.com/urvin-compliance/caracal-rails
152
136
  licenses:
153
137
  - MIT
154
- metadata: {}
155
- post_install_message:
138
+ metadata:
139
+ source_code_uri: https://github.com/urvin-compliance/caracal-rails
140
+ bug_tracker_uri: https://github.com/urvin-compliance/caracal-rails/issues
141
+ post_install_message:
156
142
  rdoc_options: []
157
143
  require_paths:
158
144
  - lib
@@ -167,8 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
153
  - !ruby/object:Gem::Version
168
154
  version: '0'
169
155
  requirements: []
170
- rubygems_version: 3.0.3
171
- signing_key:
156
+ rubygems_version: 3.5.22
157
+ signing_key:
172
158
  specification_version: 4
173
159
  summary: Caracal::Rails makes using Caracal in Rails a no-brainer.
174
160
  test_files:
data/Appraisals DELETED
@@ -1,17 +0,0 @@
1
- appraise 'rails-3.2' do
2
- gem 'rails', '~> 3.2.18'
3
- gem 'sqlite3'
4
- gem 'caracal', path: '~/workspace/plia/caracal', ref: 'e2b84b191efe6b7871259201413c13918091c6b4'
5
- end
6
-
7
- appraise 'rails-4.0' do
8
- gem 'rails', '~> 4.0.5'
9
- gem 'sqlite3'
10
- gem 'caracal', path: '~/workspace/plia/caracal', ref: 'e2b84b191efe6b7871259201413c13918091c6b4'
11
- end
12
-
13
- appraise 'rails-4.1' do
14
- gem 'rails', '~> 4.1.1'
15
- gem 'sqlite3'
16
- gem 'caracal', path: '~/workspace/plia/caracal', ref: 'e2b84b191efe6b7871259201413c13918091c6b4'
17
- end
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 3.2.18"
6
- gem "sqlite3"
7
-
8
- gemspec :path => "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 4.0.5"
6
- gem "sqlite3"
7
-
8
- gemspec :path => "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 4.1.1"
6
- gem "sqlite3"
7
-
8
- gemspec :path => "../"