demeler 1.0.6 → 1.0.7

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
  SHA1:
3
- metadata.gz: a350b5f6a09823e9fed7af88bb7184c3e3dc3826
4
- data.tar.gz: fdad247bf7ba8c9d72fe829e1406e1d54f094399
3
+ metadata.gz: c823a295499abe1da486629921987462806c22ae
4
+ data.tar.gz: d0dd3ae17811743e944aabf0043a03e32ea7cd8e
5
5
  SHA512:
6
- metadata.gz: b94943dcc4d271876540dd8198e459405faffa16d7fbac91f8d4eb468c567e6eb3f3d516a0019baffc328c63a65ad405761ba8b6d9802da1a9bafd2582d8dee2
7
- data.tar.gz: 593ce1b7bdbe6337e52b8ab1d7b326970a5578e4bcbe81f5da014ff03f4eda45502ba44267923eaa00679e92b6fec04e1daa34002ca7b89daf14276ca95dd928
6
+ metadata.gz: f7096b846d3593cc854aaf1202e08c1f34a405ba6758dff34b0de1270ccf4a194b759c7cbde469802525eacde8aa23d8aaa040a14efc46386d58a9d4bcf6e1d7
7
+ data.tar.gz: bc2bbc0d9727d6c567b796cd85fd936fc6bed3c204bd28e56fbe44a75adb6492cb40de36c2b6c3abfa2964a7fd1c269d0938c47e2daad3297a1b88679f9ce06c
data/CHANGELOG.md CHANGED
@@ -1,37 +1,3 @@
1
- # 1.0.6
1
+ # 1.0.7
2
2
 
3
- * Added a `reset` shortcut that works like the `submit` shortcut.
4
-
5
- # 1.0.5
6
-
7
- * Had to eliminate a "side effect" by cloning the :href string before using it.
8
-
9
- # 1.0.4
10
-
11
- * Added a `parms` argument to `alink` so that parameters that are being passed can be added as a hash. See the README.
12
- * Added a test in specs to test the passing of parameters in `alink`.
13
- * Updated the README and Notes.
14
-
15
- # 1.0.3
16
-
17
- * Updated the README and Notes.
18
-
19
-
20
- # 1.0.2
21
-
22
- * Renamed the 'session' variable to be 'usr'. It's become clear to me that the only way a script can access data passed from the controller to the script is through this variable: therefore, it ought to have a generic name. The variable usr will have whatever is passed in through `new` or `build`.
23
-
24
- # 1.0.1
25
-
26
- * Changed the `clear` method to return self so that clear can be chained.
27
- * Corrected some of the comments above individual methods.
28
- * Made some corrections and additions to the README.
29
- * Made `write_html` a private method because it's only used by `to_html`.
30
- * Added an argument to `build` and `initialize` to allow a session variable to be passed through.
31
- * Corrected a problem with the `select` control in that the attributes were not being applied.
32
- * Added a variable to `build` and `initialize` to be able to pass through a user argument. I called it `session` because that's what it would commonly be used for, but you could pass anything and access it in your Demeler code. For example, if you needed session _and_ some other variables, you would just pass them all in a Hash, including session.
33
- * Added a .gitignore file.
34
-
35
- # 1.0.0
36
-
37
- * Initial version.
3
+ * Added a _:default_ parameter to the opts in _checkbox_, _radio_, and _select_ controls to allow choosing a default without setting up a _obj_ parameter.
data/README.md CHANGED
@@ -317,7 +317,17 @@ For a checkbox, radio, or select control, use the formats below.
317
317
  </select>
318
318
  ```
319
319
 
320
- Opts represents a Hash with tag attributes.
320
+ Opts represents a Hash with tag attributes. In particular, note that the `:default` attribute will define the default in the case no `obj` is passed to the control.
321
+
322
+ For example, if the `:default` is `:saab` or `'saab'`, you'll get
323
+
324
+ `radio(:vehicle, {:default=>:saab}, :volvo=>"Volvo", :saab=>"Saab", :mercedes=>"Mercedes", :audi=>"Audi")` =>
325
+ ```html
326
+ <input name="vehicle" type="radio" value="volvo">Volvo</input>
327
+ <input name="vehicle" type="radio" value="saab" checked="true">Saab</input>
328
+ <input name="vehicle" type="radio" value="mercedes">Mercedes</input>
329
+ <input name="vehicle" type="radio" value="audi">Audi</input>
330
+ ```
321
331
 
322
332
 
323
333
 
data/lib/demeler.rb CHANGED
@@ -173,7 +173,14 @@ class Demeler
173
173
  raise ArgumentError.new("In Demeler#checkbox, expected Hash for argument 2, opts") if !opts.kind_of?(Hash)
174
174
  raise ArgumentError.new("In Demeler#checkbox, expected Hash for argument 3, values") if !values.kind_of?(Hash)
175
175
  n = 0
176
- data = if @obj then @obj[name] else nil end
176
+ data = case
177
+ when @obj
178
+ @obj[name]
179
+ when (default = opts[:default])
180
+ default.to_s
181
+ else
182
+ nil
183
+ end
177
184
  case data.class.name
178
185
  when "String"
179
186
  data = data.split(",")
@@ -211,7 +218,14 @@ class Demeler
211
218
  raise ArgumentError.new("In Demeler#radio, expected Symbol for argument 1, name") if !name.kind_of?(Symbol)
212
219
  raise ArgumentError.new("In Demeler#radio, expected Hash for argument 2, opts") if !opts.kind_of?(Hash)
213
220
  raise ArgumentError.new("In Demeler#radio, expected Hash for argument 3, values") if !values.kind_of?(Hash)
214
- data = if @obj then @obj[name] else nil end
221
+ data = case
222
+ when @obj
223
+ @obj[name]
224
+ when (default = opts[:default])
225
+ default.to_s
226
+ else
227
+ nil
228
+ end
215
229
  values.each do |value,nomenclature|
216
230
  sets = opts.clone
217
231
  sets[:name] = "#{name}".to_sym
@@ -257,7 +271,14 @@ class Demeler
257
271
  raise ArgumentError.new("In Demeler#select, expected Hash for argument 2, args") if !args.kind_of?(Hash)
258
272
  raise ArgumentError.new("In Demeler#select, expected Hash for argument 3, values") if !values.kind_of?(Hash)
259
273
  opts = {:name=>name}.merge(args)
260
- data = if @obj then @obj[name] else nil end
274
+ data = case
275
+ when @obj
276
+ @obj[name]
277
+ when (default = opts[:default])
278
+ default.to_s
279
+ else
280
+ nil
281
+ end
261
282
  tag_generator(:select, opts) do
262
283
  values.each do |value,nomenclature|
263
284
  sets = {:value=>value}
@@ -1,4 +1,4 @@
1
1
  module Version
2
- VERSION = "1.0.6"
3
- MODIFIED = "2017-06-23"
2
+ VERSION = "1.0.7"
3
+ MODIFIED = "2017-08-19"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: demeler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael J. Welch, Ph.D.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-23 00:00:00.000000000 Z
11
+ date: 2017-08-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This gem takes your ruby input, plus an object such as a Sequel::Model
14
14
  object, and generates HTML code. If the object has values, they're inserted into
@@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
48
  version: '0'
49
49
  requirements: []
50
50
  rubyforge_project:
51
- rubygems_version: 2.5.1
51
+ rubygems_version: 2.4.6
52
52
  signing_key:
53
53
  specification_version: 4
54
54
  summary: Yet another HTML generator.