stylr 0.0.9 → 0.0.10

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 775df439741f94f7d34cdaa9c3724df706d754c3
4
- data.tar.gz: c45c8d3394e925ea541baf63d0787117d5813b2c
3
+ metadata.gz: 0ea7cc9131144761b3dc6243fd052a6aabada35b
4
+ data.tar.gz: c718b67f218a9408e7d0e22ef47ac09307524050
5
5
  SHA512:
6
- metadata.gz: 71ed22808a68891bd9a7783140e1231ae1b26b54293b2b3b58a7b216a715d903de081ccd3f6d670dcd52ee3c329f8c8ee5b64dd1fcf9377b7a77e15a6be2b261
7
- data.tar.gz: 9b68aae0b023f654a05bb640d6e8c2f31820348068b2fef4f5ea8226ccda33e72bd32b740d47b4f729ae602a26b89d3d877d333c8673cdf06aa5418999502c5a
6
+ metadata.gz: 9c298c4c9479c35aad274921bb7b0ab2c7d9d776a32bd8022e043f342c6c69b853f2c5576f0d4461f004fe50aae2288ccbfec03e27a9acabdafb909eef811bdb
7
+ data.tar.gz: 8c532755f94bdf1798c4d0a6e4477f19a24019fe23ee45d33c384d30b48ef0b486eb3867863f80ef17a56cae7bad7e5d0306199245f10d8706ef655997df00ed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stylr (0.0.9)
4
+ stylr (0.0.11)
5
5
  main (~> 5.2, >= 5.2.0)
6
6
 
7
7
  GEM
data/lib/stylr/lint.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'yaml'
2
+ require 'ripper'
2
3
 
3
4
  class Lint
4
5
  attr_reader :errors, :violations, :exception_violations, :metaprogramming_violations, :messages
@@ -15,6 +16,7 @@ class Lint
15
16
 
16
17
  def violation?(line, number = 1)
17
18
  line = strip_strings(line)
19
+ line = remove_regex(line)
18
20
  abstract_violation?(@violations, line, number)
19
21
  end
20
22
 
@@ -32,7 +34,7 @@ class Lint
32
34
  start = /<<-?[A-Z]+/
33
35
  finish = (str[start] || "")[/[A-Z]+/]
34
36
  regexp = /#{start}.*\b#{finish}\b/
35
- str.gsub!(/#{str[regexp]}/,'""') if str[regexp]
37
+ str.gsub!(/#{str[regexp]}/, '""') if str[regexp]
36
38
  end
37
39
  end
38
40
 
@@ -40,6 +42,16 @@ class Lint
40
42
  line.gsub(/".*"/, '""').gsub(/'.*'/, "''")
41
43
  end
42
44
 
45
+ def remove_regex(line)
46
+ if possible_regex = line[/\/.*\//]
47
+ sexp = Ripper.sexp(possible_regex) || []
48
+ if sexp.flatten.grep(/regex/)
49
+ return line.gsub(possible_regex, 'REGEX')
50
+ end
51
+ end
52
+ return line
53
+ end
54
+
43
55
  private
44
56
 
45
57
  def abstract_violation?(list, line, number)
data/lib/stylr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Stylr
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
data/spec/lint_spec.rb CHANGED
@@ -127,6 +127,10 @@ module Stylr
127
127
  it "close bracket fine as only thing on a line" do
128
128
  l.violation?(" ]").should be_false
129
129
  end
130
+
131
+ it "interpolating into brackets is fine" do
132
+ l.violation?("/\#{def foo bar}/").should be_false
133
+ end
130
134
  end
131
135
 
132
136
  context "space around { and } is good" do
@@ -286,6 +290,12 @@ module Stylr
286
290
  end
287
291
  end
288
292
 
293
+ context "regex stripping" do
294
+ it "removes regexes" do
295
+ l.remove_regex("start = /<<-?[A-Z]+/").should == "start = REGEX"
296
+ end
297
+ end
298
+
289
299
  context "error messages" do
290
300
  it "keeps track of your mistakes and their lines, defaulting to line #1" do
291
301
  l.violation?("def foo bar")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stylr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Billie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-10 00:00:00.000000000 Z
11
+ date: 2014-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: main