doop 0.0.1 → 0.0.2

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDZjODg0NTdlY2FkODllYmE3YzhhMmJkYzhjNGFhOTUyZDAxYWJhMg==
4
+ ZTllNmZkNDU1YzY3ODNlY2QyYWM4YjVkNmMzYmJiY2I4MzFjM2I1NQ==
5
5
  data.tar.gz: !binary |-
6
- MmI1MGNlMWVmNWQ0NTBiMDYzMjVlMzJhYzRhMmNhNWE5NDQ5MWQxNQ==
6
+ ZjY5ZjhhYzY3MjQ0NzhhMzgyYzNmZTA1OTkzYjU0ZDkzNTE3YmUzMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWI3Y2UwYmUzNjhhNGI0YjU5ZTk2YmZiMTBhMDhlY2U2Nzk1Y2I2ZWNiNzY5
10
- ZjA4OTNkNmI0YWNjMmIzMzIyZWNiMGFjZjE5OTlmMjJmZTZmMzYxMmZlODhl
11
- ZTljMGRiODdkMDM2YWM5YjY1NmJiNjY1NzJhM2ZmYTQwNTI0N2I=
9
+ ZWMyNzg0MjliNmNkOWQyNDEzNWUyMTEzMjliMGZkOTUzMzBjNmU0NjQyMDg1
10
+ NDUwMDJmOWIzYzUyOTFjZGM2YmRmZmIxZjAxNmQ5ZDg1ZWMzY2U5ZDgxOTNm
11
+ OTE2OTM3NzNjODg4YjBmMmZmMDEwOWRlMDczN2IwNGFmOWQ1MzM=
12
12
  data.tar.gz: !binary |-
13
- YmI5M2ViZDkzYjYyNzAwYmFlNjQzMmFjZGJkMTdjZmI5YzBiNmUwZGQzZDBi
14
- YmE4ZGQyNjQ2M2RkMjg1ZjdkZWYyZmEyMTQzMmIxYTFmMTZhN2M0YmE2MTIz
15
- NjQyYjkwNTI0MTllOWYxY2U1NmNmZmY2NzU3MGVhY2JhYmU1ZmE=
13
+ ZTU3YjUwNDllYjljMTk0ZjhmMDUyZTcxZjcxNzYxZGNhODE3MDY1MTVkN2Nj
14
+ YmE5YzI2OGQ4MGIyZTk4MzExODg1OWMwNjk0ZmE5MzU0YmU4MTFlZjgxOGRl
15
+ ODc3NzQ4MjgxYTVkYmVjMWJkMDk1ZmUzZTIzYzU3ZDE1YWM3NDM=
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
  *.a
14
14
  mkmf.log
15
15
  *.swp
16
+ doop_demo/
@@ -0,0 +1,3 @@
1
+ [submodule "doop_demo"]
2
+ path = doop_demo
3
+ url = git://github.com/coder36/doop_demo.git
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  A question framework for govuk sites, inspired by the great work GDS have done to standardize the cross government internet presence.
4
4
 
5
+ Try out a demo... it's hosted on heroku so there may be a initial pause while heroku fires up the demo:
6
+
7
+ ## [Doopgovuk demo](http://blooming-wave-8670.herokuapp.com)
8
+
5
9
  # Quick start
6
10
 
7
11
  Assuming ruby, rails and nodejs is installed:
@@ -192,6 +196,7 @@ Don't forget to deal with database drivers. In your Gemfile, you will need to u
192
196
 
193
197
  * Refactor - make the code, simpler and read better
194
198
  * Doop-Rspec - it would be nice to have a DSL to drive answering questions. This could be extended to capybara.
199
+ * Responsive - on the whole the govuk frontend is responsive, fonts resize etc. But there is still some work to be done.
195
200
 
196
201
 
197
202
  ## Contributing
@@ -48,4 +48,28 @@ module DoopHelper
48
48
  l.keys.sort.each { |k| block.call( l[k], k.to_i ) }
49
49
  end
50
50
 
51
+ def when_question options = {}, &block
52
+ doop = request[:doop]
53
+ if options.include? :last_answered
54
+ path = options[:last_answered]
55
+ if doop.last_answered == path
56
+ block.call doop[path]["_answer"]
57
+ end
58
+ elsif options.include? :changed
59
+ path = options[:changed]
60
+ if doop.is_being_changed(path)
61
+ block.call doop[path]["_answer"]
62
+ end
63
+ end
64
+ end
65
+
66
+ def tooltip &block
67
+ render( "doop/tooltip", :content => block )
68
+ end
69
+
70
+ def change_answer_tooltip &block
71
+ render( "doop/change_answer_tooltip", :content => block )
72
+ end
73
+
74
+
51
75
  end
File without changes
@@ -2,6 +2,18 @@
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'doop/version'
5
+ require 'fileutils'
6
+
7
+ # Copy files for rails doopgovuk template:
8
+ if !Dir['doop_demo/*'].empty?
9
+ dest = "lib/generators/doopgovuk/templates"
10
+ FileUtils.cp "doop_demo/app/assets/stylesheets/demo.css.scss", "#{dest}/app/assets/stylesheets/demo.css.scss"
11
+ FileUtils.cp "doop_demo/app/assets/javascripts/demo.js.coffee", "#{dest}/app/assets/javascripts/demo.js.coffee"
12
+ FileUtils.cp "doop_demo/app/controllers/demo_controller.rb", "#{dest}/app/controllers/demo_controller.rb"
13
+ FileUtils.cp "doop_demo/app/views/layouts/application.html.erb", "#{dest}/app/views/layouts/application.html.erb"
14
+ FileUtils.cp_r "doop_demo/app/views/doop", "#{dest}/app/views"
15
+ FileUtils.cp_r "doop_demo/app/views/demo", "#{dest}/app/views"
16
+ end
5
17
 
6
18
  Gem::Specification.new do |spec|
7
19
  spec.name = "doop"
@@ -9,7 +21,7 @@ Gem::Specification.new do |spec|
9
21
  spec.authors = ["Mark Middleton"]
10
22
  spec.email = ["markymiddleton@gmail.com"]
11
23
  spec.summary = %q{Question framework for govuk websites.}
12
- spec.description = %q{A question framework for govuk sites, inspired by the great work GDS have done to standardize the cross government internet presence.}
24
+ spec.description = %q{A question framework for govuk sites, inspired by the work GDS have done to standardize the cross government internet presence.}
13
25
  spec.homepage = "https://github.com/coder36/doop"
14
26
  spec.license = "MIT"
15
27
 
@@ -24,3 +36,4 @@ Gem::Specification.new do |spec|
24
36
 
25
37
  spec.add_runtime_dependency "rails"
26
38
  end
39
+
@@ -43,10 +43,12 @@ module Doop
43
43
  end
44
44
 
45
45
  def default_on_answer( root, path, context, answer )
46
+
46
47
  self[path + "/_answer"] = context["answer"] if context["answer"] != nil
47
48
  self[path + "/_summary"] = context["summary"] if context["summary"] != nil
48
49
  self[path + "/_answered"] = true
49
50
  self[path + "/_open"] = false
51
+ get_top["_last_answered"] = root["_path"]
50
52
  {}
51
53
  end
52
54
 
@@ -144,6 +146,7 @@ module Doop
144
146
  root["_enabled"] = true if !root.has_key?("_enabled")
145
147
  root["_answered"] = false if !root.has_key?("_answered")
146
148
  root["_answer"] = nil if !root.has_key?("_answer")
149
+ root["_path"] = path
147
150
  end
148
151
  end
149
152
 
@@ -246,6 +249,7 @@ module Doop
246
249
  end
247
250
 
248
251
  def change path
252
+ get_top["_last_answered"] = nil
249
253
  each_path_elem_reverse(currently_asked) do |p|
250
254
  self[p + "/_open"] = false
251
255
  end
@@ -268,12 +272,14 @@ module Doop
268
272
  self[path]["_answer"] = a
269
273
  self[path]["_answered"] = true
270
274
  self[path]["_summary"] = summary == nil ? a : summary
275
+ get_top["_last_answered"] = root["_path"]
271
276
  {}
272
277
  end
273
278
 
274
279
  def answer_with root, hash
275
280
  root["_answered"] = true
276
281
  hash.keys.each { |k| root[k] = hash[k] }
282
+ get_top["_last_answered"] = root["_path"]
277
283
  end
278
284
 
279
285
  def unanswer_path path
@@ -307,6 +313,19 @@ module Doop
307
313
  end
308
314
  end
309
315
 
316
+ def get_top
317
+ @hash[@hash.first[0]]
318
+ end
319
+
320
+ def last_answered
321
+ get_top[ "_last_answered"]
322
+ end
323
+
324
+ def is_being_changed path
325
+ question = self[path]
326
+ question[ "_enabled" ] && question[ "_answered" ] && question[ "_open" ]
327
+ end
328
+
310
329
 
311
330
  end
312
331
 
@@ -1,3 +1,3 @@
1
1
  module Doop
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -5,18 +5,12 @@ class DoopgovukGenerator < Rails::Generators::Base
5
5
 
6
6
  def generate_layout
7
7
  copy_file "app/assets/stylesheets/demo.css.scss", "app/assets/stylesheets/#{name}.css.scss"
8
+ copy_file "app/assets/javascripts/demo.js.coffee", "app/assets/javascripts/#{name}.js.coffee"
8
9
  template "app/controllers/demo_controller.rb", "app/controllers/#{name}_controller.rb"
9
- copy_file "app/views/demo/index.html.erb", "app/views/#{name}/index.html.erb"
10
- copy_file "app/views/demo/index.js.erb", "app/views/#{name}/index.js.erb"
11
- copy_file "app/views/demo/_preamble.html.erb", "app/views/#{name}/_preamble.html.erb"
12
- copy_file "app/views/demo/_summary.html.erb", "app/views/#{name}/_summary.html.erb"
13
- copy_file "app/views/demo/_your_details.html.erb", "app/views/#{name}/_your_details.html.erb"
14
10
  copy_file "app/views/layouts/application.html.erb", "app/views/layouts/application.html.erb"
15
- copy_file "app/views/doop/_error.html.erb", "app/views/doop/_error.html.erb"
16
- copy_file "app/views/doop/_info_box.html.erb", "app/views/doop/_info_box.html.erb"
17
- copy_file "app/views/doop/_navbar.html.erb", "app/views/doop/_navbar.html.erb"
18
- copy_file "app/views/doop/_question_form.html.erb", "app/views/doop/_question_form.html.erb"
19
- copy_file "app/views/doop/_question.html.erb", "app/views/doop/_question.html.erb"
11
+ directory "app/views/doop"
12
+ directory "app/views/demo", "app/views/#{name}"
13
+ gsub_file "app/controllers/#{name}_controller.rb", /DemoController/, "#{name.capitalize}Controller"
20
14
 
21
15
 
22
16
  route "root '#{name}#index'"
@@ -0,0 +1,9 @@
1
+ $( () ->
2
+ history.pushState("back", null, null);
3
+ if typeof history.pushState == "function"
4
+ history.pushState("back", null, null);
5
+ window.onpopstate = (evt) ->
6
+ history.pushState('back', null, null);
7
+ $( "#back_a_page" ).val( "pressed" )
8
+ $( "#back_a_page" ).click()
9
+ )
@@ -157,32 +157,91 @@ button {
157
157
 
158
158
  .navbar {
159
159
 
160
- border-width: 0 0 1px 0;
161
- border-style: dotted;
162
- border-color: #bfc1c3;
163
-
164
- ol {
165
- list-style-type: none;
166
- margin: 0;
167
- padding: 10px;
168
- text-align: center;
160
+
161
+ @include media($min-width: 500px) {
162
+
163
+ border-width: 0 0 1px 0;
164
+ border-style: dotted;
165
+ border-color: #bfc1c3;
166
+
167
+ ol {
168
+ list-style-type: none;
169
+ margin: 0;
170
+ padding: 10px;
171
+ text-align: center;
172
+ }
173
+ li.todo {
174
+ display: inline;
175
+ margin: 0 30px 0 0;
176
+ @include core-16();
177
+ }
178
+
179
+ li.doing {
180
+ display: inline;
181
+ margin: 0 30px 0 0;
182
+ @include bold-16();
183
+ }
184
+
185
+ li.done {
186
+ display: inline;
187
+ margin: 0 30px 0 0;
188
+ @include core-16();
189
+ }
169
190
  }
170
- li.todo {
171
- display: inline;
172
- margin: 0 30px 0 0;
173
- @include core-16();
191
+
192
+ @include media($max-width: 500px) {
193
+
194
+ ol {
195
+ list-style-type: none;
196
+ text-align: left;
197
+ padding: 0;
198
+ }
199
+ li.todo {
200
+ @include core-16();
201
+ padding: 6px 0 0 0;
202
+ }
203
+
204
+ li.doing {
205
+ @include bold-16();
206
+ padding: 6px 0 0 0;
207
+ }
208
+
209
+ li.done {
210
+ @include core-16();
211
+ padding: 6px 0 0 0;
212
+ }
174
213
  }
214
+ }
175
215
 
176
- li.doing {
177
- display: inline;
178
- margin: 0 30px 0 0;
179
- @include bold-16();
216
+
217
+ .tooltip {
218
+ border: 1px solid #666;
219
+ color: #000;
220
+ box-shadow: 0 0 7px #ccc;
221
+ border-radius: 0.75em;
222
+ background-color: #FFF3CE;
223
+ p {
224
+ margin: 10px;
225
+ }
226
+ @include media($max-width: 700px) {
227
+ width: 100%;
228
+ margin: 4px 0 20px 0;
229
+ }
230
+ @include media($min-width: 700px) {
231
+ width: 700px;
232
+ margin: 4px 0 20px auto;
180
233
  }
181
234
 
182
- li.done {
183
- display: inline;
184
- margin: 0 30px 0 0;
185
- @include core-16();
235
+ }
236
+
237
+ .change_answer_tooltip {
238
+ border: 1px solid #F8C830;
239
+ background-color: #FFF4B5;
240
+ margin: 20px 0 0 0;
241
+ p {
242
+ margin: 10px;
186
243
  }
187
244
  }
188
245
 
246
+
247
+
@@ -2,7 +2,7 @@
2
2
  require 'doop'
3
3
  require 'yaml'
4
4
 
5
- class <%=name.capitalize%>Controller < ApplicationController
5
+ class DemoController < ApplicationController
6
6
 
7
7
  delegate :index, :answer, to: :@doop_controller
8
8
  before_filter :setup_doop
@@ -6,6 +6,20 @@
6
6
  <button name="b_answer" value="No">No, turn debugging off</button>
7
7
  <% end %>
8
8
 
9
+ <% when_question :last_answered => "/page/preamble/debug_on" do |answer|%>
10
+ <% if answer == "No" %>
11
+ <%=tooltip do %>
12
+ <p><strong>Are you sure ?</strong></p>
13
+ <p>By selecting no, you will not be able to see the yaml which doop generates behind the scenes</p>
14
+ <% end %>
15
+ <% end %>
16
+ <% end %>
17
+
18
+ <% when_question :changed => "/page/preamble/enrolled_before" do |current_answer| %>
19
+ <%=change_answer_tooltip do %>
20
+ <p>If you change this answer, additional questions may be asked</p>
21
+ <% end %>
22
+ <% end %>
9
23
  <%=question "/page/preamble/enrolled_before" do |root,answer| %>
10
24
  <button name="b_answer" value="Yes">Yes, I've applied before</button><br/>
11
25
  <button name="b_answer" value="No">No, I haven't applied before</button>
@@ -0,0 +1,3 @@
1
+ <div class="change_answer_tooltip">
2
+ <% content.call %>
3
+ </div>
@@ -0,0 +1,3 @@
1
+ <div class="tooltip">
2
+ <% content.call %>
3
+ </div>
@@ -160,6 +160,16 @@ describe "Doop" do
160
160
  q
161
161
  }
162
162
 
163
+ it "remembers that last question to be answered" do
164
+ expect(question.currently_asked).to eq( "/root/age" )
165
+ question.answer( { "answer" => 36 } )
166
+ expect(question.last_answered).to eq( "/root/age" )
167
+ expect(question.currently_asked).to eq( "/root/address/address_line__1" )
168
+ question.answer( { "answer" => "address1" } )
169
+ expect(question.last_answered).to eq( "/root/address/address_line__1" )
170
+
171
+ end
172
+
163
173
  it "gets the next unaswered question" do
164
174
  expect(question.currently_asked).to eq( "/root/age" )
165
175
  end
@@ -214,6 +224,15 @@ describe "Doop" do
214
224
  expect(question.currently_asked).to eq( "/root/address/address_line__3" )
215
225
  end
216
226
 
227
+ it "tells you if a question is being changed rather than just answered for the first time" do
228
+ expect(question.currently_asked).to eq( "/root/age" )
229
+ expect( question.is_being_changed("/root/age") ).to eq(false)
230
+ question.answer( {"answer" => 36} )
231
+ question.change( "/root/age" )
232
+ expect( question.is_being_changed("/root/age") ).to eq(true)
233
+
234
+ end
235
+
217
236
  it "provides a mechanism to see if all questions are answered under a given path" do
218
237
 
219
238
  expect(question.currently_asked).to eq( "/root/age" )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Middleton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-17 00:00:00.000000000 Z
11
+ date: 2014-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,8 +66,8 @@ dependencies:
66
66
  - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: A question framework for govuk sites, inspired by the great work GDS
70
- have done to standardize the cross government internet presence.
69
+ description: A question framework for govuk sites, inspired by the work GDS have done
70
+ to standardize the cross government internet presence.
71
71
  email:
72
72
  - markymiddleton@gmail.com
73
73
  executables:
@@ -76,6 +76,7 @@ extensions: []
76
76
  extra_rdoc_files: []
77
77
  files:
78
78
  - .gitignore
79
+ - .gitmodules
79
80
  - Gemfile
80
81
  - LICENSE.txt
81
82
  - README.md
@@ -91,6 +92,7 @@ files:
91
92
  - lib/doop_controller.rb
92
93
  - lib/generators/doopgovuk/USAGE
93
94
  - lib/generators/doopgovuk/doopgovuk_generator.rb
95
+ - lib/generators/doopgovuk/templates/app/assets/javascripts/demo.js.coffee
94
96
  - lib/generators/doopgovuk/templates/app/assets/stylesheets/demo.css.scss
95
97
  - lib/generators/doopgovuk/templates/app/controllers/demo_controller.rb
96
98
  - lib/generators/doopgovuk/templates/app/views/demo/_preamble.html.erb
@@ -98,11 +100,13 @@ files:
98
100
  - lib/generators/doopgovuk/templates/app/views/demo/_your_details.html.erb
99
101
  - lib/generators/doopgovuk/templates/app/views/demo/index.html.erb
100
102
  - lib/generators/doopgovuk/templates/app/views/demo/index.js.erb
103
+ - lib/generators/doopgovuk/templates/app/views/doop/_change_answer_tooltip.html.erb
101
104
  - lib/generators/doopgovuk/templates/app/views/doop/_error.html.erb
102
105
  - lib/generators/doopgovuk/templates/app/views/doop/_info_box.html.erb
103
106
  - lib/generators/doopgovuk/templates/app/views/doop/_navbar.html.erb
104
107
  - lib/generators/doopgovuk/templates/app/views/doop/_question.html.erb
105
108
  - lib/generators/doopgovuk/templates/app/views/doop/_question_form.html.erb
109
+ - lib/generators/doopgovuk/templates/app/views/doop/_tooltip.html.erb
106
110
  - lib/generators/doopgovuk/templates/app/views/layouts/application.html.erb
107
111
  - spec/doop_spec.rb
108
112
  - spec/spec_helper.rb