shamazing 0.0.3 → 0.0.4

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.
data/README.md CHANGED
@@ -36,6 +36,11 @@ $ shamazing 9c2cddfaedaea9689a22e376aa20191041554fe8 -i
36
36
  # Search through the shas using `git log --format="%H"` in the current directory.
37
37
  $ shamazing -s
38
38
  cddfaedaea
39
+
40
+ # Return the full SHA with --full
41
+ $ shamazing --full
42
+ Longest string: 17705a5a37fbd11017f0d5e053b474dabbbd4022
43
+ Longest integer: 0c4b61fc2c5e7dd5566d42d0de1c431984899ddf
39
44
  ```
40
45
 
41
46
  ### Ruby Interface
@@ -24,7 +24,8 @@ require 'shamazing'
24
24
 
25
25
  options = {
26
26
  :string => false,
27
- :integer => false
27
+ :integer => false,
28
+ :full => false
28
29
  }
29
30
 
30
31
  parser = OptionParser.new do |opts|
@@ -44,6 +45,10 @@ parser = OptionParser.new do |opts|
44
45
  options[:integer] = true
45
46
  end
46
47
 
48
+ opts.on("-f", "--full", "Display full SHAs instead of snippets") do
49
+ options[:full] = true
50
+ end
51
+
47
52
  opts.on("-h", "--help", "Show this message") do
48
53
  puts opts
49
54
  exit
@@ -58,12 +63,12 @@ if !sha
58
63
  shas = `git log --format="%H"`.split("\n")
59
64
 
60
65
  if options[:string] && !options[:integer]
61
- puts Shamazing.string_from_array(shas)
66
+ puts Shamazing.string_from_array(shas,options[:full])
62
67
  elsif options[:integer]
63
- puts Shamazing.integer_from_array(shas)
68
+ puts Shamazing.integer_from_array(shas,options[:full])
64
69
  else
65
- puts "Longest string: #{Shamazing.string_from_array(shas)}"
66
- puts "Longest integer: #{Shamazing.integer_from_array(shas)}"
70
+ puts "Longest string: #{Shamazing.string_from_array(shas,options[:full])}"
71
+ puts "Longest integer: #{Shamazing.integer_from_array(shas,options[:full])}"
67
72
  end
68
73
  else
69
74
  if options[:string] && !options[:integer]
@@ -1,5 +1,5 @@
1
1
  class Shamazing
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
 
4
4
  # Finds the longest continuous String in a SHA.
5
5
  #
@@ -17,13 +17,15 @@ class Shamazing
17
17
  # Finds the longest continuous String in an Array of SHAs.
18
18
  #
19
19
  # shas - The Array of SHAs to analyze.
20
+ # full - A Boolean: should we return the full SHA instead of the snippet?
20
21
  #
21
22
  # Returns the longest String.
22
- def self.string_from_array(shas)
23
- shas.
23
+ def self.string_from_array(shas,full=false)
24
+ longest = shas.
24
25
  collect{|sha| string(sha)}.
25
26
  sort{|a,b| b.length <=> a.length}.
26
27
  first
28
+ full ? shas.find{|sha| sha.match(/#{longest}/)} : longest
27
29
  end
28
30
 
29
31
  # Finds the longest continuous Integer in a SHA.
@@ -41,12 +43,14 @@ class Shamazing
41
43
  # Finds the longest continuous Integer in an Array of SHAs.
42
44
  #
43
45
  # shas - The Array of SHAs to analyze.
46
+ # full - A Boolean: should we return the full SHA instead of the snippet?
44
47
  #
45
48
  # Returns the longest Integer.
46
- def self.integer_from_array(shas)
47
- shas.
49
+ def self.integer_from_array(shas,full=false)
50
+ longest = shas.
48
51
  collect{|sha| integer(sha).to_s}.
49
52
  sort{|a,b| b.length <=> a.length}.
50
53
  first.to_i
54
+ full ? shas.find{|sha| sha.match(/#{longest}/)} : longest
51
55
  end
52
56
  end
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.5'
5
5
 
6
6
  s.name = 'shamazing'
7
- s.version = '0.0.3'
8
- s.date = '2012-03-27'
7
+ s.version = '0.0.4'
8
+ s.date = '2012-03-28'
9
9
  s.rubyforge_project = 'shamazing'
10
10
 
11
11
  s.summary = "Short description used in Gem listings."
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shamazing
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Zach Holman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-27 00:00:00 -07:00
18
+ date: 2012-03-28 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21