Skip to content

Commit

Permalink
bump version
Browse files Browse the repository at this point in the history
- including rubocop autocleanup
- add changelog
  • Loading branch information
andreaseger committed Jul 29, 2019
1 parent 99d1e53 commit b13a11d
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ Changelog
master
---

2.2.0
---

- also inspect `.rake` files
- readme format changes

2.1.0
---
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

source 'https://rubygems.org'
gemspec
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 runtastic GmbH
Copyright (c) 2019 runtastic GmbH

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'

begin
Expand Down
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'rubocop_runner'
Expand Down
14 changes: 10 additions & 4 deletions lib/rubocop_runner.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rubocop_runner/version'
require 'rubocop'

Expand All @@ -7,6 +9,7 @@ module RubocopRunner
# from https://github.com/djberg96/ptools/blob/master/lib/ptools.rb#L90
def binary?(file)
return true if File.ftype(file) != 'file'

s = (File.read(file, File.stat(file).blksize) || '').split(//)
((s.size - s.grep(' '..'~').size) / s.size.to_f) > 0.30
end
Expand Down Expand Up @@ -42,8 +45,8 @@ def files
end
end

RUBY_PATTERN = /\.(rb|gemspec|rake)$/
RUBY_NAMES = %w(Guardfile Gemfile Rakefile config.ru).freeze
RUBY_PATTERN = /\.(rb|gemspec|rake)$/.freeze
RUBY_NAMES = %w[Guardfile Gemfile Rakefile config.ru].freeze

def ruby_file?(filename)
RUBY_NAMES.include?(filename) || !(filename =~ RUBY_PATTERN).nil?
Expand All @@ -55,12 +58,13 @@ def staged_ruby_files
end
end

DEFAULT_ARGS = %w(--auto-correct
DEFAULT_ARGS = %w[--auto-correct
--format fuubar
--force-exclusion
--fail-level autocorrect).freeze
--fail-level autocorrect].freeze
def run
return 0 if staged_ruby_files.empty?

::RuboCop::CLI.new.run(DEFAULT_ARGS + staged_ruby_files)
end

Expand All @@ -73,6 +77,7 @@ def root

def create_backup(pre_commit_path)
return unless File.exist?(pre_commit_path)

FileUtils.mv(pre_commit_path,
pre_commit_path.join('.bkp'),
force: true)
Expand All @@ -82,6 +87,7 @@ def install(root = '.')
require 'fileutils'
git_root = Pathname.new "#{root}/.git"
return false unless File.exist?(git_root)

pre_commit_path = git_root.join('hooks', 'pre-commit')
create_backup(pre_commit_path)

Expand Down
4 changes: 3 additions & 1 deletion lib/rubocop_runner/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RubocopRunner
VERSION = '2.1.0'.freeze
VERSION = '2.2.0'
end
1 change: 1 addition & 0 deletions lib/template/pre-commit
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

begin
require 'bundler/setup'
Expand Down
9 changes: 5 additions & 4 deletions rubocop_runner.gemspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
# frozen_string_literal: true

lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rubocop_runner/version'

Expand All @@ -22,9 +23,9 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']

spec.add_development_dependency 'bundler', '~> 1.10'
spec.add_development_dependency 'bundler', '> 1.10', '<3'
spec.add_development_dependency 'rake', '~> 10.0'

spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'rubocop'
end

0 comments on commit b13a11d

Please sign in to comment.