smartdown 0.5.3 → 0.5.4

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.
@@ -35,7 +35,7 @@ module Smartdown
35
35
  transition = Transition.new(state, current_node, unprocessed_responses.shift(1))
36
36
  else
37
37
  answers = current_node.questions.map do |question|
38
- question.answer_type.new(question, unprocessed_responses.shift)
38
+ question.answer_type.new(unprocessed_responses.shift, question)
39
39
  end
40
40
 
41
41
  transition = Transition.new(state, current_node, answers)
@@ -17,9 +17,9 @@ module Smartdown
17
17
 
18
18
  attr_reader :question, :value
19
19
 
20
- def initialize(question, value)
21
- @question = question
20
+ def initialize(value, question=nil)
22
21
  @value = parse_value(value)
22
+ @question = question
23
23
  end
24
24
 
25
25
  private
@@ -1,3 +1,3 @@
1
1
  module Smartdown
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
@@ -4,6 +4,7 @@ require 'smartdown/model/answer/money'
4
4
  require 'smartdown/engine/interpolator'
5
5
  require 'smartdown/engine/state'
6
6
  require 'parslet'
7
+ require 'date'
7
8
 
8
9
  describe Smartdown::Engine::Interpolator do
9
10
  subject(:interpolator) { described_class.new }
@@ -116,7 +117,7 @@ describe Smartdown::Engine::Interpolator do
116
117
  let(:state) {
117
118
  Smartdown::Engine::State.new(
118
119
  current_node: node.name,
119
- date_answer: Smartdown::Model::Answer::Date.new("date_question", "2014-1-1")
120
+ date_answer: Smartdown::Model::Answer::Date.new("2014-1-1")
120
121
  )
121
122
  }
122
123
  it "interpolates the result of the function call" do
@@ -129,7 +130,7 @@ describe Smartdown::Engine::Interpolator do
129
130
  let(:state) {
130
131
  Smartdown::Engine::State.new(
131
132
  current_node: node.name,
132
- money_answer: Smartdown::Model::Answer::Money.new("money_answer", 12.32523)
133
+ money_answer: Smartdown::Model::Answer::Money.new(12.32523)
133
134
  )
134
135
  }
135
136
  it "interpolates the result of the function call" do
@@ -4,7 +4,7 @@ describe Smartdown::Model::Answer::Base do
4
4
  let(:question) { :a_question }
5
5
  let(:value) { 'a value' }
6
6
 
7
- subject(:instance) {Smartdown::Model::Answer::Base.new(question, value)}
7
+ subject(:instance) {Smartdown::Model::Answer::Base.new(value, question)}
8
8
 
9
9
  specify { expect(instance.question).to eql question }
10
10
 
@@ -4,7 +4,7 @@ require 'smartdown/model/element/question/date'
4
4
  describe Smartdown::Model::Answer::Date do
5
5
  let(:date_string) { "2014-9-4" }
6
6
  let(:question) { Smartdown::Model::Element::Question::Date.new("a_date") }
7
- subject(:instance) { described_class.new(question, date_string) }
7
+ subject(:instance) { described_class.new(date_string, question) }
8
8
 
9
9
  specify { expect(instance.value).to eql Date.new(2014, 9, 4) }
10
10
  specify { expect(instance.to_s).to eql "2014-9-4" }
@@ -59,23 +59,23 @@ describe Smartdown::Model::Answer::Date do
59
59
  end
60
60
 
61
61
  context "comparing against Answer::Dates" do
62
- specify { expect(instance == described_class.new(nil, "2000-1-10")).to eql true }
62
+ specify { expect(instance == described_class.new("2000-1-10")).to eql true }
63
63
 
64
- specify { expect(instance < described_class.new(nil, "2000-1-11")).to eql true }
65
- specify { expect(instance < described_class.new(nil, "2000-1-10")).to eql false }
66
- specify { expect(instance < described_class.new(nil, "2000-1-9")).to eql false }
64
+ specify { expect(instance < described_class.new("2000-1-11")).to eql true }
65
+ specify { expect(instance < described_class.new("2000-1-10")).to eql false }
66
+ specify { expect(instance < described_class.new("2000-1-9")).to eql false }
67
67
 
68
- specify { expect(instance > described_class.new(nil, "2000-1-11")).to eql false }
69
- specify { expect(instance > described_class.new(nil, "2000-1-10")).to eql false }
70
- specify { expect(instance > described_class.new(nil, "2000-1-9")).to eql true }
68
+ specify { expect(instance > described_class.new("2000-1-11")).to eql false }
69
+ specify { expect(instance > described_class.new("2000-1-10")).to eql false }
70
+ specify { expect(instance > described_class.new("2000-1-9")).to eql true }
71
71
 
72
- specify { expect(instance <= described_class.new(nil, "2000-1-11")).to eql true }
73
- specify { expect(instance <= described_class.new(nil, "2000-1-10")).to eql true }
74
- specify { expect(instance <= described_class.new(nil, "2000-1-9")).to eql false }
72
+ specify { expect(instance <= described_class.new("2000-1-11")).to eql true }
73
+ specify { expect(instance <= described_class.new("2000-1-10")).to eql true }
74
+ specify { expect(instance <= described_class.new("2000-1-9")).to eql false }
75
75
 
76
- specify { expect(instance >= described_class.new(nil, "2000-1-11")).to eql false }
77
- specify { expect(instance >= described_class.new(nil, "2000-1-10")).to eql true }
78
- specify { expect(instance >= described_class.new(nil, "2000-1-9")).to eql true }
76
+ specify { expect(instance >= described_class.new("2000-1-11")).to eql false }
77
+ specify { expect(instance >= described_class.new("2000-1-10")).to eql true }
78
+ specify { expect(instance >= described_class.new("2000-1-9")).to eql true }
79
79
  end
80
80
  end
81
81
  end
@@ -4,7 +4,7 @@ require 'smartdown/model/answer/money'
4
4
  describe Smartdown::Model::Answer::Money do
5
5
 
6
6
  let(:money_float) { 523.42 }
7
- subject(:instance) { described_class.new(nil, money_float) }
7
+ subject(:instance) { described_class.new(money_float) }
8
8
 
9
9
  describe "#humanize" do
10
10
  it "specifies money in the correct format" do
@@ -4,7 +4,7 @@ require 'smartdown/model/element/question/date'
4
4
  describe Smartdown::Model::Answer::Salary do
5
5
  let(:salary_string) { "500-week" }
6
6
  let(:question) { Smartdown::Model::Element::Question::Date.new("a_date") }
7
- subject(:instance) { described_class.new(question, salary_string) }
7
+ subject(:instance) { described_class.new(salary_string, question) }
8
8
 
9
9
  specify { expect(instance.period).to eql('week') }
10
10
  specify { expect(instance.amount_per_period).to eql(500.00) }
@@ -76,23 +76,23 @@ describe Smartdown::Model::Answer::Salary do
76
76
  end
77
77
 
78
78
  context "comparing against Answer::Salaries" do
79
- specify { expect(instance == described_class.new(nil, "1200-week")).to eql true }
79
+ specify { expect(instance == described_class.new("1200-week")).to eql true }
80
80
 
81
- specify { expect(instance < described_class.new(nil, "1200.1-week")).to eql true }
82
- specify { expect(instance < described_class.new(nil, "1200.0-week")).to eql false }
83
- specify { expect(instance < described_class.new(nil, "1199.9-week")).to eql false }
81
+ specify { expect(instance < described_class.new("1200.1-week")).to eql true }
82
+ specify { expect(instance < described_class.new("1200.0-week")).to eql false }
83
+ specify { expect(instance < described_class.new("1199.9-week")).to eql false }
84
84
 
85
- specify { expect(instance > described_class.new(nil, "1200.1-week")).to eql false }
86
- specify { expect(instance > described_class.new(nil, "1200.0-week")).to eql false }
87
- specify { expect(instance > described_class.new(nil, "1199.9-week")).to eql true }
85
+ specify { expect(instance > described_class.new("1200.1-week")).to eql false }
86
+ specify { expect(instance > described_class.new("1200.0-week")).to eql false }
87
+ specify { expect(instance > described_class.new("1199.9-week")).to eql true }
88
88
 
89
- specify { expect(instance <= described_class.new(nil, "1200.1-week")).to eql true }
90
- specify { expect(instance <= described_class.new(nil, "1200.0-week")).to eql true }
91
- specify { expect(instance <= described_class.new(nil, "1199.9-week")).to eql false }
89
+ specify { expect(instance <= described_class.new("1200.1-week")).to eql true }
90
+ specify { expect(instance <= described_class.new("1200.0-week")).to eql true }
91
+ specify { expect(instance <= described_class.new("1199.9-week")).to eql false }
92
92
 
93
- specify { expect(instance >= described_class.new(nil, "1200.1-week")).to eql false }
94
- specify { expect(instance >= described_class.new(nil, "1200.0-week")).to eql true }
95
- specify { expect(instance >= described_class.new(nil, "1199.9-week")).to eql true }
93
+ specify { expect(instance >= described_class.new("1200.1-week")).to eql false }
94
+ specify { expect(instance >= described_class.new("1200.0-week")).to eql true }
95
+ specify { expect(instance >= described_class.new("1199.9-week")).to eql true }
96
96
  end
97
97
  end
98
98
  end
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.5.3
4
+ version: 0.5.4
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: &18591420 !ruby/object:Gem::Requirement
16
+ requirement: &10346540 !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: *18591420
24
+ version_requirements: *10346540
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &18589340 !ruby/object:Gem::Requirement
27
+ requirement: &10344500 !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: *18589340
35
+ version_requirements: *10344500
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &18612100 !ruby/object:Gem::Requirement
38
+ requirement: &10342380 !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: *18612100
46
+ version_requirements: *10342380
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: gem_publisher
49
- requirement: &18611440 !ruby/object:Gem::Requirement
49
+ requirement: &10366360 !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: *18611440
57
+ version_requirements: *10366360
58
58
  description:
59
59
  email: david.heath@digital.cabinet-office.gov.uk
60
60
  executables:
@@ -212,7 +212,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
212
212
  version: '0'
213
213
  segments:
214
214
  - 0
215
- hash: -2081171920268489084
215
+ hash: 1694965112533004237
216
216
  required_rubygems_version: !ruby/object:Gem::Requirement
217
217
  none: false
218
218
  requirements:
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
221
  version: '0'
222
222
  segments:
223
223
  - 0
224
- hash: -2081171920268489084
224
+ hash: 1694965112533004237
225
225
  requirements: []
226
226
  rubyforge_project:
227
227
  rubygems_version: 1.8.11