smartdown 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/lib/smartdown/api/previous_question.rb +2 -0
- data/lib/smartdown/api/question_page.rb +3 -0
- data/lib/smartdown/api/text_question.rb +8 -0
- data/lib/smartdown/model/answer/text.rb +13 -0
- data/lib/smartdown/model/element/question/text.rb +15 -0
- data/lib/smartdown/parser/element/text_question.rb +22 -0
- data/lib/smartdown/parser/node_parser.rb +2 -0
- data/lib/smartdown/parser/node_transform.rb +7 -0
- data/lib/smartdown/version.rb +1 -1
- data/spec/model/answer/text_spec.rb +6 -0
- data/spec/parser/element/text_question_spec.rb +28 -0
- data/spec/support/model_builder.rb +1 -0
- metadata +19 -11
data/README.md
CHANGED
@@ -15,6 +15,8 @@ module Smartdown
|
|
15
15
|
@question = DateQuestion.new(elements)
|
16
16
|
elsif elements.find{|element| element.is_a? Smartdown::Model::Element::Question::Salary}
|
17
17
|
@question = SalaryQuestion.new(elements)
|
18
|
+
elsif elements.find{|element| element.is_a? Smartdown::Model::Element::Question::Text}
|
19
|
+
@question = TextQuestion.new(elements)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'smartdown/api/multiple_choice'
|
2
2
|
require 'smartdown/api/date_question'
|
3
3
|
require 'smartdown/api/salary_question'
|
4
|
+
require 'smartdown/api/text_question'
|
4
5
|
|
5
6
|
module Smartdown
|
6
7
|
module Api
|
@@ -15,6 +16,8 @@ module Smartdown
|
|
15
16
|
Smartdown::Api::DateQuestion.new(question_element_group)
|
16
17
|
elsif question_element_group.find{|element| element.is_a? Smartdown::Model::Element::Question::Salary}
|
17
18
|
Smartdown::Api::SalaryQuestion.new(question_element_group)
|
19
|
+
elsif question_element_group.find{|element| element.is_a? Smartdown::Model::Element::Question::Text}
|
20
|
+
Smartdown::Api::TextQuestion.new(question_element_group)
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'smartdown/parser/base'
|
2
|
+
|
3
|
+
module Smartdown
|
4
|
+
module Parser
|
5
|
+
module Element
|
6
|
+
class TextQuestion < Base
|
7
|
+
rule(:text_question) {
|
8
|
+
(
|
9
|
+
str("[text:") >>
|
10
|
+
optional_space >>
|
11
|
+
question_identifier.as(:identifier) >>
|
12
|
+
optional_space >>
|
13
|
+
str("]") >>
|
14
|
+
optional_space >>
|
15
|
+
line_ending
|
16
|
+
).as(:text)
|
17
|
+
}
|
18
|
+
root(:text_question)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -5,6 +5,7 @@ require 'smartdown/parser/element/start_button'
|
|
5
5
|
require 'smartdown/parser/element/multiple_choice_question'
|
6
6
|
require 'smartdown/parser/element/date_question'
|
7
7
|
require 'smartdown/parser/element/salary_question'
|
8
|
+
require 'smartdown/parser/element/text_question'
|
8
9
|
require 'smartdown/parser/element/markdown_heading'
|
9
10
|
require 'smartdown/parser/element/markdown_paragraph'
|
10
11
|
require 'smartdown/parser/element/conditional'
|
@@ -19,6 +20,7 @@ module Smartdown
|
|
19
20
|
Element::MultipleChoiceQuestion.new |
|
20
21
|
Element::DateQuestion.new |
|
21
22
|
Element::SalaryQuestion.new |
|
23
|
+
Element::TextQuestion.new |
|
22
24
|
Rules.new |
|
23
25
|
Element::StartButton.new |
|
24
26
|
Element::NextSteps.new |
|
@@ -7,6 +7,7 @@ require 'smartdown/model/next_node_rules'
|
|
7
7
|
require 'smartdown/model/element/question/multiple_choice'
|
8
8
|
require 'smartdown/model/element/question/date'
|
9
9
|
require 'smartdown/model/element/question/salary'
|
10
|
+
require 'smartdown/model/element/question/text'
|
10
11
|
require 'smartdown/model/element/start_button'
|
11
12
|
require 'smartdown/model/element/markdown_heading'
|
12
13
|
require 'smartdown/model/element/markdown_paragraph'
|
@@ -81,6 +82,12 @@ module Smartdown
|
|
81
82
|
)
|
82
83
|
}
|
83
84
|
|
85
|
+
rule(:text => {identifier: simple(:identifier)}) {
|
86
|
+
Smartdown::Model::Element::Question::Text.new(
|
87
|
+
identifier.to_s
|
88
|
+
)
|
89
|
+
}
|
90
|
+
|
84
91
|
rule(:next_steps => { content: simple(:content) }) {
|
85
92
|
Smartdown::Model::Element::NextSteps.new(content.to_s)
|
86
93
|
}
|
data/lib/smartdown/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'smartdown/parser/node_parser'
|
2
|
+
require 'smartdown/parser/node_interpreter'
|
3
|
+
require 'smartdown/parser/element/text_question'
|
4
|
+
|
5
|
+
describe Smartdown::Parser::Element::TextQuestion do
|
6
|
+
subject(:parser) { described_class.new }
|
7
|
+
|
8
|
+
context "with question tag" do
|
9
|
+
let(:source) { "[text: hometown]" }
|
10
|
+
|
11
|
+
it "parses" do
|
12
|
+
should parse(source).as(
|
13
|
+
text: {
|
14
|
+
identifier: "hometown",
|
15
|
+
}
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "transformed" do
|
20
|
+
let(:node_name) { "my_node" }
|
21
|
+
subject(:transformed) {
|
22
|
+
Smartdown::Parser::NodeInterpreter.new(node_name, source, parser: parser).interpret
|
23
|
+
}
|
24
|
+
|
25
|
+
it { should eq(Smartdown::Model::Element::Question::Text.new("hometown")) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -6,6 +6,7 @@ require 'smartdown/model/element/start_button'
|
|
6
6
|
require 'smartdown/model/element/question/multiple_choice'
|
7
7
|
require 'smartdown/model/element/question/date'
|
8
8
|
require 'smartdown/model/element/question/salary'
|
9
|
+
require 'smartdown/model/element/question/text'
|
9
10
|
require 'smartdown/model/element/conditional'
|
10
11
|
require 'smartdown/model/next_node_rules'
|
11
12
|
require 'smartdown/model/rule'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2014-07-09 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parslet
|
16
|
-
requirement: &
|
16
|
+
requirement: &18240820 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.6.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *18240820
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &18238780 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *18238780
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &18237320 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *18237320
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: gem_publisher
|
49
|
-
requirement: &
|
49
|
+
requirement: &18235860 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *18235860
|
58
58
|
description:
|
59
59
|
email: david.heath@digital.cabinet-office.gov.uk
|
60
60
|
executables:
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- lib/smartdown/parser/element/multiple_choice_question.rb
|
83
83
|
- lib/smartdown/parser/element/next_steps.rb
|
84
84
|
- lib/smartdown/parser/element/markdown_heading.rb
|
85
|
+
- lib/smartdown/parser/element/text_question.rb
|
85
86
|
- lib/smartdown/parser/flow_interpreter.rb
|
86
87
|
- lib/smartdown/api/date_question.rb
|
87
88
|
- lib/smartdown/api/coversheet.rb
|
@@ -95,6 +96,7 @@ files:
|
|
95
96
|
- lib/smartdown/api/previous_question.rb
|
96
97
|
- lib/smartdown/api/outcome.rb
|
97
98
|
- lib/smartdown/api/multiple_choice.rb
|
99
|
+
- lib/smartdown/api/text_question.rb
|
98
100
|
- lib/smartdown/api/previous_question_page.rb
|
99
101
|
- lib/smartdown/version.rb
|
100
102
|
- lib/smartdown/engine/node_presenter.rb
|
@@ -122,6 +124,7 @@ files:
|
|
122
124
|
- lib/smartdown/model/answer/salary.rb
|
123
125
|
- lib/smartdown/model/answer/money.rb
|
124
126
|
- lib/smartdown/model/answer/multiple_choice.rb
|
127
|
+
- lib/smartdown/model/answer/text.rb
|
125
128
|
- lib/smartdown/model/element/conditional.rb
|
126
129
|
- lib/smartdown/model/element/markdown_paragraph.rb
|
127
130
|
- lib/smartdown/model/element/start_button.rb
|
@@ -130,6 +133,7 @@ files:
|
|
130
133
|
- lib/smartdown/model/element/question/date.rb
|
131
134
|
- lib/smartdown/model/element/question/salary.rb
|
132
135
|
- lib/smartdown/model/element/question/multiple_choice.rb
|
136
|
+
- lib/smartdown/model/element/question/text.rb
|
133
137
|
- lib/smartdown/model/next_node_rules.rb
|
134
138
|
- lib/smartdown/model/nested_rule.rb
|
135
139
|
- lib/smartdown/model/rule.rb
|
@@ -153,6 +157,7 @@ files:
|
|
153
157
|
- spec/parser/element/markdown_heading_spec.rb
|
154
158
|
- spec/parser/element/front_matter_spec.rb
|
155
159
|
- spec/parser/element/salary_question_spec.rb
|
160
|
+
- spec/parser/element/text_question_spec.rb
|
156
161
|
- spec/parser/node_parser_spec.rb
|
157
162
|
- spec/parser/snippet_pre_parser_spec.rb
|
158
163
|
- spec/support/flow_input_interface.rb
|
@@ -188,6 +193,7 @@ files:
|
|
188
193
|
- spec/model/node_spec.rb
|
189
194
|
- spec/model/flow_spec.rb
|
190
195
|
- spec/model/answer/money_spec.rb
|
196
|
+
- spec/model/answer/text_spec.rb
|
191
197
|
- spec/model/answer/base_spec.rb
|
192
198
|
- spec/model/answer/salary_spec.rb
|
193
199
|
- spec/model/answer/date_spec.rb
|
@@ -212,7 +218,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
212
218
|
version: '0'
|
213
219
|
segments:
|
214
220
|
- 0
|
215
|
-
hash:
|
221
|
+
hash: -4119241983513724352
|
216
222
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
223
|
none: false
|
218
224
|
requirements:
|
@@ -221,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
227
|
version: '0'
|
222
228
|
segments:
|
223
229
|
- 0
|
224
|
-
hash:
|
230
|
+
hash: -4119241983513724352
|
225
231
|
requirements: []
|
226
232
|
rubyforge_project:
|
227
233
|
rubygems_version: 1.8.11
|
@@ -246,6 +252,7 @@ test_files:
|
|
246
252
|
- spec/parser/element/markdown_heading_spec.rb
|
247
253
|
- spec/parser/element/front_matter_spec.rb
|
248
254
|
- spec/parser/element/salary_question_spec.rb
|
255
|
+
- spec/parser/element/text_question_spec.rb
|
249
256
|
- spec/parser/node_parser_spec.rb
|
250
257
|
- spec/parser/snippet_pre_parser_spec.rb
|
251
258
|
- spec/support/flow_input_interface.rb
|
@@ -281,6 +288,7 @@ test_files:
|
|
281
288
|
- spec/model/node_spec.rb
|
282
289
|
- spec/model/flow_spec.rb
|
283
290
|
- spec/model/answer/money_spec.rb
|
291
|
+
- spec/model/answer/text_spec.rb
|
284
292
|
- spec/model/answer/base_spec.rb
|
285
293
|
- spec/model/answer/salary_spec.rb
|
286
294
|
- spec/model/answer/date_spec.rb
|