red_cap 0.4.0 → 0.5.0

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: 23e77e89b7534b408882b97f3a0f2ef6481bd48d
4
- data.tar.gz: 100d5e1c4e9c069e6c8b8ffe4d51de9caad67015
3
+ metadata.gz: aa2bdc0735b838f2fd8f193c93c60b7e3cc365f5
4
+ data.tar.gz: 3b0e83dcace8e17baf0d367fe4ad8fdbf32ccece
5
5
  SHA512:
6
- metadata.gz: 3cea82c792788f6e28ddc5e67931fd2c8d3157bb54fef4adb8b4b0de2d9bce70eb07fe6e94c8fa8e360ebe4724f9950043ef00cf3c0ae3090191f00c7c58d20d
7
- data.tar.gz: cfe34f23aeb1e38667633f13b831556c423adc5b7b7b5512fd4f788d9fd20ba048b1d035c96b792c1c51d6072627312fa2f18f7df85697e357b0704c8607eedc
6
+ metadata.gz: 6c75397662f37a89705320130c0c4c6ce93226412d29afaaa05915c8fcd52a0a9e444a2cceadf5c3f4610aad53b156c90a0e85ee2515163b451915a59e22647c
7
+ data.tar.gz: 0ddac355f3b6757a9ed17df062a31fba45b575d1d12207da616623d58eee4c6345ecc6efe46f05f60caba29c72c952c1a13b019e6fd72d3aaa98a939fd145e16
@@ -51,7 +51,11 @@ module REDCap
51
51
  end
52
52
 
53
53
  class Text < Field; end
54
- class Notes < Field; end
54
+ class Notes < Text
55
+ def text?
56
+ true
57
+ end
58
+ end
55
59
  class Descriptive < Field; end
56
60
  class Dropdown < Field; end
57
61
  class Sql < Field; end
@@ -109,16 +113,20 @@ module REDCap
109
113
  class CheckboxesWithOther < Checkboxes
110
114
  def value
111
115
  selected_options.map do |key, value|
112
- if key == "501" # Other
113
- "#{value}: #{other_text_field&.value}"
116
+ if other?(key)
117
+ "#{value}: #{other_text_field(key).value}"
114
118
  else
115
119
  value
116
120
  end
117
121
  end
118
122
  end
119
123
 
120
- def other_text_field
121
- associated_fields_for_key("501").find(&:text?)
124
+ def other_text_field key
125
+ associated_fields_for_key(key).find(&:text?)
126
+ end
127
+
128
+ def other? key
129
+ other_text_field(key)
122
130
  end
123
131
  end
124
132
 
@@ -127,11 +135,15 @@ module REDCap
127
135
 
128
136
  class CheckboxesWithRadioButtonsOrOther < CheckboxesWithOther
129
137
  def value
130
- radio_values = selected_options.keys.map do |key|
131
- radio_field_for(key).value
138
+ radio_or_other_values = selected_options.keys.map do |key|
139
+ if other?(key)
140
+ other_text_field(key)&.value
141
+ else
142
+ radio_field_for(key)&.value
143
+ end
132
144
  end
133
145
 
134
- Hash[super.zip(radio_values)]
146
+ Hash[selected_options.values.zip(radio_or_other_values)]
135
147
  end
136
148
 
137
149
  private
@@ -150,7 +162,7 @@ module REDCap
150
162
  end
151
163
 
152
164
  if selected_options.keys.include?("501")
153
- right[-1] = [other_text_field&.value]
165
+ right[-1] = [other_text_field("501")&.value]
154
166
  end
155
167
 
156
168
  Hash[left.zip(right)]
@@ -1,3 +1,3 @@
1
1
  module REDCap
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red_cap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-02 00:00:00.000000000 Z
11
+ date: 2019-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday