vls 0.3.5 → 0.3.6

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: 17db29744dbbccea1c7827ffdb8ae7949c7e9995
4
- data.tar.gz: a958d743642683678a760339c8c8240721ae5e93
3
+ metadata.gz: f00674ec64efd09019927af8a965dd74bb0eb4a7
4
+ data.tar.gz: 4e34a3c7ede30d8d205cad663b494ff7a6a0b9ae
5
5
  SHA512:
6
- metadata.gz: 2b9b80c584773aa52d4dac99761c254f66a66bed1b5516922d9f1cabf7d4d7bb3d7e1a2154d1bf7f09a7fe6d299c2133dccd6003196293b5eae6a96d8a846228
7
- data.tar.gz: 02f4781c24339dd1323489353d383be4b2f81ebd7a5ec868c90660bd8dae843e4328c2d9f4959fecb43bdb505558487ffaca2d42bcc6b98a68295a26ec6e084c
6
+ metadata.gz: f9232aed7288924b26178cee63a2a276ea49a44181c85077832e6d026eb3f8008f7564c61b3d9ba030b2a89f4b004fea6e054d0189f871f5cf8c5fac28945726
7
+ data.tar.gz: d2d4d3b9f2b4f4fce35209fed9fab50a53b970c9e8f5e2de8cbad1a97de95cde72917e489da195e4c2e26e890a367bc026a4143371e7e3c500fc859fc758809f
data/README.md CHANGED
@@ -25,16 +25,30 @@ The vls gem itself is found at: ( https://rubygems.org/gems/vls )
25
25
 
26
26
  ## Usage
27
27
 
28
- The vls utility is normally used at the command line. The basic usage template
28
+ The vls utility is normally used at the command line. The usage template
29
29
  is:
30
30
 
31
- $ vls <names>
31
+ vls (VersionLS): 0.3.6
32
32
 
33
- where names is a list of gems and/or files to be required before the
34
- module/classes are displayed with their VERSION information. For example:
33
+ A command line utility that lists the versions of modules used by the specified
34
+ gems/ruby files.
35
+
36
+ Usage: $ vls <options> <names>
37
+
38
+ <options>
39
+ --filter, -f <s/r> = Filter results by string or regular expression.
40
+ --help, -h, -? = Display this text and exit.
41
+ --raw, -r = Display results with no header text.
42
+
43
+ <names> are gems/files to be required before modules are listed.
44
+
45
+ Note:
46
+ To specify a file instead of a gem, a '.rb' extension is required.
47
+
48
+ For example:
35
49
 
36
50
  $ vls rails
37
- vls (VersionLS): 0.3.0
51
+ vls (VersionLS): 0.3.6
38
52
 
39
53
  ActionPack, 4.2.6
40
54
  ActiveSupport, 4.2.6
@@ -53,7 +67,7 @@ In order to use relative paths instead of the gem search path, the .rb extension
53
67
  needs to be specified on the target file.
54
68
 
55
69
  $ vls ruby_sscanf.rb
56
- vls (VersionLS): 0.3.0
70
+ vls (VersionLS): 0.3.6
57
71
 
58
72
  FormatEngine, 0.7.2
59
73
  Gem, 2.2.2
@@ -62,7 +76,7 @@ needs to be specified on the target file.
62
76
  The vls utility is also available for use within an application. It may be
63
77
  accessed with:
64
78
  ```ruby
65
- module_version_list = VersionLS.vls
79
+ module_version_list = VersionLS.vls(filter=/./)
66
80
  ```
67
81
  This returns an array of entries, sorted by module name, consisting of an
68
82
  array with the module and a string with its version. Also, the Object class
@@ -70,7 +84,7 @@ is monkey patched with the vls method that outputs the information to the
70
84
  console.
71
85
 
72
86
  ```ruby
73
- vls
87
+ vls(filter=/./)
74
88
  ```
75
89
 
76
90
  Note that these methods do not accept a list of modules to be required. It
@@ -79,6 +93,8 @@ would have already been loaded. In addition, the vls listing to the console
79
93
  has no header information. If this is desired, the application should do a
80
94
  puts of the appropriate descriptive text.
81
95
 
96
+ Both of these methods _do_ take an optional filter string or regular expression.
97
+
82
98
  ## The Rails Console
83
99
 
84
100
  If the vls gem has been added to a rails project (in its Gemfile), its
@@ -168,6 +184,19 @@ load out of the web site. For example:
168
184
  => nil
169
185
  irb(main):002:0>
170
186
 
187
+ Of course, filtering is available at this level too:
188
+
189
+ irb(main):003:0> vls 'Rails'
190
+ Coffee::Rails, 4.1.1
191
+ Jquery::Rails, 4.1.1
192
+ Rails, 4.2.6
193
+ Rails::Html::FullSanitizer, 1.0.3
194
+ Rails::Html::LinkSanitizer, 1.0.3
195
+ Rails::Html::Sanitizer, 1.0.3
196
+ Rails::Html::WhiteListSanitizer, 1.0.3
197
+ Sass::Rails, 5.0.4
198
+ Sprockets::Rails, 3.0.4
199
+
171
200
  ## Usage in Rails Views
172
201
 
173
202
  It is also possible to incorporate vls data into a view using the VersionLS.vls
data/bin/vls CHANGED
@@ -12,25 +12,32 @@ def vls_show_help
12
12
  puts VersionLS::DESCRIPTION
13
13
  puts "\nUsage: $ vls <options> <names>"
14
14
  puts "\n<options>"
15
- puts " --help, -h, -? = Display this text and exit."
16
- puts " --raw, -r = Display results with no header text."
15
+ puts " --filter, -f <s/r> = Filter results by string or regular expression."
16
+ puts " --help, -h, -? = Display this text and exit."
17
+ puts " --raw, -r = Display results with no header text."
17
18
  puts "\n<names> are gems/files to be required before modules are listed."
18
19
  puts "\nNote:"
19
20
  puts " To specify a file instead of a gem, a '.rb' extension is required."
20
21
  exit
21
22
  end
22
23
 
23
- load_list, no_header = [], false
24
+ load_list, no_header, special, option_args = [], false, false, {filter: "/./"}
24
25
 
25
26
  #Process the script argument list.
26
27
  ARGV.each do |arg|
27
- case arg
28
- when "--help", "-h", "-?"
29
- vls_show_help
30
- when "--raw", "-r"
31
- no_header = true
28
+ if special
29
+ option_args[special], special = arg, false
32
30
  else
33
- load_list << arg
31
+ case arg
32
+ when "--filter", "-f"
33
+ special = :filter
34
+ when "--help", "-h", "-?"
35
+ vls_show_help
36
+ when "--raw", "-r"
37
+ no_header = true
38
+ else
39
+ load_list << arg
40
+ end
34
41
  end
35
42
  end
36
43
 
@@ -52,4 +59,6 @@ load_list.each do |pkg|
52
59
  end
53
60
  end
54
61
 
55
- VersionLS.ls unless errors_found
62
+ filter = option_args[:filter]
63
+ filter = Regexp.new(filter[1...-1]) if /^\/.*\/$/ =~ filter
64
+ VersionLS.print_vls(filter) unless errors_found
data/lib/vls.rb CHANGED
@@ -6,15 +6,19 @@ require_relative "vls/version"
6
6
  # The Version LiSt utility module.
7
7
  module VersionLS
8
8
  #Perform a Versioned LiSt to the console.
9
- def self.ls
10
- vls.each{|mod| puts "#{mod[0]}, #{mod[1]}"}
9
+ #<br>Parameters
10
+ #* filter - a string or regex used to filter the list of modules.
11
+ def self.print_vls(filter)
12
+ vls(filter).each{|mod| puts "#{mod[0]}, #{mod[1]}"}
11
13
  nil
12
14
  end
13
15
 
14
16
  #Execute the core of the vls command and return an array of
15
17
  #[module, version] arrays.
16
- def self.vls
17
- modules.map do |mod|
18
+ #<br>Parameters
19
+ #* filter - a string or regex used to filter the list of modules.
20
+ def self.vls(filter=/./)
21
+ modules(filter).map do |mod|
18
22
  begin
19
23
  version = mod::VERSION
20
24
  rescue
@@ -26,10 +30,15 @@ module VersionLS
26
30
  end
27
31
 
28
32
  #Get a list of modules that have VERSION info.
29
- def self.modules
33
+ #<br>Parameters
34
+ #* filter - a string or regex used to filter the list of modules.
35
+ #<br>Returns
36
+ #* An array of module objects.
37
+ def self.modules(filter)
30
38
  mods = ObjectSpace.each_object(Module).
31
39
  select do |mod|
32
- mod.const_defined?("VERSION")
40
+ mod.const_defined?("VERSION") &&
41
+ mod.name.partition(filter)[1] != ""
33
42
  end.
34
43
  sort do |first, second|
35
44
  first.name <=> second.name
@@ -8,8 +8,10 @@ class Object
8
8
  end
9
9
 
10
10
  #A simple shortcut method for ease of use in irb and rails console.
11
- def vls
12
- VersionLS.ls
11
+ #<br>Endemic Code Smells
12
+ #* :reek:UtilityFunction
13
+ def vls(filter=/./)
14
+ VersionLS.ls(filter)
13
15
  end
14
16
  end
15
17
 
data/lib/vls/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module VersionLS
2
- STRING = VERSION = "0.3.5"
2
+ STRING = VERSION = "0.3.6"
3
3
 
4
4
  DESCRIPTION = "A command line utility that lists the versions of " +
5
5
  "modules used by the specified gems/ruby files."
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Camilleri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-29 00:00:00.000000000 Z
11
+ date: 2016-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler