best_practice_project 0.0.0 → 0.0.1

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: 3feff99f742a8d651220cda76b234a83e21aac1c
4
- data.tar.gz: f13c39da87f542f1f5cb832d6b30666f6137a286
3
+ metadata.gz: c461d3d29af225c5b4d7dc63106672f1475a5461
4
+ data.tar.gz: 86c8f5715fe4892e48051eccdf49a509241fb5c3
5
5
  SHA512:
6
- metadata.gz: 0497860d33208af0b7fa473401bbbc6bb279a1ee9b3f363d35566e6a05603a2dd492dffd38860f741903eda022e728e042abb21f442b8323680664670bd0f82d
7
- data.tar.gz: b3c3841612b4e8c990654f2ccb2c126efb42e442159c82e347f2a9914123c1b9da986f33c57c57e31bfd838e3d4a933a90ea11126ce10c89d442e9ff49672de7
6
+ metadata.gz: c5cf5c610bd621e35fffa543f643c02f2bb2d1ba1f9a5b4f735448ab727fdb9da03820229e11a89165bdbd18aea9695f52f208029cc4b96f816ffba8b10c8d89
7
+ data.tar.gz: 3b14768ddd300da0804a1cbddea3266505ab5438d728ae5ba48723fc0adcbd1733befd127a98ec5fbf6ea3d6b06c2c13397b7ff0ac7f096099c2ce8c3fe1b200
data/README.md CHANGED
@@ -1,6 +1,49 @@
1
+ [![Build Status](https://img.shields.io/shippable/56404e3d1895ca447422feda.svg)](https://app.shippable.com/projects/56404e3d1895ca447422feda/builds/latest)
2
+
1
3
  # BestPracticeProject
2
4
 
3
- Description goes here.
5
+ A bundle of various coverage and analytical tools to help you keep your code clean. The idea is that you only have to bundle this project, run the generate config command and start writing clean code for your project.
6
+
7
+ - Rubocop
8
+ - Rails Best Practices
9
+ - SCSS Lint
10
+ - CoffeeLint
11
+
12
+ ## In development!
13
+
14
+ This project is still in early development. Currently generating configs only works for Rubocop and SCSS Lint.
15
+
16
+ ## Install
17
+
18
+ Add to your Gemfile and bundle:
19
+ ```ruby
20
+ gem "best_practice_project"
21
+ ```
22
+
23
+ Add this to your Rakefile:
24
+ ```ruby
25
+ BestPracticeProject.load_tasks
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ First you can generate some todo configs like this:
31
+ ```bash
32
+ bundle exec rake best_practice_project:generate_configs
33
+ ```
34
+
35
+ You can then run all the checks like this:
36
+ ```bash
37
+ bundle exec rake best_practice_project:run
38
+ ```
39
+
40
+ You can also run each check manually like this:
41
+ ```bash
42
+ bundle exec rake best_practice_project:run_rubocop
43
+ bundle exec rake best_practice_project:run_rails_best_practices
44
+ bundle exec rake best_practice_project:run_coffee_lint
45
+ bundle exec rake best_practice_project:run_scss_lint
46
+ ```
4
47
 
5
48
  ## Contributing to best_practice_project
6
49
 
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'rubygems'
4
- require 'bundler'
3
+ require "rubygems"
4
+ require "bundler"
5
5
  begin
6
6
  Bundler.setup(:default, :development)
7
7
  rescue Bundler::BundlerError => e
@@ -9,42 +9,45 @@ rescue Bundler::BundlerError => e
9
9
  $stderr.puts "Run `bundle install` to install missing gems"
10
10
  exit e.status_code
11
11
  end
12
- require 'rake'
12
+ require "rake"
13
13
 
14
- require 'jeweler'
14
+ require "jeweler"
15
15
  Jeweler::Tasks.new do |gem|
16
16
  # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
17
  gem.name = "best_practice_project"
18
18
  gem.homepage = "http://github.com/kaspernj/best_practice_project"
19
19
  gem.license = "MIT"
20
- gem.summary = %Q{A bundle of various linters and code inspection tools}
21
- gem.description = %Q{A bundle of various linters and code inspection tools}
20
+ gem.summary = %(A bundle of various linters and code inspection tools)
21
+ gem.description = %(A bundle of various linters and code inspection tools)
22
22
  gem.email = "k@spernj.org"
23
23
  gem.authors = ["kaspernj"]
24
24
  # dependencies defined in Gemfile
25
25
  end
26
26
  Jeweler::RubygemsDotOrgTasks.new
27
27
 
28
- require 'rspec/core'
29
- require 'rspec/core/rake_task'
28
+ require "rspec/core"
29
+ require "rspec/core/rake_task"
30
30
  RSpec::Core::RakeTask.new(:spec) do |spec|
31
- spec.pattern = FileList['spec/**/*_spec.rb']
31
+ spec.pattern = FileList["spec/**/*_spec.rb"]
32
32
  end
33
33
 
34
34
  desc "Code coverage detail"
35
35
  task :simplecov do
36
- ENV['COVERAGE'] = "true"
37
- Rake::Task['spec'].execute
36
+ ENV["COVERAGE"] = "true"
37
+ Rake::Task["spec"].execute
38
38
  end
39
39
 
40
- task :default => :spec
40
+ task default: :spec
41
41
 
42
- require 'rdoc/task'
42
+ require "rdoc/task"
43
43
  Rake::RDocTask.new do |rdoc|
44
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+ version = File.exist?("VERSION") ? File.read("VERSION") : ""
45
45
 
46
- rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.rdoc_dir = "rdoc"
47
47
  rdoc.title = "best_practice_project #{version}"
48
- rdoc.rdoc_files.include('README*')
49
- rdoc.rdoc_files.include('lib/**/*.rb')
48
+ rdoc.rdoc_files.include("README*")
49
+ rdoc.rdoc_files.include("lib/**/*.rb")
50
50
  end
51
+
52
+ require "best_practice_project"
53
+ BestPracticeProject.load_tasks
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
@@ -0,0 +1,79 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: best_practice_project 0.0.1 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "best_practice_project"
9
+ s.version = "0.0.1"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["kaspernj"]
14
+ s.date = "2015-11-13"
15
+ s.description = "A bundle of various linters and code inspection tools"
16
+ s.email = "k@spernj.org"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.md",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "best_practice_project.gemspec",
31
+ "config/rubocop.yml",
32
+ "lib/best_practice_project.rb",
33
+ "lib/tasks/best_practice_project.rake",
34
+ "shippable.yml",
35
+ "spec/best_practice_project_spec.rb",
36
+ "spec/spec_helper.rb"
37
+ ]
38
+ s.homepage = "http://github.com/kaspernj/best_practice_project"
39
+ s.licenses = ["MIT"]
40
+ s.rubygems_version = "2.4.0"
41
+ s.summary = "A bundle of various linters and code inspection tools"
42
+
43
+ if s.respond_to? :specification_version then
44
+ s.specification_version = 4
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<rubocop>, ["= 0.35.0"])
48
+ s.add_runtime_dependency(%q<coffeelint>, ["= 1.11.0"])
49
+ s.add_runtime_dependency(%q<scss_lint>, [">= 0"])
50
+ s.add_runtime_dependency(%q<rails_best_practices>, [">= 0"])
51
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
52
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
53
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
54
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
55
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
56
+ else
57
+ s.add_dependency(%q<rubocop>, ["= 0.35.0"])
58
+ s.add_dependency(%q<coffeelint>, ["= 1.11.0"])
59
+ s.add_dependency(%q<scss_lint>, [">= 0"])
60
+ s.add_dependency(%q<rails_best_practices>, [">= 0"])
61
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
62
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
63
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
64
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
65
+ s.add_dependency(%q<simplecov>, [">= 0"])
66
+ end
67
+ else
68
+ s.add_dependency(%q<rubocop>, ["= 0.35.0"])
69
+ s.add_dependency(%q<coffeelint>, ["= 1.11.0"])
70
+ s.add_dependency(%q<scss_lint>, [">= 0"])
71
+ s.add_dependency(%q<rails_best_practices>, [">= 0"])
72
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
73
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
74
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
75
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
76
+ s.add_dependency(%q<simplecov>, [">= 0"])
77
+ end
78
+ end
79
+
@@ -0,0 +1,43 @@
1
+ AllCops:
2
+ Exclude:
3
+ - db/schema.rb
4
+
5
+ Metrics/LineLength:
6
+ Max: 160
7
+
8
+ Metrics/MethodLength:
9
+ Max: 50
10
+
11
+ Metrics/AbcSize:
12
+ Max: 25
13
+
14
+ Style/AccessModifierIndentation:
15
+ EnforcedStyle: outdent
16
+
17
+ Style/ClassAndModuleChildren:
18
+ EnforcedStyle: compact
19
+
20
+ Style/Documentation:
21
+ Enabled: false
22
+
23
+ Style/EmptyLines:
24
+ Enabled: false
25
+
26
+ StringLiterals:
27
+ EnforcedStyle: double_quotes
28
+
29
+ StringLiteralsInInterpolation:
30
+ Enabled: false
31
+
32
+ Style/SignalException:
33
+ EnforcedStyle: only_raise
34
+
35
+ Style/MultilineOperationIndentation:
36
+ EnforcedStyle: indented
37
+
38
+ Style/SpaceInsideHashLiteralBraces:
39
+ EnforcedStyle: no_space
40
+
41
+ Style/TrivialAccessors:
42
+ ExactNameMatch: true
43
+ Enabled: true
@@ -0,0 +1,140 @@
1
+ class BestPracticeProject
2
+ attr_reader :rails
3
+ alias_method :rails?, :rails
4
+
5
+ def self.load_tasks
6
+ load "#{File.dirname(__FILE__)}/tasks/best_practice_project.rake"
7
+ end
8
+
9
+ def initialize
10
+ @rubocop_actual_config_path = File.realpath("#{File.dirname(__FILE__)}/../config/rubocop.yml")
11
+
12
+ if Object.const_defined?(:Rails)
13
+ @rails = true
14
+
15
+ @rubocop_config_path = Rails.root.join("config", "rubocop.yml").to_s
16
+ @scss_config_path = Rails.root.join("config", "scss-lint.yml").to_s
17
+ @coffee_lint_config_path = Rails.root.join("config", "coffeelint.json").to_s
18
+ else
19
+ @rails = false
20
+
21
+ @rubocop_config_path = "config/rubocop.yml"
22
+ end
23
+
24
+ @commands = []
25
+
26
+ if rails?
27
+ @commands << scss_lint_command
28
+ @commands << coffee_lint_command
29
+ @commands << rails_best_practices_command
30
+ end
31
+
32
+ @commands << rubocop_command
33
+ end
34
+
35
+ def execute
36
+ process_status = true
37
+
38
+ @commands.each do |command|
39
+ puts "Executing: #{command}"
40
+
41
+ status = system(command)
42
+ process_status = status unless status
43
+ end
44
+
45
+ process_status
46
+ end
47
+
48
+ def generate_configs
49
+ generate_rubocop_config
50
+ generate_scss_config
51
+ generate_coffee_lint_config
52
+ end
53
+
54
+ def rubocop_command
55
+ command = "bundle exec rubocop --display-cop-names"
56
+ command << " --rails" if rails?
57
+
58
+ if File.exist?(@rubocop_config_path)
59
+ command << " \"--config=#{@rubocop_config_path}\""
60
+ end
61
+
62
+ command
63
+ end
64
+
65
+ def scss_lint_command
66
+ "bundle exec scss-lint --config config/scss-lint.yml app/assets/stylesheets/" if rails?
67
+ end
68
+
69
+ def coffee_lint_command
70
+ "bundle exec coffeelint.rb -f config/coffeelint.json -r app/assets/javascripts/" if rails?
71
+ end
72
+
73
+ def rails_best_practices_command
74
+ "bundle exec rails_best_practices" if rails?
75
+ end
76
+
77
+ private
78
+
79
+ def generate_coffee_lint_config
80
+ return puts "Coffee-Lint config already exists in #{@coffee_lint_config_path}" if File.exist?(@coffee_lint_config_path)
81
+
82
+ puts "FIXME: Generate Coffee-Lint configuration!"
83
+ end
84
+
85
+ def generate_scss_config
86
+ return puts "SCSS-Lint config already exists in #{@scss_config_path}" if File.exist?(@scss_config_path)
87
+
88
+ config = `bundle exec scss-lint --format=Config`
89
+
90
+ File.open(@scss_config_path, "w") do |fp|
91
+ fp.write(config)
92
+ end
93
+
94
+ puts "Generated SCSS-Lint config in #{@scss_config_path}"
95
+ end
96
+
97
+ def generate_rubocop_config
98
+ return puts "Rubocop config already exists in #{@rubocop_config_path}" if File.exist?(@rubocop_config_path)
99
+
100
+ project_todo_path = Rails.root.join("config", "rubocop_todo.yml").to_s
101
+
102
+ generated_todo_config = {}
103
+ generated_todo_config["inherit_from"] = @rubocop_actual_config_path
104
+ generated_todo_config.merge!(generate_rubocop_todo_config)
105
+
106
+ File.open(project_todo_path, "w") do |fp|
107
+ fp.write(YAML.dump(generated_todo_config))
108
+ end
109
+
110
+ puts "Generated Rubocop todo config in #{project_todo_path}"
111
+
112
+ generated_config = {}
113
+ generated_config["inherit_from"] = "rubocop_todo.yml"
114
+
115
+ File.open(@rubocop_config_path, "w") do |fp|
116
+ fp.write(YAML.dump(generated_config))
117
+ end
118
+
119
+ puts "Generated Rubocop config in #{@rubocop_config_path}"
120
+ end
121
+
122
+ def generate_rubocop_todo_config
123
+ todo_file_path = Rails.root.join(".rubocop_todo.yml").to_s
124
+ todo_backup_file_path = Rails.root.join(".rubocop_todo_backup.yml").to_s
125
+
126
+ if File.exist?(todo_file_path)
127
+ File.rename(todo_file_path, todo_backup_file_path)
128
+ end
129
+
130
+ system("rubocop --rails --display-cop-names --auto-gen-config --config=#{@rubocop_actual_config_path}")
131
+
132
+ raise "Todo-file was not generated" unless File.exist?(todo_file_path)
133
+
134
+ todo_config = YAML.load_file(todo_file_path)
135
+ File.unlink(todo_file_path)
136
+ File.rename(todo_backup_file_path, todo_file_path) if File.exist?(todo_backup_file_path)
137
+
138
+ todo_config
139
+ end
140
+ end
@@ -0,0 +1,37 @@
1
+ namespace "best_practice_project" do
2
+ task "run" do
3
+ exit BestPracticeProject.new.execute
4
+ end
5
+
6
+ task "run_rubocop" do
7
+ best_practice_project = BestPracticeProject.new
8
+
9
+ puts "Executing: #{best_practice_project.rubocop_command}"
10
+ exit system(best_practice_project.rubocop_command)
11
+ end
12
+
13
+ task "run_scss_lint" do
14
+ best_practice_project = BestPracticeProject.new
15
+
16
+ puts "Executing: #{best_practice_project.scss_lint_command}"
17
+ exit system(best_practice_project.scss_lint_command)
18
+ end
19
+
20
+ task "run_coffee_lint" do
21
+ best_practice_project = BestPracticeProject.new
22
+
23
+ puts "Executing: #{best_practice_project.coffee_lint_command}"
24
+ exit system(best_practice_project.coffee_lint_command)
25
+ end
26
+
27
+ task "run_rails_best_practices" do
28
+ best_practice_project = BestPracticeProject.new
29
+
30
+ puts "Executing: #{best_practice_project.rails_best_practices_command}"
31
+ exit system(best_practice_project.rails_best_practices_command)
32
+ end
33
+
34
+ task "generate_configs" do
35
+ BestPracticeProject.new.generate_configs
36
+ end
37
+ end
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ cache: bundler
3
+ archive: true
4
+ rvm:
5
+ - ruby-2.1.2
6
+ script:
7
+ - bundle exec rspec
8
+ - bundle exec best_practice_project:run
9
+ notifications:
10
+ email: false
@@ -1,7 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2
2
 
3
3
  describe "BestPracticeProject" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
6
- end
7
4
  end
@@ -1,4 +1,4 @@
1
- require 'simplecov'
1
+ require "simplecov"
2
2
 
3
3
  module SimpleCov::Configuration
4
4
  def clean_filters
@@ -8,22 +8,21 @@ end
8
8
 
9
9
  SimpleCov.configure do
10
10
  clean_filters
11
- load_adapter 'test_frameworks'
11
+ load_adapter "test_frameworks"
12
12
  end
13
13
 
14
14
  ENV["COVERAGE"] && SimpleCov.start do
15
15
  add_filter "/.rvm/"
16
16
  end
17
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
17
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
18
18
  $LOAD_PATH.unshift(File.dirname(__FILE__))
19
19
 
20
- require 'rspec'
21
- require 'best_practice_project'
20
+ require "rspec"
21
+ require "best_practice_project"
22
22
 
23
23
  # Requires supporting files with custom matchers and macros, etc,
24
24
  # in ./support/ and its subdirectories.
25
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
25
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
26
26
 
27
27
  RSpec.configure do |config|
28
-
29
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: best_practice_project
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-09 00:00:00.000000000 Z
11
+ date: 2015-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -152,7 +152,11 @@ files:
152
152
  - README.md
153
153
  - Rakefile
154
154
  - VERSION
155
+ - best_practice_project.gemspec
156
+ - config/rubocop.yml
155
157
  - lib/best_practice_project.rb
158
+ - lib/tasks/best_practice_project.rake
159
+ - shippable.yml
156
160
  - spec/best_practice_project_spec.rb
157
161
  - spec/spec_helper.rb
158
162
  homepage: http://github.com/kaspernj/best_practice_project