pronto 0.0.1 → 0.0.2

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: dbcc408192f44fa98564a2351e36c04e98d4b1c3
4
- data.tar.gz: 4e3a335091ad6ec180f3df9963c8c8674fe5005d
3
+ metadata.gz: 32afa53492ee02c977a4c7def6376ff63f1789af
4
+ data.tar.gz: c62b2494b9f26207d368e4788b432e971c0f81c5
5
5
  SHA512:
6
- metadata.gz: 446f7b42f168e571ef9abb8fb5a89c2e509cae8c74cec5e4e67ab3ba9269190e8e1628b02e38d2d951cc41fdf220ef1d1349ebbdf879355f0d6dbe0d4df40ef4
7
- data.tar.gz: b0ca226f41782526e6133f3703377d4aae720efe6dbe6f346e1d22c026c16d9370b8bf46a7d1ec516f5d7ca1654432ae2cb0a7dbc63aaf9a56322080a7f244cb
6
+ metadata.gz: 4ccaf764dfd8eb44ac04dfd5e48d65c119ef98c0a1388cb2936450bc9d7f644a8c32714b8ee9b8a43d94868ce342aa9553dc834b5952f860737dbf25250ad30b
7
+ data.tar.gz: 94ee6628d7ac7443f4992afc3ae0a0694dfa00d16580edd5d86c3a00996dbe1c890de2386e092ed7c7826c50cfe6e62923efeeaec491d7cb121aabe859f82b64
@@ -1,4 +1,7 @@
1
1
  require 'rugged'
2
+ require_relative 'rugged/diff'
3
+ require_relative 'rugged/tree'
4
+ require_relative 'rugged/diff/delta'
2
5
 
3
6
  require 'pronto/plugin'
4
7
  require 'pronto/message'
@@ -8,8 +11,8 @@ require 'pronto/formatter/text_formatter'
8
11
 
9
12
  module Pronto
10
13
  def self.run(commit1 = nil, commit2 = 'master', repo_path = '.')
11
- diffs = diff(repo_path, commit1, commit2)
12
- result = run_all_runners(diffs)
14
+ patches = diff(repo_path, commit1, commit2)
15
+ result = run_all_runners(patches)
13
16
  Formatter::TextFormatter.new.format(result)
14
17
  end
15
18
 
@@ -37,9 +40,9 @@ module Pronto
37
40
  repo.diff(commit1, commit2)
38
41
  end
39
42
 
40
- def self.run_all_runners(diffs)
43
+ def self.run_all_runners(patches)
41
44
  Runner.runners.map do |runner|
42
- runner.new.run(diffs)
45
+ runner.new.run(patches)
43
46
  end.flatten.compact
44
47
  end
45
48
  end
@@ -1,3 +1,5 @@
1
+ require 'tempfile'
2
+
1
3
  module Pronto
2
4
  class Runner
3
5
  include Plugin
@@ -6,10 +8,49 @@ module Pronto
6
8
  repository
7
9
  end
8
10
 
11
+ def create_tempfiles(blobs)
12
+ return [] if blobs.nil?
13
+
14
+ files = blobs.map { |blob| write(blob) }.compact
15
+ return [] if files.empty?
16
+
17
+ begin
18
+ if block_given?
19
+ files.each(&:flush)
20
+ yield(files)
21
+ else
22
+ files
23
+ end
24
+ ensure
25
+ files.each do |file|
26
+ file.close unless file.closed?
27
+ end
28
+ end
29
+ end
30
+
9
31
  def create_tempfile(blob)
32
+ file = write(blob)
33
+ return if file.nil?
34
+
35
+ begin
36
+ if block_given?
37
+ file.flush
38
+ yield(file)
39
+ else
40
+ file
41
+ end
42
+ ensure
43
+ file.close if file && !file.closed?
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def write(blob)
50
+ return if blob.nil?
51
+
10
52
  file = Tempfile.new(blob.oid)
11
53
  file.write(blob.text)
12
- file.close
13
54
  file
14
55
  end
15
56
  end
@@ -1,3 +1,3 @@
1
1
  module Pronto
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -0,0 +1,6 @@
1
+ module Rugged
2
+ class Diff
3
+ attr_reader :owner
4
+ alias tree owner
5
+ end
6
+ end
@@ -0,0 +1,26 @@
1
+ module Rugged
2
+ class Diff
3
+ class Delta
4
+ def new_blob
5
+ blob(new_file)
6
+ end
7
+
8
+ def old_blob
9
+ blob(old_file)
10
+ end
11
+
12
+ def repo
13
+ diff.tree.repo
14
+ end
15
+
16
+ private
17
+
18
+ def blob(file)
19
+ return if file.nil?
20
+ return if file[:oid] == '0000000000000000000000000000000000000000'
21
+
22
+ repo.lookup(file[:oid])
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,6 @@
1
+ module Rugged
2
+ class Tree
3
+ attr_reader :owner
4
+ alias repo owner
5
+ end
6
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mindaugas Mozūras
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-15 00:00:00.000000000 Z
11
+ date: 2013-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged
@@ -80,6 +80,9 @@ files:
80
80
  - lib/pronto/runner.rb
81
81
  - lib/pronto/version.rb
82
82
  - lib/pronto.rb
83
+ - lib/rugged/diff/delta.rb
84
+ - lib/rugged/diff.rb
85
+ - lib/rugged/tree.rb
83
86
  - LICENSE
84
87
  - README.md
85
88
  - bin/pronto
@@ -103,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
106
  version: 1.3.6
104
107
  requirements: []
105
108
  rubyforge_project:
106
- rubygems_version: 2.0.3
109
+ rubygems_version: 2.0.7
107
110
  signing_key:
108
111
  specification_version: 4
109
112
  summary: pronto