source_finder 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22d5b1f80ba1bf86e1565da7101acd64ee7773c1
4
- data.tar.gz: abe921f0693d83ae6edfd347b698fcabeaac5998
3
+ metadata.gz: 34934d1cd0a9f1f90153d9511eeb9b18ee82f893
4
+ data.tar.gz: ccd5a30b7973be85f16c85a30e3c4ed6b4690d2b
5
5
  SHA512:
6
- metadata.gz: 6025b9da3235737b58fb1962e8eb15e5299fc922aa0813124e42c4903efa8e5377d1256024686d8f620c903279911e15b5bbfabe8816e1792cf0758e821843c2
7
- data.tar.gz: cd1ae77cf5b73d058b6648b050161d41c86ed80d86d7a8425304d1fa29e5047c3cab24e70ebea8c40c457591580af7e1ba7e52566d0828f11c8e1f2928011b9c
6
+ metadata.gz: f38caca91611f5baf959a93f548adf9a3e5ed4dd98087a67b919618f1c4c4bcb2acc4ec2ed1f7111ffb7cedc278413174ccb4760f549b7e99db8326d26991822
7
+ data.tar.gz: 99cb880b3b9a2470786d7ddabde7844877fb8683831ee2d1a00dfa165aaf83751c03550d743b19d0e2c244cec1eab7403008422e337c8e3632639b3b2c21aabc
@@ -0,0 +1,32 @@
1
+ module SourceFinder
2
+ # Globber for JavaScript
3
+ module JsSourceFileGlobber
4
+ attr_accessor :js_dirs_arr, :extra_js_files_arr,
5
+ :js_file_extensions_arr
6
+
7
+ def js_dirs_arr
8
+ @js_dirs_arr ||= %w(app src www)
9
+ end
10
+
11
+ def extra_js_files_arr
12
+ @extra_js_files_arr ||= []
13
+ end
14
+
15
+ def js_file_extensions_arr
16
+ @js_file_extensions_arr || %w(js)
17
+ end
18
+
19
+ def js_file_extensions_glob
20
+ @js_file_extensions_glob ||= js_file_extensions_arr.join(',')
21
+ end
22
+
23
+ def js_files_glob
24
+ make_files_glob(extra_js_files_arr, js_dirs_arr,
25
+ js_file_extensions_glob)
26
+ end
27
+
28
+ def js_files_arr
29
+ exclude_garbage(@globber.glob(js_files_glob) - exclude_files_arr)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ module SourceFinder
2
+ # Globber for Python
3
+ module PythonSourceFileGlobber
4
+ attr_accessor :python_dirs_arr, :extra_python_files_arr,
5
+ :python_file_extensions_arr
6
+
7
+ def python_dirs_arr
8
+ @python_dirs_arr ||= %w(src)
9
+ end
10
+
11
+ def extra_python_files_arr
12
+ @extra_python_files_arr ||= []
13
+ end
14
+
15
+ def python_file_extensions_arr
16
+ @python_file_extensions_arr || %w(py)
17
+ end
18
+
19
+ def python_file_extensions_glob
20
+ @python_file_extensions_glob ||= python_file_extensions_arr.join(',')
21
+ end
22
+
23
+ def python_files_glob
24
+ make_files_glob(extra_python_files_arr, python_dirs_arr,
25
+ python_file_extensions_glob)
26
+ end
27
+
28
+ def python_files_arr
29
+ exclude_garbage(@globber.glob(python_files_glob) - exclude_files_arr)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ module SourceFinder
2
+ # Globber for Ruby
3
+ module RubySourceFileGlobber
4
+ attr_accessor :ruby_dirs_arr, :extra_ruby_files_arr,
5
+ :ruby_file_extensions_arr
6
+
7
+ def ruby_dirs_arr
8
+ @ruby_dirs_arr ||= %w(app config db feature lib spec src test)
9
+ end
10
+
11
+ def extra_ruby_files_arr
12
+ @extra_ruby_files_arr ||= %w(Rakefile)
13
+ end
14
+
15
+ def ruby_file_extensions_arr
16
+ @ruby_file_extensions_arr || %w(gemspec rake rb)
17
+ end
18
+
19
+ def ruby_file_extensions_glob
20
+ @ruby_file_extensions_glob ||= ruby_file_extensions_arr.join(',')
21
+ end
22
+
23
+ def ruby_files_glob
24
+ make_files_glob(extra_ruby_files_arr, ruby_dirs_arr,
25
+ ruby_file_extensions_glob)
26
+ end
27
+
28
+ def ruby_files_arr
29
+ exclude_garbage(@globber.glob(ruby_files_glob) - exclude_files_arr)
30
+ end
31
+ end
32
+ end
@@ -1,33 +1,39 @@
1
+ require_relative 'langs/ruby'
2
+ require_relative 'langs/js'
3
+ require_relative 'langs/python'
4
+
1
5
  module SourceFinder
2
6
  # Give configuration, finds source file locations by using an
3
7
  # inclusion and exclusion glob
4
8
  class SourceFileGlobber
5
9
  # See README.md for documentation on these configuration parameters.
6
- attr_accessor :ruby_dirs_arr, :source_dirs_arr, :extra_source_files_arr,
7
- :extra_ruby_files_arr, :ruby_file_extensions_arr,
8
- :source_file_extensions_arr, :exclude_files_arr,
9
- :source_files_glob, :source_files_exclude_glob,
10
+ attr_accessor :source_dirs_arr, :extra_source_files_arr,
11
+ :source_file_extensions_arr, :source_files_glob,
12
+ :source_files_exclude_glob,
10
13
  :source_file_extensions_glob
11
14
 
15
+ attr_accessor :exclude_files_arr
16
+
17
+ include RubySourceFileGlobber
18
+
19
+ include JsSourceFileGlobber
20
+
21
+ include PythonSourceFileGlobber
22
+
12
23
  def initialize(globber: Dir)
13
24
  @globber = globber
14
25
  end
15
26
 
16
- def ruby_dirs_arr
17
- @ruby_dirs_arr ||= %w(src app config db lib test spec feature)
18
- end
19
-
20
27
  def source_dirs_arr
21
- @source_dirs_arr ||= ruby_dirs_arr.clone
28
+ @source_dirs_arr ||= (ruby_dirs_arr + js_dirs_arr +
29
+ python_dirs_arr).sort.uniq
22
30
  end
23
31
 
24
32
  def extra_source_files_arr
25
33
  @extra_source_files_arr ||=
26
- extra_ruby_files_arr.clone.concat(%w(Dockerfile))
27
- end
28
-
29
- def extra_ruby_files_arr
30
- @extra_ruby_files_arr ||= %w(Rakefile)
34
+ (extra_ruby_files_arr +
35
+ extra_js_files_arr +
36
+ extra_python_files_arr).concat(%w(Dockerfile)).sort.uniq
31
37
  end
32
38
 
33
39
  def default_source_files_exclude_glob
@@ -36,11 +42,11 @@ module SourceFinder
36
42
 
37
43
  def exclude_files_arr
38
44
  if @source_files_exclude_glob
39
- @globber.glob(@source_files_exclude_glob)
45
+ exclude_garbage(@globber.glob(@source_files_exclude_glob))
40
46
  elsif @exclude_files_arr
41
47
  @exclude_files_arr
42
48
  else
43
- @globber.glob(default_source_files_exclude_glob)
49
+ exclude_garbage(@globber.glob(default_source_files_exclude_glob))
44
50
  end
45
51
  end
46
52
 
@@ -56,8 +62,10 @@ module SourceFinder
56
62
 
57
63
  def source_file_extensions_arr
58
64
  @source_file_extensions_arr ||=
59
- ruby_file_extensions_arr +
60
- %w(swift cpp c java py clj cljs scala js yml sh json)
65
+ exclude_garbage((ruby_file_extensions_arr +
66
+ js_file_extensions_arr +
67
+ python_file_extensions_arr +
68
+ %w(swift cpp c java py clj cljs scala yml sh json)))
61
69
  end
62
70
 
63
71
  def doc_file_extensions_arr
@@ -69,7 +77,7 @@ module SourceFinder
69
77
  end
70
78
 
71
79
  def source_and_doc_file_extensions_arr
72
- doc_file_extensions_arr + source_file_extensions_arr
80
+ exclude_garbage(doc_file_extensions_arr + source_file_extensions_arr)
73
81
  end
74
82
 
75
83
  def source_and_doc_file_extensions_glob
@@ -88,26 +96,23 @@ module SourceFinder
88
96
  source_and_doc_file_extensions_glob)
89
97
  end
90
98
 
99
+ def arr2glob(arr)
100
+ glob = ''
101
+ glob += "#{arr.join(',')}," if arr.size > 0
102
+ glob
103
+ end
104
+
91
105
  def make_files_glob(extra_source_files_arr,
92
106
  dirs_arr,
93
107
  extensions_glob)
94
- "{#{extra_source_files_arr.join(',')}," \
95
- "{*,.*}.{#{extensions_glob}}," +
96
- File.join("{#{dirs_arr.join(',')}}", '**',
108
+ glob = '{'
109
+ glob += arr2glob(extra_source_files_arr)
110
+ glob +=
111
+ "{*,.*}.{#{extensions_glob}}," +
112
+ File.join("{#{dirs_arr.join(',')}}",
113
+ '**',
97
114
  "{*,.*}.{#{extensions_glob}}") + '}'
98
- end
99
-
100
- def ruby_file_extensions_arr
101
- @ruby_file_extensions_arr || %w(rb rake gemspec)
102
- end
103
-
104
- def ruby_file_extensions_glob
105
- @ruby_file_extensions_glob ||= ruby_file_extensions_arr.join(',')
106
- end
107
-
108
- def ruby_files_glob
109
- make_files_glob(extra_ruby_files_arr, ruby_dirs_arr,
110
- ruby_file_extensions_glob)
115
+ glob
111
116
  end
112
117
 
113
118
  def emacs_lockfile?(filename)
@@ -116,10 +121,7 @@ module SourceFinder
116
121
 
117
122
  def exclude_garbage(files_arr)
118
123
  files_arr.reject { |filename| emacs_lockfile?(filename) }
119
- end
120
-
121
- def ruby_files_arr
122
- exclude_garbage(@globber.glob(ruby_files_glob) - exclude_files_arr)
124
+ .sort.uniq
123
125
  end
124
126
 
125
127
  def source_files_arr
@@ -1,4 +1,4 @@
1
1
  # SourceFinder finds source and documentation files within a project.
2
2
  module SourceFinder
3
- VERSION = '2.2.2'
3
+ VERSION = '2.2.3'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: source_finder
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-29 00:00:00.000000000 Z
11
+ date: 2015-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,6 +91,9 @@ files:
91
91
  - LICENSE.txt
92
92
  - README.md
93
93
  - lib/source_finder.rb
94
+ - lib/source_finder/langs/js.rb
95
+ - lib/source_finder/langs/python.rb
96
+ - lib/source_finder/langs/ruby.rb
94
97
  - lib/source_finder/option_parser.rb
95
98
  - lib/source_finder/source_file_globber.rb
96
99
  - lib/source_finder/version.rb