pronto 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dbcc408192f44fa98564a2351e36c04e98d4b1c3
4
+ data.tar.gz: 4e3a335091ad6ec180f3df9963c8c8674fe5005d
5
+ SHA512:
6
+ metadata.gz: 446f7b42f168e571ef9abb8fb5a89c2e509cae8c74cec5e4e67ab3ba9269190e8e1628b02e38d2d951cc41fdf220ef1d1349ebbdf879355f0d6dbe0d4df40ef4
7
+ data.tar.gz: b0ca226f41782526e6133f3703377d4aae720efe6dbe6f346e1d22c026c16d9370b8bf46a7d1ec516f5d7ca1654432ae2cb0a7dbc63aaf9a56322080a7f244cb
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2013 Mindaugas Mozūras
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # pronto
2
+
3
+ [![Build Status](https://secure.travis-ci.org/mmozuras/pronto.png)](http://travis-ci.org/mmozuras/pronto)
4
+
5
+ ## Usage
6
+
7
+ pronto runs static analysis on your branches quickly by analysing only the
8
+ introduced changes.
9
+
10
+ ## Installation
11
+
12
+ Install like any other Ruby gem:
13
+
14
+ gem install pronto
data/bin/pronto ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pronto'
4
+ require 'pronto/cli'
5
+
6
+ Pronto::CLI.start
data/lib/pronto.rb ADDED
@@ -0,0 +1,45 @@
1
+ require 'rugged'
2
+
3
+ require 'pronto/plugin'
4
+ require 'pronto/message'
5
+ require 'pronto/runner'
6
+
7
+ require 'pronto/formatter/text_formatter'
8
+
9
+ module Pronto
10
+ def self.run(commit1 = nil, commit2 = 'master', repo_path = '.')
11
+ diffs = diff(repo_path, commit1, commit2)
12
+ result = run_all_runners(diffs)
13
+ Formatter::TextFormatter.new.format(result)
14
+ end
15
+
16
+ def self.gem_names
17
+ gems = Gem::Specification.find_all.select do |gem|
18
+ if gem.name =~ /^pronto-/
19
+ true
20
+ elsif gem.name != 'pronto'
21
+ runner_path = File.join(gem.full_gem_path, "lib/pronto/#{gem.name}.rb")
22
+ File.exists?(runner_path)
23
+ end
24
+ end
25
+
26
+ gems.map { |gem| gem.name.sub(/^pronto-/, '') }
27
+ .uniq
28
+ .sort
29
+ end
30
+
31
+ private
32
+
33
+ def self.diff(repo_path, commit1, commit2)
34
+ repo = Rugged::Repository.new(repo_path)
35
+ commit1 ||= repo.head.target
36
+ commit2 ||= 'master'
37
+ repo.diff(commit1, commit2)
38
+ end
39
+
40
+ def self.run_all_runners(diffs)
41
+ Runner.runners.map do |runner|
42
+ runner.new.run(diffs)
43
+ end.flatten.compact
44
+ end
45
+ end
data/lib/pronto/cli.rb ADDED
@@ -0,0 +1,54 @@
1
+ require 'thor'
2
+
3
+ module Pronto
4
+ class CLI < Thor
5
+ require 'pronto'
6
+ require 'pronto/version'
7
+
8
+ desc 'exec', 'Run Pronto'
9
+
10
+ method_option :commit1,
11
+ type: :string,
12
+ default: nil,
13
+ aliases: '-f',
14
+ banner: 'First commit for the diff, defaults to current HEAD'
15
+
16
+ method_option :commit2,
17
+ type: :string,
18
+ default: nil,
19
+ aliases: '-s',
20
+ banner: 'Second commit for the diff, defaults to master'
21
+
22
+ method_option :runner,
23
+ type: :array,
24
+ default: [],
25
+ aliases: '-r',
26
+ banner: 'Run only the passed runners'
27
+
28
+ def exec
29
+ gem_names = options[:runner].any? ? options[:runner]
30
+ : ::Pronto.gem_names
31
+ gem_names.each do |gem_name|
32
+ require "pronto/#{gem_name}"
33
+ end
34
+ puts ::Pronto.run(options[:commit1], options[:commit2])
35
+ rescue Rugged::RepositoryError
36
+ puts '"pronto" should be run from a git repository'
37
+ rescue => e
38
+ puts e.message
39
+ end
40
+
41
+ desc 'list', 'Lists pronto runners that are available to be used'
42
+
43
+ def list
44
+ puts ::Pronto.gem_names
45
+ end
46
+
47
+ desc 'version', 'Show the Pronto version'
48
+ map %w(-v --version) => :version
49
+
50
+ def version
51
+ puts "Pronto version #{::Pronto::VERSION}"
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,13 @@
1
+ module Pronto
2
+ module Formatter
3
+ class TextFormatter
4
+ def format(messages)
5
+ messages.map do |message|
6
+ level = message.level[0].upcase
7
+ line = message.line
8
+ "#{message.path}:#{line.new_lineno} #{level}: #{message.msg}"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ module Pronto
2
+ class Message
3
+ attr_reader :path, :line, :level, :msg
4
+
5
+ LEVELS = [:info, :warning, :error, :fatal]
6
+
7
+ def initialize(path, line, level, msg)
8
+ unless LEVELS.include?(level)
9
+ raise ::ArgumentError, "level should be set to one of #{LEVELS}"
10
+ end
11
+
12
+ @path, @line, @level, @msg = path, line, level, msg
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ module Pronto
2
+ module Plugin
3
+ module ClassMethods
4
+ def repository
5
+ @repository ||= []
6
+ end
7
+
8
+ def inherited(klass)
9
+ repository << klass
10
+ end
11
+ end
12
+
13
+ def self.included(klass)
14
+ klass.extend ClassMethods
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ module Pronto
2
+ class Runner
3
+ include Plugin
4
+
5
+ def self.runners
6
+ repository
7
+ end
8
+
9
+ def create_tempfile(blob)
10
+ file = Tempfile.new(blob.oid)
11
+ file.write(blob.text)
12
+ file.close
13
+ file
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module Pronto
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pronto
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mindaugas Mozūras
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rugged
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.19.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.19.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.18.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.18.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: 10.1.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 10.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.13.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.13.0
69
+ description: pronto
70
+ email: mindaugas.mozuras@gmail.com
71
+ executables:
72
+ - pronto
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - lib/pronto/cli.rb
77
+ - lib/pronto/formatter/text_formatter.rb
78
+ - lib/pronto/message.rb
79
+ - lib/pronto/plugin.rb
80
+ - lib/pronto/runner.rb
81
+ - lib/pronto/version.rb
82
+ - lib/pronto.rb
83
+ - LICENSE
84
+ - README.md
85
+ - bin/pronto
86
+ homepage: http://github.org/mmozuras/pronto
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: 1.3.6
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.0.3
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: pronto
110
+ test_files: []