-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ae3440
commit 472ee21
Showing
14 changed files
with
272 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module PolishGeeks | ||
module DevTools | ||
module Commands | ||
# Validator used to check if all files don't contain merge conflict | ||
# @example: <<<<<<< HEAD | ||
class GitConflicts < Base | ||
self.type = :validator | ||
|
||
attr_reader :counter | ||
|
||
# Regexp that we want to use to catch files with git conflicts like <<<<<<< HEAD | ||
CHECKED_REGEXP = '^<<<<<<<[ \t]'.freeze | ||
|
||
# Executes this command and set output variable | ||
def execute | ||
@output = invalid_files | ||
end | ||
|
||
# @return [Boolean] true if all files don't contain git conflict | ||
def valid? | ||
output.empty? | ||
end | ||
|
||
# @return [String] default label for this command | ||
def label | ||
'Git conflicts' | ||
end | ||
|
||
# @return [String] message that should be printed when some files has git conflict | ||
def error_message | ||
"Following files have git conflicts: \n#{output.join("\n")}\n" | ||
end | ||
|
||
private | ||
|
||
# @return [Array<String>] list of files which contain merge conflict marker | ||
def invalid_files | ||
cmd = "grep -r -l '#{CHECKED_REGEXP}' . | xargs -n1 basename" | ||
PolishGeeks::DevTools::Shell.new.execute(cmd).split("\n") | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module PolishGeeks | ||
module DevTools | ||
# Helpers wrapper | ||
module Helpers | ||
# Helper useful to manage paths and files | ||
module FileHelper | ||
# @param [String] file name that we want to sanitize | ||
# @return [String] sanitized file name | ||
# @example | ||
# file = /home/something/app/lib/lib.rb, | ||
# where /home/something/app/ is a app root path, then | ||
# sanitize(file) #=> lib/lib.rb | ||
def sanitize(file) | ||
file.gsub("#{PolishGeeks::DevTools.app_root}/", '') | ||
end | ||
|
||
# @param [String] path from which we want take files | ||
# @return [Array<String>] list of files in path with app prefix path | ||
# @note if path is a file return array with file path with app prefix path | ||
def files_from_path(path) | ||
full_path = "#{::PolishGeeks::DevTools.app_root}/#{path}" | ||
return [full_path] if File.file?(full_path) | ||
|
||
Dir.glob(full_path).select { |f| File.file? f } | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,58 @@ | ||
%w( | ||
yaml | ||
yard | ||
pry | ||
fileutils | ||
timecop | ||
faker | ||
ostruct | ||
).each { |lib| require lib } | ||
|
||
%w( | ||
validators/base | ||
commands/base | ||
commands/empty_methods | ||
commands/empty_methods/string_refinements | ||
).each { |lib| require "polish_geeks/dev_tools/#{lib}" } | ||
# Require all from files array. If prefix is set method paste it before every file | ||
# @param [Array<String>] files to require | ||
# @param [String] prefix path | ||
def require_files(files, prefix = nil) | ||
files.each do |file| | ||
require prefix ? File.join(prefix, file) : file | ||
end | ||
end | ||
|
||
%w( | ||
*.rb | ||
validators/*.rb | ||
commands/*.rb | ||
commands/**/*.rb | ||
).each do |path| | ||
base_path = File.dirname(__FILE__) + "/polish_geeks/dev_tools/#{path}" | ||
Dir[base_path].each { |file| require file } | ||
# Require all file from dirs array. If prefix is set method paste it before every dir | ||
# @param [Array<String>] dirs from whic we want require files | ||
# @param [String] prefix path | ||
def require_dirs(dirs, prefix = 'polish_geeks/dev_tools') | ||
dirs.each do |path| | ||
base_path = File.join(File.dirname(__FILE__), prefix, path) | ||
Dir[base_path].each { |file| require file } | ||
end | ||
end | ||
|
||
require_files( | ||
%w( | ||
yaml | ||
yard | ||
pry | ||
fileutils | ||
timecop | ||
faker | ||
ostruct | ||
) | ||
) | ||
|
||
require_dirs( | ||
%w( | ||
helpers/**/*.rb | ||
) | ||
) | ||
|
||
require_files( | ||
%w( | ||
validators/base | ||
commands/base | ||
commands/empty_methods | ||
commands/empty_methods/string_refinements | ||
), | ||
'polish_geeks/dev_tools' | ||
) | ||
|
||
require_dirs( | ||
%w( | ||
*.rb | ||
validators/*.rb | ||
commands/*.rb | ||
commands/**/*.rb | ||
) | ||
) | ||
|
||
require 'polish_geeks/dev_tools' | ||
load 'polish_geeks/dev_tools/tasks/dev-tools.rake' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.