git.rb 0.10.4 → 0.11.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
  SHA256:
3
- metadata.gz: 8811ab31189842e2c75abf4af873bf6083ebb1fa38cd0bff1504384551f06712
4
- data.tar.gz: a2d6d29989ed7ee61ef72378ea647087d9973a42d7415c1ee827baade92ed806
3
+ metadata.gz: 877ad4b138a4459b013c00d5fffd8bbd42ef5dbd3062141fdca0e4392ecc18b5
4
+ data.tar.gz: a81786d724174284167edb05749c6dece6e76624b4fefe2dfb1d2f90b3d172c5
5
5
  SHA512:
6
- metadata.gz: 6a4b85a1ca3cb6e7f4c4cec89117b52590a72c5acbf4427cafb391deb87feee626e8f874f98d5efd0f068547d56cb75a753eb58a8a8c90174bae3a829c9ff82f
7
- data.tar.gz: ed51826c59eb3669cd39703242949f9fe164b5a73137f6e128d5fc620567c24bac24bd8909f607cc98a138dbf139e74627443414395126584fd6671ea75e7117
6
+ metadata.gz: a76547e738e94c23a6f316c650dc7b23851fba39fe9a4d9dd66ce236bde3bb7832b1fa53dac8cba9175b6bfdc8e6c5e8ce431723ae56f943b5fd33752855ff87
7
+ data.tar.gz: 11bad50830bc2e8126db9ba55792df46ac5df5cbe7d5047899770c071344a913b52edabaacbda4f80eea5ed8287891700b0adb3169793751d2d0e4e127b7a929
@@ -18,6 +18,7 @@
18
18
  # => "thoran"
19
19
 
20
20
  require 'Ordinal/Array'
21
+ require 'String/capture'
21
22
 
22
23
  module Git
23
24
  class Log
@@ -26,23 +27,45 @@ module Git
26
27
 
27
28
  class << self
28
29
  def parse(commit_string)
29
- parsed_commit_string = commit_string.split("\n").collect{|line| line.strip}.select{|line| !line.empty?}
30
- Commit.new(
31
- hash: parsed_commit_string.first.gsub(/^commit /, ''),
32
- author: parsed_commit_string.second.gsub(/^Author: /, ''),
33
- date: parsed_commit_string.third.gsub(/^Date: /, ''),
34
- message: parsed_commit_string.fourth
35
- )
30
+ hash = merge = author = date = message = ''
31
+ commit_string.split("\n").each do |line|
32
+ case line.strip
33
+ when /^commit (\w+)/
34
+ hash = line.strip.capture(/^commit (\w+)/)
35
+ when /^Merge: /
36
+ merge = line.strip.gsub(/^Merge: /, '')
37
+ when /^Author: /
38
+ author = line.strip.gsub(/^Author: /, '')
39
+ when /^Date: /
40
+ date = line.strip.gsub(/^Date: /, '')
41
+ else
42
+ if line.strip.empty?
43
+ (message ||= '') << "\n\n"
44
+ else
45
+ (message ||= '') << line.lstrip
46
+ end
47
+ end
48
+ end
49
+ commit_args = {
50
+ hash: hash,
51
+ author: author,
52
+ date: date,
53
+ message: message.lstrip
54
+ }
55
+ commit_args.merge!(merge: merge)
56
+ Commit.new(commit_args)
36
57
  end
37
58
  end # class << self
38
59
 
39
60
  attr_reader :hash
61
+ attr_reader :merge
40
62
  attr_reader :author
41
63
  attr_reader :date
42
64
  attr_reader :message
43
65
 
44
66
  def initialize(values = {})
45
67
  @hash = values[:hash]
68
+ @merge = values[:merge]
46
69
  @author = values[:author]
47
70
  @date = values[:date]
48
71
  @message = values[:message]
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
 
3
- VERSION = '0.10.4'
3
+ VERSION = '0.11.0'
4
4
 
5
5
  end
@@ -0,0 +1,28 @@
1
+ # Thoran/String/Capture/capture.rb
2
+ # Thoran::String::Capture#capture
3
+
4
+ # 20161109
5
+ # 0.3.1
6
+
7
+ # Changes since 0.2:
8
+ # 1. + Thoran namespace.
9
+ # 0/1
10
+ # 2. Updated the MiniTest superclass only---no implementation changes.
11
+
12
+ module Thoran
13
+ module String
14
+ module Capture
15
+
16
+ def capture(regex)
17
+ if md = self.match(regex)
18
+ md[1]
19
+ else
20
+ nil
21
+ end
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+
28
+ String.send(:include, Thoran::String::Capture)
@@ -0,0 +1,7 @@
1
+ # String/capture.rb
2
+ # String#capture
3
+
4
+ # 20201008
5
+ # 0.3.1 (The same version number as the current version of Thoran/String/Capture.)
6
+
7
+ require 'Thoran/String/Capture/capture'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.4
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-19 00:00:00.000000000 Z
11
+ date: 2020-10-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Do stuff with git-blame, git-branch, git-log, and git-remote from Ruby.
14
14
  email: code@thoran.com
@@ -26,15 +26,17 @@ files:
26
26
  - lib/Git/VERSION.rb
27
27
  - lib/Ordinal.rb
28
28
  - lib/Ordinal/Array.rb
29
+ - lib/String/capture.rb
29
30
  - lib/Thoran/Array/AllButFirst/all_but_first.rb
30
31
  - lib/Thoran/Array/AllButLast/all_but_last.rb
31
32
  - lib/Thoran/Array/FirstX/firstX.rb
32
33
  - lib/Thoran/Array/LastX/lastX.rb
34
+ - lib/Thoran/String/Capture/capture.rb
33
35
  homepage: http://github.com/thoran/git.rb
34
36
  licenses:
35
37
  - MIT
36
38
  metadata: {}
37
- post_install_message:
39
+ post_install_message:
38
40
  rdoc_options: []
39
41
  require_paths:
40
42
  - lib
@@ -49,8 +51,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
51
  - !ruby/object:Gem::Version
50
52
  version: '0'
51
53
  requirements: []
52
- rubygems_version: 3.0.3
53
- signing_key:
54
+ rubygems_version: 3.2.0.rc.1
55
+ signing_key:
54
56
  specification_version: 4
55
57
  summary: Do git stuff from Ruby.
56
58
  test_files: []