kanaui 0.5.1 → 0.6.0

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -9
  3. data/app/assets/javascripts/application.js +0 -1
  4. data/app/assets/stylesheets/application.css +1 -0
  5. data/app/assets/stylesheets/bootstrap_and_overrides.css +0 -4
  6. data/app/controllers/kanaui/dashboard_controller.rb +13 -7
  7. data/app/views/kanaui/dashboard/index.html.erb +10 -10
  8. data/lib/kanaui/engine.rb +3 -1
  9. data/lib/kanaui/version.rb +1 -1
  10. data/test/dummy/bin/bundle +3 -0
  11. data/test/dummy/bin/rails +4 -0
  12. data/test/dummy/bin/rake +4 -0
  13. data/test/dummy/bin/setup +38 -0
  14. data/test/dummy/bin/update +29 -0
  15. data/test/dummy/bin/yarn +11 -0
  16. data/test/dummy/config/application.rb +15 -47
  17. data/test/dummy/config/boot.rb +2 -9
  18. data/test/dummy/config/environment.rb +4 -4
  19. data/test/dummy/config/environments/development.rb +38 -18
  20. data/test/dummy/config/environments/production.rb +61 -39
  21. data/test/dummy/config/environments/test.rb +20 -14
  22. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  23. data/test/dummy/config/initializers/assets.rb +14 -0
  24. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  25. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  26. data/test/dummy/config/initializers/inflections.rb +6 -5
  27. data/test/dummy/config/initializers/mime_types.rb +0 -1
  28. data/test/dummy/config/initializers/new_framework_defaults_5_1.rb +14 -0
  29. data/test/dummy/config/initializers/wrap_parameters.rb +5 -5
  30. data/test/dummy/config/locales/en.yml +30 -2
  31. data/test/dummy/config/secrets.yml +32 -0
  32. data/test/integration/navigation_test.rb +6 -4
  33. metadata +81 -186
  34. data/app/models/kanaui/dashboard.rb +0 -5
  35. data/test/dummy/config/database.yml +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b509920c148aef35ccf0bffbe38b935b669a35ff
4
- data.tar.gz: e5d121e521e55c1c3f882f7f0bbfd576c961a7e9
3
+ metadata.gz: 44408c840e86c3b09c99de32d8562b6f6cb11f8b
4
+ data.tar.gz: b4c65299ff506937976f193d337701969e0cba65
5
5
  SHA512:
6
- metadata.gz: e8ebbb2db468390719e6c125880f483382f2cfd61ca4256128409c7dfa89aa11b367d3f6b5bdc039897c81de3fd627007348ff2c86e82096e94392c4c7f47b4d
7
- data.tar.gz: bc6c3397d0fa1f6192f81cf85c199934126c4a42283791ec8e6ec7b0b8e31dc7678804dc5c288474713f22a9ccad7dac089967a2a6fed42440b5edb83956bc81
6
+ metadata.gz: a1fd5e4063dea83305ead4baa1e6b60d9c532d86a4518067c2a2995709fab84df428c266f0a2d5a96222f5729bc8d3f7336d9036046b8d222fc2e4bd0dcb6e7f
7
+ data.tar.gz: b62394e70ab37f0d418930846d288e8da1fec047dc9ad37a35cdaa0b5be8c9d6801aa54a84073e7c3d9ed8c131379e76265dc72ea2a972eb1f41e566559931ee
data/README.md CHANGED
@@ -12,7 +12,8 @@ Kill Bill compatibility
12
12
  | Kanaui version | Kill Bill version |
13
13
  | -------------: | ----------------: |
14
14
  | 0.4.y | 0.16.z |
15
- | 0.5.y | 0.18.z |
15
+ | 0.5.y | 0.18.z (Rails 4) |
16
+ | 0.6.y | 0.18.z (Rails 5) |
16
17
 
17
18
  Getting Started
18
19
  ===============
@@ -34,15 +35,18 @@ KillBillClient.api_key = 'bob'
34
35
  KillBillClient.api_secret = 'lazar'
35
36
  ```
36
37
 
37
- Running Kanaui
38
- --------------
38
+ Testing
39
+ -------
39
40
 
40
- You can run Kanaui locally by using the test/dummy app provided:
41
+ To run the dummy app:
41
42
 
42
43
  ```
43
- bundle install
44
- cd test/dummy
45
- export RAILS_ENV=development
46
- bundle install
47
- rails server
44
+ rails s
45
+ ```
46
+
47
+
48
+ To run tests:
49
+
50
+ ```
51
+ rails t
48
52
  ```
@@ -6,7 +6,6 @@
6
6
  //
7
7
  //= require js-routes
8
8
  //= require log4javascript
9
- //= require moment
10
9
  //= require spin
11
10
  //= require jquery
12
11
  //= require jquery_ujs
@@ -6,6 +6,7 @@
6
6
  *= require bootstrap-datepicker3
7
7
  *= require dataTables/jquery.dataTables
8
8
  *= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
9
+ *= require font-awesome
9
10
  *= require bootstrap_and_overrides
10
11
  *= require kanaui/kanaui
11
12
  */
@@ -1,9 +1,5 @@
1
1
  /*
2
2
  *= require twitter-bootstrap-static/bootstrap
3
- *
4
- * Use Font Awesome icons (default)
5
- * To use Glyphicons sprites instead of Font Awesome, replace with "require twitter-bootstrap-static/sprites"
6
- *= require twitter-bootstrap-static/fontawesome
7
3
  */
8
4
 
9
5
  /* Override Bootstrap 3 font locations */
@@ -24,15 +24,21 @@ module Kanaui
24
24
  if query.present? || params[:start_date].blank? || params[:end_date].blank?
25
25
  # TODO Make metrics configurable
26
26
  name = query.present? ? "#{params[:name]}#{query}^metric:count" : params[:name]
27
- redirect_to dashboard_index_path(:start_date => @start_date,
28
- :end_date => @end_date,
29
- :name => name,
30
- :smooth => params[:smooth],
31
- :sql_only => params[:sql_only],
32
- :format => params[:format]) and return
27
+ query_params = {:start_date => @start_date,
28
+ :end_date => @end_date,
29
+ :name => name,
30
+ :smooth => params[:smooth],
31
+ :sql_only => params[:sql_only],
32
+ :format => params[:format]}
33
+
34
+ # Test only
35
+ query_params[:fake] = params[:fake] unless params[:fake].blank?
36
+ query_params[:type] = params[:type] unless params[:type].blank?
37
+
38
+ redirect_to dashboard_index_path(query_params) and return
33
39
  end
34
40
 
35
- render
41
+ params.permit!
36
42
  end
37
43
 
38
44
  # Not used anymore as reports are pulled from index
@@ -35,7 +35,7 @@
35
35
  </li>
36
36
  <% end %>
37
37
  <% @reports.each do |r| %>
38
- <% link = kanaui_engine.dashboard_index_path(params.merge(:name => r['reportName'])) %>
38
+ <% link = kanaui_engine.dashboard_index_path(params.to_h.merge(:name => r['reportName'])) %>
39
39
  <li class="nav-element <%= params[:name] == r['reportName'] ? 'current' : '' %>">
40
40
  <%= link_to r['reportPrettyName'], link, :class => "truncate-text", title: r['reportName'].titleize %>
41
41
  </li>
@@ -53,17 +53,17 @@
53
53
  <%= @raw_name.titleize %>
54
54
  </h2>
55
55
  <div id="loading-spinner"></div>
56
- <div id="chartAnchor" data-reports-path="<%= kanaui_engine.reports_path(params) %>"></div>
56
+ <div id="chartAnchor" data-reports-path="<%= kanaui_engine.reports_path(params.to_h) %>"></div>
57
57
  <div id="date-controls" style="display: none;">
58
58
  <ul class="nav nav-pills nav-justified">
59
59
  <% @available_start_dates.each do |key, value| %>
60
- <li><%= link_to key, kanaui_engine.dashboard_index_path(params.merge(:start_date => value)) %></li>
60
+ <li><%= link_to key, kanaui_engine.dashboard_index_path(params.to_h.merge(:start_date => value)) %></li>
61
61
  <% end %>
62
62
  </ul>
63
63
  </div>
64
64
  <hr>
65
65
  <div class="pull-right">
66
- <%= link_to 'Download raw data', kanaui_engine.reports_path(params.merge(:format => 'csv')), class: 'btn btn-default' %>
66
+ <%= link_to 'Download raw data', kanaui_engine.reports_path(params.to_h.merge(:format => 'csv')), class: 'btn btn-default' %>
67
67
  </div>
68
68
  <a class="btn btn-default" role="button" data-toggle="collapse" href="#advanced-controls" aria-expanded="false" aria-controls="advanced-controls">
69
69
  Advanced controls
@@ -75,22 +75,22 @@
75
75
  <% at_least_two_months = params[:start_date].blank? || params[:end_date].blank? || (params[:end_date].to_date.beginning_of_month - 1.month > params[:start_date].to_date) %>
76
76
  <% at_least_two_weeks = params[:start_date].blank? || params[:end_date].blank? || (params[:end_date].to_date.beginning_of_week - 1.week > params[:start_date].to_date) %>
77
77
  <% if params[:smooth] != 'AVERAGE_WEEKLY' && at_least_two_weeks %>
78
- <li><%= link_to 'Weekly average', kanaui_engine.dashboard_index_path(params.merge(:smooth => 'AVERAGE_WEEKLY')) %></li>
78
+ <li><%= link_to 'Weekly average', kanaui_engine.dashboard_index_path(params.to_h.merge(:smooth => 'AVERAGE_WEEKLY')) %></li>
79
79
  <% end %>
80
80
  <% if params[:smooth] != 'AVERAGE_MONTHLY' && at_least_two_months %>
81
- <li><%= link_to 'Monthly average', kanaui_engine.dashboard_index_path(params.merge(:smooth => 'AVERAGE_MONTHLY')) %></li>
81
+ <li><%= link_to 'Monthly average', kanaui_engine.dashboard_index_path(params.to_h.merge(:smooth => 'AVERAGE_MONTHLY')) %></li>
82
82
  <% end %>
83
83
  <% if params[:smooth] != 'SUM_WEEKLY' && at_least_two_weeks %>
84
- <li><%= link_to 'Weekly sum', kanaui_engine.dashboard_index_path(params.merge(:smooth => 'SUM_WEEKLY')) %></li>
84
+ <li><%= link_to 'Weekly sum', kanaui_engine.dashboard_index_path(params.to_h.merge(:smooth => 'SUM_WEEKLY')) %></li>
85
85
  <% end %>
86
86
  <% if params[:smooth] != 'SUM_MONTHLY' && at_least_two_months %>
87
- <li><%= link_to 'Monthly sum', kanaui_engine.dashboard_index_path(params.merge(:smooth => 'SUM_MONTHLY')) %></li>
87
+ <li><%= link_to 'Monthly sum', kanaui_engine.dashboard_index_path(params.to_h.merge(:smooth => 'SUM_MONTHLY')) %></li>
88
88
  <% end %>
89
89
  <% end %>
90
90
  <% filter_fields = ((@report['schema'] || {})['fields'] || []).select { |field| !field['distinctValues'].blank? && field['dataType'] =~ /char/ } # To ignore tenant_record_id %>
91
91
  <% unless filter_fields.empty? %>
92
92
  <li>Slicing & Dicing:
93
- <%= form_tag kanaui_engine.dashboard_index_path(params), :method => :get, :class => 'form-horizontal' do %>
93
+ <%= form_tag kanaui_engine.dashboard_index_path(params.to_h), :method => :get, :class => 'form-horizontal' do %>
94
94
  <input name="start_date" type="hidden" value="<%= @start_date %>">
95
95
  <input name="end_date" type="hidden" value="<%= @end_date %>">
96
96
  <input name="name" type="hidden" value="<%= @raw_name %>">
@@ -132,7 +132,7 @@
132
132
  <pre><%= params[:name] -%></pre>
133
133
  </li>
134
134
  <% end %>
135
- <li><%= link_to 'SQL query', kanaui_engine.reports_path(params.merge(:sql_only => true)) %></li>
135
+ <li><%= link_to 'SQL query', kanaui_engine.reports_path(params.to_h.merge(:sql_only => true)) %></li>
136
136
  </ul>
137
137
  </div>
138
138
  </div>
data/lib/kanaui/engine.rb CHANGED
@@ -4,11 +4,13 @@
4
4
  # We need to explicitly require all of our dependencies listed in kanaui.gemspec
5
5
  #
6
6
  # See also https://github.com/carlhuda/bundler/issues/49
7
+ require 'js-routes'
7
8
  require 'jquery-rails'
8
9
  require 'jquery-datatables-rails'
10
+ require 'font-awesome-rails'
11
+ require 'twitter-bootstrap-rails'
9
12
  require 'bootstrap-datepicker-rails'
10
13
  require 'd3_rails'
11
- require 'momentjs-rails'
12
14
  require 'spinjs-rails'
13
15
  require 'killbill_client'
14
16
 
@@ -1,3 +1,3 @@
1
1
  module Kanaui
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -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', __dir__)
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,38 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # path to your application root.
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
14
+ # This script is a starting point to setup your application.
15
+ # Add necessary setup steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+ system('bundle check') || system!('bundle install')
20
+
21
+ # Install JavaScript dependencies if using Yarn
22
+ # system('bin/yarn')
23
+
24
+
25
+ # puts "\n== Copying sample files =="
26
+ # unless File.exist?('config/database.yml')
27
+ # cp 'config/database.yml.sample', 'config/database.yml'
28
+ # end
29
+
30
+ puts "\n== Preparing database =="
31
+ system! 'bin/rails db:setup'
32
+
33
+ puts "\n== Removing old logs and tempfiles =="
34
+ system! 'bin/rails log:clear tmp:clear'
35
+
36
+ puts "\n== Restarting application server =="
37
+ system! 'bin/rails restart'
38
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # path to your application root.
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
14
+ # This script is a way to update your development environment automatically.
15
+ # Add necessary update steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+ system('bundle check') || system!('bundle install')
20
+
21
+ puts "\n== Updating database =="
22
+ system! 'bin/rails db:migrate'
23
+
24
+ puts "\n== Removing old logs and tempfiles =="
25
+ system! 'bin/rails log:clear tmp:clear'
26
+
27
+ puts "\n== Restarting application server =="
28
+ system! 'bin/rails restart'
29
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ VENDOR_PATH = File.expand_path('..', __dir__)
3
+ Dir.chdir(VENDOR_PATH) do
4
+ begin
5
+ exec "yarnpkg #{ARGV.join(" ")}"
6
+ rescue Errno::ENOENT
7
+ $stderr.puts "Yarn executable was not detected in the system."
8
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
9
+ exit 1
10
+ end
11
+ end
@@ -1,58 +1,26 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ require_relative 'boot'
2
2
 
3
- require 'rails/all'
4
- Bundler.require(*Rails.groups)
5
- require "kanaui"
3
+ require 'action_controller/railtie'
4
+ require 'action_view/railtie'
5
+ require 'rails/test_unit/railtie'
6
+ require 'sprockets/railtie'
6
7
 
7
- require "jquery-rails"
8
- require "twitter-bootstrap-rails"
9
- require "d3_rails"
8
+ # Require the gems listed in Gemfile, including any gems
9
+ # you've limited to :test, :development, or :production.
10
+ Bundler.require(*Rails.groups)
10
11
 
11
- require "js-routes"
12
+ #
13
+ # Required to load the Kanaui engine into the dummy app
14
+ #
15
+ require File.expand_path('../../../../lib/kanaui.rb', __FILE__)
12
16
 
13
17
  module Dummy
14
18
  class Application < Rails::Application
19
+ # Initialize configuration defaults for originally generated Rails version.
20
+ config.load_defaults 5.1
21
+
15
22
  # Settings in config/environments/* take precedence over those specified here.
16
23
  # Application configuration should go into files in config/initializers
17
24
  # -- all .rb files in that directory are automatically loaded.
18
-
19
- # Custom directories with classes and modules you want to be autoloadable.
20
- # config.autoload_paths += %W(#{config.root}/extras)
21
-
22
- # Only load the plugins named here, in the order given (default is alphabetical).
23
- # :all can be used as a placeholder for all plugins not explicitly named.
24
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
25
-
26
- # Activate observers that should always be running.
27
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
28
-
29
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
30
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
31
- # config.time_zone = 'Central Time (US & Canada)'
32
-
33
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
34
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
35
- # config.i18n.default_locale = :de
36
-
37
- # Configure the default encoding used in templates for Ruby 1.9.
38
- config.encoding = "utf-8"
39
-
40
- # Configure sensitive parameters which will be filtered from the log file.
41
- config.filter_parameters += [:password]
42
-
43
- # Enable escaping HTML in JSON.
44
- config.active_support.escape_html_entities_in_json = true
45
-
46
- # Use SQL instead of Active Record's schema dumper when creating the database.
47
- # This is necessary if your schema can't be completely dumped by the schema dumper,
48
- # like if you have constraints or database-specific column types
49
- # config.active_record.schema_format = :sql
50
-
51
- # Enable the asset pipeline
52
- config.assets.enabled = true
53
-
54
- # Version of your assets, change this if you want to expire all your assets
55
- config.assets.version = '1.0'
56
25
  end
57
26
  end
58
-
@@ -1,10 +1,3 @@
1
- require 'rubygems'
2
- gemfile = File.expand_path('../../../../Gemfile', __FILE__)
1
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3
2
 
4
- if File.exist?(gemfile)
5
- ENV['BUNDLE_GEMFILE'] = gemfile
6
- require 'bundler'
7
- Bundler.setup
8
- end
9
-
10
- $:.unshift File.expand_path('../../../../lib', __FILE__)
3
+ require 'bundler/setup' # Set up gems listed in the Gemfile.
@@ -1,5 +1,5 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
1
+ # Load the Rails application.
2
+ require_relative 'application'
3
3
 
4
- # Initialize the rails application
5
- Dummy::Application.initialize!
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -1,34 +1,54 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # In the development environment your application's code is reloaded on
5
5
  # every request. This slows down response time but is perfect for development
6
6
  # since you don't have to restart the web server when you make code changes.
7
7
  config.cache_classes = false
8
8
 
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports.
13
+ config.consider_all_requests_local = true
14
+
15
+ # Enable/disable caching. By default caching is disabled.
16
+ if Rails.root.join('tmp/caching-dev.txt').exist?
17
+ config.action_controller.perform_caching = true
11
18
 
12
- # Show full error reports and disable caching
13
- config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
19
+ config.cache_store = :memory_store
20
+ config.public_file_server.headers = {
21
+ 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
22
+ }
23
+ else
24
+ config.action_controller.perform_caching = false
15
25
 
16
- # Don't care if the mailer can't send
17
- config.action_mailer.raise_delivery_errors = false
26
+ config.cache_store = :null_store
27
+ end
18
28
 
19
- # Print deprecation notices to the Rails logger
29
+ # Don't care if the mailer can't send.
30
+ # config.action_mailer.raise_delivery_errors = false
31
+
32
+ # config.action_mailer.perform_caching = false
33
+
34
+ # Print deprecation notices to the Rails logger.
20
35
  config.active_support.deprecation = :log
21
36
 
22
- # Only use best-standards-support built into browsers
23
- config.action_dispatch.best_standards_support = :builtin
37
+ # Raise an error on page load if there are pending migrations.
38
+ # config.active_record.migration_error = :page_load
24
39
 
25
- #config.assets.paths << "#{Rails}/vendor/assets/fonts"
40
+ # Debug mode disables concatenation and preprocessing of assets.
41
+ # This option may cause significant delays in view rendering with a large
42
+ # number of complex assets.
43
+ config.assets.debug = true
26
44
 
27
- # Do not compress assets
28
- config.assets.compress = false
45
+ # Suppress logger output for asset requests.
46
+ config.assets.quiet = true
29
47
 
30
- # Expands the lines which load the assets
31
- config.assets.debug = false
48
+ # Raises error for missing translations
49
+ # config.action_view.raise_on_missing_translations = true
32
50
 
33
- config.eager_load = false
51
+ # Use an evented file watcher to asynchronously detect changes in source code,
52
+ # routes, locales, etc. This feature depends on the listen gem.
53
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
34
54
  end