snapgit 0.6.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.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.editorconfig +17 -0
  4. data/.gitattributes +1 -0
  5. data/.gitignore +14 -0
  6. data/.rubocop.yml +10 -0
  7. data/.rubocop_todo.yml +57 -0
  8. data/.travis.yml +42 -0
  9. data/Gemfile +4 -0
  10. data/LICENSE +165 -0
  11. data/README.md +28 -0
  12. data/Rakefile +79 -0
  13. data/bin/lolcommits +335 -0
  14. data/bin/snapgit +14 -0
  15. data/config/cucumber.yml +2 -0
  16. data/features/bugs.feature +63 -0
  17. data/features/lolcommits.feature +286 -0
  18. data/features/plugins.feature +20 -0
  19. data/features/step_definitions/lolcommits_steps.rb +142 -0
  20. data/features/support/env.rb +61 -0
  21. data/features/support/path_helpers.rb +39 -0
  22. data/lib/core_ext/class.rb +8 -0
  23. data/lib/core_ext/mini_magick/utilities.rb +15 -0
  24. data/lib/lolcommits.rb +34 -0
  25. data/lib/lolcommits/capturer.rb +24 -0
  26. data/lib/lolcommits/capturer/capture_cygwin.rb +22 -0
  27. data/lib/lolcommits/capturer/capture_fake.rb +9 -0
  28. data/lib/lolcommits/capturer/capture_linux.rb +45 -0
  29. data/lib/lolcommits/capturer/capture_linux_animated.rb +72 -0
  30. data/lib/lolcommits/capturer/capture_mac.rb +23 -0
  31. data/lib/lolcommits/capturer/capture_mac_animated.rb +73 -0
  32. data/lib/lolcommits/capturer/capture_windows.rb +22 -0
  33. data/lib/lolcommits/cli/fatals.rb +77 -0
  34. data/lib/lolcommits/cli/launcher.rb +29 -0
  35. data/lib/lolcommits/cli/process_runner.rb +48 -0
  36. data/lib/lolcommits/cli/timelapse_gif.rb +45 -0
  37. data/lib/lolcommits/configuration.rb +138 -0
  38. data/lib/lolcommits/git_info.rb +82 -0
  39. data/lib/lolcommits/init.rb +121 -0
  40. data/lib/lolcommits/installation.rb +128 -0
  41. data/lib/lolcommits/platform.rb +127 -0
  42. data/lib/lolcommits/plugin.rb +130 -0
  43. data/lib/lolcommits/plugins/dot_com.rb +50 -0
  44. data/lib/lolcommits/plugins/lol_protonet.rb +68 -0
  45. data/lib/lolcommits/plugins/lol_slack.rb +68 -0
  46. data/lib/lolcommits/plugins/lol_tumblr.rb +127 -0
  47. data/lib/lolcommits/plugins/lol_twitter.rb +155 -0
  48. data/lib/lolcommits/plugins/lol_yammer.rb +85 -0
  49. data/lib/lolcommits/plugins/lolsrv.rb +59 -0
  50. data/lib/lolcommits/plugins/loltext.rb +147 -0
  51. data/lib/lolcommits/plugins/snapgit.rb +167 -0
  52. data/lib/lolcommits/plugins/tranzlate.rb +115 -0
  53. data/lib/lolcommits/plugins/uploldz.rb +65 -0
  54. data/lib/lolcommits/runner.rb +134 -0
  55. data/lib/lolcommits/version.rb +5 -0
  56. data/snapgit.gemspec +63 -0
  57. data/test/images/test_image.jpg +0 -0
  58. data/test/lolcommits_test.rb +35 -0
  59. data/test/plugins_test.rb +52 -0
  60. data/vendor/ext/CommandCam/COPYING +674 -0
  61. data/vendor/ext/CommandCam/CommandCam.exe +0 -0
  62. data/vendor/ext/CommandCam/LICENSE +16 -0
  63. data/vendor/ext/imagesnap/ReadMeOrDont.rtf +117 -0
  64. data/vendor/ext/imagesnap/imagesnap +0 -0
  65. data/vendor/ext/videosnap/videosnap +0 -0
  66. data/vendor/fonts/Lato.ttf +0 -0
  67. data/vendor/logos/Snapgit.png +0 -0
  68. metadata +509 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fc5c86c517905a33ac08b6d60f73d2c7b6cae62d
4
+ data.tar.gz: d9d8caefcf751dcbee5e94b8fce19dbe8480b03b
5
+ SHA512:
6
+ metadata.gz: 1bffccc058ae15f503b3705160fa8a4dc20d44bfc98a59dc11ca86839d7c871c9a2935bb2431bdb53fce2c65098cd22c7bf341fef28d2f84ad730d9c410bae2d
7
+ data.tar.gz: 0057b7df0bb13967a8c50c076e87f2dcda62423e87b0fc04c70ea3a68399f71312b4f4efcb274bcb68ce80cfd92e08225cb8ca4d6e1e9ac9b96dbb82783db715
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.editorconfig ADDED
@@ -0,0 +1,17 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+
5
+ root = true
6
+
7
+ [*]
8
+ indent_style = space
9
+ indent_size = 2
10
+
11
+ end_of_line = lf
12
+ charset = utf-8
13
+ trim_trailing_whitespace = true
14
+ insert_final_newline = true
15
+
16
+ [*.md]
17
+ trim_trailing_whitespace = false
data/.gitattributes ADDED
@@ -0,0 +1 @@
1
+ * text=auto
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ coverage
2
+ *.gem
3
+ .bundle
4
+ Gemfile.lock
5
+ pkg/*
6
+ .rvmrc
7
+ .ruby-version
8
+ .ruby-gemset
9
+ results.html
10
+ html
11
+ tmp
12
+ *.swp
13
+ *.swo
14
+ vendor/bundle
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ AllCops:
2
+ Exclude:
3
+ - vendor/bundle/**/*
4
+ - .bundle/**/*
5
+
6
+ inherit_from: .rubocop_todo.yml
7
+
8
+ # Enforce Ruby 1.8.7 compatible syntax
9
+ HashSyntax:
10
+ EnforcedStyle: hash_rockets
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,57 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2015-04-12 19:24:55 +0200 using RuboCop version 0.30.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 23
9
+ Metrics/AbcSize:
10
+ Max: 38
11
+
12
+ # Offense count: 2
13
+ # Configuration parameters: CountComments.
14
+ Metrics/ClassLength:
15
+ Max: 127
16
+
17
+ # Offense count: 5
18
+ Metrics/CyclomaticComplexity:
19
+ Max: 9
20
+
21
+ # Offense count: 92
22
+ # Configuration parameters: AllowURI, URISchemes.
23
+ Metrics/LineLength:
24
+ Max: 170
25
+
26
+ # Offense count: 24
27
+ # Configuration parameters: CountComments.
28
+ Metrics/MethodLength:
29
+ Max: 31
30
+
31
+ # Offense count: 4
32
+ Metrics/PerceivedComplexity:
33
+ Max: 11
34
+
35
+ # Offense count: 1
36
+ # Cop supports --auto-correct.
37
+ Performance/Sample:
38
+ Enabled: false
39
+
40
+ # Offense count: 12
41
+ # Cop supports --auto-correct.
42
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
43
+ Style/BarePercentLiterals:
44
+ Enabled: false
45
+
46
+ # Offense count: 1
47
+ Style/CaseEquality:
48
+ Enabled: false
49
+
50
+ # Offense count: 1
51
+ # Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep.
52
+ Style/CaseIndentation:
53
+ Enabled: false
54
+
55
+ # Offense count: 28
56
+ Style/Documentation:
57
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,42 @@
1
+ sudo: false
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 1.8.7
6
+ - 1.9.2
7
+ - 1.9.3
8
+ - 2.0.0
9
+ - 2.1.7
10
+ - 2.2.4
11
+ - 2.3.0
12
+ - ruby-head
13
+
14
+ before_install:
15
+ # stub mplayer/ffmpeg so it looks like they are installed
16
+ - mkdir ~/bin
17
+ - touch ~/bin/mplayer ~/bin/ffmpeg
18
+ - chmod +x ~/bin/mplayer ~/bin/ffmpeg
19
+ - export PATH=~/bin:$PATH
20
+ - git --version
21
+
22
+ matrix:
23
+ allow_failures:
24
+ - rvm: ruby-head
25
+
26
+ branches:
27
+ except:
28
+ - gh-pages
29
+
30
+ notifications:
31
+ slack:
32
+ secure: BkGsQOYMJqW55j94S1QwmR17BkwuTIULKVhwzRdnv37BvVcC17y9KLMo8NH+bcao36XZx9DukXcTyaDQc6tCSlFEbG/FcPUJM8bx9EWjHUoGVg1KdpVu/nVHu+GKosrB41lM3nfJWCnF0TOSnmTXU+bV8Pwkij+L5X+gNyAT2Ns=
33
+
34
+ deploy:
35
+ provider: rubygems
36
+ api_key:
37
+ secure: Y7FFOMDahITtHYRV3UQAw+BA2JbqoArN/Ii9PUTU6RaLmTIvpZBzqtvR3r8ah3SdXNh0Cx10gVf0pRc6HXKTNQdwMWCkOQwukAb+9kLDKFxl3x+w4X2u6yWmtsyNMTWK1gF4hEF1IHnsdg2dYEoFfE2M5bHex85ND/Q6820sPa8=
38
+ gem: lolcommits
39
+ on:
40
+ tags: true
41
+ all_branches: true
42
+ repo: mroth/lolcommits
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify gem dependencies in lolcommits.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # snapgit
2
+
3
+ [![Twitter: @KrauseFx](https://img.shields.io/badge/Twitter-@KrauseFx-blue.svg?style=flat)](https://twitter.com/KrauseFx)
4
+ [![Twitter: @icofyre](https://img.shields.io/badge/Twitter-@icofyre-blue.svg?style=flat)](https://twitter.com/icofyre)
5
+ [![Twitter: @fsha](https://img.shields.io/badge/Twitter-@fsha-blue.svg?style=flat)](https://twitter.com/fsha)
6
+ [![Gem Version](https://badge.fury.io/rb/snapgit.svg)](https://rubygems.org/gems/snapgit)
7
+
8
+ ## Requirements
9
+
10
+ - A mac
11
+
12
+ ## Installation
13
+
14
+ ```
15
+ sudo gem install snapgit
16
+ ```
17
+
18
+ If the installation fails, uninstall [lolcommits](https://github.com/mroth/lolcommits) using `sudo gem uninstall lolcommits`.
19
+
20
+ ```
21
+ snapgit init
22
+ ```
23
+
24
+ This will help you get up and running in no time. It is recommended to just enable lolcommits for all repos
25
+
26
+ # License
27
+
28
+ `snapgit` was forked from [mroth/lolcommits](https://github.com/mroth/lolcommits). `snapgit` is under the same license as `lolcommits`: [GNU lesser general public license](https://github.com/snapgit/snapgit/blob/master/LICENSE).
data/Rakefile ADDED
@@ -0,0 +1,79 @@
1
+ require 'bundler'
2
+ require 'rake/clean'
3
+
4
+ require 'rake/testtask'
5
+
6
+ require 'cucumber'
7
+ require 'cucumber/rake/task'
8
+ gem 'rdoc' # we need the installed RDoc gem, not the system one
9
+ require 'rdoc/task'
10
+
11
+ include Rake::DSL
12
+
13
+ Bundler::GemHelper.install_tasks
14
+
15
+ task :fix_permissions do
16
+ # Reset all permissions.
17
+ system 'bash -c "find . -type f -exec chmod 644 {} \; && find . -type d -exec chmod 755 {} \;"'
18
+ # Executable files.
19
+ executables = %w(
20
+ vendor/ext/imagesnap/imagesnap
21
+ vendor/ext/videosnap/videosnap
22
+ vendor/ext/CommandCam/CommandCam.exe
23
+ )
24
+
25
+ system "bash -c \"chmod +x ./bin/* #{executables.join(' ')}\""
26
+ end
27
+
28
+ Rake::Task[:build].prerequisites.unshift :fix_permissions
29
+
30
+ Rake::TestTask.new do |t|
31
+ t.pattern = 'test/*_test.rb'
32
+ end
33
+
34
+ Rake::FileUtilsExt.verbose(false)
35
+ CUKE_RESULTS = 'results.html'.freeze
36
+ CLEAN << CUKE_RESULTS
37
+ Cucumber::Rake::Task.new(:features) do |t|
38
+ optstr = "features --format html -o #{CUKE_RESULTS} --format Fivemat -x"
39
+ optstr << " --tags @#{ENV['tag']}" unless ENV['tag'].nil?
40
+ optstr << ' --tags ~@unstable' if ENV['tag'].nil? # ignore unstable tests unless specifying something at CLI
41
+ t.cucumber_opts = optstr
42
+ t.fork = false
43
+ end
44
+
45
+ Rake::RDocTask.new do |rd|
46
+ rd.main = 'README.rdoc'
47
+ rd.rdoc_files.include('README.rdoc', 'lib/**/*.rb', 'bin/**/*')
48
+ end
49
+
50
+ # only run rubocop on platforms where it is supported, sigh
51
+ if RUBY_VERSION >= '1.9.3'
52
+ require 'rubocop/rake_task'
53
+ RuboCop::RakeTask.new
54
+ task :default => [:rubocop, :test, :features]
55
+ else
56
+ task :default => [:test, :features]
57
+ end
58
+
59
+ desc 'Migrate an existing local .lolcommits directory to Dropbox'
60
+ task :dropboxify do
61
+ dropbox_loldir = "#{ENV['HOME']}/Dropbox/lolcommits"
62
+ loldir = "#{ENV['HOME']}/.lolcommits"
63
+ backup_loldir = "#{ENV['HOME']}/.lolcommits.old"
64
+
65
+ # check whether we've done this already
66
+ abort 'already dropboxified!' if File.symlink? loldir
67
+
68
+ # create dropbox folder
69
+ FileUtils.mkdir_p dropbox_loldir unless File.directory? dropbox_loldir
70
+
71
+ # backup existing loldir
72
+ FileUtils.mv(loldir, backup_loldir) if File.directory? loldir
73
+
74
+ # symlink dropbox to local
75
+ FileUtils.ln_s(dropbox_loldir, loldir)
76
+
77
+ # copy over existing files
78
+ FileUtils.cp_r("#{backup_loldir}/.", loldir)
79
+ end
data/bin/lolcommits ADDED
@@ -0,0 +1,335 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+
4
+ begin
5
+ require 'lolcommits'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'lolcommits'
9
+ end
10
+
11
+ require 'lolcommits/cli/fatals'
12
+ require 'lolcommits/cli/launcher'
13
+ require 'lolcommits/cli/process_runner'
14
+ require 'lolcommits/cli/timelapse_gif'
15
+
16
+ include Lolcommits
17
+ include Lolcommits::CLI
18
+
19
+ require 'choice'
20
+ require 'methadone'
21
+ include Methadone::CLILogging
22
+
23
+ #
24
+ # NO ARGUMENTS SPECIFIED, HELP THE USER OUT
25
+ #
26
+ def do_noargs
27
+ # TODO: make this a contextual helper to know whether lolcommits is enabled
28
+ puts 'Do what exactly?'
29
+ puts 'Try: lolcommits --enable (when in a git repository)'
30
+ puts 'Or: lolcommits --help'
31
+ end
32
+
33
+ # Gets a configuration object. If running in test mode will override the
34
+ # LOLDIR for the configuration.
35
+ #
36
+ # @return [Lolcommits::Configuration]
37
+ def configuration
38
+ if Choice.choices[:test]
39
+ Configuration.new(:loldir => Configuration.loldir_for('test'))
40
+ else
41
+ Configuration.new
42
+ end
43
+ end
44
+
45
+ # Duration for animated capture.
46
+ #
47
+ # If animation is enabled, returns an integer representing seconds OR a string
48
+ # containing the char representation of an integer.
49
+ # If animation is disabled, or if the platform doesn't support animated capture,
50
+ # returns nil instead.
51
+ #
52
+ # FIXME: we really should standardize this to always return integer, and remove
53
+ # all the to_i calls elsewhere.
54
+ #
55
+ # @return [Integer, String, nil]
56
+ def capture_animate
57
+ return unless Platform.can_animate?
58
+ Choice.choices[:animate] || ENV['LOLCOMMITS_ANIMATE'] || nil
59
+ end
60
+
61
+ def default_device
62
+ result = Choice.choices[:device] || ENV['LOLCOMMITS_DEVICE']
63
+
64
+ result ||= Dir.glob('/dev/video*').first if Platform.platform_linux?
65
+
66
+ result
67
+ end
68
+
69
+ #
70
+ # IF --CAPTURE, DO CAPTURE
71
+ #
72
+ def do_capture
73
+ capture_delay = Choice.choices[:delay] || ENV['LOLCOMMITS_DELAY'] || 0
74
+ capture_stealth = Choice.choices[:stealth] || ENV['LOLCOMMITS_STEALTH'] || nil
75
+ capture_device = default_device
76
+
77
+ capture_options = {
78
+ :capture_delay => capture_delay,
79
+ :capture_stealth => capture_stealth,
80
+ :capture_device => capture_device,
81
+ :capture_animate => capture_animate,
82
+ :config => configuration
83
+ }
84
+
85
+ process_runner = ProcessRunner.new(configuration)
86
+ should_we_fork = Choice.choices[:fork] || ENV['LOLCOMMITS_FORK']
87
+ process_runner.fork_me?(should_we_fork) do
88
+ if Choice.choices[:test]
89
+ info '*** Capturing in test mode.'
90
+
91
+ # get optional fake commit msg and sha from command line
92
+ override_text = {
93
+ :message => Choice.choices[:msg],
94
+ :sha => Choice.choices[:sha]
95
+ }
96
+
97
+ # fire off runner with the overriden fake commit metadata
98
+ runner = Lolcommits::Runner.new(capture_options.merge(override_text))
99
+ runner.run
100
+
101
+ # automatically open so user can see the test image results immediately
102
+ Launcher.open_image(runner.main_image)
103
+ else
104
+ runner = Lolcommits::Runner.new(capture_options)
105
+ runner.run
106
+ end
107
+ end
108
+ end
109
+
110
+ def do_configure
111
+ $stdout.sync = true
112
+ configuration.do_configure! Choice.choices[:plugin]
113
+ end
114
+
115
+ def do_last
116
+ Fatals.die_if_not_git_repo!
117
+ lolimage = configuration.most_recent
118
+ if lolimage.nil?
119
+ warn 'No lolcommits have been captured for this repository yet.'
120
+ exit 1
121
+ end
122
+ Launcher.open_image(lolimage)
123
+ end
124
+
125
+ def print_version_and_exit
126
+ puts Lolcommits::VERSION
127
+ exit 0
128
+ end
129
+
130
+ def change_dir_to_root_or_repo!
131
+ debug 'Walking up dir tree'
132
+ loop do
133
+ cur = File.expand_path('.')
134
+ nxt = File.expand_path('..', cur)
135
+ if File.directory?(File.expand_path('.git')) || nxt == cur
136
+ return # found root or git dir
137
+ end
138
+ Dir.chdir(nxt)
139
+ end
140
+ end
141
+
142
+ # FIXME: this should be moved out of the CLI, but to where?
143
+ def load_local_plugins!
144
+ plugins_dir = Configuration.loldir_for('.plugins')
145
+ Dir.glob("#{plugins_dir}/*.rb").each do |plugin|
146
+ load plugin
147
+ end
148
+ end
149
+
150
+ #
151
+ # Command line parsing fun
152
+ #
153
+ Choice.options do
154
+ option :version do
155
+ long '--version'
156
+ short '-v'
157
+ desc 'print version and exit'
158
+ action { print_version_and_exit }
159
+ end
160
+
161
+ option :enable do
162
+ long '--enable'
163
+ short '-e'
164
+ desc 'install lolcommits for this repo'
165
+ action do
166
+ Installation.do_enable
167
+ exit 0
168
+ end
169
+ end
170
+
171
+ option :disable do
172
+ long '--disable'
173
+ short '-d'
174
+ desc 'uninstall lolcommits for this repo'
175
+ action do
176
+ Installation.do_disable
177
+ exit 0
178
+ end
179
+ end
180
+
181
+ option :capture do
182
+ long '--capture'
183
+ short '-c'
184
+ desc 'capture lolcommit based on last git commit'
185
+ end
186
+
187
+ option :last do
188
+ long '--last'
189
+ short '-l'
190
+ desc 'view the most recent lolcommit'
191
+ end
192
+
193
+ option :browse do
194
+ long '--browse'
195
+ short '-b'
196
+ desc "browse this repo's lolcommits"
197
+ end
198
+
199
+ option :configure do
200
+ long '--config'
201
+ desc 'configure a plugin'
202
+ end
203
+
204
+ option :show_config do
205
+ short '-sc'
206
+ long '--show-config'
207
+ desc 'display configuration file'
208
+ end
209
+
210
+ option :plugin do
211
+ desc 'pass plugin name for --config'
212
+ long '--plugin'
213
+ short '-p'
214
+ default nil
215
+ end
216
+
217
+ option :plugins do
218
+ desc 'list all available plugins'
219
+ long '--plugins'
220
+ end
221
+
222
+ option :test do
223
+ long '--test'
224
+ desc 'Run in test mode'
225
+ end
226
+
227
+ option :sha do
228
+ desc 'pass SHA manually [TEST-MODE]'
229
+ long '--sha'
230
+ short '-s'
231
+ default "test-#{rand(10**10)}"
232
+ end
233
+
234
+ option :msg do
235
+ desc 'pass commit msg manually [TEST-MODE]'
236
+ long '--msg'
237
+ short '-m'
238
+ default 'this is a test message i didnt really commit something'
239
+ end
240
+
241
+ option :delay do
242
+ long '--delay=SECONDS'
243
+ desc 'delay taking of the snapshot by n seconds'
244
+ cast Integer
245
+ short '-w'
246
+ end
247
+
248
+ option :stealth do
249
+ long '--stealth'
250
+ desc 'capture image in stealth mode'
251
+ end
252
+
253
+ option :device do
254
+ long '--device=DEVICE'
255
+ desc 'the device name used to take the snapshot (mac/linux only)'
256
+ end
257
+
258
+ option :devices do
259
+ long '--devices'
260
+ desc 'list all video devices available (mac only)'
261
+ end
262
+
263
+ option :debug do
264
+ long '--debug'
265
+ desc 'output debugging information'
266
+ end
267
+
268
+ option :gif do
269
+ long '--gif'
270
+ short '-g'
271
+ desc 'generate animated timeline gif from captured images'
272
+ end
273
+
274
+ if Platform.can_animate?
275
+ option :animate do
276
+ long '--animate=SECONDS'
277
+ short '-a'
278
+ cast Integer
279
+ desc 'enable animated gif captures with duration (seconds)'
280
+ end
281
+ end
282
+
283
+ option :fork do
284
+ long '--fork'
285
+ desc 'fork the lolcommits runner to the background'
286
+ end
287
+ end
288
+
289
+ # Set debug level if needed
290
+ debug_mode = Choice.choices[:debug] || ENV['LOLCOMMITS_DEBUG'] || nil
291
+ if debug_mode
292
+ logger.level = Logger::DEBUG
293
+ debug 'Outputting at DEBUG verbosity'
294
+ end
295
+
296
+ #
297
+ # check for fatal conditions before execution
298
+ #
299
+ Fatals.die_if_no_valid_ffmpeg_installed! if capture_animate
300
+ Fatals.die_on_fatal_platform_conditions!
301
+
302
+ #
303
+ # change working dir to either a repo or the fs root
304
+ #
305
+ change_dir_to_root_or_repo!
306
+
307
+ #
308
+ # load system local plugins
309
+ #
310
+ load_local_plugins!
311
+
312
+ #
313
+ # Handle actions manually since choice seems weird
314
+ #
315
+ if Choice.choices[:capture]
316
+ do_capture
317
+ elsif Choice.choices[:configure]
318
+ do_configure
319
+ elsif Choice.choices[:show_config]
320
+ puts configuration
321
+ elsif Choice.choices[:plugins]
322
+ configuration.puts_plugins
323
+ elsif Choice.choices[:devices]
324
+ puts Platform.device_list
325
+ puts 'Specify a device with --device="{device name}" or set the LOLCOMMITS_DEVICE env variable'
326
+ elsif Choice.choices[:last]
327
+ do_last
328
+ elsif Choice.choices[:browse]
329
+ Fatals.die_if_not_git_repo!
330
+ Launcher.open_folder(configuration.loldir)
331
+ elsif Choice.choices[:gif]
332
+ TimelapseGif.new(configuration).run(Choice.choices[:gif])
333
+ else
334
+ do_noargs
335
+ end