prawn-rails-forms 0.1.1 → 0.1.2

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
2
  SHA1:
3
- metadata.gz: 16c20f8f7686c055d7ba65f206a774d5d5e4b6f8
4
- data.tar.gz: f417f0e482894757ab1ff87db27e84b78bb52f4f
3
+ metadata.gz: c9a7c6307083765422e4080c93dd8494bbc10b68
4
+ data.tar.gz: ebaf431a17c891267ff285e41a1f462cf7745356
5
5
  SHA512:
6
- metadata.gz: 6eafaf48b3838eebcdac6399c107d3284b5a269160739cd6788c3e40bf901790852299a2231c4cd2c6f513e95ca0479d061cc19a252b60d92740fe35e9153b2b
7
- data.tar.gz: fd87878a95697d7e3b97238e1a1b534aa95cb1b441148735f25ad5af04fa50ed9584a179fd836765d19aea0c54aa9d9ba9e445cf9fabfc14b25758c56bea5afe
6
+ metadata.gz: 2e7889acedcb012989222a4adf7bf51da245971eed27715003af23edb97f61c3a04ca20964f94ac4fda0a2d6cd5d727516aa8440a8ef96799e77339b8a279e02
7
+ data.tar.gz: 6e8cda5e6bfa3ca974a85d874c653e26f31ac7462cb692085533d83177474145c47a7787042f1b313689bde2ee63d9f9e3f84dc8ade4361aaba43ad1c57a4940
data/README.md CHANGED
@@ -141,6 +141,12 @@ row.text_field field: 'Favorite fruit', value: @user.favorite_fruit,
141
141
  if: @user.likes_fruit?, unless: @user.hates_fruit? }
142
142
  ```
143
143
 
144
+ If you have options which you wish to apply to *all* of your text fields, you can set them globally:
145
+ ```ruby
146
+ PrawnRailsForms.default_text_field_options = { style: :bold }
147
+ ```
148
+ Following which any invocations of `row.text_field` will have those options applied, except where you manually override them.
149
+
144
150
  ### Check box fields
145
151
 
146
152
  For selecting one of a group of options (the equivalent of an HTML select tag), you can have check box fields, e.g.:
@@ -6,6 +6,13 @@ require 'prawn-rails-forms/version'
6
6
  require 'prawn-rails'
7
7
 
8
8
  module PrawnRailsForms
9
+ def default_text_field_options=(options)
10
+ @options = options
11
+ end
12
+
13
+ def default_text_field_options
14
+ @options ||= {}
15
+ end
9
16
  end
10
17
 
11
18
  module PrawnRails
@@ -12,6 +12,7 @@ module PrawnRailsForms
12
12
  private
13
13
 
14
14
  def make_text_field(start, width, height, field:, value:, options: {})
15
+ options.reverse_merge! PrawnRailsForms.default_text_field_options
15
16
  bounding_box start, width: width, height: height do
16
17
  stroke_bounds
17
18
  bounds.add_left_padding 2
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PrawnRailsForms
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
@@ -6,6 +6,7 @@ gem 'puma', '~> 3.7'
6
6
 
7
7
  group :development do
8
8
  gem 'listen', '>= 3.0.5', '< 3.2'
9
+ gem 'pry-byebug'
9
10
  gem 'spring'
10
11
  gem 'spring-watcher-listen', '~> 2.0.0'
11
12
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- prawn-rails-forms (0.1.0)
4
+ prawn-rails-forms (0.1.2)
5
5
  prawn-rails (~> 1.0)
6
6
 
7
7
  GEM
@@ -46,6 +46,8 @@ GEM
46
46
  tzinfo (~> 1.1)
47
47
  arel (8.0.0)
48
48
  builder (3.2.3)
49
+ byebug (9.1.0)
50
+ coderay (1.1.2)
49
51
  concurrent-ruby (1.0.5)
50
52
  erubi (1.6.0)
51
53
  ffi (1.9.18)
@@ -73,12 +75,18 @@ GEM
73
75
  prawn (2.2.2)
74
76
  pdf-core (~> 0.7.0)
75
77
  ttfunk (~> 1.5)
76
- prawn-rails (1.0.0)
78
+ prawn-rails (1.0.1)
77
79
  prawn
78
80
  prawn-table
79
81
  rails (>= 3.1.0)
80
82
  prawn-table (0.2.2)
81
83
  prawn (>= 1.3.0, < 3.0.0)
84
+ pry (0.11.0)
85
+ coderay (~> 1.1.0)
86
+ method_source (~> 0.8.1)
87
+ pry-byebug (3.5.1)
88
+ byebug (~> 9.1)
89
+ pry (~> 0.10)
82
90
  puma (3.8.2)
83
91
  rack (2.0.3)
84
92
  rack-test (0.6.3)
@@ -138,10 +146,11 @@ PLATFORMS
138
146
  DEPENDENCIES
139
147
  listen (>= 3.0.5, < 3.2)
140
148
  prawn-rails-forms!
149
+ pry-byebug
141
150
  puma (~> 3.7)
142
151
  rails (~> 5.1.1)
143
152
  spring
144
153
  spring-watcher-listen (~> 2.0.0)
145
154
 
146
155
  BUNDLED WITH
147
- 1.15.0
156
+ 1.16.0
@@ -30,7 +30,7 @@ prawn_document do |pdf|
30
30
  height: 25
31
31
  end
32
32
 
33
- pdf.move_down 70
33
+ pdf.move_down 30
34
34
  pdf.text 'Text boxes - conditional display options',
35
35
  align: :center, size: 14
36
36
  unit_width = pdf.bounds.width / 4
@@ -53,7 +53,7 @@ prawn_document do |pdf|
53
53
  options: { unless: true }
54
54
  end
55
55
 
56
- pdf.move_down 70
56
+ pdf.move_down 30
57
57
  pdf.text 'Check boxes',
58
58
  align: :center, size: 14
59
59
  unit_width = pdf.bounds.width / 5
@@ -88,10 +88,9 @@ prawn_document do |pdf|
88
88
  checked: numbers.map(&:even?), per_column: 2
89
89
  end
90
90
 
91
- pdf.move_down 70
91
+ pdf.move_down 30
92
92
  pdf.text 'Splitting rows',
93
93
  align: :center, size: 14
94
- pdf.move_down 10
95
94
  pdf.text 'This should look as expected', size: 10, align: :center
96
95
 
97
96
  pdf.field_row height: 50, units: 2 do |row|
@@ -105,4 +104,19 @@ prawn_document do |pdf|
105
104
  end
106
105
  end
107
106
 
107
+ PrawnRailsForms.default_text_field_options = { style: :bold }
108
+
109
+ pdf.move_down 30
110
+ pdf.text 'Global options', align: :center, size: 14
111
+ pdf.text "These should all be bold, except the last one", size: 10, align: :center
112
+
113
+ pdf.field_row height: 30, units: 6 do |row|
114
+ row.text_field field: 'Do', value: 'I'
115
+ row.text_field field: 'you', value: 'like'
116
+ row.text_field field: 'like', value: 'all'
117
+ row.text_field field: 'all', value: 'kinds'
118
+ row.text_field field: 'the', value: 'of'
119
+ row.text_field field: 'fruit?', value: 'fruits!',
120
+ options: { style: :italic }
121
+ end
108
122
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-rails-forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - UMass Transportation Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-08 00:00:00.000000000 Z
11
+ date: 2017-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn-rails