Skip to content

Commit

Permalink
Merge pull request #1 from adamhunter/ah-upgrade-2.6.3
Browse files Browse the repository at this point in the history
rails 5.2.3 and ruby 2.6.3
  • Loading branch information
adamhunter committed Jun 13, 2019
2 parents 81564d5 + aa8e1c2 commit 9caa85e
Show file tree
Hide file tree
Showing 41 changed files with 79 additions and 75 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Expand Up @@ -6,9 +6,9 @@ Gemfile.lock
log/*.log
pkg/
coverage/*
spec/dummy/db/*.sqlite3
spec/dummy/log/*.log
spec/dummy/tmp/
spec/dummy/.sass-cache
spec/sample/db/*.sqlite3
spec/sample/log/*.log
spec/sample/tmp/
spec/sample/.sass-cache
spec/fixtures/db/*.yml
spec/fixtures/db/*.sqlite3
15 changes: 7 additions & 8 deletions .travis.yml
@@ -1,14 +1,13 @@
language: ruby
rvm:
- "1.9.3"
- "2.0.0"
- "2.1.2"
- "2.2.2"
- "2.4.6"
- "2.5.5"
- "2.6.3"
env:
- "RAILS_VERSION=3.2.22"
- "RAILS_VERSION=4.0.13"
- "RAILS_VERSION=4.1.12"
- "RAILS_VERSION=4.2.3"
- "RAILS_VERSION=4.2.11.1"
- "RAILS_VERSION=5.0.7.2"
- "RAILS_VERSION=5.1.7"
- "RAILS_VERSION=5.2.3"
script:
- DOSSIER_DB=sqlite3 bundle exec rspec
- DOSSIER_DB=mysql2 bundle exec rspec
Expand Down
12 changes: 6 additions & 6 deletions Gemfile
Expand Up @@ -2,18 +2,18 @@ source "https://rubygems.org"

gemspec

RAILS_VERSION = ENV.fetch('RAILS_VERSION', '4.2.3')
ruby '~> 2.4'

RAILS_VERSION = ENV.fetch('RAILS_VERSION', '5.2.3')
gem "activesupport", RAILS_VERSION
gem "actionpack", RAILS_VERSION
gem "actionmailer", RAILS_VERSION
gem "railties", RAILS_VERSION
gem "activerecord", RAILS_VERSION

# gems used by the dummy application
# gems used by the sample application
gem "jquery-rails"
gem "mysql2"
gem "pg"
gem "pg", '~> 0.15'
gem 'coveralls', require: false

# test unit removed from stdlib in ruby 2.2.0
gem 'test-unit' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
gem 'test-unit'
21 changes: 13 additions & 8 deletions README.md
Expand Up @@ -6,10 +6,10 @@ Dossier is a Rails engine that turns SQL into reports. Reports can be easily ren
- If you **love** SQL, you can use every feature your database supports.

[![Gem Version](https://badge.fury.io/rb/dossier.svg)](http://badge.fury.io/rb/dossier)
[![Code Climate](https://codeclimate.com/github/tma1/dossier/badges/gpa.svg)](https://codeclimate.com/github/tma1/dossier)
[![Build Status](https://travis-ci.org/tma1/dossier.svg?branch=master)](https://travis-ci.org/tma1/dossier)
[![Coverage Status](https://coveralls.io/repos/tma1/dossier/badge.svg?branch=master&service=github)](https://coveralls.io/github/tma1/dossier?branch=master)
[![Dependency Status](https://gemnasium.com/tma1/dossier.svg)](https://gemnasium.com/tma1/dossier)
[![Code Climate](https://codeclimate.com/github/adamhunter/dossier/badges/gpa.svg)](https://codeclimate.com/github/adamhunter/dossier)
[![Build Status](https://travis-ci.org/adamhunter/dossier.svg?branch=master)](https://travis-ci.org/adamhunter/dossier)
[![Coverage Status](https://coveralls.io/repos/adamhunter/dossier/badge.svg?branch=master&service=github)](https://coveralls.io/github/adamhunter/dossier?branch=master)
[![Dependency Status](https://gemnasium.com/adamhunter/dossier.svg)](https://gemnasium.com/adamhunter/dossier)

## Setup

Expand Down Expand Up @@ -246,7 +246,7 @@ end

## Advanced Usage

To see a report with all the bells and whistles, check out `spec/dummy/app/reports/employee_report.rb` or other reports in `spec/dummy/app/reports`.
To see a report with all the bells and whistles, check out `spec/sample/app/reports/employee_report.rb` or other reports in `spec/sample/app/reports`.

## Compatibility

Expand Down Expand Up @@ -298,7 +298,7 @@ Note: when you run the tests, Dossier will **make and/or truncate** some tables

- Run `bundle`
- `RAILS_ENV=test rake db:create`
- `cp spec/dummy/config/database.yml{.example,}` and edit it so that it can connect to the test database.
- `cp spec/sample/config/database.yml{.example,}` and edit it so that it can connect to the test database.
- `cp spec/fixtures/db/mysql2.yml{.example,}`
- `cp spec/fixtures/db/sqlite3.yml{.example,}`
- `rspec spec`
Expand All @@ -319,5 +319,10 @@ Note: when you run the tests, Dossier will **make and/or truncate** some tables

## Roadmap

- Moar Dokumentationz pleaze
- Use the [`roo`](https://github.com/hmcgowan/roo) gem to generate a variety of output formats
- Make Roadmap

## Versions

Rails 3.x and 4.x are supported in the Dossier 2.x version.
Ruby 2.4+, Rails 4.2.11, Rails 5.0.x, 5.1.x, 5.2.x are supported in the Dossier 3.x version.

2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -14,7 +14,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('lib/**/*.rb')
end

APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
APP_RAKEFILE = File.expand_path("../spec/sample/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'

Bundler::GemHelper.install_tasks
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
2.13.1
3.0.0.pre
4 changes: 2 additions & 2 deletions app/controllers/dossier/reports_controller.rb
Expand Up @@ -17,15 +17,15 @@ def multi
private

def report_class
Dossier::Model.name_to_class(params[:report])
Dossier::Model.name_to_class(params.fetch :report)
end

def report
@report ||= report_class.new(options_params)
end

def options_params
params[:options].presence || {}
params.slice(:options).permit![:options] || {}
end
end
end
4 changes: 4 additions & 0 deletions app/helpers/dossier/application_helper.rb
@@ -1,6 +1,10 @@
module Dossier
module ApplicationHelper

def report
@report
end

def formatted_dossier_report_path(format, report)
dossier_report_path(format: format, options: report.options, report: report.report_name)
end
Expand Down
36 changes: 18 additions & 18 deletions dossier.gemspec
Expand Up @@ -7,29 +7,29 @@ require "dossier/version"
Gem::Specification.new do |s|
s.name = "dossier"
s.version = Dossier::VERSION
s.authors = ["TMA IT"]
s.email = ["developer@tma1.com"]
s.authors = ["Adam Hunter"]
s.email = ["adamhunter@me.com"]
s.summary = "SQL based report generation."
s.description = "Easy SQL based report generation with the ability to accept request parameters and render multiple formats."
s.homepage = "https://github.com/tma1/dossier"
s.homepage = "https://github.com/adamhunter/dossier"
s.license = 'MIT'

s.files = Dir["{app,config,db,lib}/**/*"] + %w[MIT-LICENSE Rakefile README.md VERSION]
s.test_files = Dir["spec/**/*"] - %w[spec/dummy/config/dossier.yml]
s.test_files = Dir["spec/**/*"] - %w[spec/sample/config/dossier.yml]

s.add_dependency "arel", ">= 3.0"
s.add_dependency "activesupport", ">= 3.2"
s.add_dependency "actionpack", ">= 3.2"
s.add_dependency "actionmailer", ">= 3.2"
s.add_dependency "railties", ">= 3.2"
s.add_dependency "haml", ">= 3.1"
s.add_dependency "responders", ">= 1.1"
s.add_dependency "arel", ">= 4.2.11.1"
s.add_dependency "activesupport", ">= 4.2.11.1"
s.add_dependency "actionpack", ">= 4.2.11.1"
s.add_dependency "actionmailer", ">= 4.2.11.1"
s.add_dependency "railties", ">= 4.2.11.1"
s.add_dependency "haml", ">= 5.1"
s.add_dependency "responders", ">= 2.4"

s.add_development_dependency "activerecord", ">= 3.2"
s.add_development_dependency "sqlite3", ">= 1.3.6"
s.add_development_dependency "pry", ">= 0.10.1"
s.add_development_dependency "rspec-rails", ">= 3.3.3"
s.add_development_dependency "generator_spec", "~> 0.9.3"
s.add_development_dependency "capybara", "~> 2.4.4"
s.add_development_dependency "simplecov", "~> 0.10.0"
s.add_development_dependency "activerecord", ">= 4.2.11.1"
s.add_development_dependency "sqlite3", "~> 1.3.6"
s.add_development_dependency "pry", ">= 0.12.1"
s.add_development_dependency "rspec-rails", ">= 3.8.2"
s.add_development_dependency "generator_spec", "~> 0.9.4"
s.add_development_dependency "capybara", "~> 3.23.0"
s.add_development_dependency "simplecov", "~> 0.16.1"
end
2 changes: 1 addition & 1 deletion lib/dossier/formatter.rb
Expand Up @@ -14,7 +14,7 @@ def number_to_dollars(value)

def commafy_number(value, precision = nil)
whole, fraction = value.to_s.split('.')
fraction = "%.#{precision}d" % (BigDecimal.new("0.#{fraction}").round(precision) * 10**precision).to_i if precision
fraction = "%.#{precision}d" % (BigDecimal("0.#{fraction || 0}").round(precision) * 10**precision).to_i if precision
[whole.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,"), fraction].compact.join('.')
end

Expand Down
2 changes: 1 addition & 1 deletion lib/dossier/multi_report.rb
Expand Up @@ -12,7 +12,7 @@ def self.combine(*reports)
end

def initialize(options = {})
self.options = options.dup.with_indifferent_access
self.options = options.to_hash.dup.with_indifferent_access
end

def reports
Expand Down
5 changes: 1 addition & 4 deletions lib/dossier/renderer.rb
Expand Up @@ -3,9 +3,6 @@ class Renderer
attr_reader :report
attr_writer :engine

# Conditional for Rails 4.1 or < 4.1 Layout module
Layouts = defined?(ActionView::Layouts) ? ActionView::Layouts : AbstractController::Layouts

def initialize(report)
@report = report
end
Expand Down Expand Up @@ -41,7 +38,7 @@ def default_template_path

class Engine < AbstractController::Base
include AbstractController::Rendering
include Renderer::Layouts
include ActionView::Layouts
include ViewContextWithReportFormatter

attr_reader :report
Expand Down
2 changes: 1 addition & 1 deletion lib/dossier/report.rb
Expand Up @@ -25,7 +25,7 @@ def self.filename
end

def initialize(options = {})
@options = options.dup.with_indifferent_access
@options = options.to_hash.dup.with_indifferent_access
end

def sql
Expand Down
3 changes: 2 additions & 1 deletion lib/dossier/responder.rb
Expand Up @@ -15,7 +15,8 @@ def to_json

def to_csv
set_content_disposition!
controller.response_body = StreamCSV.new(*collection_and_headers(report.raw_results.arrays))
controller.response_body =
StreamCSV.new(*collection_and_headers(report.raw_results.arrays))
end

def to_xls
Expand Down
5 changes: 4 additions & 1 deletion spec/dossier/responder_spec.rb
Expand Up @@ -12,8 +12,11 @@ def mock_out_report_results(report)
let(:results) { double(arrays: [%w[hi], %w[there]], hashes: [{hi: 'there'}]) }
let(:report) { EmployeeReport.new }
let(:reports) { [mock_out_report_results(report)] }

let(:controller) {
ActionController::Base.new.tap { |controller| allow(controller).to receive(:headers).and_return({}) }
ActionController::Base.new.tap { |controller|
controller.response = ActionDispatch::TestResponse.new(200, {}, [''])
}
}
let(:responder) { described_class.new(controller, reports, {}) }

Expand Down
3 changes: 0 additions & 3 deletions spec/dummy/app/controllers/application_controller.rb

This file was deleted.

1 change: 0 additions & 1 deletion spec/dummy/config.ru

This file was deleted.

File renamed without changes.
2 changes: 2 additions & 0 deletions spec/sample/app/controllers/application_controller.rb
@@ -0,0 +1,2 @@
ApplicationController = Class.new(ActionController::Base)
ApplicationController.protect_from_forgery with: :exception
Expand Up @@ -74,7 +74,7 @@ def format_name(name)
end

def format_suspended(value)
value.to_s.in?(%w(1 t)) ? 'Yes' : 'No'
value.to_s.in?(%w(true 1 t)) ? 'Yes' : 'No'
end

def example_before_hook
Expand Down
File renamed without changes.
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<title>Sample</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions spec/sample/config.ru
@@ -0,0 +1 @@
run Sample::Application
Expand Up @@ -9,7 +9,7 @@

Bundler.require

module Dummy
module Sample
class Application < ::Rails::Application
config.cache_classes = true
config.active_support.deprecation = :stderr
Expand All @@ -18,13 +18,13 @@ class Application < ::Rails::Application

# Raise exceptions instead of rendering exception templates
config.action_dispatch.show_exceptions = false
# because this belongs here for some reason...??? also in spec_helper
# thanks rails 5 :/
config.active_support.test_order = :random

config.secret_token = config.secret_key_base =
config.secret_key_base =
'http://s3-ec.buzzfed.com/static/enhanced/webdr03/2013/5/25/8/anigif_enhanced-buzz-11857-1369483324-0.gif'

config.active_record.sqlite3.tap { |x| x.represent_boolean_as_integer = true if x }
end
end

Dummy::Application.initialize!
Sample::Application.initialize!
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 3 additions & 7 deletions spec/spec_helper.rb
Expand Up @@ -2,18 +2,14 @@
require 'simplecov'
require 'coveralls'

# not sure why I need to do this now, its after I added dummy-application
# ApplicationController.helper Dossier::ApplicationHelper
# SiteController.helper Dossier::ApplicationHelper

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
]
])
SimpleCov.start
Coveralls.wear!('rails')

require File.expand_path("../dummy/config/application.rb", __FILE__)
require File.expand_path("../sample/config/application.rb", __FILE__)
require 'rspec/rails'
require 'pry'
require 'generator_spec'
Expand Down

0 comments on commit 9caa85e

Please sign in to comment.