travis-lint 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,6 +1,8 @@
1
- .DS_Store
2
1
  #~
3
- *~
4
- Gemfile.lock
5
2
  *.gem
6
- .rvmrc
3
+ *.swp
4
+ *~
5
+ .DS_Store
6
+ /.rvmrc
7
+ /Gemfile.lock
8
+ /TAGS
data/Gemfile CHANGED
@@ -2,6 +2,3 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- group :test do
6
- gem "rake", ">= 0.9.2.2"
7
- end
data/README.md CHANGED
@@ -7,11 +7,12 @@
7
7
 
8
8
  ## Installation
9
9
 
10
- TBD: we need to do initial gem release first
10
+ gem install travis-lint
11
11
 
12
12
 
13
13
  ## Usage
14
14
 
15
+ travis-lint # inside a dir with .travis.yml
15
16
  travis-lint ./.travis.yml
16
17
  travis-lint ~/your/project/.travis.yml
17
18
 
@@ -3,6 +3,12 @@ require "travis/lint/validator"
3
3
  module Travis
4
4
  module Lint
5
5
  module DSL
6
+ def blank? object
7
+ # This implementation is based on rails' activesupport. It is used
8
+ # under the MIT license.
9
+ object.respond_to?(:empty?) ? object.empty? : !object
10
+ end
11
+
6
12
  @@validators = []
7
13
 
8
14
  def validator_for(language, key, message, &validator)
@@ -1,6 +1,7 @@
1
- require "active_support/core_ext/object/blank"
2
1
  require "travis/lint/dsl"
3
2
 
3
+ require "hashr"
4
+
4
5
  module Travis
5
6
  module Lint
6
7
  class Linter
@@ -17,6 +18,8 @@ module Travis
17
18
  #
18
19
 
19
20
  def self.validate(hsh)
21
+ hsh = Hashr.new hsh
22
+
20
23
  issues = find_validators_for(hsh[:language]).inject([]) do |acc, val|
21
24
  acc << val.call(hsh)
22
25
  acc
@@ -32,8 +35,8 @@ module Travis
32
35
  # General
33
36
  #
34
37
 
35
- validator_for :all, :language, "Language: key is mandatory" do |hsh|
36
- hsh[:language].blank?
38
+ validator_for :all, :language, "The \"language\" key is mandatory" do |hsh|
39
+ blank? hsh[:language]
37
40
  end
38
41
 
39
42
 
@@ -41,8 +44,8 @@ module Travis
41
44
  # Erlang
42
45
  #
43
46
 
44
- validator_for :erlang, :otp_release, "Specify OTP releases you want to test against using the :otp_release key" do |hsh|
45
- hsh[:language].to_s.downcase == "erlang" && hsh[:otp_release].blank?
47
+ validator_for :erlang, :otp_release, "Specify OTP releases you want to test against using the \"otp_release\" key" do |hsh|
48
+ hsh[:language].to_s.downcase == "erlang" && blank?(hsh[:otp_release])
46
49
  end
47
50
 
48
51
 
@@ -50,8 +53,8 @@ module Travis
50
53
  # Ruby
51
54
  #
52
55
 
53
- validator_for :ruby, :rvm, "Specify Ruby versions/implementations you want to test against using the :rvm key" do |hsh|
54
- hsh[:language].to_s.downcase == "ruby" && hsh[:rvm].blank?
56
+ validator_for :ruby, :rvm, "Specify Ruby versions/implementations you want to test against using the \"rvm\" key" do |hsh|
57
+ hsh[:language].to_s.downcase == "ruby" && blank?(hsh[:rvm])
55
58
  end
56
59
 
57
60
  validator_for :ruby, :rvm, "Prefer jruby-18mode RVM alias to jruby" do |hsh|
@@ -81,7 +84,7 @@ module Travis
81
84
 
82
85
 
83
86
  validator_for :ruby, :language, "Language is set to Ruby but node_js key is present. Ruby builder will ignore node_js key." do |hsh|
84
- hsh[:language].to_s.downcase == "ruby" && hsh[:node_js].present?
87
+ hsh[:language].to_s.downcase == "ruby" && ! blank?(hsh[:node_js])
85
88
  end
86
89
  end
87
90
  end
@@ -1,8 +1,6 @@
1
1
  require "pathname"
2
2
  require "yaml"
3
3
 
4
- require "hashr"
5
-
6
4
  require "travis/lint/linter"
7
5
 
8
6
  module Travis
@@ -55,7 +53,7 @@ module Travis
55
53
  end
56
54
 
57
55
  def parsed_travis_yml
58
- Hashr.new(YAML.load_file(@travis_file_path))
56
+ YAML.load_file(@travis_file_path)
59
57
  end
60
58
 
61
59
  def show_help
@@ -1,6 +1,6 @@
1
1
  module Travis
2
2
  module Lint
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  Version = VERSION
5
5
  end
6
6
  end
@@ -2,11 +2,11 @@ require "spec_helper"
2
2
 
3
3
  describe "A .travis.yml" do
4
4
  let(:language_key_is_mandatory) do
5
- { :key => :language, :issue => "Language: key is mandatory" }
5
+ { :key => :language, :issue => "The \"language\" key is mandatory" }
6
6
  end
7
7
 
8
8
  let(:rvm_key_is_recommended) do
9
- { :key => :rvm, :issue => "Specify Ruby versions/implementations you want to test against using the :rvm key" }
9
+ { :key => :rvm, :issue => "Specify Ruby versions/implementations you want to test against using the \"rvm\" key" }
10
10
  end
11
11
 
12
12
  let(:prefer_jruby18mode_over_jruby) do
@@ -25,14 +25,17 @@ describe "A .travis.yml" do
25
25
  { :key => :rvm, :issue => "rbx-2.0.0pre RVM alias is no longer provided. Please use rbx-18mode or rbx-19mode instead." }
26
26
  end
27
27
 
28
+ let(:otp_release_key_is_required) do
29
+ { :key => :otp_release, :issue => "Specify OTP releases you want to test against using the \"otp_release\" key" }
30
+ end
31
+
28
32
 
29
33
  def content_of_sample_file(name)
30
34
  path = Pathname.new(File.join("spec", "files", name)).expand_path
31
35
 
32
- Hashr.new(YAML.load_file(path.to_s))
36
+ YAML.load_file(path.to_s)
33
37
  end
34
38
 
35
-
36
39
  context "that is blank" do
37
40
  it "is invalid" do
38
41
  Travis::Lint::Linter.validate({}).should include(language_key_is_mandatory)
@@ -41,8 +44,14 @@ describe "A .travis.yml" do
41
44
  end
42
45
  end
43
46
 
47
+ context "using String keys" do
48
+ it "is validates as with Symbol keys" do
49
+ Travis::Lint::Linter.validate({ "language" => "ruby" }).should include(rvm_key_is_recommended)
50
+ end
51
+ end
52
+
44
53
  context "that has language set to Ruby" do
45
- context "but has no :rvm key" do
54
+ context "but has no \"rvm\" key" do
46
55
  it "is invalid" do
47
56
  Travis::Lint::Linter.validate({ :language => "ruby" }).should include(rvm_key_is_recommended)
48
57
  Travis::Lint::Linter.valid?(content_of_sample_file("no_rvm_key.yml")).should be_false
@@ -106,4 +115,13 @@ describe "A .travis.yml" do
106
115
  end
107
116
  end
108
117
  end
118
+
119
+ context "that has language set to erlang" do
120
+ context "but has no \"otp_release\" key" do
121
+ it "is invalid" do
122
+ Travis::Lint::Linter.validate({ :language => "erlang" }).should include(otp_release_key_is_required)
123
+ Travis::Lint::Linter.valid?({ :language => "erlang" }).should be_false
124
+ end
125
+ end
126
+ end
109
127
  end
data/travis-lint.gemspec CHANGED
@@ -16,10 +16,6 @@ Gem::Specification.new do |s|
16
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
17
  s.require_paths = ["lib"]
18
18
 
19
- s.add_runtime_dependency("activesupport", ["~> 3.2.0"])
20
- # activesupport 3.1 and 3.2 have a bug in HashWithIndifferentAccess that
21
- # causes an undefined method exception when hash values are arrays, so we
22
- # retreat to Hashr. MK.
23
19
  s.add_runtime_dependency("hashr", [">= 0.0.19"])
24
20
 
25
21
  s.add_development_dependency("rspec", ["~> 2.8.0"])
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travis-lint
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 1.0.0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael S. Klishin
@@ -16,28 +16,12 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-02-10 00:00:00 Z
19
+ date: 2012-02-16 00:00:00 Z
20
20
  dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: activesupport
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 15
30
- segments:
31
- - 3
32
- - 2
33
- - 0
34
- version: 3.2.0
35
- type: :runtime
36
- version_requirements: *id001
37
21
  - !ruby/object:Gem::Dependency
38
22
  name: hashr
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ requirement: &id001 !ruby/object:Gem::Requirement
41
25
  none: false
42
26
  requirements:
43
27
  - - ">="
@@ -49,11 +33,11 @@ dependencies:
49
33
  - 19
50
34
  version: 0.0.19
51
35
  type: :runtime
52
- version_requirements: *id002
36
+ version_requirements: *id001
53
37
  - !ruby/object:Gem::Dependency
54
38
  name: rspec
55
39
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ requirement: &id002 !ruby/object:Gem::Requirement
57
41
  none: false
58
42
  requirements:
59
43
  - - ~>
@@ -65,7 +49,7 @@ dependencies:
65
49
  - 0
66
50
  version: 2.8.0
67
51
  type: :development
68
- version_requirements: *id003
52
+ version_requirements: *id002
69
53
  description: travis-lint is a tool that check your .travis.yml for possible issues, deprecations and so on. Recommended for all travis-ci.org users.
70
54
  email:
71
55
  - michaelklishin@me.com
@@ -127,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
111
  requirements: []
128
112
 
129
113
  rubyforge_project:
130
- rubygems_version: 1.8.10
114
+ rubygems_version: 1.8.15
131
115
  signing_key:
132
116
  specification_version: 3
133
117
  summary: Checks your .travis.yml for possible issues, deprecations and so on