ci-syntax-tool 0.2.1 → 0.3.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7c3461eaa3027ce8705c0bfeba5b6626a2336e7a
4
+ data.tar.gz: a1f992455023269aee81c0f8588d36fddac8e8dd
5
+ SHA512:
6
+ metadata.gz: 89327fff6ec2fb1a7528fe13a4ac770355f0424c58a710c26b7afa1cd0d351b2eb829ae83dc73086ea7af32bcd88ef019628279a7890463847bac213c773fa99
7
+ data.tar.gz: 85249a76eb60cf104f094e3ca5c94138f9164d09fb79640c867739db4d968971ea90f80f27635d4b31351e23454090e78185e47019c78975abecf3d58e13b021
@@ -2,6 +2,10 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [0.3.0] - 2016-01-04
6
+ ### New Features
7
+ - Python language support
8
+
5
9
  ## [0.2.1] - 2016-01-04
6
10
  ### New Features
7
11
  - Added Changelog.
@@ -0,0 +1,68 @@
1
+ require 'fileutils'
2
+
3
+ module CI
4
+ module Syntax
5
+ module Tool
6
+ module Language
7
+ class Python < Language::Base
8
+
9
+ attr_reader :python_bin
10
+
11
+ def initialize(args)
12
+ super
13
+ @python_bin = `which python`.chomp
14
+ end
15
+
16
+ def default_globs
17
+ ['**/*.py']
18
+ end
19
+
20
+
21
+ # Called once before any files are checked
22
+ # An opportunity to spawn a process, for example.
23
+ # TODO: consider spawning a python process, reading filenames
24
+ # see this: http://stackoverflow.com/a/4284526/3284458
25
+ def check_starting(_lang_result)
26
+ end
27
+
28
+
29
+ # Called once for each file being checked.
30
+ # path [String] - path to filename to check
31
+ # file_result [Result::File] - Results object for the outcome.
32
+ # Returns: Result::File
33
+ def check_file(file_result)
34
+ # A clean compile will emit silence to STDERR and STDOUT, and leave behind a pyc file.
35
+ output = `#{python_bin} -m py_compile #{file_result.path} 2>&1`
36
+
37
+ # Errors look like this, with no newline (so far:
38
+ # Sorry: IndentationError: unexpected indent (bad-indentation.py, line 4)
39
+ output.scan(/Sorry:\s+(.+):\s+(.+)\s+\((.+),\s+line\s+(\d+)\)/).each do |match|
40
+ file_result.add_issue(
41
+ line_number: match[3],
42
+ level: :error,
43
+ raw_message: match[1],
44
+ )
45
+ end
46
+
47
+ # Check for and delete a PYC file if one was created.
48
+ pyc_file = file_result.path + 'c'
49
+ if File.exist?(pyc_file) then
50
+ FileUtils.rm(pyc_file)
51
+ end
52
+ end
53
+
54
+
55
+ # Called once after all files are checked
56
+ # Use for cleanup, or adding metadata to
57
+ # the result.
58
+ # result [Language::Result] - populated
59
+ # results of the run.
60
+ # TODO: shutdown sub proc
61
+ def check_ending(_result)
62
+ end
63
+
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -3,8 +3,8 @@ module CI
3
3
  # CI::Syntax::Tool module
4
4
  # Simple container for namespacing the project. Here, just the
5
5
  # version string.
6
- module Tool
7
- VERSION = '0.2.1'
6
+ module Tool
7
+ VERSION = '0.3.0'
8
8
  end
9
9
  end
10
10
  end
@@ -0,0 +1,34 @@
1
+ Feature: Python Language support
2
+
3
+ In order to be able to check Python files for errors
4
+ As a developer
5
+ I want to be able to run the tool on yaml files
6
+
7
+ Scenario: Use Python explicitly on clean files
8
+ Given I have installed the tool
9
+ When I run it on the command line specifying the Python language and clean files
10
+ Then I should get a 0 exit code
11
+ And the output should show only files for Python
12
+ And the output should have 0 warnings
13
+ And the output should have 0 errors
14
+
15
+
16
+ Scenario: Run all lamnguages on clean files
17
+ Given I have installed the tool
18
+ When I run it on the command line specifying all languages and clean files
19
+ Then I should get a 0 exit code
20
+ And the output should include files for Python
21
+ And the output should have 0 warnings
22
+ And the output should have 0 errors
23
+
24
+
25
+ Scenario: Use Python explicitly on error files
26
+ Given I have installed the tool
27
+ When I run it on the command line specifying the Python language and error files
28
+ Then I should get a 1 exit code
29
+ And the output should show only files for Python
30
+ And the output should have 0 warnings
31
+ And the output should have 1 errors
32
+
33
+
34
+
@@ -68,6 +68,7 @@ module CI
68
68
 
69
69
  def list_core_languages
70
70
  return [
71
+ 'Python',
71
72
  'YAML',
72
73
  ]
73
74
  end
@@ -0,0 +1,8 @@
1
+ def blue_parrot():
2
+ print "Prolonged Squawk"
3
+
4
+ if True:
5
+ exit
6
+
7
+ if False:
8
+ print "Well, don't exit, I suppose."
@@ -0,0 +1,8 @@
1
+ def blue_parrot():
2
+ print "Prolonged Squawk"
3
+
4
+ if True:
5
+ exit
6
+
7
+ if False:
8
+ print "Well, don't exit, I suppose."
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ci-syntax-tool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Clinton Wolfe
@@ -14,81 +13,71 @@ dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0.8'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0.8'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: cucumber
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: '2.0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: '2.0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rubocop
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0.28'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0.28'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: nokogiri
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - "~>"
84
74
  - !ruby/object:Gem::Version
85
75
  version: '1.6'
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - "~>"
92
81
  - !ruby/object:Gem::Version
93
82
  version: '1.6'
94
83
  description: Checks YAML, JSON, Ruby, ERB, and other syntaxes, then reports errors
@@ -100,7 +89,7 @@ executables:
100
89
  extensions: []
101
90
  extra_rdoc_files: []
102
91
  files:
103
- - .gitignore
92
+ - ".gitignore"
104
93
  - CHANGELOG.md
105
94
  - LICENSE
106
95
  - README.md
@@ -115,6 +104,7 @@ files:
115
104
  - lib/ci-syntax-tool/format/progress.rb
116
105
  - lib/ci-syntax-tool/format_factory.rb
117
106
  - lib/ci-syntax-tool/language/base.rb
107
+ - lib/ci-syntax-tool/language/python.rb
118
108
  - lib/ci-syntax-tool/language/yaml.rb
119
109
  - lib/ci-syntax-tool/language_factory.rb
120
110
  - lib/ci-syntax-tool/rake_task.rb
@@ -124,6 +114,7 @@ files:
124
114
  - test/features/.keep
125
115
  - test/features/command-line-help.feature
126
116
  - test/features/format-junit.feature
117
+ - test/features/language-python.feature
127
118
  - test/features/language-yaml.feature
128
119
  - test/features/pluggable-formatters.feature
129
120
  - test/features/pluggable-languages.feature
@@ -138,7 +129,9 @@ files:
138
129
  - test/fixtures/files/clean/README.md
139
130
  - test/fixtures/files/clean/ansiblish.yaml
140
131
  - test/fixtures/files/clean/kitchenish.yml
132
+ - test/fixtures/files/clean/monty.py
141
133
  - test/fixtures/files/clean/rubocopish.yaml
134
+ - test/fixtures/files/error/bad-indentation.py
142
135
  - test/fixtures/files/error/bad-indentation.yaml
143
136
  - test/fixtures/files/error/missing-array-element.yaml
144
137
  - test/fixtures/files/error/unquoted-jinja-template.yaml
@@ -157,33 +150,33 @@ files:
157
150
  homepage: https://github.com/clintoncwolfe/ci-syntax-tool
158
151
  licenses:
159
152
  - BSD (3-clause)
153
+ metadata: {}
160
154
  post_install_message:
161
155
  rdoc_options: []
162
156
  require_paths:
163
157
  - lib
164
158
  required_ruby_version: !ruby/object:Gem::Requirement
165
- none: false
166
159
  requirements:
167
- - - ! '>='
160
+ - - ">="
168
161
  - !ruby/object:Gem::Version
169
162
  version: '0'
170
163
  required_rubygems_version: !ruby/object:Gem::Requirement
171
- none: false
172
164
  requirements:
173
- - - ! '>='
165
+ - - ">="
174
166
  - !ruby/object:Gem::Version
175
167
  version: '0'
176
168
  requirements: []
177
169
  rubyforge_project:
178
- rubygems_version: 1.8.23
170
+ rubygems_version: 2.4.4
179
171
  signing_key:
180
- specification_version: 3
172
+ specification_version: 4
181
173
  summary: A Rubygem implementing a suite of source code syntax checkers, with well-behaved
182
174
  output fo use with CI engines.
183
175
  test_files:
184
176
  - test/features/.keep
185
177
  - test/features/command-line-help.feature
186
178
  - test/features/format-junit.feature
179
+ - test/features/language-python.feature
187
180
  - test/features/language-yaml.feature
188
181
  - test/features/pluggable-formatters.feature
189
182
  - test/features/pluggable-languages.feature
@@ -198,7 +191,9 @@ test_files:
198
191
  - test/fixtures/files/clean/README.md
199
192
  - test/fixtures/files/clean/ansiblish.yaml
200
193
  - test/fixtures/files/clean/kitchenish.yml
194
+ - test/fixtures/files/clean/monty.py
201
195
  - test/fixtures/files/clean/rubocopish.yaml
196
+ - test/fixtures/files/error/bad-indentation.py
202
197
  - test/fixtures/files/error/bad-indentation.yaml
203
198
  - test/fixtures/files/error/missing-array-element.yaml
204
199
  - test/fixtures/files/error/unquoted-jinja-template.yaml
@@ -214,3 +209,4 @@ test_files:
214
209
  - test/unit/language_factory_spec.rb
215
210
  - test/unit/result_spec.rb
216
211
  - test/unit/spec_helper.rb
212
+ has_rdoc: