commitshots 0.0.8 → 0.0.9

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.
@@ -1,45 +1,22 @@
1
- require 'optparse'
1
+ require 'commitshots/options'
2
+ require 'commitshots/backends/git'
3
+ require 'commitshots/backends/hg'
2
4
  require 'commitshots/commits'
3
5
 
4
- options = {}
5
-
6
- optparse = OptionParser.new do|opts|
7
- # Set a banner, displayed at the top
8
- # of the help screen.
9
- opts.banner = "Usage: commitshots [OPTIONS] url"
10
-
11
-
12
- options[:width] = 800
13
- opts.on( '--width WIDTH', 'Width of the browser window' ) do |width|
14
- options[:width] = width
15
- end
16
-
17
- options[:height] = 600
18
- opts.on( '--height HEIGHT', 'Height of the browser window' ) do |height|
19
- options[:height] = height
20
- end
21
-
22
- # This displays the help screen, all programs are
23
- # assumed to have this option.
24
- opts.on( '-h', '--help', 'Display this screen' ) do
25
- puts opts
26
- exit
27
- end
28
- end
29
-
30
- optparse.parse!
31
-
6
+ options = Commitshots::Options.get_commandline_options
32
7
  phantomScript = File.join(File.dirname(__FILE__), 'phantomjs/screenshot.js')
33
8
  url = ARGV[0]
34
9
  width = options[:width]
35
10
  height = options[:height]
11
+ backend = Commitshots::Backends.const_get(options[:backend].capitalize).new
12
+
36
13
 
37
14
  num = 0
38
15
  baseFileName = 'screenshots/image-'
39
16
  fileType = 'png'
40
17
  waitTime = 0.5
41
18
 
42
- Commitshots::Commits.new.each do |id, msg|
19
+ Commitshots::Commits.new(backend).each do |id, msg|
43
20
  sleep(waitTime)
44
21
  fileName = "#{baseFileName}#{"%08d" % num}.#{fileType}"
45
22
  `phantomjs #{phantomScript} "#{url}" "#{fileName}" #{width} #{height}`
@@ -0,0 +1,14 @@
1
+ module Commitshots
2
+ module Backends
3
+ class Git
4
+ def get_revisions
5
+ `git rev-list --reverse --all --pretty=oneline`.split("\n")
6
+ end
7
+
8
+ def checkout_revision(id)
9
+ `git checkout #{id}`
10
+ end
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,14 @@
1
+ module Commitshots
2
+ module Backends
3
+ class Hg
4
+ def get_revisions
5
+
6
+ end
7
+
8
+ def checkout_revision(id)
9
+
10
+ end
11
+ end
12
+ end
13
+ end
14
+
@@ -1,11 +1,15 @@
1
1
  module Commitshots
2
2
  class Commits
3
+ def initialize(backend)
4
+ @backend = backend
5
+ end
6
+
3
7
  def each
4
- `git rev-list --reverse --all --pretty=oneline`.split("\n").each do |line|
8
+ @backend.get_revisions.each do |line|
5
9
  parts = line.split(' ')
6
10
  id = parts[0]
7
11
  msg = line.gsub(id, '')
8
- `git checkout #{id}`
12
+ @backend.checkout_revision(id)
9
13
  yield id, msg
10
14
  end
11
15
  end
@@ -0,0 +1,41 @@
1
+ require 'optparse'
2
+
3
+ module Commitshots
4
+ class Options
5
+ def self.get_commandline_options
6
+ options = {}
7
+
8
+ optparse = OptionParser.new do|opts|
9
+ # Set a banner, displayed at the top
10
+ # of the help screen.
11
+ opts.banner = "Usage: commitshots [OPTIONS] url"
12
+
13
+
14
+ options[:width] = 800
15
+ opts.on( '--width WIDTH', "Width of the browser window, defaults to #{options[:width]}" ) do |width|
16
+ options[:width] = width
17
+ end
18
+
19
+ options[:height] = 600
20
+ opts.on( '--height HEIGHT', "Height of the browser window, defaults to #{options[:height]}" ) do |height|
21
+ options[:height] = height
22
+ end
23
+
24
+ options[:backend] = 'git'
25
+ opts.on( '--backend [git|hg]', "Backend to use, defaults to #{options[:backend]}") do |backend|
26
+ options[:backend] = backend
27
+ end
28
+
29
+ # This displays the help screen, all programs are
30
+ # assumed to have this option.
31
+ opts.on( '-h', '--help', 'Display this screen' ) do
32
+ puts opts
33
+ exit
34
+ end
35
+ end
36
+
37
+ optparse.parse!
38
+ options
39
+ end
40
+ end
41
+ end
@@ -1,4 +1,4 @@
1
1
  module Commitshots
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commitshots
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -26,7 +26,10 @@ files:
26
26
  - bin/commitshots
27
27
  - commitshots.gemspec
28
28
  - lib/commitshots.rb
29
+ - lib/commitshots/backends/git.rb
30
+ - lib/commitshots/backends/hg.rb
29
31
  - lib/commitshots/commits.rb
32
+ - lib/commitshots/options.rb
30
33
  - lib/commitshots/version.rb
31
34
  - lib/phantomjs/screenshot.js
32
35
  homepage: http://rubygems.org/gems/commitshots