Skip to content

Commit

Permalink
Merge branch 'example-comparator-diffs' of https://github.com/kowal/p…
Browse files Browse the repository at this point in the history
…olishgeeks-dev-tools into example-comparator-diffs

Conflicts:
	lib/polishgeeks/dev-tools/commands/examples_comparator.rb
	lib/polishgeeks/dev-tools/hash.rb
	spec/lib/polishgeeks/dev-tools/commands/examples_comparator_spec.rb
	spec/lib/polishgeeks/dev-tools/hash_spec.rb
  • Loading branch information
kowal committed Nov 18, 2015
2 parents c2a4dea + e7ba9a9 commit cbb0a70
Show file tree
Hide file tree
Showing 65 changed files with 444 additions and 432 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ tmp
*.o
*.a
mkmf.log
.DS_Store
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# PolishGeeks Dev Tools Changelog

## 1.2.2
- Bump rubocop dependency to 0.35.1
- Bump rubycritic dependency to 2.1.0
- Bump rspec dependency to 3.4.0
- Bump activemodel dependency to 4.2.5

## 1.2.1
- Extracted all errors to PolishGeeks::DevTools::Errors namespace
- Add support for validators
- Rename Command to Commands namespace

## 1.2.0
- Added EmptyMethod command which checks if some files have empty methods
Expand Down
58 changes: 31 additions & 27 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ GEM
remote: https://rubygems.org/
specs:
abstract_type (0.0.7)
activemodel (4.2.4)
activesupport (= 4.2.4)
activemodel (4.2.5)
activesupport (= 4.2.5)
builder (~> 3.1)
activesupport (4.2.4)
activesupport (4.2.5)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
Expand Down Expand Up @@ -67,10 +67,10 @@ GEM
faker (1.5.0)
i18n (~> 0.5)
fastercsv (1.5.5)
flay (2.4.0)
flay (2.6.1)
ruby_parser (~> 3.0)
sexp_processor (~> 4.0)
flog (4.2.1)
flog (4.3.2)
ruby_parser (~> 3.1, > 3.1.0)
sexp_processor (~> 4.4)
haml (4.0.7)
Expand All @@ -89,7 +89,7 @@ GEM
minitest (5.8.2)
mongo (2.1.2)
bson (~> 3.0)
mongoid (5.0.0)
mongoid (5.0.1)
activemodel (~> 4.0)
mongo (~> 2.1)
origin (~> 2.1)
Expand All @@ -103,47 +103,50 @@ GEM
parser (2.2.3.0)
ast (>= 1.1, < 3.0)
powerpack (0.1.1)
private_attr (1.1.0)
procto (0.0.2)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rainbow (2.0.0)
rake (10.4.2)
reek (1.6.5)
parser (~> 2.2.0.pre.7)
rainbow (>= 1.99, < 3.0)
reek (3.6.0)
parser (~> 2.2, >= 2.2.2.5)
private_attr (~> 1.1)
rainbow (~> 2.0)
unparser (~> 0.2.2)
rspec (3.3.0)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-core (3.3.2)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.1)
rspec (3.4.0)
rspec-core (~> 3.4.0)
rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.4.0)
rspec-core (3.4.0)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-mocks (3.3.2)
rspec-support (~> 3.4.0)
rspec-mocks (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-support (3.3.0)
rubocop (0.34.2)
rspec-support (~> 3.4.0)
rspec-support (3.4.0)
rubocop (0.35.1)
astrolabe (~> 1.3)
parser (>= 2.2.2.5, < 3.0)
parser (>= 2.2.3.0, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (~> 1.7)
tins (<= 1.6.0)
ruby-progressbar (1.7.5)
ruby2ruby (2.2.0)
ruby_parser (~> 3.1)
sexp_processor (~> 4.0)
ruby_parser (3.7.2)
sexp_processor (~> 4.1)
rubycritic (1.4.0)
flay (= 2.4.0)
flog (= 4.2.1)
rubycritic (2.1.0)
flay (= 2.6.1)
flog (= 4.3.2)
parser (>= 2.2.0, < 3.0)
reek (= 1.6.5)
reek (= 3.6.0)
virtus (~> 1.0)
safe_yaml (1.0.4)
sass (3.4.19)
Expand All @@ -169,6 +172,7 @@ GEM
thread_safe (0.3.5)
tilt (2.0.1)
timecop (0.8.0)
tins (1.6.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
unparser (0.2.4)
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ task :check do
config.brakeman = false
config.haml_lint = false
config.expires_in_files_ignored = %w(
lib/polishgeeks/dev-tools/command/expires_in.rb
lib/polishgeeks/dev-tools/commands/expires_in.rb
)
config.empty_method_ignored = %w(
empty_method_spec.rb
Expand Down
46 changes: 26 additions & 20 deletions lib/polishgeeks-dev-tools.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
require 'yaml'
require 'yard'
require 'pry'
require 'fileutils'
require 'timecop'
require 'faker'
require 'ostruct'

base_path = File.dirname(__FILE__) + '/polishgeeks/dev-tools/*.rb'
Dir[base_path].each { |file| require file }
%w(
yaml
yard
pry
fileutils
timecop
faker
ostruct
).each { |lib| require lib }

%w(
validators/base
commands/base
commands/empty_method
commands/empty_method/string_refinements
).each { |lib| require "polishgeeks/dev-tools/#{lib}" }

%w(
*.rb
validators/*.rb
commands/*.rb
commands/**/*.rb
).each do |path|
base_path = File.dirname(__FILE__) + "/polishgeeks/dev-tools/#{path}"
Dir[base_path].each { |file| require file }
end

module PolishGeeks
module DevTools
Expand Down Expand Up @@ -35,14 +51,4 @@ def self.setup(&block)
end
end

require 'polishgeeks/dev-tools/command/base'
require 'polishgeeks/dev-tools/command/empty_method'
require 'polishgeeks/dev-tools/command/empty_method/string_refinements'

commands_path = File.dirname(__FILE__) + '/polishgeeks/dev-tools/command/*.rb'
Dir[commands_path].each { |file| require file }

commands_path = File.dirname(__FILE__) + '/polishgeeks/dev-tools/command/**/*.rb'
Dir[commands_path].each { |file| require file }

load 'polishgeeks/dev-tools/tasks/dev-tools.rake'
32 changes: 0 additions & 32 deletions lib/polishgeeks/dev-tools/command/simplecov.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module PolishGeeks
module DevTools
module Command
module Commands
# Checking config directory that all files are allowed
class AllowedExtensions < Base
self.type = :validator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module PolishGeeks
module DevTools
# Module encapsulating all the commands that we use to check/verify code
module Command
module Commands
# Base class for all the commands
# @abstract Subclass and use
class Base
# Output string that we get after executing this command
attr_reader :output
# stored_output [PolishGeeks::DevTools::OutputStorer] storer with results of previous
# commands (they might use output from previous/other commands)
Expand All @@ -17,7 +18,7 @@ class Base

class << self
attr_accessor :type
attr_accessor :framework
attr_accessor :validators

TYPES.each do |type|
# @return [Boolean] if it is a given type command
Expand All @@ -27,13 +28,6 @@ class << self
end
end

# When we will try to use a given command, we need to check if it requires
# a given framework (Rails, Sinatra), if so, then we need to check if it is
# present, because without it a given command cannot run
def initialize
ensure_framework_if_required
end

# @raise [NotImplementedError] this should be implemented in a subclass
def execute
fail Errors::NotImplementedError
Expand All @@ -52,16 +46,16 @@ def error_message
output
end

private

# Checks if a framework is required for a given command, and if so, it wont
# allow to execute this command if it is not present
# @raise [PolishGeeks::DevTools::Command::Base::MissingFramework] if req framework missing
def ensure_framework_if_required
return unless self.class.framework
return if PolishGeeks::DevTools.config.public_send(:"#{self.class.framework}?")

fail Errors::MissingFramework, self.class.framework
# Runs validators if any to check if all requirements of this command
# are met in order to execute it properly
# @raise [PolishGeeks::DevTools::Errors::InvalidValidatorClassError] when invalid
# validator class name is defined
# @raise [PolishGeeks::DevTools::Errors::PreCommandValidationError] when validator
# conditions are not met
def ensure_executable!
(self.class.validators || []).each do |validator_class|
validator_class.new(stored_output).validate!
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
module PolishGeeks
module DevTools
module Command
module Commands
# A static analysis security vulnerability scanner for Ruby on Rails applications
# @see https://github.com/presidentbeef/brakeman
class Brakeman < Base
self.type = :validator
self.framework = :rails
self.validators = [
Validators::Rails
]

# Regexps to get some stat info from brakeman output
REGEXPS = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module PolishGeeks
module DevTools
module Command
module Commands
# Validator used to check if all '.rb' files don't have empty methods
class EmptyMethod < Base
self.type = :validator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module PolishGeeks
module DevTools
module Command
module Commands
class EmptyMethod
# Parse file and search whether it contain empty methods
class FileParser
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module PolishGeeks
module DevTools
module Command
module Commands
class EmptyMethod
# Adds ability to check strings on specific regex matching
module StringRefinements
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module PolishGeeks
module DevTools
module Command
module Commands
# Command wrapper for ExamplesComparator rake task
# It informs us if our .example files structure is the same as non-example once
class ExamplesComparator < Base
Expand Down Expand Up @@ -67,8 +67,8 @@ def successful_compare(compare_header)

# @param [String] compare_header output message
# @return [String] failed message for single file
def failed_compare(compare_header, details='')
"\e[31m failed\e[0m - #{compare_header} - structure not equal:\n\t#{details}\n"
def failed_compare(compare_header, details = '')
"\e[31m failed\e[0m - #{compare_header} - structure not equal#{details}\n"
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module PolishGeeks
module DevTools
module Command
module Commands
# Checking Rails cache options especially expires_in
class ExpiresIn < Base
self.type = :validator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module PolishGeeks
module DevTools
module Command
module Commands
# Validator used to check if all files have final blank line
class FinalBlankLine < Base
self.type = :validator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module PolishGeeks
module DevTools
module Command
module Commands
# Command wrapper for Haml lint validation
# It informs us if haml is formatted in a proper way
# @see https://github.com/causes/haml-lint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module PolishGeeks
module DevTools
module Command
module Commands
# Checks README.rb exists
class Readme < Base
self.type = :validator
Expand Down
Loading

0 comments on commit cbb0a70

Please sign in to comment.