utter_events 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +4 -0
  6. data/CODE_OF_CONDUCT.md +12 -0
  7. data/Gemfile +4 -0
  8. data/Guardfile +70 -0
  9. data/README.md +110 -0
  10. data/Rakefile +1 -0
  11. data/bin/console +8 -0
  12. data/bin/setup +8 -0
  13. data/lib/utter.rb +47 -0
  14. data/lib/utter/version.rb +3 -0
  15. data/sample_rails_app/.gitignore +17 -0
  16. data/sample_rails_app/Gemfile +17 -0
  17. data/sample_rails_app/Gemfile.lock +157 -0
  18. data/sample_rails_app/README.rdoc +28 -0
  19. data/sample_rails_app/Rakefile +6 -0
  20. data/sample_rails_app/app/assets/images/.keep +0 -0
  21. data/sample_rails_app/app/assets/javascripts/application.js +15 -0
  22. data/sample_rails_app/app/assets/javascripts/articles.js +2 -0
  23. data/sample_rails_app/app/assets/javascripts/comments.js +2 -0
  24. data/sample_rails_app/app/assets/javascripts/welcome.js +2 -0
  25. data/sample_rails_app/app/assets/stylesheets/application.css +15 -0
  26. data/sample_rails_app/app/assets/stylesheets/articles.scss +3 -0
  27. data/sample_rails_app/app/assets/stylesheets/comments.scss +3 -0
  28. data/sample_rails_app/app/assets/stylesheets/welcome.scss +3 -0
  29. data/sample_rails_app/app/controllers/application_controller.rb +5 -0
  30. data/sample_rails_app/app/controllers/articles_controller.rb +51 -0
  31. data/sample_rails_app/app/controllers/comments_controller.rb +19 -0
  32. data/sample_rails_app/app/controllers/concerns/.keep +0 -0
  33. data/sample_rails_app/app/controllers/welcome_controller.rb +4 -0
  34. data/sample_rails_app/app/helpers/application_helper.rb +2 -0
  35. data/sample_rails_app/app/helpers/articles_helper.rb +2 -0
  36. data/sample_rails_app/app/helpers/comments_helper.rb +2 -0
  37. data/sample_rails_app/app/helpers/welcome_helper.rb +2 -0
  38. data/sample_rails_app/app/mailers/.keep +0 -0
  39. data/sample_rails_app/app/models/.keep +0 -0
  40. data/sample_rails_app/app/models/article.rb +5 -0
  41. data/sample_rails_app/app/models/comment.rb +3 -0
  42. data/sample_rails_app/app/models/concerns/.keep +0 -0
  43. data/sample_rails_app/app/views/articles/_form.html.erb +31 -0
  44. data/sample_rails_app/app/views/articles/edit.html.erb +5 -0
  45. data/sample_rails_app/app/views/articles/index.html.erb +21 -0
  46. data/sample_rails_app/app/views/articles/new.html.erb +5 -0
  47. data/sample_rails_app/app/views/articles/show.html.erb +18 -0
  48. data/sample_rails_app/app/views/comments/_comment.html.erb +15 -0
  49. data/sample_rails_app/app/views/comments/_form.html.erb +13 -0
  50. data/sample_rails_app/app/views/layouts/application.html.erb +14 -0
  51. data/sample_rails_app/app/views/welcome/index.html.erb +2 -0
  52. data/sample_rails_app/bin/bundle +3 -0
  53. data/sample_rails_app/bin/rails +9 -0
  54. data/sample_rails_app/bin/rake +9 -0
  55. data/sample_rails_app/bin/setup +29 -0
  56. data/sample_rails_app/bin/spring +15 -0
  57. data/sample_rails_app/config.ru +4 -0
  58. data/sample_rails_app/config/application.rb +35 -0
  59. data/sample_rails_app/config/boot.rb +3 -0
  60. data/sample_rails_app/config/database.yml +25 -0
  61. data/sample_rails_app/config/environment.rb +5 -0
  62. data/sample_rails_app/config/environments/development.rb +41 -0
  63. data/sample_rails_app/config/environments/production.rb +79 -0
  64. data/sample_rails_app/config/environments/test.rb +42 -0
  65. data/sample_rails_app/config/initializers/assets.rb +11 -0
  66. data/sample_rails_app/config/initializers/backtrace_silencers.rb +7 -0
  67. data/sample_rails_app/config/initializers/cookies_serializer.rb +3 -0
  68. data/sample_rails_app/config/initializers/filter_parameter_logging.rb +4 -0
  69. data/sample_rails_app/config/initializers/inflections.rb +16 -0
  70. data/sample_rails_app/config/initializers/mime_types.rb +4 -0
  71. data/sample_rails_app/config/initializers/session_store.rb +3 -0
  72. data/sample_rails_app/config/initializers/utter.rb +8 -0
  73. data/sample_rails_app/config/initializers/wrap_parameters.rb +14 -0
  74. data/sample_rails_app/config/locales/en.yml +23 -0
  75. data/sample_rails_app/config/routes.rb +7 -0
  76. data/sample_rails_app/config/secrets.yml +22 -0
  77. data/sample_rails_app/db/migrate/20160218085536_create_articles.rb +10 -0
  78. data/sample_rails_app/db/migrate/20160222061605_create_comments.rb +11 -0
  79. data/sample_rails_app/db/schema.rb +33 -0
  80. data/sample_rails_app/db/seeds.rb +7 -0
  81. data/sample_rails_app/lib/assets/.keep +0 -0
  82. data/sample_rails_app/lib/tasks/.keep +0 -0
  83. data/sample_rails_app/log/.keep +0 -0
  84. data/sample_rails_app/public/404.html +67 -0
  85. data/sample_rails_app/public/422.html +67 -0
  86. data/sample_rails_app/public/500.html +66 -0
  87. data/sample_rails_app/public/favicon.ico +0 -0
  88. data/sample_rails_app/public/robots.txt +5 -0
  89. data/sample_rails_app/vendor/assets/javascripts/.keep +0 -0
  90. data/sample_rails_app/vendor/assets/stylesheets/.keep +0 -0
  91. data/utter.gemspec +31 -0
  92. metadata +221 -0
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the articles controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the Comments controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the welcome controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,51 @@
1
+ class ArticlesController < ApplicationController
2
+ include Utter
3
+ def index
4
+ utter(:index_viewed, params: params)
5
+ @articles = Article.all
6
+ end
7
+
8
+ def show
9
+ @article = Article.find(params[:id])
10
+ end
11
+
12
+ def new
13
+ @article = Article.new
14
+ end
15
+
16
+ def edit
17
+ @article = Article.find(params[:id])
18
+ end
19
+
20
+ def create
21
+ @article = Article.new(article_params)
22
+
23
+ if @article.save
24
+ redirect_to @article
25
+ else
26
+ render 'new'
27
+ end
28
+ end
29
+
30
+ def update
31
+ @article = Article.find(params[:id])
32
+
33
+ if @article.update(article_params)
34
+ redirect_to @article
35
+ else
36
+ render 'edit'
37
+ end
38
+ end
39
+
40
+ def destroy
41
+ @article = Article.find(params[:id])
42
+ @article.destroy
43
+
44
+ redirect_to articles_path
45
+ end
46
+
47
+ private
48
+ def article_params
49
+ params.require(:article).permit(:title, :text)
50
+ end
51
+ end
@@ -0,0 +1,19 @@
1
+ class CommentsController < ApplicationController
2
+ def create
3
+ @article = Article.find(params[:article_id])
4
+ @comment = @article.comments.create(comment_params)
5
+ redirect_to article_path(@article)
6
+ end
7
+
8
+ def destroy
9
+ @article = Article.find(params[:article_id])
10
+ @comment = @article.comments.find(params[:id])
11
+ @comment.destroy
12
+ redirect_to article_path(@article)
13
+ end
14
+
15
+ private
16
+ def comment_params
17
+ params.require(:comment).permit(:commenter, :body)
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ class WelcomeController < ApplicationController
2
+ def index
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module ArticlesHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module CommentsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module WelcomeHelper
2
+ end
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ class Article < ActiveRecord::Base
2
+ has_many :comments, dependent: :destroy
3
+ validates :title, presence: true,
4
+ length: { minimum: 5 }
5
+ end
@@ -0,0 +1,3 @@
1
+ class Comment < ActiveRecord::Base
2
+ belongs_to :article
3
+ end
@@ -0,0 +1,31 @@
1
+ <%= form_for @article do |f| %>
2
+
3
+ <% if @article.errors.any? %>
4
+ <div id="error_explanation">
5
+ <h2>
6
+ <%= pluralize(@article.errors.count, "error") %> prohibited
7
+ this article from being saved:
8
+ </h2>
9
+ <ul>
10
+ <% @article.errors.full_messages.each do |msg| %>
11
+ <li><%= msg %></li>
12
+ <% end %>
13
+ </ul>
14
+ </div>
15
+ <% end %>
16
+
17
+ <p>
18
+ <%= f.label :title %><br>
19
+ <%= f.text_field :title %>
20
+ </p>
21
+
22
+ <p>
23
+ <%= f.label :text %><br>
24
+ <%= f.text_area :text %>
25
+ </p>
26
+
27
+ <p>
28
+ <%= f.submit %>
29
+ </p>
30
+
31
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <h1>Editing article</h1>
2
+
3
+ <%= render "form" %>
4
+
5
+ <%= link_to 'Back', articles_path %>
@@ -0,0 +1,21 @@
1
+ <h1>Listing Articles</h1>
2
+ <%= link_to 'New article', new_article_path %>
3
+ <table>
4
+ <tr>
5
+ <th>Title</th>
6
+ <th>Text</th>
7
+ <th colspan="3"></th>
8
+ </tr>
9
+
10
+ <% @articles.each do |article| %>
11
+ <tr>
12
+ <td><%= article.title %></td>
13
+ <td><%= article.text %></td>
14
+ <td><%= link_to 'Show', article_path(article) %></td>
15
+ <td><%= link_to 'Edit', edit_article_path(article) %></td>
16
+ <td><%= link_to 'Destroy', article_path(article),
17
+ method: :delete,
18
+ data: { confirm: 'Are you sure?' } %></td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
@@ -0,0 +1,5 @@
1
+ <h1>New Article</h1>
2
+
3
+ <%= render "form" %>
4
+
5
+ <%= link_to 'Back', articles_path %>
@@ -0,0 +1,18 @@
1
+ <p>
2
+ <strong>Title:</strong>
3
+ <%= @article.title %>
4
+ </p>
5
+
6
+ <p>
7
+ <strong>Text:</strong>
8
+ <%= @article.text %>
9
+ </p>
10
+
11
+ <h2>Comments</h2>
12
+ <%= render @article.comments %>
13
+
14
+ <h2>Add a comment:</h2>
15
+ <%= render 'comments/form' %>
16
+
17
+ <%= link_to 'Edit', edit_article_path(@article) %> |
18
+ <%= link_to 'Back', articles_path %>
@@ -0,0 +1,15 @@
1
+ <p>
2
+ <strong>Commenter:</strong>
3
+ <%= comment.commenter %>
4
+ </p>
5
+
6
+ <p>
7
+ <strong>Comment:</strong>
8
+ <%= comment.body %>
9
+ </p>
10
+
11
+ <p>
12
+ <%= link_to 'Destroy Comment', [comment.article, comment],
13
+ method: :delete,
14
+ data: { confirm: 'Are you sure?' } %>
15
+ </p>
@@ -0,0 +1,13 @@
1
+ <%= form_for([@article, @article.comments.build]) do |f| %>
2
+ <p>
3
+ <%= f.label :commenter %><br>
4
+ <%= f.text_field :commenter %>
5
+ </p>
6
+ <p>
7
+ <%= f.label :body %><br>
8
+ <%= f.text_area :body %>
9
+ </p>
10
+ <p>
11
+ <%= f.submit %>
12
+ </p>
13
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>SampleApp</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all' %>
6
+ <%= javascript_include_tag 'application' %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,2 @@
1
+ <h1>Hello, Rails!</h1>
2
+ <%= link_to 'My Blog', controller: 'articles' %>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
7
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
8
+ require_relative '../config/boot'
9
+ require 'rails/commands'
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
7
+ require_relative '../config/boot'
8
+ require 'rake'
9
+ Rake.application.run
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file loads spring without using Bundler, in order to be fast.
4
+ # It gets overwritten when you run the `spring binstub` command.
5
+
6
+ unless defined?(Spring)
7
+ require 'rubygems'
8
+ require 'bundler'
9
+
10
+ if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m))
11
+ Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq }
12
+ gem 'spring', match[1]
13
+ require 'spring/binstub'
14
+ end
15
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,35 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "rails"
4
+ # Pick the frameworks you want:
5
+ require "active_model/railtie"
6
+ require "active_job/railtie"
7
+ require "active_record/railtie"
8
+ require "action_controller/railtie"
9
+ require "action_mailer/railtie"
10
+ require "action_view/railtie"
11
+ require "sprockets/railtie"
12
+ # require "rails/test_unit/railtie"
13
+
14
+ # Require the gems listed in Gemfile, including any gems
15
+ # you've limited to :test, :development, or :production.
16
+ Bundler.require(*Rails.groups)
17
+
18
+ module SampleApp
19
+ class Application < Rails::Application
20
+ # Settings in config/environments/* take precedence over those specified here.
21
+ # Application configuration should go into files in config/initializers
22
+ # -- all .rb files in that directory are automatically loaded.
23
+
24
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
25
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
26
+ # config.time_zone = 'Central Time (US & Canada)'
27
+
28
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
29
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
30
+ # config.i18n.default_locale = :de
31
+
32
+ # Do not swallow errors in after_commit/after_rollback callbacks.
33
+ config.active_record.raise_in_transactional_callbacks = true
34
+ end
35
+ end