learn_linter 0.6.0 → 1.1.0

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: 4543fe96f9678ed27100772bab75faf1740c570c
4
- data.tar.gz: 218abe2d5ccc5ca8a3e9ddda3590c30a991de97e
3
+ metadata.gz: ba154f1b74ddada6873a18f2ba882bbc26da90ee
4
+ data.tar.gz: 18111390edb6629e6c8f5333a2c09981b0da096b
5
5
  SHA512:
6
- metadata.gz: b3c541f234d35652939f925e79ce130a7733b7420f9fdb308e2144764f1b33f678dd2b8d70d55def49b432620104091aeb07a67eca1d66a52587a173a0725bdb
7
- data.tar.gz: 6215189618dc554410cb72150e896289872415ac5b3035f083d7e43483c27d10481f203efe3a0ae00ecca2afa15af41ea5626e345bcecf2d022bd5415e8a71a2
6
+ metadata.gz: 96b607d790364f6993179cc198c5d39c76354bd06f8884a0d1e4e18222560b78eb5bd1be2a31b1ddac55a3a748443dc721296505cae1b2d082f3ecbf7125872e
7
+ data.tar.gz: fb9d3111b2d5d3015de52532802056fbbb5c44d1142efcf1c22af08793dbf958298e4d6cad53b87cc7c5eff51bb951e5befb0273c950271005e721fb2fe01816
data/bin/learn-lint CHANGED
@@ -1,21 +1,20 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  require 'yaml'
4
3
  require 'optparse'
5
4
  require_relative '../lib/learn_linter.rb'
6
5
 
7
6
  if ARGV.length == 0
8
- lint = LearnLinter.new.lint_directory
7
+ dir = File.expand_path(File.dirname(File.dirname(__FILE__)))
8
+ lint = LearnLinter.new(dir).lint_directory
9
9
  elsif ARGV.length == 1 && ARGV[0] == "quiet"
10
10
  dir = File.expand_path(File.dirname(File.dirname(__FILE__)))
11
11
  lint = LearnLinter.new(dir, "quiet")
12
12
  elsif ARGV.length > 1 && ARGV[1] == "quiet"
13
13
  lint = LearnLinter.new(ARGV[0], "quiet").lint_directory
14
- elsif ARGV.length > 1 && ARG[1] != "quiet"
14
+ elsif ARGV.length > 1 && ARGV[1] != "quiet"
15
15
  puts "please use 'learn-lint directory_name quiet' or 'learn-lint directory_name"
16
16
  elsif ARGV.length == 1
17
17
  lint = LearnLinter.new(ARGV[0]).lint_directory
18
18
  end
19
19
 
20
20
 
21
-
@@ -1,7 +1,8 @@
1
1
  class LearnError < StandardError
2
2
  attr_accessor :filepath, :valid_yaml, :valid_license,
3
3
  :present_learn, :present_license, :present_readme, :yaml_error,
4
- :readme_error, :license_error, :valid_readme, :correct_yaml_content
4
+ :readme_error, :license_error, :valid_readme, :correct_yaml_content,
5
+ :valid_contributing, :present_contributing, :contributing_error
5
6
 
6
7
  ESCAPES = { :green => "\033[32m",
7
8
  :yellow => "\033[33m",
@@ -13,13 +14,19 @@ class LearnError < StandardError
13
14
  @yaml_error = {present_dotlearn: false, valid_yaml: false, valid_whitespace: false, attributes: false}
14
15
  @readme_error = {present_readme: false, valid_readme: false}
15
16
  @license_error = {present_license: false, valid_license: false}
17
+ @contributing_error = {present_contributing: false, valid_contributing: false}
18
+
16
19
  @correct_yaml_content = {message: ".learn file must have 'tags', 'resources' and 'languages' keys", color: :yellow}
17
- @valid_yaml = {message: "invalid yaml or missing .learn", color: :red}
20
+
21
+ @valid_yaml = {message: "invalid yaml", color: :red}
18
22
  @valid_license = {message: "invalid or missing license content", color: :yellow}
19
23
  @valid_readme = {message: "invalid code snippet. Must have three backticks to open and close all code snippets", color: :red}
24
+ @valid_contributing = {message: "invalid or missing contributing content", color: :yellow}
25
+
20
26
  @present_learn = {message: "missing .learn file", color: :red}
21
27
  @present_license = {message: "missing LICENSE.md", color: :red}
22
28
  @present_readme = {message: "missing README.md", color: :yellow}
29
+ @present_contributing = {message: "missing CONTRIBUTING.md", color: :yellow}
23
30
 
24
31
  end
25
32
 
@@ -36,14 +43,15 @@ class LearnError < StandardError
36
43
  {
37
44
  dot_learn: yaml_error,
38
45
  license: license_error,
39
- readme: readme_error
46
+ readme: readme_error,
47
+ contributing: contributing_error
40
48
  }
41
49
 
42
50
  end
43
51
 
44
52
 
45
53
  def result_output
46
- all_results = [present_learn, valid_yaml, correct_yaml_content, present_license, valid_license, present_readme, valid_readme]
54
+ all_results = [present_learn, valid_yaml, correct_yaml_content, present_license, valid_license, present_readme, valid_readme, valid_contributing, present_contributing]
47
55
  all_results.each do |result|
48
56
  emit(result)
49
57
  end
@@ -1,4 +1,3 @@
1
- require 'pry'
2
1
  class ReadmeLinter
3
2
 
4
3
  def self.parse_file(file, learn_error)
@@ -22,7 +21,7 @@ class ReadmeLinter
22
21
  def self.validate_snippets(file, learn_error)
23
22
  file.split(" ").each do |chars|
24
23
  if chars.match(/``/)
25
- if !(chars.match(/```ruby/) || chars.match(/```bash/) || chars.match(/```objc/) || chars.match(/```javascript/) || chars.match(/``` /) || chars.match(/```sql/))
24
+ if !(chars.match(/```ruby/) || chars.match(/```bash/) || chars.match(/```objc/) || chars.match(/```javascript/) || chars.match(/``` /))
26
25
  break
27
26
  else
28
27
  green_light(learn_error)
@@ -30,4 +29,5 @@ class ReadmeLinter
30
29
  end
31
30
  end
32
31
  end
33
- end
32
+ end
33
+
@@ -1,3 +1,3 @@
1
1
  class LearnLinter
2
- VERSION = "0.6.0"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/learn_linter.rb CHANGED
@@ -3,14 +3,15 @@ require_relative './learn_linter/learn_error'
3
3
  require_relative './learn_linter/license_linter'
4
4
  require_relative './learn_linter/readme_linter'
5
5
  require_relative './learn_linter/yaml_linter'
6
+ require_relative './learn_linter/contributing_linter'
6
7
 
7
8
  class LearnLinter
8
9
 
9
10
  attr_accessor :filepath, :quiet
10
11
 
11
12
 
12
- def initialize(dir=nil, quiet=nil)
13
- @filepath = dir || Dir.pwd
13
+ def initialize(filepath, quiet=nil)
14
+ @filepath = filepath
14
15
  @learn_error = LearnError.new
15
16
  @quiet = quiet
16
17
  end
@@ -19,6 +20,7 @@ class LearnLinter
19
20
  self.yaml_lint
20
21
  self.license_lint
21
22
  self.readme_lint
23
+ self.contributing_lint
22
24
  unless quiet
23
25
  @learn_error.result_output
24
26
  end
@@ -55,4 +57,12 @@ class LearnLinter
55
57
  end
56
58
  end
57
59
 
60
+ def contributing_lint
61
+ if self.has_file?("CONTRIBUTING.md")
62
+ @learn_error.contributing_error[:present_contributing] = true
63
+ @learn_error.present_contributing = {message: "present CONTRIBUTING.md", color: :green}
64
+ ContributingLinter.parse_file("#{filepath}/CONTRIBUTING.md", @learn_error)
65
+ end
66
+ end
67
+
58
68
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: learn_linter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sophie DeBenedetto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-09 00:00:00.000000000 Z
11
+ date: 2015-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  requirements: []
91
91
  rubyforge_project:
92
- rubygems_version: 2.4.6
92
+ rubygems_version: 2.4.8
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: can lint a directory for valid .learn, license files