browsing_history 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +89 -0
  5. data/.rubocop_todo.yml +28 -0
  6. data/.ruby-version +1 -0
  7. data/Gemfile +7 -0
  8. data/Gemfile.lock +180 -0
  9. data/LICENSE +21 -0
  10. data/MIT-LICENSE +20 -0
  11. data/README.md +2 -0
  12. data/README.rdoc +3 -0
  13. data/Rakefile +28 -0
  14. data/browsing_history.gemspec +34 -0
  15. data/dump.rdb +1 -0
  16. data/lib/browsing_history/browser.rb +66 -0
  17. data/lib/browsing_history/configuration.rb +38 -0
  18. data/lib/browsing_history/error.rb +2 -0
  19. data/lib/browsing_history/historizable.rb +26 -0
  20. data/lib/browsing_history/history.rb +85 -0
  21. data/lib/browsing_history/storage.rb +44 -0
  22. data/lib/browsing_history/storages/active_record.rb +12 -0
  23. data/lib/browsing_history/storages/base.rb +40 -0
  24. data/lib/browsing_history/storages/redis.rb +113 -0
  25. data/lib/browsing_history/version.rb +3 -0
  26. data/lib/browsing_history.rb +12 -0
  27. data/lib/generators/active_record/migration_generator.rb +12 -0
  28. data/lib/generators/active_record/templates/migration.rb +15 -0
  29. data/lib/tasks/browsing_history_tasks.rake +4 -0
  30. data/spec/browsing_history/browser_spec.rb +156 -0
  31. data/spec/browsing_history/configration_spec.rb +16 -0
  32. data/spec/browsing_history/fixtures/article.rb +10 -0
  33. data/spec/browsing_history/fixtures/user.rb +10 -0
  34. data/spec/browsing_history/historizable_spec.rb +27 -0
  35. data/spec/browsing_history/history_spec.rb +273 -0
  36. data/spec/browsing_history/storage_spec.rb +45 -0
  37. data/spec/browsing_history/storages/base_spec.rb +35 -0
  38. data/spec/browsing_history/storages/redis_spec.rb +141 -0
  39. data/spec/browsing_history_spec.rb +4 -0
  40. data/spec/generator_spec.rb +34 -0
  41. data/spec/spec_helper.rb +40 -0
  42. data/spec/test_app/README.rdoc +28 -0
  43. data/spec/test_app/Rakefile +6 -0
  44. data/spec/test_app/app/assets/images/.keep +0 -0
  45. data/spec/test_app/app/assets/javascripts/application.js +13 -0
  46. data/spec/test_app/app/assets/stylesheets/application.css +15 -0
  47. data/spec/test_app/app/controllers/application_controller.rb +10 -0
  48. data/spec/test_app/app/controllers/articles_controller.rb +17 -0
  49. data/spec/test_app/app/controllers/concerns/.keep +0 -0
  50. data/spec/test_app/app/helpers/application_helper.rb +2 -0
  51. data/spec/test_app/app/mailers/.keep +0 -0
  52. data/spec/test_app/app/models/.keep +0 -0
  53. data/spec/test_app/app/models/concerns/.keep +0 -0
  54. data/spec/test_app/app/views/layouts/application.html.erb +14 -0
  55. data/spec/test_app/bin/bundle +3 -0
  56. data/spec/test_app/bin/rails +4 -0
  57. data/spec/test_app/bin/rake +4 -0
  58. data/spec/test_app/bin/setup +29 -0
  59. data/spec/test_app/config/application.rb +19 -0
  60. data/spec/test_app/config/boot.rb +5 -0
  61. data/spec/test_app/config/database.yml +12 -0
  62. data/spec/test_app/config/environment.rb +5 -0
  63. data/spec/test_app/config/environments/development.rb +18 -0
  64. data/spec/test_app/config/environments/test.rb +21 -0
  65. data/spec/test_app/config/initializers/assets.rb +11 -0
  66. data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
  67. data/spec/test_app/config/initializers/cookies_serializer.rb +3 -0
  68. data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
  69. data/spec/test_app/config/initializers/inflections.rb +16 -0
  70. data/spec/test_app/config/initializers/mime_types.rb +4 -0
  71. data/spec/test_app/config/initializers/session_store.rb +3 -0
  72. data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
  73. data/spec/test_app/config/locales/en.yml +23 -0
  74. data/spec/test_app/config/routes.rb +2 -0
  75. data/spec/test_app/config/secrets.yml +5 -0
  76. data/spec/test_app/config.ru +4 -0
  77. data/spec/test_app/db/development.sqlite3 +0 -0
  78. data/spec/test_app/db/test.sqlite3 +0 -0
  79. data/spec/test_app/lib/assets/.keep +0 -0
  80. data/spec/test_app/log/.keep +0 -0
  81. data/spec/test_app/log/development.log +0 -0
  82. data/spec/test_app/log/test.log +0 -0
  83. data/spec/test_app/public/404.html +67 -0
  84. data/spec/test_app/public/422.html +67 -0
  85. data/spec/test_app/public/500.html +66 -0
  86. data/spec/test_app/public/favicon.ico +0 -0
  87. metadata +342 -0
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -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,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ 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,19 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # Pick the frameworks you want:
4
+ require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ require "action_mailer/railtie"
7
+ require "action_view/railtie"
8
+ require "sprockets/railtie"
9
+ # require "rails/test_unit/railtie"
10
+
11
+ Bundler.require(*Rails.groups)
12
+ require "browsing_history"
13
+
14
+ module Dummy
15
+ class Application < Rails::Application
16
+ config.active_record.raise_in_transactional_callbacks = true
17
+ end
18
+ end
19
+
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,12 @@
1
+ default: &default
2
+ adapter: sqlite3
3
+ pool: 5
4
+ timeout: 5000
5
+
6
+ development:
7
+ <<: *default
8
+ database: db/development.sqlite3
9
+
10
+ test:
11
+ <<: *default
12
+ database: db/test.sqlite3
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,18 @@
1
+ Rails.application.configure do
2
+ config.cache_classes = false
3
+
4
+ config.eager_load = false
5
+
6
+ config.consider_all_requests_local = true
7
+ config.action_controller.perform_caching = false
8
+
9
+ config.active_support.deprecation = :log
10
+
11
+ config.active_record.migration_error = :page_load
12
+
13
+ config.assets.debug = true
14
+
15
+ config.assets.digest = true
16
+
17
+ config.assets.raise_runtime_errors = true
18
+ end
@@ -0,0 +1,21 @@
1
+ Rails.application.configure do
2
+ config.cache_classes = true
3
+
4
+ config.eager_load = false
5
+
6
+ config.serve_static_files = true
7
+ config.static_cache_control = 'public, max-age=3600'
8
+
9
+ config.consider_all_requests_local = true
10
+ config.action_controller.perform_caching = false
11
+
12
+ config.action_dispatch.show_exceptions = false
13
+
14
+ config.action_controller.allow_forgery_protection = false
15
+
16
+ config.action_mailer.delivery_method = :test
17
+
18
+ config.active_support.test_order = :random
19
+
20
+ config.active_support.deprecation = :stderr
21
+ end
@@ -0,0 +1,11 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Version of your assets, change this if you want to expire all your assets.
4
+ Rails.application.config.assets.version = '1.0'
5
+
6
+ # Add additional assets to the asset load path
7
+ # Rails.application.config.assets.paths << Emoji.images_path
8
+
9
+ # Precompile additional assets.
10
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11
+ # Rails.application.config.assets.precompile += %w( search.js )
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,2 @@
1
+ Rails.application.routes.draw do
2
+ end
@@ -0,0 +1,5 @@
1
+ development:
2
+ secret_key_base: b18c4001e53f3bc4cb082811882d8b2138a7205c14e3c83bcb51ac1b2f313b4fbe99f280242c63618901f1904fd8098cab6559d79cd9486f73565edbba74710d
3
+
4
+ test:
5
+ secret_key_base: d89e232489672768fae789640d847e11c32fd59b604b9d362e5c88fc1391dbada0b5df6fe25e6ab5abe7895b1903294401170ee335b731b45298ce5ba489121e
@@ -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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes