rails_voter 0.1.0 → 0.2.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: 2cdf2dab644d3921613e5a11d4525a0f63b08f22
4
- data.tar.gz: d5b0a6487b627b7baf10820855d6cacba596f655
3
+ metadata.gz: eb0425f8f46eab75a51471f41999797c15837cd7
4
+ data.tar.gz: 0ce17fda1b85257f5c508de675b9b7ca5769c264
5
5
  SHA512:
6
- metadata.gz: 4b03b5bf021633675bd766a500dfa3436b4881e57d8a082aeed2ae3f22b2f9f92f4b97cf58fb7a17577bf61548ee08dc620bc4fdc5aed9bc23c4f476676b176d
7
- data.tar.gz: 5c4c983b59ffa845a488db1d356dcb13c16ffe1daabdb784fb763b2e6e866bda44fe1f458c30828eaeb06d08971ba346e445c92ee455debd426c9b574e803e9b
6
+ metadata.gz: a1019cb937b134155afdff0ba551b14bb02f025110598eddf4419948d72e3b54e41824d98b9472b0ebae2bd1092dc654e54b4206c50a3c2fb2e9fde37878db21
7
+ data.tar.gz: 240204b970ea046c0d4111d04c2c006b898c8757ab2c18f888e1292b3b3246597d5652fec7213eca0556cbd38fed19db5464ccc7a3a7cc0ac0be01ebea9ba5c9
@@ -8,6 +8,8 @@ module RailsVoter
8
8
  expose :voting_result, -> { RailsVoter::VotingResult.new }
9
9
  expose :voting_result_show, -> { RailsVoter::VotingResult.show(params[:id]) }
10
10
 
11
+ before_action :render_layout_false, only: [:vote, :show_result]
12
+
11
13
  def new
12
14
  10.times do
13
15
  election.election_details.new
@@ -35,5 +37,9 @@ module RailsVoter
35
37
  def election_params
36
38
  params.require(:election).permit(:name, election_details_attributes: [:name, :id])
37
39
  end
40
+
41
+ def render_layout_false
42
+ render layout: false
43
+ end
38
44
  end
39
45
  end
@@ -6,6 +6,7 @@ module RailsVoter
6
6
 
7
7
  def create
8
8
  voting_result.save
9
+ render layout: false
9
10
  end
10
11
 
11
12
  private
@@ -1,4 +1,23 @@
1
1
  module RailsVoter
2
2
  module ApplicationHelper
3
+ def embed_ballot_form(id)
4
+ content_tag(:div, nil) do
5
+ content_tag(
6
+ :iframe,
7
+ nil,
8
+ src: rails_voter.vote_election_path(id),
9
+ )
10
+ end
11
+ end
12
+
13
+ def embed_voting_result(id)
14
+ content_tag(:div, nil) do
15
+ content_tag(
16
+ :iframe,
17
+ nil,
18
+ src: rails_voter.show_result_election_path(id),
19
+ )
20
+ end
21
+ end
3
22
  end
4
23
  end
@@ -1,6 +1,7 @@
1
1
  .navbar.navbar-default
2
2
  .container
3
- %button.navbar-toggle{ type: "button", 'data-toggle': "collapse", 'data-target': ".navbar-responsive-collapse" }
3
+ %button.navbar-toggle{ type: "button", 'data-toggle': "collapse",
4
+ 'data-target': ".navbar-responsive-collapse" }
4
5
  %span.icon-bar
5
6
  %span.icon-bar
6
7
  %span.icon-bar
@@ -7,15 +7,20 @@
7
7
  %title= content_for?(:title) ? yield(:title) : "Rails Voter"
8
8
  = csrf_meta_tags
9
9
  = stylesheet_link_tag "rails_voter/application", media: "all"
10
- = favicon_link_tag "apple-touch-icon-144x144-precomposed.png", rel: "apple-touch-icon-precomposed", type: "image/png", sizes: "144x144"
11
- = favicon_link_tag "apple-touch-icon-114x114-precomposed.png", rel: "apple-touch-icon-precomposed", type: "image/png", sizes: "114x114"
12
- = favicon_link_tag "apple-touch-icon-72x72-precomposed.png", rel: "apple-touch-icon-precomposed", type: "image/png", sizes: "72x72"
13
- = favicon_link_tag "apple-touch-icon-precomposed.png", rel: "apple-touch-icon-precomposed", type: "image/png"
10
+ = favicon_link_tag "apple-touch-icon-144x144-precomposed.png",
11
+ rel: "apple-touch-icon-precomposed", type: "image/png", sizes: "144x144"
12
+ = favicon_link_tag "apple-touch-icon-114x114-precomposed.png",
13
+ rel: "apple-touch-icon-precomposed", type: "image/png", sizes: "114x114"
14
+ = favicon_link_tag "apple-touch-icon-72x72-precomposed.png",
15
+ rel: "apple-touch-icon-precomposed", type: "image/png", sizes: "72x72"
16
+ = favicon_link_tag "apple-touch-icon-precomposed.png",
17
+ rel: "apple-touch-icon-precomposed", type: "image/png"
14
18
  = favicon_link_tag "favicon.ico", rel: "shortcut icon"
15
19
  = javascript_include_tag "rails_voter/application"
16
20
  / Le HTML5 shim, for IE6-8 support of HTML elements
17
21
  /[if lt IE 9]
18
- = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"
22
+ - h = "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"
23
+ = javascript_include_tag h
19
24
 
20
25
 
21
26
  %body
@@ -1,8 +1,21 @@
1
- = link_to "add", new_election_path
1
+ = link_to "add", new_election_path, class: "btn btn-success"
2
2
 
3
3
  - elections.each do |bf|
4
4
  %p
5
- = bf.name
5
+ %h2= bf.name
6
6
  = link_to "edit", edit_election_path(bf)
7
7
  = link_to "vote", vote_election_path(bf)
8
8
  = link_to "show result", show_result_election_path(bf)
9
+ %div
10
+ %h4 Add code to your view to display the ballot form.
11
+ %p erb:
12
+ %pre <%= embed_ballot_form(#{bf.id}) %>
13
+ %p haml:
14
+ %pre = embed_ballot_form(#{bf.id})
15
+
16
+ %h4 Add code to your view to display voting result.
17
+ %p erb:
18
+ %pre <%= embed_voting_result(#{bf.id}) %>
19
+ %p haml:
20
+ %pre = embed_voting_result(#{bf.id})
21
+ %hr
data/config/routes.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  RailsVoter::Engine.routes.draw do
2
2
  resources :elections do
3
- get "vote", on: :member
4
- get "show_result", on: :member
3
+ get :vote, on: :member
4
+ get :show_result, on: :member
5
5
  end
6
6
 
7
7
  resources :voting_results, only: [:create]
@@ -11,9 +11,13 @@ module RailsVoter
11
11
  rake("db:migrate")
12
12
  end
13
13
 
14
- def add_seeds
15
- copy_file "seeds.rb", "db/seeds.rb"
16
- rake("db:seed")
14
+ def add_sample_data
15
+ copy_file "sample_data.rb", "lib/tasks/rails_voter.rake"
16
+ rake("rails_voter:add_sample_data")
17
+ end
18
+
19
+ def add_helpers
20
+ copy_file "helpers.rb", "config/initializers/rails_voter_helpers.rb"
17
21
  end
18
22
  end
19
23
  end
@@ -0,0 +1,3 @@
1
+ ActiveSupport.on_load :action_controller do
2
+ helper RailsVoter::Engine.helpers
3
+ end
@@ -0,0 +1,25 @@
1
+ namespace :rails_voter do
2
+ desc "Add sample data"
3
+ task add_sample_data: :environment do
4
+ RailsVoter::VotingResult.destroy_all
5
+ RailsVoter::ElectionDetail.destroy_all
6
+ RailsVoter::Election.destroy_all
7
+
8
+ p "Add sample data"
9
+ p "United States presidential election, 2016 seeds"
10
+
11
+ bf = RailsVoter::Election.create(name: "United States presidential election, 2016")
12
+
13
+ bfd = bf.election_details.create(name: "Hillary Clinton")
14
+ 4.times { bfd.voting_results.create }
15
+
16
+ bfd = bf.election_details.create(name: "Donald Trump")
17
+ 3.times { bfd.voting_results.create }
18
+
19
+ bfd = bf.election_details.create(name: "Gary Johnson")
20
+ 2.times { bfd.voting_results.create }
21
+
22
+ bfd = bf.election_details.create(name: "Jill Stein")
23
+ 2.times { bfd.voting_results.create }
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsVoter
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_voter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sunny Rails Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-07 00:00:00.000000000 Z
11
+ date: 2016-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.9'
69
- - !ruby/object:Gem::Dependency
70
- name: faker
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: bootstrap-sass
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +178,20 @@ dependencies:
192
178
  - - ">="
193
179
  - !ruby/object:Gem::Version
194
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: shoulda-matchers
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '3.1'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '3.1'
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: pry-byebug
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -275,7 +275,7 @@ files:
275
275
  - app/assets/javascripts/rails_voter/ballot_forms.js
276
276
  - app/assets/javascripts/rails_voter/voting_results.js
277
277
  - app/assets/stylesheets/rails_voter/application.scss
278
- - app/assets/stylesheets/rails_voter/ballot_forms.css
278
+ - app/assets/stylesheets/rails_voter/elections.css
279
279
  - app/assets/stylesheets/rails_voter/voting_results.css
280
280
  - app/controllers/rails_voter/application_controller.rb
281
281
  - app/controllers/rails_voter/elections_controller.rb
@@ -285,7 +285,6 @@ files:
285
285
  - app/models/rails_voter/election_detail.rb
286
286
  - app/models/rails_voter/voting_result.rb
287
287
  - app/views/layouts/rails_voter/_menu.html.haml
288
- - app/views/layouts/rails_voter/aaaapplication.html.erb
289
288
  - app/views/layouts/rails_voter/application.html.haml
290
289
  - app/views/rails_voter/elections/_election_detail_record.html.haml
291
290
  - app/views/rails_voter/elections/_form.html.haml
@@ -307,9 +306,9 @@ files:
307
306
  - db/migrate/20160707114814_change_ballot_form_detail_name.rb
308
307
  - db/migrate/20160707131546_change_ballot_form_detail_id_name.rb
309
308
  - db/migrate/20160707143841_change_ballot_form_id_column_name.rb
310
- - db/seeds.rb
311
309
  - lib/generators/rails_voter/install/install_generator.rb
312
- - lib/generators/rails_voter/install/templates/seeds.rb
310
+ - lib/generators/rails_voter/install/templates/helpers.rb
311
+ - lib/generators/rails_voter/install/templates/sample_data.rb
313
312
  - lib/generators/rails_voter/update/update_generator.rb
314
313
  - lib/rails_voter.rb
315
314
  - lib/rails_voter/engine.rb
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>RailsVoter</title>
5
- <%= stylesheet_link_tag "rails_voter/application", media: "all" %>
6
- <%= javascript_include_tag "rails_voter/application" %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
data/db/seeds.rb DELETED
@@ -1,41 +0,0 @@
1
- require "faker"
2
-
3
- p "Remove seeds"
4
- RailsVoter::VotingResult.destroy_all
5
- RailsVoter::ElectionDetail.destroy_all
6
- RailsVoter::Election.destroy_all
7
-
8
- separator = ">>>>>>>><<<<<<<<<<"
9
-
10
- p separator
11
-
12
- 5.times do
13
- bf = RailsVoter::Election.create(name: Faker::StarWars.planet)
14
- 2.times do
15
- bfd = bf.election_details.create(name: Faker::StarWars.character)
16
- 3.times do
17
- bfd.voting_results.create
18
- end
19
- end
20
- end
21
-
22
- message = "5 ballot forms, 10 ballot form details and 30 voting results created."
23
- p separator
24
- p message
25
- p separator
26
-
27
- p "United States presidential election, 2016 seeds"
28
-
29
- bf = RailsVoter::Election.create(name: "United States presidential election, 2016")
30
-
31
- bfd = bf.election_details.create(name: "Hillary Clinton")
32
- 4.times { bfd.voting_results.create }
33
-
34
- bfd = bf.election_details.create(name: "Donald Trump")
35
- 3.times { bfd.voting_results.create }
36
-
37
- bfd = bf.election_details.create(name: "Gary Johnson")
38
- 2.times { bfd.voting_results.create }
39
-
40
- bfd = bf.election_details.create(name: "Jill Stein")
41
- 2.times { bfd.voting_results.create }
@@ -1 +0,0 @@
1
- RailsVoter::Engine.load_seed