cql_ruby 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/cql_ruby +10 -1
  3. data/lib/cql_ruby/executor.rb +10 -2
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17840020ae4f57f60763716ac438b33a68abb4b1add767d5f8e88cfb946439c8
4
- data.tar.gz: 789aa975ced7c62036da026f7e4bd377c09b1502692ff217fb697641d5478d64
3
+ metadata.gz: 4e459067630e91a0d52a1839445f881647e9c0271c052d973ccfafd6040f21b6
4
+ data.tar.gz: 39379431fb2d817930aff070a8335c02b62822d6bba0129956f6691cb5ea99b8
5
5
  SHA512:
6
- metadata.gz: ee8c4e5ea2cfde9a8837cc1e19734e0051424af9c15fe02fc5db49b11984052b70a4acb6d196b94c38820ea34bccbb8d78ff431e5bef45ac0627a55548fae324
7
- data.tar.gz: 9e550d59e360717069c3198269bbe815d73aae7cc1d43b9532ed2fc4dee60b8f9decee399051ceedb9b0ae21867e785cce0423170f1f417550b3611c018d4270
6
+ metadata.gz: 1de5455822e96348fad5fbda540e66ebf830723a4579927f8d4b1a2a9a4c9dd1c6d4763a514674eebff6974c8d61958e53af9fae74397fd643bb8a036f0a725d
7
+ data.tar.gz: 94c05fd4d565b1db7e793137495bd97456b1e459f9a58c6faba8c008c772a4898929ce5dc02d4064dec2ef0ee2ef0a7a2b68a2f9915430c681aca2a1a2bbb6f9
@@ -18,6 +18,8 @@ def show_help
18
18
  \t\tHas child: has:T(=NAME) Example: has:const has:def=valid?
19
19
 
20
20
  \tOPTIONS
21
+ \t\t--include=PATTERN Parses only files whose name matches the pattern.
22
+ \t\t--exclude=PATTERN Parses only files whose name does not match the pattern.
21
23
  \t\t-lN (N is integer) Add N surrounding line before and after.
22
24
  \t\t-nc (--no-color) No color on output.
23
25
  \t\t-nf (--no-file) No file names.
@@ -45,6 +47,8 @@ def extract_options
45
47
  show_source: true,
46
48
  recursive_search: true,
47
49
  surrounding_lines: 0,
50
+ include_pattern: nil,
51
+ exclude_pattern: nil,
48
52
  }
49
53
 
50
54
  ARGV.delete_if do |arg|
@@ -64,6 +68,10 @@ def extract_options
64
68
  options[:recursive_search] = false
65
69
  elsif arg[0..1] == '-l' && arg[2..].to_i > 0
66
70
  options[:surrounding_lines] = arg[2..].to_i
71
+ elsif arg.start_with?('--include=')
72
+ options[:include_pattern] = arg.split('=')[1]
73
+ elsif arg.start_with?('--exclude=')
74
+ options[:exclude_pattern] = arg.split('=')[1]
67
75
  else
68
76
  raise "Unknown arg #{arg}"
69
77
  end
@@ -91,7 +99,6 @@ begin
91
99
  pattern = ARGV.shift
92
100
  CqlRuby.log "Call pattern: <#{pattern}>" if CqlRuby::Config.debug_level_2?
93
101
 
94
- # TODO Make path patterns universal.
95
102
  path = ARGV.shift
96
103
  CqlRuby.log "Call path: <#{path}>" if CqlRuby::Config.debug_level_2?
97
104
 
@@ -115,6 +122,8 @@ begin
115
122
  path: path,
116
123
  filters: filters,
117
124
  recursive: options[:recursive_search],
125
+ include: options[:include_pattern],
126
+ exclude: options[:exclude_pattern],
118
127
  ).search_all
119
128
  rescue => e
120
129
  puts "Error: #{e}"
@@ -33,7 +33,9 @@ module CqlRuby
33
33
  pattern:,
34
34
  path:,
35
35
  filters: [],
36
- recursive: true
36
+ recursive: true,
37
+ include: nil,
38
+ exclude: nil
37
39
  )
38
40
  @collector = collector
39
41
  @filter_reader = filter_reader
@@ -41,10 +43,15 @@ module CqlRuby
41
43
  @path = path
42
44
  @filters = filters
43
45
  @recursive = recursive
46
+ @include = include
47
+ @exclude = exclude
44
48
  end
45
49
 
46
50
  def search_all
47
51
  files.flat_map do |file|
52
+ next if !@exclude.nil? && CqlRuby::PatternMatcher.match?(@exclude, file)
53
+ next unless @include.nil? || CqlRuby::PatternMatcher.match?(@include, file)
54
+
48
55
  CqlRuby.log "File check: #{file}" if CqlRuby::Config.debug_level_3?
49
56
  search(file)
50
57
  end
@@ -59,7 +66,8 @@ module CqlRuby
59
66
 
60
67
  nil
61
68
  rescue => e
62
- CqlRuby.log "File #{file} cannot be parsed: #{e}"
69
+ CqlRuby.log "File #{file} cannot be parsed"
70
+ CqlRuby.log "Reason: #{e}" if CqlRuby::Config.debug_level_1?
63
71
  end
64
72
 
65
73
  def walk(node, ancestors, source_reader)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cql_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - itarato