From 21e65d0e99b63bf58d1f11a476edee7cf09a30a9 Mon Sep 17 00:00:00 2001 From: rkiel Date: Fri, 29 Apr 2016 09:12:25 -0400 Subject: [PATCH] simplify: removed rails/node specific env --- lib/xgrep/commander.rb | 32 -------------------------------- lib/xgrep/node_env.rb | 34 ---------------------------------- lib/xgrep/rails_env.rb | 33 --------------------------------- lib/xgrep/simple_env.rb | 9 +++++++++ 4 files changed, 9 insertions(+), 99 deletions(-) delete mode 100644 lib/xgrep/node_env.rb delete mode 100644 lib/xgrep/rails_env.rb diff --git a/lib/xgrep/commander.rb b/lib/xgrep/commander.rb index d65fe96..dea1d15 100644 --- a/lib/xgrep/commander.rb +++ b/lib/xgrep/commander.rb @@ -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 diff --git a/lib/xgrep/node_env.rb b/lib/xgrep/node_env.rb deleted file mode 100644 index 0d6422f..0000000 --- a/lib/xgrep/node_env.rb +++ /dev/null @@ -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 diff --git a/lib/xgrep/rails_env.rb b/lib/xgrep/rails_env.rb deleted file mode 100644 index 6174f07..0000000 --- a/lib/xgrep/rails_env.rb +++ /dev/null @@ -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 diff --git a/lib/xgrep/simple_env.rb b/lib/xgrep/simple_env.rb index e2a29f4..36f2587 100644 --- a/lib/xgrep/simple_env.rb +++ b/lib/xgrep/simple_env.rb @@ -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