advertilecop 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 322ce47809d8b2c8453a58148640af7870b16770
4
+ data.tar.gz: 4fc02983121083ff851ef4e7b047b20b057379b2
5
+ SHA512:
6
+ metadata.gz: 6ac365068ce22d5b3a48a79a9fee65036e2d3e11e3b35bb1d2481c6e4a828881dfff00204a92b67128d6759731bb0d9532ec0b906e4ee28a08571ecf5c898163
7
+ data.tar.gz: 9bc3535cac43151005b71072d5200919ffdbc9b16a7ce306229a39119d850cdd9a7f6b979f864062ca5aa2407663daf0674d8e187dd23efb0e0c6f16360c74e8
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in advertilecop.gemspec
4
+ gemspec
5
+
6
+ gem "pry"
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2017 Mika Hel
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # AdvertileCop
2
+
3
+ *20% MonkeyPatch, 80% YAML, 100% Style*
4
+
5
+ AdvertileCop uses [RuboCop](https://github.com/bbatsov/rubocop) to enforce Advertile Mobiles's style guidelines.
6
+
7
+ "What are the guidelines?", I hear you bellow. Well, [check out our commented settings file](https://github.com/Advertile/advertilecop/blob/master/lib/advertilecop.yml) for more information.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'advertilecop', require: false
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it globally with:
20
+
21
+ $ gem install advertilecop
22
+
23
+ ## Usage
24
+
25
+ In a Rakefile:
26
+
27
+ ```ruby
28
+ require 'advertilecop/rake_task'
29
+ AdvertileCop::RakeTask.new(:advertilecop)
30
+ ```
31
+
32
+ This can be quite dramatic if you haven't been using a style checker previously and you have, say, 10 years of code written. Why not only lint files changed in the last N commits? This also makes advertilecop much faster in large codebases as you only have to lint recently changed files.
33
+
34
+ ```ruby
35
+ require 'advertilecop/rake_task'
36
+ AdvertileCop::RakeTask.new(:advertilecop) do |task|
37
+ task.patterns = advertilecop_files(5)
38
+ task.options = ['-D'] # Dispays name of failing cop in output.
39
+ exit if task.patterns == []
40
+ end
41
+
42
+ def advertilecop_files(pedantry)
43
+ `git diff-tree --no-commit-id --name-only -r HEAD~#{pedantry} HEAD`
44
+ .split("\n").select { |f| f.match(/(\.rb\z)|Rakefile/) && File.exist?(f) && !f.match(/db/) }
45
+ end
46
+ ```
47
+
48
+ You can also use AdvertileCop stand-alone:
49
+
50
+ ```
51
+ $ advertilecop
52
+ ```
53
+
54
+ If you are introducing advertilecop to an existing project, or bumping the advertilecop version try:
55
+
56
+ ```
57
+ $ advertilecop -a
58
+ ```
59
+ Anything that can be auto corrected will be, this will save you a lot of time!
60
+
61
+ ## Configuring / Contributing
62
+
63
+ 1. You can't configure this, thats the point.
64
+ 2. If you need to change our style guidelines, update the `lib/advertilecop.yml` file and open a pull request.
65
+ 3. If you have a good reason to break the guidelines, you can [switch off the cop for the code like this.](https://github.com/bbatsov/rubocop#disabling-cops-within-source-code)
66
+ 4. Please don't open a pull request unless you work at Advertile Mobile
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ require "bundler/gem_tasks"
4
+ require "advertilecop/rake_task"
5
+
6
+ AdvertileCop::RakeTask.new(:advertilecop)
7
+
8
+ task :advertilecop_cli do
9
+ sh "bin/advertilecop"
10
+ end
11
+
12
+ task default: [:advertilecop, :advertilecop_cli]
13
+ task build: [:advertilecop, :advertilecop_cli]
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "advertilecop/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "advertilecop"
8
+ spec.version = AdvertileCop::VERSION
9
+ spec.authors = ["Mika Hel"]
10
+ spec.email = ["mikael.henriksson@advertilemobile.com"]
11
+ spec.summary = "Like RuboCop only for Advertile"
12
+ spec.description = "RuboCop patched for to enforce the use of Advertile Style Guidelines"
13
+ spec.homepage = "http://www.advertilemobile.com"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rubocop"
22
+ spec.add_development_dependency "bundler"
23
+ spec.add_development_dependency "rake"
24
+ end
data/bin/advertilecop ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ $LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + "/../lib")
5
+
6
+ require "advertilecop"
7
+ require "benchmark"
8
+
9
+ cli = RuboCop::CLI.new
10
+ result = 0
11
+
12
+ time = Benchmark.realtime do
13
+ result = cli.run
14
+ end
15
+
16
+ puts "Finished in #{time} seconds" if cli.options[:debug]
17
+ exit result
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ require "rubocop/rake_task"
4
+
5
+ module AdvertileCop
6
+ class RakeTask < RuboCop::RakeTask
7
+ def initialize(*args, &task_block) # rubocop:disable Metrics/AbcSize
8
+ setup_ivars(args)
9
+
10
+ desc "Run RuboCop" unless ::Rake.application.last_description
11
+
12
+ task(name, *args) do |_, task_args|
13
+ RakeFileUtils.send(:verbose, verbose) do
14
+ yield(*[self, task_args].slice(0, task_block.arity)) if block_given?
15
+ run_main_task(verbose)
16
+ end
17
+ end
18
+
19
+ setup_subtasks(name, *args, &task_block)
20
+ end
21
+
22
+ def run_cli(verbose, options)
23
+ require "advertilecop"
24
+ super(verbose, options)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ module AdvertileCop
4
+ VERSION = "0.0.1".freeze
5
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ require "rubocop"
4
+
5
+ module RuboCop
6
+ class ConfigLoader
7
+ class << self
8
+ def configuration_file_for(_target_dir)
9
+ File.join(File.realpath(File.dirname(__FILE__)), "advertilecop.yml")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,74 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ DisplayStyleGuide: true
4
+ Exclude:
5
+ - !ruby/regexp /node_modules/
6
+ - !ruby/regexp /db\/schema\.rb/
7
+ - 'vendor/bundle/**/*'
8
+
9
+ Documentation:
10
+ Enabled: false
11
+
12
+ Lint/AssignmentInCondition:
13
+ AllowSafeAssignment: true
14
+ Enabled: true
15
+
16
+ Metrics/LineLength:
17
+ Max: 120
18
+ IgnoreCopDirectives: true
19
+ Enabled: true
20
+
21
+ Metrics/MethodLength:
22
+ CountComments: false # count full line comments?
23
+ Max: 10
24
+ Enabled: true
25
+
26
+ Metrics/ModuleLength:
27
+ CountComments: false # count full line comments?
28
+ Max: 100
29
+ Enabled: true
30
+
31
+ Metrics/ParameterLists:
32
+ Max: 5
33
+ CountKeywordArgs: true
34
+ Enabled: true
35
+
36
+ Metrics/PerceivedComplexity:
37
+ Max: 7
38
+ Enabled: true
39
+
40
+ Style/AlignParameters:
41
+ Enabled: true
42
+ EnforcedStyle: with_first_parameter
43
+
44
+ Style/AndOr:
45
+ Enabled: true
46
+ EnforcedStyle: always
47
+
48
+ Style/BlockDelimiters:
49
+ Enabled: true
50
+ EnforcedStyle: braces_for_chaining
51
+ IgnoredMethods:
52
+ - lambda
53
+ - proc
54
+ - it
55
+ - feature
56
+ - background
57
+ - describe
58
+ - context
59
+
60
+ Style/BracesAroundHashParameters:
61
+ EnforcedStyle: no_braces
62
+ Enabled: true
63
+
64
+ Style/StringLiterals:
65
+ EnforcedStyle: double_quotes
66
+ # If `true`, strings which span multiple lines using `\` for continuation must
67
+ # use the same type of quotes on each line.
68
+ ConsistentQuotesInMultiline: true
69
+ Enabled: true
70
+
71
+ Style/TrailingCommaInLiteral:
72
+ EnforcedStyleForMultiline: comma
73
+ Enabled: true
74
+
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: advertilecop
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mika Hel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubocop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: RuboCop patched for to enforce the use of Advertile Style Guidelines
56
+ email:
57
+ - mikael.henriksson@advertilemobile.com
58
+ executables:
59
+ - advertilecop
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - advertilecop.gemspec
69
+ - bin/advertilecop
70
+ - lib/advertilecop.rb
71
+ - lib/advertilecop.yml
72
+ - lib/advertilecop/rake_task.rb
73
+ - lib/advertilecop/version.rb
74
+ homepage: http://www.advertilemobile.com
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.6.8
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Like RuboCop only for Advertile
98
+ test_files: []