simplify: removed rails/node specific env

This commit is contained in:
rkiel
2016-04-29 09:12:25 -04:00
parent 60b1c90cc1
commit 21e65d0e99
4 changed files with 9 additions and 99 deletions

View File

@@ -22,18 +22,6 @@ module Xgrep
@option_parser = OptionParser.new do |op|
op.banner = "Usage: xgrep options term(s)"
op.on('-a','--asset') do |argument|
options.pathspec << :asset
end
op.on('-b','--db') do |argument|
options.pathspec << :db
end
op.on('-c','--controller') do |argument|
options.pathspec << :controller
end
op.on('-d','--[no-]debug') do |argument|
options.debug = argument
end
@@ -42,26 +30,10 @@ module Xgrep
options.git_grep << "-L"
end
op.on('-g','--config') do |argument|
options.pathspec << :config
end
op.on('-i','--invert') do |argument|
options.git_grep << '-v'
end
op.on('-l','--lib') do |argument|
options.pathspec << :lib
end
op.on('-m','--model') do |argument|
options.pathspec << :model
end
op.on('-o','--core') do |argument|
options.pathspec << :core
end
op.on_tail('-h','--help') do |argument|
puts op
exit
@@ -123,10 +95,6 @@ module Xgrep
def default_environment
if File.exist?('./.xgrep')
Xgrep::CustomEnv.new
elsif File.exist?("Gemfile")
Xgrep::RailsEnv.new
elsif File.exist?("package.json")
Xgrep::NodeEnv.new
else
Xgrep::SimpleEnv.new
end

View File

@@ -1,34 +0,0 @@
module Xgrep
class NodeEnv
attr_accessor :pathspec
def initialize
@pathspec = { }
end
def update_pathspec ( pathspec )
files = %w{app.js Gruntfile.js routes.js server.js package.json}
dirs = %w{api app config controllers db lib models routes script views}
specs = %w{spec test}
assets = {}
%w{js css less}.each do |ext|
assets += Dir.glob("assets/**/*.#{ext}").reject { |x| x =- Regexp.new("\\.min\\.#{ext}$") }
end
if pathspec.empty?
@pathspec = files + dirs + specs
elsif pathspec.include? :core
@pathspec = files + dirs
else
@pathspec += assets if pathspec.include? :asset
@pathspec += %w{models api/models app/models} if pathspec.include? :models
@pathspec += %w{views api/views app/views} if pathspec.include? :views
@pathspec += %w{controllers api/controllers app/controllers} if pathspec.include? :controllers
@pathspec += %w{config} if pathspec.include? :config
@pathspec += %w{db} if pathspec.include? :db
@pathspec += %w{lib} if pathspec.include? :lib
@pathspec += %w{spec test} if pathspec.include? :spec
end
end
end
end

View File

@@ -1,33 +0,0 @@
module Xgrep
class RailsEnv
attr_accessor :pathspec
def initialize
@pathspec = { }
end
def update_pathspec ( pathspec )
files = %w{Capfile Gemfile Rakefile}
dirs = %w{app config db lib}
specs = %w{spec}
if pathspec.empty?
@pathspec = files + dirs + specs
elsif pathspec.include? :core
@pathspec = files + dirs
else
@pathspec += %w{app/assets} if pathspec.include? :asset
@pathspec += %w{app/helpers} if pathspec.include? :helper
@pathspec += %w{app/mailers} if pathspec.include? :mailer
@pathspec += %w{app/models} if pathspec.include? :models
@pathspec += %w{app/views} if pathspec.include? :views
@pathspec += %w{app/controllers} if pathspec.include? :controllers
@pathspec += %w{app/services} if pathspec.include? :services
@pathspec += %w{config} if pathspec.include? :config
@pathspec += %w{db} if pathspec.include? :db
@pathspec += %w{lib} if pathspec.include? :lib
@pathspec += %w{spec} if pathspec.include? :spec
end
end
end
end

View File

@@ -7,6 +7,15 @@ module Xgrep
end
def update_pathspec ( pathspec )
files = %w{}
dirs = %w{.}
specs = %w{}
if pathspec.empty?
@pathspec = files + dirs + specs
else
@pathspec = pathspec
end
end
end
end