prawn_cocktail 0.7.1 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: cb77563957d34bfccd712288a44393dcc250cf7f
4
- data.tar.gz: c2ce56312ac0b9ce75fa7e9531ec7b7754d66664
2
+ SHA256:
3
+ metadata.gz: 61d84eedd5dfe30a88044ffc489cb3045888cdc2d55ce2418ee1f7c1a8069034
4
+ data.tar.gz: 64c8bf00e8398dbf2f66c545c0c287633104b7fa9087694fb24ad3cabae60a90
5
5
  SHA512:
6
- metadata.gz: ce20074e919bc258a631287632d816f21d0cc7fa6d2c9cc4097a13b4e16573d121e1c8a836b50afd5dfa08504013c75c6d7ff90b0aed446dc2bbbe794a368f5e
7
- data.tar.gz: 055eb84d6c3418f43fe2b400e87044e647211fda697c89acf626e49a5d00d02a3b0180e9a7cebdd4c04f97c0eae1139d1f41ef868c628dd7b6c848fffd381610
6
+ metadata.gz: 75f3e9779418238920e385563ec5b451e7dfd23d1be4379973ef6ac4f30eebbccdce798cae7a8116c3d33de7a1e8a5a52d093f2e385a39278ebddecf9b4e7824
7
+ data.tar.gz: be55301fdc96c7cc719a8a5f79b38de2a456c191f668a91fd14f8c24f75424de45712c5ab904e264ddf04b10943cf9a5f90c2e63ce20792c200b9d30ec6d8878
@@ -0,0 +1,26 @@
1
+ name: Ruby CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+
14
+ strategy:
15
+ matrix:
16
+ ruby-version: ["3.0", "2.7", "2.6", "2.5"]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby ${{ matrix.ruby-version }}
21
+ uses: ruby/setup-ruby@ae9cb3b565e36682a2c6045e4f664388da4c73aa
22
+ with:
23
+ ruby-version: ${{ matrix.ruby-version }}
24
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
25
+ - name: Run tests
26
+ run: bundle exec rake
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ AllCops:
2
+ Exclude:
3
+ - "tmp/**/*"
4
+ inherit_gem:
5
+ barsoom_utils: shared_rubocop.yml
data/Gemfile CHANGED
@@ -1,4 +1,9 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in prawn_cocktail.gemspec
4
4
  gemspec
5
+
6
+ group :development do
7
+ gem "barsoom_utils", github: "barsoom/barsoom_utils"
8
+ gem "rubocop"
9
+ end
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # PrawnCocktail
2
2
 
3
- [![Build status](https://secure.travis-ci.org/barsoom/prawn_cocktail.png)](https://travis-ci.org/#!/barsoom/prawn_cocktail/builds)
3
+ [![Ruby CI](https://github.com/barsoom/prawn_cocktail/actions/workflows/ci.yml/badge.svg)](https://github.com/barsoom/prawn_cocktail/actions/workflows/ci.yml)
4
4
 
5
5
  Simple documents, templates and helpers on top of Prawn.
6
6
 
@@ -8,8 +8,6 @@ Because writing Prawn documents PHP 4 style is no fun.
8
8
 
9
9
  If you're using this with Ruby on Rails, get [`PrawnCocktailRails`](http://github.com/barsoom/prawn_cocktail_rails).
10
10
 
11
- Ruby 1.9 only since we use and love instance\_exec.
12
-
13
11
  ![](http://upload.wikimedia.org/wikipedia/commons/f/f8/Cocktail_1_bg_060702.jpg)
14
12
 
15
13
  ## Usage
data/Rakefile CHANGED
@@ -5,4 +5,4 @@ Rake::TestTask.new do |t|
5
5
  t.pattern = "spec/*_spec.rb"
6
6
  end
7
7
 
8
- task :default => :test
8
+ task default: :test
@@ -8,7 +8,7 @@ module PrawnCocktail
8
8
  self.initializers = []
9
9
 
10
10
  def self.initialize_template(&block)
11
- self.initializers += [block]
11
+ self.initializers += [ block ]
12
12
  end
13
13
 
14
14
  def self.helper(mod)
@@ -5,13 +5,14 @@ require_relative "utils/recursive_closed_struct"
5
5
  module PrawnCocktail
6
6
  class Renderer
7
7
  def initialize(template_name, data, initializers)
8
+ @prawn_document_options = {}
8
9
  @template_name = template_name
9
10
  @data = data
10
11
  @initializers = initializers
11
12
  end
12
13
 
13
14
  def meta(opts)
14
- @prawn_document_options = opts
15
+ @prawn_document_options.merge!(opts)
15
16
  end
16
17
 
17
18
  def content(&block)
@@ -3,8 +3,8 @@ class RecursiveClosedStruct
3
3
  @hash = hash
4
4
  end
5
5
 
6
- def has_key?(key)
7
- @hash.has_key? key
6
+ def include?(key)
7
+ @hash.include?(key)
8
8
  end
9
9
 
10
10
  def method_missing(name, *)
@@ -1,3 +1,3 @@
1
1
  module PrawnCocktail
2
- VERSION = "0.7.1"
2
+ VERSION = "0.8.1"
3
3
  end
@@ -1,20 +1,21 @@
1
1
  # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'prawn_cocktail/version'
4
+ require "prawn_cocktail/version"
5
5
 
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "prawn_cocktail"
8
8
  gem.version = PrawnCocktail::VERSION
9
- gem.authors = ["Henrik Nyh"]
10
- gem.email = ["henrik@barsoom.se"]
9
+ gem.authors = [ "Henrik Nyh" ]
10
+ gem.email = [ "henrik@barsoom.se" ]
11
11
  gem.summary = "Simple documents, templates and helpers on top of Prawn."
12
12
  gem.homepage = ""
13
+ gem.metadata = { "rubygems_mfa_required" => "true" }
14
+
13
15
 
14
16
  gem.files = `git ls-files`.split($/)
15
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
- gem.require_paths = ["lib"]
18
+ gem.require_paths = [ "lib" ]
18
19
 
19
20
  gem.add_dependency "prawn"
20
21
  gem.add_dependency "activesupport"
@@ -15,7 +15,7 @@ describe PrawnCocktail do
15
15
  it "has the right contents" do
16
16
  assert_equal(
17
17
  [ "Init works.", "Test document", "Status: success" ],
18
- parse_strings(data)
18
+ parse_strings(data),
19
19
  )
20
20
  end
21
21
 
@@ -33,7 +33,7 @@ describe PrawnCocktail do
33
33
  it "has the right contents" do
34
34
  assert_equal(
35
35
  [ "Init works.", "Test document", "Status: success" ],
36
- parse_strings(data)
36
+ parse_strings(data),
37
37
  )
38
38
  end
39
39
 
@@ -50,7 +50,7 @@ describe PrawnCocktail do
50
50
  it "inherits initializers and helpers" do
51
51
  assert_equal(
52
52
  [ "Init works.", "Sub-init works.", "Sub test document", "Status: success" ],
53
- parse_strings(data)
53
+ parse_strings(data),
54
54
  )
55
55
  end
56
56
  end
@@ -65,5 +65,5 @@ def parse_geometry(pdf_data)
65
65
  end
66
66
 
67
67
  def expected_geometry(name)
68
- Prawn::Document::PageGeometry::SIZES[name]
68
+ PDF::Core::PageGeometry::SIZES[name]
69
69
  end
@@ -17,25 +17,25 @@ describe RecursiveClosedStruct do
17
17
 
18
18
  it "recurses through hashes" do
19
19
  subject = RecursiveClosedStruct.new({
20
- one: { two: { three: "four" } }
20
+ one: { two: { three: "four" } },
21
21
  })
22
22
  assert_equal "four", subject.one.two.three
23
23
  end
24
24
 
25
+ describe "#include?" do
26
+ it "is true if that key exists" do
27
+ subject = RecursiveClosedStruct.new(real: true)
28
+ assert subject.include?(:real)
29
+ end
25
30
 
26
- it "lets a user check if the key exists without throwing an error" do
27
- subject = RecursiveClosedStruct.new({
28
- real: true
29
- })
30
-
31
- assert subject.has_key?(:real)
32
- end
33
-
34
- it "lets a user check if the key does not exist without throwing an error" do
35
- subject = RecursiveClosedStruct.new({
36
- real: true
37
- })
31
+ it "is false if that key does not exist" do
32
+ subject = RecursiveClosedStruct.new(real: true)
33
+ refute subject.include?(:imaginary)
34
+ end
38
35
 
39
- refute subject.has_key?(:imaginary)
36
+ it "recurses" do
37
+ subject = RecursiveClosedStruct.new(one: { two: "three" })
38
+ assert subject.one.include?(:two)
39
+ end
40
40
  end
41
41
  end
@@ -0,0 +1,14 @@
1
+ require_relative "spec_helper"
2
+
3
+ describe PrawnCocktail::Renderer do
4
+ describe "#meta" do
5
+ it "merges options if run multiple times" do
6
+ subject = PrawnCocktail::Renderer.new(nil, nil, nil)
7
+ subject.meta one: nil, two: 2
8
+ subject.meta one: 1, three: 3
9
+
10
+ expected = { one: 1, two: 2, three: 3 }
11
+ assert_equal expected, subject.send(:prawn_document_options)
12
+ end
13
+ end
14
+ end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn_cocktail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-16 00:00:00.000000000 Z
11
+ date: 2021-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pdf-inspector
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description:
@@ -73,8 +73,9 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
77
- - .travis.yml
76
+ - ".github/workflows/ci.yml"
77
+ - ".gitignore"
78
+ - ".rubocop.yml"
78
79
  - Gemfile
79
80
  - README.md
80
81
  - Rakefile
@@ -91,27 +92,28 @@ files:
91
92
  - spec/fixtures/test_document.pdf.rb
92
93
  - spec/integration_spec.rb
93
94
  - spec/recursive_closed_struct_spec.rb
95
+ - spec/renderer_spec.rb
94
96
  - spec/spec_helper.rb
95
97
  homepage: ''
96
98
  licenses: []
97
- metadata: {}
99
+ metadata:
100
+ rubygems_mfa_required: 'true'
98
101
  post_install_message:
99
102
  rdoc_options: []
100
103
  require_paths:
101
104
  - lib
102
105
  required_ruby_version: !ruby/object:Gem::Requirement
103
106
  requirements:
104
- - - ! '>='
107
+ - - ">="
105
108
  - !ruby/object:Gem::Version
106
109
  version: '0'
107
110
  required_rubygems_version: !ruby/object:Gem::Requirement
108
111
  requirements:
109
- - - ! '>='
112
+ - - ">="
110
113
  - !ruby/object:Gem::Version
111
114
  version: '0'
112
115
  requirements: []
113
- rubyforge_project:
114
- rubygems_version: 2.0.3
116
+ rubygems_version: 3.2.31
115
117
  signing_key:
116
118
  specification_version: 4
117
119
  summary: Simple documents, templates and helpers on top of Prawn.
@@ -121,5 +123,5 @@ test_files:
121
123
  - spec/fixtures/test_document.pdf.rb
122
124
  - spec/integration_spec.rb
123
125
  - spec/recursive_closed_struct_spec.rb
126
+ - spec/renderer_spec.rb
124
127
  - spec/spec_helper.rb
125
- has_rdoc:
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0.0
4
- - 1.9.3
5
- - rbx-19mode