path-expander-1.1.0/0000755000175000017500000000000013715572727015511 5ustar debbiecocoadebbiecocoapath-expander-1.1.0/History.rdoc0000444000175000017500000000134513715572727020024 0ustar debbiecocoadebbiecocoa=== 1.1.0 / 2019-09-22 * 1 minor enhancement: * Added a default path (default: ".") to scan if no files are initially found. === 1.0.5 / 2019-09-14 * 1 bug fix: * Fixed a deprecation warning from File.exists? === 1.0.4 / 2019-05-26 * 1 bug fix: * Sorted the output from expand_dirs_to_files. (deivid-rodriguez) === 1.0.3 / 2018-03-16 * 1 bug fix: * Don't process files if path expands to root directory. Prevents -n /./ from hanging. === 1.0.2 / 2017-05-09 * 1 bug fix: * Fixed expand_dirs_to_files returning non-files on glob expansion. === 1.0.1 / 2016-11-30 * 1 bug fix: * Expanded paths in filter_files to fix globs w/ absolute paths. (mknapik) === 1.0.0 / 2016-05-11 * 1 major enhancement * Birthday! path-expander-1.1.0/.autotest0000444000175000017500000000104013715572727017353 0ustar debbiecocoadebbiecocoa# -*- ruby -*- require "autotest/restart" Autotest.add_hook :initialize do |at| at.testlib = "minitest/autorun" at.add_exception "tmp" # at.extra_files << "../some/external/dependency.rb" # # at.libs << ":../some/external" # # at.add_exception "vendor" # # at.add_mapping(/dependency.rb/) do |f, _| # at.files_matching(/test_.*rb$/) # end # # %w(TestA TestB).each do |klass| # at.extra_class_map[klass] = "test/test_misc.rb" # end end # Autotest.add_hook :run_command do |at| # system "rake build" # end path-expander-1.1.0/README.rdoc0000444000175000017500000000460613715572727017323 0ustar debbiecocoadebbiecocoa= path_expander home :: https://github.com/seattlerb/path_expander rdoc :: http://docs.seattlerb.org/path_expander == DESCRIPTION: PathExpander helps pre-process command-line arguments expanding directories into their constituent files. It further helps by providing additional mechanisms to make specifying subsets easier with path subtraction and allowing for command-line arguments to be saved in a file. NOTE: this is NOT an options processor. It is a path processor (basically everything else besides options). It does provide a mechanism for pre-filtering cmdline options, but not with the intent of actually processing them in PathExpander. Use OptionParser to deal with options either before or after passing ARGV through PathExpander. == FEATURES/PROBLEMS: * Processes command-line arguments. * Expands directories into files using custom globs. * Allows for negation of files. * Allows for use of files as persisted args. * Provides a .ignore mechanism for lightweight persistent exclusion. == SYNOPSIS: class MyPathExpander < PathExpander MY_GLOB = "**/*.rb" def initialize args = ARGV super args, MY_GLOB end end MyPathExpander.new(ARGV, my_glob).process.each do |f| # do something with each file end == REQUIREMENTS: * ruby == INSTALL: * sudo gem install path_expander == LICENSE: (The MIT License) Copyright (c) Ryan Davis, seattle.rb Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. path-expander-1.1.0/Manifest.txt0000444000175000017500000000023013715572727020011 0ustar debbiecocoadebbiecocoa.autotest History.rdoc Manifest.txt README.rdoc Rakefile lib/path_expander.rb test/bad_named_dir.rb/.ignore test/test_bad.rb test/test_path_expander.rb path-expander-1.1.0/lib/0000755000175000017500000000000013715572727016257 5ustar debbiecocoadebbiecocoapath-expander-1.1.0/lib/path_expander.rb0000444000175000017500000001252213715572727021426 0ustar debbiecocoadebbiecocoa## # PathExpander helps pre-process command-line arguments expanding # directories into their constituent files. It further helps by # providing additional mechanisms to make specifying subsets easier # with path subtraction and allowing for command-line arguments to be # saved in a file. # # NOTE: this is NOT an options processor. It is a path processor # (basically everything else besides options). It does provide a # mechanism for pre-filtering cmdline options, but not with the intent # of actually processing them in PathExpander. Use OptionParser to # deal with options either before or after passing ARGV through # PathExpander. class PathExpander VERSION = "1.1.0" # :nodoc: ## # The args array to process. attr_accessor :args ## # The glob used to expand dirs to files. attr_accessor :glob ## # The path to scan if no paths are found in the initial scan. attr_accessor :path ## # Create a new path expander that operates on args and expands via # glob as necessary. Takes an optional +path+ arg to fall back on if # no paths are found on the initial scan (see #process_args). def initialize args, glob, path = "." self.args = args self.glob = glob self.path = path end ## # Takes an array of paths and returns an array of paths where all # directories are expanded to all files found via the glob provided # to PathExpander. def expand_dirs_to_files *dirs dirs.flatten.map { |p| if File.directory? p then Dir[File.join(p, glob)].find_all { |f| File.file? f } else p end }.flatten.sort end ## # Process a file into more arguments. Override this to add # additional capabilities. def process_file path File.readlines(path).map(&:chomp) end ## # Enumerate over args passed to PathExpander and return a list of # files and flags to process. Arguments are processed as: # # @file_of_args :: Read the file and append to args. # -file_path :: Subtract path from file to be processed. # -dir_path :: Expand and subtract paths from files to be processed. # -not_a_path :: Add to flags to be processed. # dir_path :: Expand and add to files to be processed. # file_path :: Add to files to be processed. # # See expand_dirs_to_files for details on how expansion occurs. # # Subtraction happens last, regardless of argument ordering. # # If no files are found (which is not the same as having an empty # file list after subtraction), then fall back to expanding on the # default #path given to initialize. def process_args pos_files = [] neg_files = [] flags = [] clean = true args.each do |arg| case arg when /^@(.*)/ then # push back on, so they can have dirs/-/@ as well clean = false args.concat process_file $1 when /^-(.*)/ then if File.exist? $1 then clean = false neg_files += expand_dirs_to_files($1) else flags << arg end else root_path = File.expand_path(arg) == "/" # eg: -n /./ if File.exist? arg and not root_path then clean = false pos_files += expand_dirs_to_files(arg) else flags << arg end end end files = pos_files - neg_files files += expand_dirs_to_files(self.path) if files.empty? && clean [files, flags] end ## # Process over flags and treat any special ones here. Returns an # array of the flags you haven't processed. # # This version does nothing. Subclass and override for # customization. def process_flags flags flags end ## # Top-level method processes args. It replaces args' contents with a # new array of flags to process and returns a list of files to # process. Eg # # PathExpander.new(ARGV).process.each do |f| # puts "./#{f}" # end def process files, flags = process_args args.replace process_flags flags files.uniq end ## # A file filter mechanism similar to, but not as extensive as, # .gitignore files: # # + If a pattern does not contain a slash, it is treated as a shell glob. # + If a pattern ends in a slash, it matches on directories (and contents). # + Otherwise, it matches on relative paths. # # File.fnmatch is used throughout, so glob patterns work for all 3 types. # # Takes a list of +files+ and either an io or path of +ignore+ data # and returns a list of files left after filtering. def filter_files files, ignore ignore_paths = if ignore.respond_to? :read then ignore.read elsif File.exist? ignore then File.read ignore end if ignore_paths then nonglobs, globs = ignore_paths.split("\n").partition { |p| p.include? "/" } dirs, ifiles = nonglobs.partition { |p| p.end_with? "/" } dirs = dirs.map { |s| s.chomp "/" } dirs.map! { |i| File.expand_path i } globs.map! { |i| File.expand_path i } ifiles.map! { |i| File.expand_path i } only_paths = File::FNM_PATHNAME files = files.reject { |f| f = File.expand_path(f) dirs.any? { |i| File.fnmatch?(i, File.dirname(f), only_paths) } || globs.any? { |i| File.fnmatch?(i, f) } || ifiles.any? { |i| File.fnmatch?(i, f, only_paths) } } end files end end path-expander-1.1.0/checksums.yaml.gz.sig0000444000175000017500000000040013715572727021552 0ustar debbiecocoadebbiecocoa%4nG܅IENRPn7`BsγdhZ+,ϋyI ]FSj5mM=@BɊME+Hbbl%$E KA3}[4C=?RSLnH.'6dT.+-%"HUA⳩w3J jHl ,N1l%܅܏ ږd*훾&m]T̀ m8bn~~f;mϽ^J%kr@path-expander-1.1.0/Rakefile0000444000175000017500000000101113715572727017145 0ustar debbiecocoadebbiecocoa# -*- ruby -*- require "rubygems" require "hoe" Hoe.plugin :isolate Hoe.plugin :seattlerb Hoe.plugin :rdoc # Hoe.plugin :compiler # Hoe.plugin :doofus # Hoe.plugin :email # Hoe.plugin :gem_prelude_sucks # Hoe.plugin :history # Hoe.plugin :inline # Hoe.plugin :isolate # Hoe.plugin :minitest # Hoe.plugin :perforce # Hoe.plugin :racc # Hoe.plugin :rcov # Hoe.plugin :rdoc # Hoe.plugin :seattlerb Hoe.spec "path_expander" do developer "Ryan Davis", "ryand-ruby@zenspider.com" license "MIT" end # vim: syntax=ruby path-expander-1.1.0/path_expander.gemspec0000644000175000017500000000670513715572727021710 0ustar debbiecocoadebbiecocoa######################################################### # This file has been automatically generated by gem2tgz # ######################################################### # -*- encoding: utf-8 -*- # stub: path_expander 1.1.0 ruby lib Gem::Specification.new do |s| s.name = "path_expander".freeze s.version = "1.1.0" s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= s.require_paths = ["lib".freeze] s.authors = ["Ryan Davis".freeze] s.cert_chain = ["-----BEGIN CERTIFICATE-----\nMIIDPjCCAiagAwIBAgIBAzANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu\nZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB\nGRYDY29tMB4XDTE4MTIwNDIxMzAxNFoXDTE5MTIwNDIxMzAxNFowRTETMBEGA1UE\nAwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS\nJomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda\nb9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx\ntaCPaLmfYIaFcHHCSY4hYDJijRQkLxPeB3xbOfzfLoBDbjvx5JxgJxUjmGa7xhcT\noOvjtt5P8+GSK9zLzxQP0gVLS/D0FmoE44XuDr3iQkVS2ujU5zZL84mMNqNB1znh\nGiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt\nqhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV\ngBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw\nHQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB\nAQCbJwLmpJR2PomLU+Zzw3KRzH/hbyUWc/ftru71AopZ1fy4iY9J/BW5QYKVYwbP\nV0FSBWtvfI/RdwfKGtuGhPKECZgmLieGuZ3XCc09qPu1bdg7i/tu1p0t0c6163ku\nnDMDIC/t/DAFK0TY9I3HswuyZGbLW7rgF0DmiuZdN/RPhHq2pOLMLXJmFclCb/im\n9yToml/06TJdUJ5p64mkBs0TzaK66DIB1Smd3PdtfZqoRV+EwaXMdx0Hb3zdR1JR\nEm82dBUFsipwMLCYj39kcyHWAxyl6Ae1Cn9r/ItVBCxoeFdrHjfavnrIEoXUt4bU\nUfBugfLD19bu3nvL+zTAGx/U\n-----END CERTIFICATE-----\n".freeze] s.date = "2019-09-22" s.description = "PathExpander helps pre-process command-line arguments expanding\ndirectories into their constituent files. It further helps by\nproviding additional mechanisms to make specifying subsets easier\nwith path subtraction and allowing for command-line arguments to be\nsaved in a file.\n\nNOTE: this is NOT an options processor. It is a path processor\n(basically everything else besides options). It does provide a\nmechanism for pre-filtering cmdline options, but not with the intent\nof actually processing them in PathExpander. Use OptionParser to\ndeal with options either before or after passing ARGV through\nPathExpander.".freeze s.email = ["ryand-ruby@zenspider.com".freeze] s.extra_rdoc_files = ["History.rdoc".freeze, "Manifest.txt".freeze, "README.rdoc".freeze] s.files = [".autotest".freeze, "History.rdoc".freeze, "Manifest.txt".freeze, "README.rdoc".freeze, "Rakefile".freeze, "lib/path_expander.rb".freeze, "test/bad_named_dir.rb/.ignore".freeze, "test/test_bad.rb".freeze, "test/test_path_expander.rb".freeze] s.homepage = "https://github.com/seattlerb/path_expander".freeze s.licenses = ["MIT".freeze] s.rdoc_options = ["--main".freeze, "README.rdoc".freeze] s.rubygems_version = "3.1.2".freeze s.summary = "PathExpander helps pre-process command-line arguments expanding directories into their constituent files".freeze if s.respond_to? :specification_version then s.specification_version = 4 end if s.respond_to? :add_runtime_dependency then s.add_development_dependency(%q.freeze, ["~> 3.18"]) s.add_development_dependency(%q.freeze, [">= 4.0", "< 7"]) else s.add_dependency(%q.freeze, ["~> 3.18"]) s.add_dependency(%q.freeze, [">= 4.0", "< 7"]) end end path-expander-1.1.0/data.tar.gz.sig0000444000175000017500000000040013715572727020322 0ustar debbiecocoadebbiecocoa} ,=yn0C>[IuOZ ]VzR;32S-΀ֆu_