Skip to content
Prev Previous commit
Next Next commit
Update rubocop and rspec. Rubocop fixes
  • Loading branch information
michael-misshore committed Dec 29, 2017
commit 53a421c2c28d3792351b5375abe750bfd19a262c
30 changes: 23 additions & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2015-10-29 13:19:55 -0500 using RuboCop version 0.34.1.
# on 2017-12-29 15:04:25 +0000 using RuboCop version 0.52.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Max: 91
# Offense count: 1
Metrics/AbcSize:
Max: 19

# Offense count: 1
# Configuration parameters: Exclude.
Style/FileName:
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 31

# Offense count: 1
Naming/AccessorMethodName:
Exclude:
- 'spec/support/static_file_server.rb'

# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'lib/critical-path-css-rails.rb'

# Offense count: 4
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 96
2 changes: 1 addition & 1 deletion critical-path-css-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
s.require_path = 'lib'

s.add_development_dependency 'rspec', '~> 3.6'
s.add_development_dependency 'rspec', '~> 3.7'

s.extensions = ['ext/npm/extconf.rb']
end
1 change: 0 additions & 1 deletion ext/npm/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
File.write 'Makefile',
"make:\n\t\ninstall:\n\truby install.rb\nclean:\n\t\n"

2 changes: 1 addition & 1 deletion lib/critical-path-css-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'critical_path_css/rails/config_loader'

module CriticalPathCss
CACHE_NAMESPACE = 'critical-path-css'
CACHE_NAMESPACE = 'critical-path-css'.freeze

def self.generate(route)
::Rails.cache.write(
Expand Down
1 change: 0 additions & 1 deletion lib/critical_path_css/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'erb'
module CriticalPathCss
class Configuration

def initialize(config)
@config = config
end
Expand Down
2 changes: 1 addition & 1 deletion lib/critical_path_css/css_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def css_for_route(route)
# '^\.regexWorksToo'
],
# ms; abort critical CSS generation after this timeout
'timeout' => 30000,
'timeout' => 30_000,
# set to true to throw on CSS errors (will run faster if no errors)
'strict' => false,
# characters; strip out inline base64 encoded resources larger than this
Expand Down
4 changes: 2 additions & 2 deletions lib/critical_path_css/rails/config_loader.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module CriticalPathCss
module Rails
class ConfigLoader
CONFIGURATION_FILENAME = 'critical_path_css.yml'
CONFIGURATION_FILENAME = 'critical_path_css.yml'.freeze

def load
config = YAML.load(ERB.new(File.read(configuration_file_path)).result)[::Rails.env]
config = YAML.safe_load(ERB.new(File.read(configuration_file_path)).result)[::Rails.env]
config['css_path'] = "#{::Rails.root}/public" + (
config['css_path'] ||
ActionController::Base.helpers.stylesheet_path(
Expand Down
2 changes: 1 addition & 1 deletion lib/critical_path_css/rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module CriticalPathCSS
module Rails
VERSION = '1.0.1'
VERSION = '1.0.1'.freeze
end
end
5 changes: 2 additions & 3 deletions lib/npm_commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

# NPM wrapper with helpful error messages
class NpmCommands

# @return [Boolean] whether the installation succeeded
def install(*args) # rubocop:disable Metrics/MethodLength
def install(*args)
return false unless check_nodejs_installed
STDERR.puts 'Installing npm dependencies...'
install_status = Dir.chdir File.expand_path('..', File.dirname(__FILE__)) do
Expand All @@ -24,7 +23,7 @@ def install(*args) # rubocop:disable Metrics/MethodLength

private

def check_nodejs_installed # rubocop:disable Metrics/MethodLength
def check_nodejs_installed
return true if executable?('node')
STDERR.puts(
'-' * 60,
Expand Down
2 changes: 1 addition & 1 deletion spec/support/static_file_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module StaticFileServer
class << self
def start # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
def start
@port = get_free_port
rd, wt = IO.pipe
@pid = fork do
Expand Down