simplify: removed rails/node specific env
This commit is contained in:
@@ -22,18 +22,6 @@ module Xgrep
|
|||||||
@option_parser = OptionParser.new do |op|
|
@option_parser = OptionParser.new do |op|
|
||||||
op.banner = "Usage: xgrep options term(s)"
|
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|
|
op.on('-d','--[no-]debug') do |argument|
|
||||||
options.debug = argument
|
options.debug = argument
|
||||||
end
|
end
|
||||||
@@ -42,26 +30,10 @@ module Xgrep
|
|||||||
options.git_grep << "-L"
|
options.git_grep << "-L"
|
||||||
end
|
end
|
||||||
|
|
||||||
op.on('-g','--config') do |argument|
|
|
||||||
options.pathspec << :config
|
|
||||||
end
|
|
||||||
|
|
||||||
op.on('-i','--invert') do |argument|
|
op.on('-i','--invert') do |argument|
|
||||||
options.git_grep << '-v'
|
options.git_grep << '-v'
|
||||||
end
|
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|
|
op.on_tail('-h','--help') do |argument|
|
||||||
puts op
|
puts op
|
||||||
exit
|
exit
|
||||||
@@ -123,10 +95,6 @@ module Xgrep
|
|||||||
def default_environment
|
def default_environment
|
||||||
if File.exist?('./.xgrep')
|
if File.exist?('./.xgrep')
|
||||||
Xgrep::CustomEnv.new
|
Xgrep::CustomEnv.new
|
||||||
elsif File.exist?("Gemfile")
|
|
||||||
Xgrep::RailsEnv.new
|
|
||||||
elsif File.exist?("package.json")
|
|
||||||
Xgrep::NodeEnv.new
|
|
||||||
else
|
else
|
||||||
Xgrep::SimpleEnv.new
|
Xgrep::SimpleEnv.new
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -7,6 +7,15 @@ module Xgrep
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_pathspec ( pathspec )
|
def update_pathspec ( pathspec )
|
||||||
|
files = %w{}
|
||||||
|
dirs = %w{.}
|
||||||
|
specs = %w{}
|
||||||
|
|
||||||
|
if pathspec.empty?
|
||||||
|
@pathspec = files + dirs + specs
|
||||||
|
else
|
||||||
|
@pathspec = pathspec
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user