lolcommits 0.5.7 → 0.5.8.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +8 -8
  2. data/.rubocop.yml +1 -0
  3. data/.rubocop_todo.yml +16 -161
  4. data/.travis.yml +11 -4
  5. data/Gemfile +2 -2
  6. data/Rakefile +24 -32
  7. data/bin/lolcommits +62 -125
  8. data/features/bugs.feature +24 -9
  9. data/features/lolcommits.feature +136 -145
  10. data/features/plugins.feature +16 -33
  11. data/features/step_definitions/lolcommits_steps.rb +91 -71
  12. data/features/support/env.rb +18 -48
  13. data/features/support/path_helpers.rb +9 -8
  14. data/lib/lolcommits.rb +3 -10
  15. data/lib/lolcommits/capturer.rb +10 -2
  16. data/lib/lolcommits/capturer/capture_linux.rb +1 -1
  17. data/lib/lolcommits/capturer/capture_linux_animated.rb +12 -13
  18. data/lib/lolcommits/capturer/capture_mac_animated.rb +12 -13
  19. data/lib/lolcommits/cli/fatals.rb +77 -0
  20. data/lib/lolcommits/cli/launcher.rb +29 -0
  21. data/lib/lolcommits/cli/process_runner.rb +48 -0
  22. data/lib/lolcommits/cli/timelapse_gif.rb +45 -0
  23. data/lib/lolcommits/configuration.rb +30 -133
  24. data/lib/lolcommits/git_info.rb +58 -28
  25. data/lib/lolcommits/installation.rb +11 -21
  26. data/lib/lolcommits/platform.rb +134 -0
  27. data/lib/lolcommits/plugin.rb +2 -2
  28. data/lib/lolcommits/plugins/dot_com.rb +15 -15
  29. data/lib/lolcommits/plugins/lol_protonet.rb +68 -0
  30. data/lib/lolcommits/plugins/lol_twitter.rb +12 -15
  31. data/lib/lolcommits/plugins/lol_yammer.rb +4 -6
  32. data/lib/lolcommits/plugins/lolsrv.rb +8 -11
  33. data/lib/lolcommits/plugins/loltext.rb +7 -7
  34. data/lib/lolcommits/plugins/tranzlate.rb +70 -70
  35. data/lib/lolcommits/plugins/uploldz.rb +8 -8
  36. data/lib/lolcommits/runner.rb +36 -35
  37. data/lib/lolcommits/version.rb +1 -1
  38. data/lolcommits.gemspec +11 -10
  39. data/test/lolcommits_test.rb +35 -0
  40. data/test/plugins_test.rb +52 -0
  41. metadata +41 -20
  42. data/test/test_lolcommits.rb +0 -78
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWE3MGEwZGZkZDk1ZGVhMzgyOGUzODdhMjY4OGQ5OWNjYjc4YWYwZQ==
4
+ N2MyN2VjMGMzZDE5NjFlODNjOTQ1OWI4YmE4NjNiMWVlOGU3ZTBjYw==
5
5
  data.tar.gz: !binary |-
6
- ODczNTk4MGFlODMwODg5OTdjMGJkNWJhOTk1N2QwMzMyZjkwZWE1Mw==
6
+ ZjY5ZWYwYjVlZTY0OGU3OWVjMDBmYjNiOTc1Y2U0MjkxN2U0YzExNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjJhYTc0YTVmY2E2ZGU4MmU3ODBkYjQyYTUyYjg2ODM1NjY5YTdiY2E0Mzli
10
- NjRhOTVlODNhMDdjNzI2NjM1MjcxN2VjN2EzYzJjNmYxMTQ4ZTU1NWQyNTk5
11
- ZDljZTc1MTQ0ODY4NzhmMjQyYjYxNTVmYTVhY2M0OTA2OGM0MDU=
9
+ NGZjN2RhNGRhM2RkMDQ4ZWE1YTM0ZDY5ZmRiNzQxYzgzMjk3ZTJlZmJkNTdi
10
+ ZWFlOTM0NmE5OGFhM2QwZTE3Y2E0ZTVlMDU3YjkwMDc3NmVkNmQ4NGI5NThk
11
+ ODg4NjYwNTQyYWI0NmIzYmY4ZGIyOGFiNDJiMWE4YWI5NGM1MDg=
12
12
  data.tar.gz: !binary |-
13
- OGY4Zjg5OGU3Mzc1MGZlODg1YzQzODE0NTQ3Y2FhMGQ1ODU1YTQwODhhY2Nk
14
- ODVmOWM3ZGM5MDYyNTM2YTkzMDA5ZDhlYTE3YzQ1Y2IzNmMwM2ZjYTliNmJl
15
- NTkwZmFlYTI5ZjNlODUyM2FkODc0ZTVhNzUxMjk4YTBkN2YyMjE=
13
+ NmU3NjU0YWIwYzAzNDRjYjQzYzAxZmM1ZmQ2ODBlOTMwN2Q1M2MxNDZhMGUx
14
+ MzhkYTZlNjE5MjZhNWM5ZjQ3NGFjMzYxZGMwOTljZjI4OGI0NGE5YWM2OWQ1
15
+ ZGJlYjlkNDU0MjhmNmE1NDliODA3ODM1OWQzMTQ5YWJkZTdlZTE=
data/.rubocop.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  AllCops:
2
2
  Exclude:
3
3
  - vendor/bundle/**/*
4
+ - .bundle/**/*
4
5
 
5
6
  inherit_from: .rubocop_todo.yml
6
7
 
data/.rubocop_todo.yml CHANGED
@@ -1,202 +1,57 @@
1
1
  # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2014-12-09 17:12:22 +0000 using RuboCop version 0.27.1.
2
+ # on 2015-04-12 19:24:55 +0200 using RuboCop version 0.30.0.
3
3
  # The point is for the user to remove these configuration records
4
4
  # one by one as the offenses are removed from the code base.
5
5
  # Note that changes in the inspected code, or installation of new
6
6
  # versions of RuboCop, may require this file to be generated again.
7
7
 
8
- # Offense count: 22
9
- Lint/AmbiguousRegexpLiteral:
10
- Enabled: false
11
-
12
- # Offense count: 8
13
- # Cop supports --auto-correct.
14
- Lint/DeprecatedClassMethods:
15
- Enabled: false
16
-
17
- # Offense count: 2
18
- # Cop supports --auto-correct.
19
- Lint/StringConversionInInterpolation:
20
- Enabled: false
21
-
22
- # Offense count: 1
23
- # Cop supports --auto-correct.
24
- Lint/UnusedMethodArgument:
25
- Enabled: false
26
-
27
- # Offense count: 1
28
- Lint/UselessAccessModifier:
29
- Enabled: false
30
-
31
- # Offense count: 2
32
- Lint/UselessAssignment:
33
- Enabled: false
34
-
35
8
  # Offense count: 23
36
9
  Metrics/AbcSize:
37
- Max: 59
10
+ Max: 38
38
11
 
39
12
  # Offense count: 2
40
13
  # Configuration parameters: CountComments.
41
14
  Metrics/ClassLength:
42
- Max: 184
15
+ Max: 127
43
16
 
44
- # Offense count: 6
17
+ # Offense count: 5
45
18
  Metrics/CyclomaticComplexity:
46
- Max: 10
19
+ Max: 9
47
20
 
48
- # Offense count: 101
21
+ # Offense count: 92
49
22
  # Configuration parameters: AllowURI, URISchemes.
50
23
  Metrics/LineLength:
51
24
  Max: 157
52
25
 
53
- # Offense count: 26
26
+ # Offense count: 24
54
27
  # Configuration parameters: CountComments.
55
28
  Metrics/MethodLength:
56
- Max: 32
29
+ Max: 31
57
30
 
58
- # Offense count: 5
31
+ # Offense count: 4
59
32
  Metrics/PerceivedComplexity:
60
33
  Max: 11
61
34
 
62
- # Offense count: 3
63
- # Cop supports --auto-correct.
64
- # Configuration parameters: EnforcedStyle, SupportedStyles.
65
- Style/BarePercentLiterals:
66
- Enabled: false
67
-
68
- # Offense count: 1
69
- Style/CaseEquality:
70
- Enabled: false
71
-
72
- # Offense count: 1
73
- # Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep.
74
- Style/CaseIndentation:
75
- Enabled: false
76
-
77
- # Offense count: 25
78
- Style/Documentation:
79
- Enabled: false
80
-
81
- # Offense count: 1
82
- Style/DoubleNegation:
83
- Enabled: false
84
-
85
35
  # Offense count: 1
86
36
  # Cop supports --auto-correct.
87
- Style/EmptyLines:
88
- Enabled: false
89
-
90
- # Offense count: 1
91
- # Configuration parameters: EnforcedStyle, SupportedStyles.
92
- Style/FormatString:
93
- Enabled: false
94
-
95
- # Offense count: 4
96
- # Configuration parameters: AllowedVariables.
97
- Style/GlobalVars:
98
- Enabled: false
99
-
100
- # Offense count: 10
101
- # Configuration parameters: MinBodyLength.
102
- Style/GuardClause:
37
+ Performance/Sample:
103
38
  Enabled: false
104
39
 
105
40
  # Offense count: 12
106
- # Configuration parameters: MaxLineLength.
107
- Style/IfUnlessModifier:
108
- Enabled: false
109
-
110
- # Offense count: 1
111
41
  # Cop supports --auto-correct.
112
42
  # Configuration parameters: EnforcedStyle, SupportedStyles.
113
- Style/IndentHash:
114
- Enabled: true
115
-
116
- # Offense count: 13
117
- # Cop supports --auto-correct.
118
- Style/LeadingCommentSpace:
119
- Enabled: false
120
-
121
- # Offense count: 7
122
- # Cop supports --auto-correct.
123
- Style/NegatedIf:
124
- Enabled: false
125
-
126
- # Offense count: 7
127
- # Cop supports --auto-correct.
128
- Style/Not:
129
- Enabled: false
130
-
131
- # Offense count: 1
132
- Style/OneLineConditional:
133
- Enabled: false
134
-
135
- # Offense count: 79
136
- # Cop supports --auto-correct.
137
- # Configuration parameters: PreferredDelimiters.
138
- Style/PercentLiteralDelimiters:
139
- Enabled: false
140
-
141
- # Offense count: 3
142
- # Cop supports --auto-correct.
143
- Style/Proc:
144
- Enabled: false
145
-
146
- # Offense count: 1
147
- # Cop supports --auto-correct.
148
- Style/RedundantBegin:
149
- Enabled: false
150
-
151
- # Offense count: 76
152
- # Cop supports --auto-correct.
153
- Style/RedundantSelf:
154
- Enabled: false
155
-
156
- # Offense count: 1
157
- Style/RegexpLiteral:
158
- MaxSlashes: 2
159
-
160
- # Offense count: 1
161
- # Cop supports --auto-correct.
162
- Style/SingleSpaceBeforeFirstArg:
163
- Enabled: false
164
-
165
- # Offense count: 2
166
- # Cop supports --auto-correct.
167
- Style/SpaceAfterComma:
43
+ Style/BarePercentLiterals:
168
44
  Enabled: false
169
45
 
170
46
  # Offense count: 1
171
- # Cop supports --auto-correct.
172
- # Configuration parameters: EnforcedStyle, SupportedStyles.
173
- Style/SpaceBeforeBlockBraces:
174
- Enabled: false
175
-
176
- # Offense count: 5
177
- # Cop supports --auto-correct.
178
- Style/SpaceInsideParens:
47
+ Style/CaseEquality:
179
48
  Enabled: false
180
49
 
181
50
  # Offense count: 1
182
- # Cop supports --auto-correct.
183
- Style/SpecialGlobalVars:
184
- Enabled: false
185
-
186
- # Offense count: 15
187
- # Cop supports --auto-correct.
188
- # Configuration parameters: EnforcedStyle, SupportedStyles.
189
- Style/StringLiterals:
51
+ # Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep.
52
+ Style/CaseIndentation:
190
53
  Enabled: false
191
54
 
192
- # Offense count: 1
193
- # Cop supports --auto-correct.
194
- # Configuration parameters: EnforcedStyle, SupportedStyles.
195
- Style/StringLiteralsInInterpolation:
55
+ # Offense count: 28
56
+ Style/Documentation:
196
57
  Enabled: false
197
-
198
- # Offense count: 4
199
- # Cop supports --auto-correct.
200
- # Configuration parameters: WordRegex.
201
- Style/WordArray:
202
- MinSize: 3
data/.travis.yml CHANGED
@@ -1,16 +1,21 @@
1
+ sudo: false
1
2
  language: ruby
3
+ cache: bundler
2
4
  rvm:
3
5
  - 1.8.7
4
6
  - 1.9.2
5
7
  - 1.9.3
6
8
  - 2.0.0
7
9
  - 2.1.5
8
- - 2.2.0
10
+ - 2.2.1
9
11
  - ruby-head
10
12
 
11
13
  before_install:
12
- - sudo apt-get update -qq
13
- - sudo apt-get install -qq -y mplayer ffmpeg
14
+ # stub mplayer/ffmpeg so it looks like they are installed
15
+ - mkdir ~/bin
16
+ - touch ~/bin/mplayer ~/bin/ffmpeg
17
+ - chmod +x ~/bin/mplayer ~/bin/ffmpeg
18
+ - export PATH=~/bin:$PATH
14
19
 
15
20
  matrix:
16
21
  allow_failures:
@@ -21,7 +26,9 @@ branches:
21
26
  - gh-pages
22
27
 
23
28
  notifications:
24
- irc: "chat.freenode.net#lolcommits"
29
+ irc: chat.freenode.net#lolcommits
30
+ slack:
31
+ secure: BkGsQOYMJqW55j94S1QwmR17BkwuTIULKVhwzRdnv37BvVcC17y9KLMo8NH+bcao36XZx9DukXcTyaDQc6tCSlFEbG/FcPUJM8bx9EWjHUoGVg1KdpVu/nVHu+GKosrB41lM3nfJWCnF0TOSnmTXU+bV8Pwkij+L5X+gNyAT2Ns=
25
32
 
26
33
  deploy:
27
34
  provider: rubygems
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in lolcommits.gemspec
3
+ # Specify gem dependencies in lolcommits.gemspec
4
4
  gemspec
data/Rakefile CHANGED
@@ -28,7 +28,7 @@ end
28
28
  Rake::Task[:build].prerequisites.unshift :fix_permissions
29
29
 
30
30
  Rake::TestTask.new do |t|
31
- t.pattern = 'test/test_*.rb'
31
+ t.pattern = 'test/*_test.rb'
32
32
  end
33
33
 
34
34
  Rake::FileUtilsExt.verbose(false)
@@ -36,15 +36,15 @@ CUKE_RESULTS = 'results.html'
36
36
  CLEAN << CUKE_RESULTS
37
37
  Cucumber::Rake::Task.new(:features) do |t|
38
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
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
41
  t.cucumber_opts = optstr
42
42
  t.fork = false
43
43
  end
44
44
 
45
45
  Rake::RDocTask.new do |rd|
46
- rd.main = "README.rdoc"
47
- rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
46
+ rd.main = 'README.rdoc'
47
+ rd.rdoc_files.include('README.rdoc', 'lib/**/*.rb', 'bin/**/*')
48
48
  end
49
49
 
50
50
  # only run rubocop on platforms where it is supported, sigh
@@ -56,32 +56,24 @@ else
56
56
  task :default => [:test, :features]
57
57
  end
58
58
 
59
-
60
- desc "Migrate an existing local .lolcommits directory to Dropbox"
59
+ desc 'Migrate an existing local .lolcommits directory to Dropbox'
61
60
  task :dropboxify do
62
- $home = ENV['HOME']
63
- dropbox_loldir = "#{$home}/Dropbox/lolcommits"
64
- loldir = "#{$home}/.lolcommits"
65
- backup_loldir = "#{$home}/.lolcommits.old"
66
-
67
- #check whether we've done this already
68
- if File.symlink? loldir
69
- abort "already dropboxified!"
70
- end
71
-
72
- #create dropbox folder
73
- if not File.directory? dropbox_loldir
74
- FileUtils.mkdir_p dropbox_loldir
75
- end
76
-
77
- #backup existing loldir
78
- if File.directory? loldir
79
- FileUtils.mv( loldir, backup_loldir )
80
- end
81
-
82
- #symlink dropbox to local
83
- FileUtils.ln_s( dropbox_loldir, loldir )
84
-
85
- #copy over existing files
86
- FileUtils.cp_r( "#{backup_loldir}/.", loldir)
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)
87
79
  end
data/bin/lolcommits CHANGED
@@ -8,71 +8,32 @@ rescue LoadError
8
8
  require 'lolcommits'
9
9
  end
10
10
 
11
+ require 'lolcommits/cli/fatals'
12
+ require 'lolcommits/cli/launcher'
13
+ require 'lolcommits/cli/process_runner'
14
+ require 'lolcommits/cli/timelapse_gif'
15
+
11
16
  include Lolcommits
12
- require 'launchy'
13
- require 'choice'
17
+ include Lolcommits::CLI
14
18
 
19
+ require 'choice'
15
20
  require 'methadone'
16
21
  include Methadone::CLILogging
17
22
 
18
- #
19
- # CHECK FOR FURTHER DEPENDENCIES
20
- #
21
-
22
- def die_on_fatal_conditions!
23
- if Configuration.platform_mac?
24
- %w(imagesnap videosnap).each do |executable|
25
- unless File.executable? File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', executable, executable)
26
- fatal "Couldn't properly execute #{executable} for some reason, please file a bug?!"
27
- exit 1
28
- end
29
- end
30
- elsif Configuration.platform_linux?
31
- if not Configuration.command_which('mplayer')
32
- fatal "Couldn't find mplayer in your PATH!"
33
- exit 1
34
- end
35
- end
36
- unless File.readable? File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'fonts', 'Impact.ttf')
37
- fatal "Couldn't properly read Impact font from gem package, please file a bug?!"
38
- exit 1
39
- end
40
- if !Configuration.valid_ffmpeg_installed? && capture_animate
41
- fatal 'FATAL: ffmpeg does not appear to be properly installed!'
42
- exit 1
43
- end
44
- unless Configuration.valid_imagemagick_installed?
45
- fatal 'FATAL: ImageMagick does not appear to be properly installed!'
46
- exit 1
47
- end
48
- if Configuration.git_config_color_always?
49
- fatal "Due to a bug in the ruby-git library, git config for color.ui cannot be set to 'always'."
50
- fatal "Try setting it to 'auto' instead!"
51
- exit 1
52
- end
53
- end
54
-
55
- def die_if_not_git_repo!
56
- begin
57
- debug 'Checking for valid git repo'
58
- g = Git.open('.')
59
- rescue ArgumentError
60
- # ruby-git throws an argument error if path isnt for a valid git repo...
61
- fatal "Erm? Can't do that since we're not in a valid git repository!"
62
- exit 1
63
- end
64
- end
65
-
66
23
  #
67
24
  # NO ARGUMENTS SPECIFIED, HELP THE USER OUT
68
25
  #
69
26
  def do_noargs
70
- # TODO: make this a contextual helper to know status of whether lolcommits is enabled
27
+ # TODO: make this a contextual helper to know whether lolcommits is enabled
71
28
  puts 'Do what exactly?'
72
29
  puts 'Try: lolcommits --enable (when in a git repository)'
73
30
  puts 'Or: lolcommits --help'
74
31
  end
75
32
 
33
+ # Gets a configuration object. If running in test mode will override the
34
+ # LOLDIR for the configuration.
35
+ #
36
+ # @return [Lolcommits::Configuration]
76
37
  def configuration
77
38
  if Choice.choices[:test]
78
39
  Configuration.new(:loldir => Configuration.loldir_for('test'))
@@ -81,18 +42,26 @@ def configuration
81
42
  end
82
43
  end
83
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]
84
56
  def capture_animate
85
- if Configuration.can_animate?
86
- Choice.choices[:animate] || ENV['LOLCOMMITS_ANIMATE'] || nil
87
- end
57
+ return unless Platform.can_animate?
58
+ Choice.choices[:animate] || ENV['LOLCOMMITS_ANIMATE'] || nil
88
59
  end
89
60
 
90
61
  def default_device
91
62
  result = Choice.choices[:device] || ENV['LOLCOMMITS_DEVICE']
92
63
 
93
- if Configuration.platform_linux?
94
- result ||= Dir.glob('/dev/video*').first
95
- end
64
+ result ||= Dir.glob('/dev/video*').first if Platform.platform_linux?
96
65
 
97
66
  result
98
67
  end
@@ -101,10 +70,10 @@ end
101
70
  # IF --CAPTURE, DO CAPTURE
102
71
  #
103
72
  def do_capture
104
- capture_delay = Choice.choices[:delay] || ENV['LOLCOMMITS_DELAY'] || 0
105
- capture_stealth = Choice.choices[:stealth] || ENV['LOLCOMMITS_STEALTH'] || nil
73
+ capture_delay = Choice.choices[:delay] || ENV['LOLCOMMITS_DELAY'] || 0
74
+ capture_stealth = Choice.choices[:stealth] || ENV['LOLCOMMITS_STEALTH'] || nil
75
+ capture_font = Choice.choices[:font] || ENV['LOLCOMMITS_FONT'] || nil
106
76
  capture_device = default_device
107
- capture_font = Choice.choices[:font] || ENV['LOLCOMMITS_FONT'] || nil
108
77
 
109
78
  capture_options = {
110
79
  :capture_delay => capture_delay,
@@ -115,7 +84,9 @@ def do_capture
115
84
  :config => configuration
116
85
  }
117
86
 
118
- fork_me? do
87
+ process_runner = ProcessRunner.new(configuration)
88
+ should_we_fork = Choice.choices[:fork] || ENV['LOLCOMMITS_FORK']
89
+ process_runner.fork_me?(should_we_fork) do
119
90
  if Choice.choices[:test]
120
91
  info '*** Capturing in test mode.'
121
92
 
@@ -125,11 +96,12 @@ def do_capture
125
96
  :sha => Choice.choices[:sha]
126
97
  }
127
98
 
99
+ # fire off runner with the overriden fake commit metadata
128
100
  runner = Lolcommits::Runner.new(capture_options.merge override_text)
129
101
  runner.run
130
102
 
131
- # automatically open so the user can see the test image results immediately
132
- Launchy.open(runner.main_image)
103
+ # automatically open so user can see the test image results immediately
104
+ Launcher.open_image(runner.main_image)
133
105
  else
134
106
  runner = Lolcommits::Runner.new(capture_options)
135
107
  runner.run
@@ -137,69 +109,19 @@ def do_capture
137
109
  end
138
110
  end
139
111
 
140
- def fork_me?(&block)
141
- if Choice.choices[:fork] || ENV['LOLCOMMITS_FORK']
142
- $stdout.sync = true
143
- write_pid fork {
144
- yield block
145
- delete_pid
146
- }
147
- else
148
- yield block
149
- end
150
- end
151
-
152
- def write_pid(pid)
153
- File.open(pid_file, 'w') { |f| f.write(pid) }
154
- end
155
-
156
- def delete_pid
157
- File.delete(pid_file) if File.exist?(pid_file)
158
- end
159
-
160
- def pid_file
161
- File.join(configuration.loldir, 'lolcommits.pid')
162
- end
163
-
164
112
  def do_configure
113
+ $stdout.sync = true
165
114
  configuration.do_configure! Choice.choices[:plugin]
166
115
  end
167
116
 
168
117
  def do_last
169
- die_if_not_git_repo!
118
+ Fatals.die_if_not_git_repo!
170
119
  lolimage = configuration.most_recent
171
120
  if lolimage.nil?
172
121
  warn 'No lolcommits have been captured for this repository yet.'
173
122
  exit 1
174
123
  end
175
- Launchy.open lolimage
176
- end
177
-
178
- def do_gif
179
- die_if_not_git_repo!
180
-
181
- case Choice.choices[:gif]
182
- when 'today'
183
- lolimages = configuration.jpg_images_today
184
- filename = "#{Date.today.to_s}.gif"
185
- else
186
- lolimages = configuration.jpg_images
187
- filename = 'archive.gif'
188
- end
189
-
190
- if lolimages.empty?
191
- warn 'No lolcommits have been captured for this time yet.'
192
- exit 1
193
- end
194
-
195
- puts '*** Generating animated gif.'
196
-
197
- gif = MiniMagick::Image.new File.join configuration.archivedir, filename
198
-
199
- # This is for ruby 1.8.7, *lolimages just doesn't work with ruby 187
200
- gif.run_command('convert', *['-delay', '50', '-loop', '0', lolimages, "#{gif.path}"].flatten)
201
-
202
- puts "*** #{gif.path} generated."
124
+ Launcher.open_image(lolimage)
203
125
  end
204
126
 
205
127
  def print_version_and_exit
@@ -219,11 +141,18 @@ def change_dir_to_root_or_repo!
219
141
  end
220
142
  end
221
143
 
144
+ # FIXME: this should be moved out of the CLI, but to where?
145
+ def load_local_plugins!
146
+ plugins_dir = Configuration.loldir_for('.plugins')
147
+ Dir.glob("#{plugins_dir}/*.rb").each do |plugin|
148
+ load plugin
149
+ end
150
+ end
151
+
222
152
  #
223
153
  # Command line parsing fun
224
154
  #
225
155
  Choice.options do
226
-
227
156
  option :version do
228
157
  long '--version'
229
158
  short '-v'
@@ -270,7 +199,7 @@ Choice.options do
270
199
 
271
200
  option :show_config do
272
201
  short '-sc'
273
- long '--show-config'
202
+ long '--show-config'
274
203
  desc 'display configuration file'
275
204
  end
276
205
 
@@ -344,7 +273,7 @@ Choice.options do
344
273
  desc 'generate animated timeline gif from captured images'
345
274
  end
346
275
 
347
- if Configuration.can_animate?
276
+ if Platform.can_animate?
348
277
  option :animate do
349
278
  long '--animate=SECONDS'
350
279
  short '-a'
@@ -369,17 +298,23 @@ end
369
298
  #
370
299
  # check for fatal conditions before execution
371
300
  #
372
- die_on_fatal_conditions!
301
+ Fatals.die_if_no_valid_ffmpeg_installed! if capture_animate
302
+ Fatals.die_on_fatal_platform_conditions!
373
303
 
374
304
  #
375
305
  # change working dir to either a repo or the fs root
376
306
  #
377
307
  change_dir_to_root_or_repo!
378
308
 
309
+ #
310
+ # load system local plugins
311
+ #
312
+ load_local_plugins!
313
+
379
314
  #
380
315
  # Handle actions manually since choice seems weird
381
316
  #
382
- if not (Choice.choices[:enable] || Choice.choices[:disable])
317
+ if !Choice.choices[:enable] || !Choice.choices[:disable]
383
318
  if Choice.choices[:capture]
384
319
  do_capture
385
320
  elsif Choice.choices[:configure]
@@ -389,14 +324,16 @@ if not (Choice.choices[:enable] || Choice.choices[:disable])
389
324
  elsif Choice.choices[:plugins]
390
325
  configuration.puts_plugins
391
326
  elsif Choice.choices[:devices]
392
- configuration.puts_devices
327
+ puts Platform.device_list
328
+ puts "Specify a device with --device=\"{device name}\" "\
329
+ 'or set the LOLCOMMITS_DEVICE env variable'
393
330
  elsif Choice.choices[:last]
394
331
  do_last
395
332
  elsif Choice.choices[:browse]
396
- die_if_not_git_repo!
397
- Launchy.open configuration.loldir
333
+ Fatals.die_if_not_git_repo!
334
+ Launcher.open_folder(configuration.loldir)
398
335
  elsif Choice.choices[:gif]
399
- do_gif
336
+ TimelapseGif.new(configuration).run(Choice.choices[:gif])
400
337
  else
401
338
  do_noargs
402
339
  end