stylr 0.0.6 → 0.0.7

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: d24c550f19bdc73beb58ad28bc25ae1a10295d0b
4
- data.tar.gz: c4eb18254875e21ac141c4fbaabf6488a82c9bbe
3
+ metadata.gz: bdf726c26f1e23ea59d8fc2e5d2cf49ab380affa
4
+ data.tar.gz: 0fb13c52ebd99e2c4860e5f519d860c97a8a0a1a
5
5
  SHA512:
6
- metadata.gz: adc05ab742724d576381d07e498b8992fd4f0c34342d5e36ec5b0192e3c91bc61cf03975c07139000c38bb6d7d6fa0bf1b3e0f4fe76fb50813803b400c66eabb
7
- data.tar.gz: e5502a2c101be36b9ecd344dec9da4ee4d4ba813f67e8374e1513f6e43988cc99305779a718236b4e207b41505be3fbf3ba704606c4463f9ffa1f34e0b088adf
6
+ metadata.gz: 50a0ea83435412f4c28761765fe4c559a8760ebd5903e7cac49faaa92712cfb3e86aeb13da54bcbb6593e7338a0f403b697b647d90d442f8ed8409d092847ed6
7
+ data.tar.gz: a2f259890cc2fcd6d5d9135a40aed7871d84e5bfb16069fbf264b36469701f110992192343fd4bcb520c81a25a92a26085f1f4d5174193c46384c8435379d81a
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stylr (0.0.4)
5
- main (~> 5.2.0)
4
+ stylr (0.0.6)
5
+ main (~> 5.2, >= 5.2.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  <h1>stylr</h1>
2
+ <h4>a Ruby styleguide enforcer</h4>
3
+ <img src="https://badge.fury.io/rb/stylr.png"/>
4
+ <img src="http://ike18t.no-ip.biz/job/Stylr/badge/icon"/>
2
5
 
3
- Check if source code conforms to some elements of the Github Ruby Style Guidelines ( https://github.com/styleguide/ruby )
6
+ This gem will check if source code conforms to some elements of the Github Ruby Style Guidelines (https://github.com/styleguide/ruby) - currently supporting Ruby 2.1.0 (although it may work with earlier versions)
4
7
 
5
8
  Kind of raw still. Currently supports checking against the following:
6
9
 
@@ -30,8 +33,14 @@ All of these things are configurable via yml. See "stylr.yml" in the repo, and
30
33
 
31
34
  Checks all *.rb files in the specified directory and subdirectories, excluding _spec.rb and _test.rb
32
35
 
33
- <b>Usage</b>
36
+ <h4>Usage</h4>
34
37
 
35
- ./stylr /path/to/directory # normal checks
38
+ <code>gem install stylr</code>
36
39
 
37
- ./stylr /path/to/directory --meta # also check for use of metaprogramming
40
+ <code>stylr /path/to/directory</code> normal checks
41
+
42
+ <code>stylr /path/to/directory --meta</code> also check for use of metaprogramming
43
+
44
+ <h4>Contributing</h4>
45
+
46
+ Please feel free to contribute! There are issues and unimplemented features. I'd love any help I can get. Thanks!
data/Rakefile CHANGED
@@ -1 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ task :default do
4
+ exec 'rspec'
5
+ end
data/bin/stylr CHANGED
@@ -5,29 +5,27 @@ require 'stylr'
5
5
 
6
6
  module Stylr
7
7
  Main {
8
-
9
8
  argument('directory') {
10
- description "The directory to be parsed."
11
- cast :string
12
- }
13
-
14
- option('meta') {
15
- default false
16
- description "Check for metaprogramming violations. Defaults to false."
17
- }
18
-
19
- def run
20
- directory = params['directory'].values.first
21
- meta = params['meta'].values.first ? true : false
22
- dir_loader = DirLoader.new
23
- dir_loader.load_dir(directory)
24
-
25
- dir_loader.filenames.each do |filename|
26
- puts "Checking #{filename}..."
27
- FileParser.new(filename, Lint.new, true).violations?(meta)
9
+ description "The directory to be parsed."
10
+ cast :string
11
+ }
12
+
13
+ option('meta') {
14
+ default false
15
+ description "Check for metaprogramming violations. Defaults to false."
16
+ }
17
+
18
+ def run
19
+ directory = params['directory'].values.first
20
+ meta = params['meta'].values.first ? true : false
21
+ dir_loader = DirLoader.new
22
+ dir_loader.load_dir(directory)
23
+
24
+ dir_loader.filenames.each do |filename|
25
+ puts "Checking #{filename}..."
26
+ FileParser.new(filename, Lint.new, true).violations?(meta)
27
+ end
28
28
  end
29
- end
30
-
31
29
  }
32
30
  end
33
31
 
data/lib/stylr.rb CHANGED
@@ -3,6 +3,3 @@ require "stylr/file_parser"
3
3
  require "stylr/lint"
4
4
  require "stylr/dir_loader"
5
5
 
6
- module Stylr
7
- # Your code goes here...
8
- end
@@ -1,16 +1,13 @@
1
1
  class DirLoader
2
2
  attr_reader :filenames
3
3
 
4
- DEPTH = "**/**/**/**/**/**/**/**/**/**/**/**" # lol wut
5
-
6
4
  def load_dir(dir)
7
- @filenames = Dir[File.expand_path(dir) + DEPTH].select do |f|
8
- File.file?(f) &&
9
- f =~ /\.rb$/
10
- end.reject do |f|
11
- f =~ /_spec\.rb$/ || f =~ /_test\.rb$/
5
+ Dir.chdir(File.expand_path(dir)) do
6
+ @filenames = Dir.glob('**/*.rb').map { |file| File.expand_path(file) }
7
+ end
8
+ @filenames.reject! do |filename|
9
+ filename =~ /(_spec|_test).rb$/
12
10
  end
13
11
  end
14
-
15
12
  end
16
13
 
@@ -53,6 +53,7 @@ module Stylr
53
53
 
54
54
  def display_no_error_message
55
55
  puts "Your file is free of errors."
56
+ puts
56
57
  end
57
58
 
58
59
  def display_errors
@@ -62,6 +63,7 @@ module Stylr
62
63
  line_number = hash.values.first
63
64
  puts "Line #{line_number}: #{@lint.send(error)}"
64
65
  end
66
+ puts
65
67
  end
66
68
  end
67
69
  end
data/lib/stylr/lint.rb CHANGED
@@ -3,9 +3,9 @@ require 'yaml'
3
3
  class Lint
4
4
  attr_reader :errors, :violations, :exception_violations, :metaprogramming_violations, :messages
5
5
 
6
- def initialize
6
+ def initialize(config = nil)
7
7
  @errors = []
8
- @config = YAML.load_file(ENV["HOME"] + "/.stylr.yml")
8
+ @config = config || YAML.load_file(File.join(Dir.pwd, 'stylr.yml'))
9
9
  setup_class_values
10
10
  end
11
11
 
data/lib/stylr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Stylr
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -5,19 +5,19 @@ module Stylr
5
5
  let(:d) { DirLoader.new }
6
6
 
7
7
  it "loads all ruby files in a directory" do
8
- dir = "/Users/Thoughtworker/stylr/spec/dir"
8
+ dir = File.join(Dir.pwd, 'spec', 'dir')
9
9
  d.load_dir(dir)
10
- d.filenames.should == ["#{dir}/one.rb", "#{dir}/two.rb", "#{dir}/three.rb"].sort
10
+ d.filenames.sort.should == ["#{dir}/one.rb", "#{dir}/two.rb", "#{dir}/three.rb"].sort
11
11
  end
12
12
 
13
13
  it "loads all files even in a recursive structure" do
14
- dir = "/Users/Thoughtworker/stylr/spec/rdir"
14
+ dir = File.join(Dir.pwd, 'spec', 'rdir')
15
15
  d.load_dir(dir)
16
- d.filenames.should == ["#{dir}/one/one.rb", "#{dir}/two/two.rb", "#{dir}/three/three.rb", "#{dir}/base.rb"].sort
16
+ d.filenames.sort.should == ["#{dir}/one/one.rb", "#{dir}/two/two.rb", "#{dir}/three/three.rb", "#{dir}/base.rb"].sort
17
17
  end
18
18
 
19
19
  it "ignores specs" do
20
- dir = "/Users/Thoughtworker/stylr/spec/sdir"
20
+ dir = File.join(Dir.pwd, 'spec', 'sdir')
21
21
  d.load_dir(dir)
22
22
  d.filenames.should == []
23
23
  end
@@ -1,12 +1,15 @@
1
1
  require "stylr"
2
2
 
3
3
  module Stylr
4
- YAML_FILE_LOCATION = "/Users/Thoughtworker/stylr/stylr.yml"
5
4
  describe FileParser do
5
+ before do
6
+ @config = YAML.load_file('stylr.yml')
7
+ end
8
+
6
9
  context "sample_1" do
7
10
  before(:each) do
8
- @string = "/Users/Thoughtworker/stylr/spec/txt/sample_1.rb"
9
- @f = FileParser.new(@string, Lint.new)
11
+ @string = 'spec/txt/sample_1.rb'
12
+ @f = FileParser.new(@string, Lint.new(@config))
10
13
  end
11
14
 
12
15
  it "checks the file for errors" do
@@ -15,20 +18,17 @@ module Stylr
15
18
  end
16
19
 
17
20
  context "sample_fail" do
18
- before(:each) do
19
- @string = "/Users/Thoughtworker/stylr/spec/txt/sample_fail.rb"
20
- @f = FileParser.new(@string, Lint.new)
21
- end
22
-
23
21
  it "knows when something has failed" do
22
+ @string = "spec/txt/sample_fail.rb"
23
+ @f = FileParser.new(@string, Lint.new(@config))
24
24
  @f.violations?.should be_true
25
25
  end
26
26
  end
27
27
 
28
28
  context "sample_pass2" do
29
29
  before(:each) do
30
- @string = "/Users/Thoughtworker/stylr/spec/txt/sample_pass2.rb"
31
- @f = FileParser.new(@string, Lint.new)
30
+ @string = "spec/txt/sample_pass2.rb"
31
+ @f = FileParser.new(@string, Lint.new(@config))
32
32
  end
33
33
 
34
34
  it "doesn't break when shit appears in strings" do
@@ -38,8 +38,8 @@ module Stylr
38
38
 
39
39
  context "sample_fail2" do
40
40
  before(:each) do
41
- @string = "/Users/Thoughtworker/stylr/spec/txt/sample_fail2.rb"
42
- @f = FileParser.new(@string, Lint.new)
41
+ @string = "spec/txt/sample_fail2.rb"
42
+ @f = FileParser.new(@string, Lint.new(@config))
43
43
  end
44
44
 
45
45
  it "knows when something has failed" do
@@ -49,8 +49,8 @@ module Stylr
49
49
 
50
50
  context "sample_fail3" do
51
51
  before(:each) do
52
- @string = "/Users/Thoughtworker/stylr/spec/txt/sample_fail3.rb"
53
- @f = FileParser.new(@string, Lint.new)
52
+ @string = "spec/txt/sample_fail3.rb"
53
+ @f = FileParser.new(@string, Lint.new(@config))
54
54
  end
55
55
 
56
56
  it "knows when something has failed" do
@@ -60,8 +60,8 @@ module Stylr
60
60
 
61
61
  context "sample_fail4" do
62
62
  before(:each) do
63
- @string = "/Users/Thoughtworker/stylr/spec/txt/sample_fail4.rb"
64
- @f = FileParser.new(@string, Lint.new)
63
+ @string = "spec/txt/sample_fail4.rb"
64
+ @f = FileParser.new(@string, Lint.new(@config))
65
65
  end
66
66
 
67
67
  it "knows when something has failed" do
@@ -71,8 +71,8 @@ module Stylr
71
71
 
72
72
  context "sample_fail5" do
73
73
  before(:each) do
74
- @string = "/Users/Thoughtworker/stylr/spec/txt/sample_fail5.rb"
75
- @f = FileParser.new(@string, Lint.new)
74
+ @string = "spec/txt/sample_fail5.rb"
75
+ @f = FileParser.new(@string, Lint.new(@config))
76
76
  end
77
77
 
78
78
  it "knows when something has failed" do
data/spec/lint_spec.rb CHANGED
@@ -2,7 +2,7 @@ require "stylr"
2
2
 
3
3
  module Stylr
4
4
  describe Lint do
5
- let(:l) { Lint.new }
5
+ let(:l) { Lint.new(YAML.load_file('stylr.yml')) }
6
6
 
7
7
  context "#violation?" do
8
8
  context "missing_parens" do
data/stylr.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency "main", "~> 5.2.0"
21
+ spec.add_runtime_dependency "main", "~> 5.2", ">= 5.2.0"
22
22
  spec.add_development_dependency "bundler", "~> 1.3"
23
23
  spec.add_development_dependency "rspec"
24
24
  spec.add_development_dependency "rake"
metadata CHANGED
@@ -1,69 +1,75 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stylr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Billie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-20 00:00:00.000000000 Z
11
+ date: 2014-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: main
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.2'
20
+ - - ">="
18
21
  - !ruby/object:Gem::Version
19
22
  version: 5.2.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - ~>
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '5.2'
30
+ - - ">="
25
31
  - !ruby/object:Gem::Version
26
32
  version: 5.2.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - ~>
37
+ - - "~>"
32
38
  - !ruby/object:Gem::Version
33
39
  version: '1.3'
34
40
  type: :development
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - ~>
44
+ - - "~>"
39
45
  - !ruby/object:Gem::Version
40
46
  version: '1.3'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: rspec
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - '>='
51
+ - - ">="
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - '>='
58
+ - - ">="
53
59
  - !ruby/object:Gem::Version
54
60
  version: '0'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: rake
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - '>='
65
+ - - ">="
60
66
  - !ruby/object:Gem::Version
61
67
  version: '0'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - '>='
72
+ - - ">="
67
73
  - !ruby/object:Gem::Version
68
74
  version: '0'
69
75
  description: An attempt at enforcing https://github.com/styleguide/ruby
@@ -74,7 +80,7 @@ executables:
74
80
  extensions: []
75
81
  extra_rdoc_files: []
76
82
  files:
77
- - .gitignore
83
+ - ".gitignore"
78
84
  - Gemfile
79
85
  - Gemfile.lock
80
86
  - LICENSE.txt
@@ -116,17 +122,17 @@ require_paths:
116
122
  - lib
117
123
  required_ruby_version: !ruby/object:Gem::Requirement
118
124
  requirements:
119
- - - '>='
125
+ - - ">="
120
126
  - !ruby/object:Gem::Version
121
127
  version: '0'
122
128
  required_rubygems_version: !ruby/object:Gem::Requirement
123
129
  requirements:
124
- - - '>='
130
+ - - ">="
125
131
  - !ruby/object:Gem::Version
126
132
  version: '0'
127
133
  requirements: []
128
134
  rubyforge_project:
129
- rubygems_version: 2.0.6
135
+ rubygems_version: 2.2.0.rc.1
130
136
  signing_key:
131
137
  specification_version: 4
132
138
  summary: stylr - enforcing Ruby coding style standards