lolcommits 0.5.9 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODE2NDgxMzBmNWVjZWEyOTM3YTEzZTU2N2FlMWE0OThkNjZhODBjZg==
4
+ ZjA1ZjZlYWRmOGZjOGM4MDcxNTQ4NGQzYWM5OGI3MTY0ODQ5ZjliYQ==
5
5
  data.tar.gz: !binary |-
6
- NWUxZmJlOGNiZjAwZjJlYWU0NzBmM2Y1NTRlNzBmYzhmMGI2MDk5YQ==
6
+ YTAwODliMjE0MjIxNTljYjI4OWU5MzllM2E0ODM0YTZiNGE4MjIyOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTk4OGQzMDNhZGFmMTAzYjBhZWViNTJmODdjNDI3NzE1MjA1ZjJhZGIzODgw
10
- YmNiOTc1NTc0YjhiNmE4NTY5NTE3YzQ4ZTViZjJiYzk2MjJiYjIxNGNmNDhi
11
- YjNjN2NjNjIwYjAyNjQ1NzkwODlmNDhhNjE0ZWMxNzVjNmEyZGU=
9
+ MzJkNmZhMWVlZTQ2MmQ1NWE4NTA1NDU3MWE2YTc3NzRjMTY3MDk2MmIyOGEw
10
+ NGRiNzhlZWE4ZDY3OTFjZWYwNDJlZjA2NTMxMGNkNWU3MWVjOTM5MTQ5ZGRk
11
+ ZTI5MTcyYzgyNTZjNGMyMWY1YTg2MzU1MTI4ZWVkZDc1MzJjOWE=
12
12
  data.tar.gz: !binary |-
13
- Y2Y1NGJkMTY3NWQ1OTIzMzI1YzljNjg2ZWQ4NWU1NDRkY2NlMDY1YzBiOTdl
14
- ZWE5OTQ2MjU4YTVlZDFlNDNkMDI0OWM5NGUxZGUxZTE3N2ZjODQxYWExNWIy
15
- YTRlNzM3MWUwN2Y5OWVjOGZmNjA0M2MyMzQwOWZkNjlkZTA2NzU=
13
+ Y2JlNTIwZjMyNmFiODc4MDU0NjU2NThmZDQwOTg0ZmNiYzEyMDk5YWYzMGEy
14
+ M2MwNmJkOGU3ZjZjN2QwOGIyMjE3YjVmNTBlZDY4MDk1Y2JkOTdiM2YxYjc3
15
+ NDQwOTZlNWYwOTAzZmY4ZWU1NGI2NDQ1MGU5ODNkMjUwZjA2MmY=
@@ -1,6 +1,14 @@
1
- 0.6.0 (WIP)
1
+ ### Version History
2
+
3
+ 0.7.0 (WIP)
2
4
  * extract plugins to seperate gems ...
3
5
 
6
+ 0.6.0 (27 July 2015)
7
+ * Configurable text options for loltext plugin (@matthutchinson #282)
8
+ * Working AppVeyor configuration added (@nysthee #280)
9
+ * Tumblr plugin (@mveytsman #279)
10
+ * CHANGELOG (this file) now in markdown format (@matthutchinson)
11
+
4
12
  0.5.9 (24 April 2015)
5
13
  * Fix windows post commit hook path (@matthutchinson #278)
6
14
 
@@ -20,7 +28,7 @@
20
28
  * More configurable twitter plugin (@woodrowbarlow #207 @matthutchinson)
21
29
  * Upgrade all gems that can be, 4 held back (#244 @matthutchinson)
22
30
  * Ruby 2.2.0 compatible (#244 @matthutchinson)
23
- * Glob /dev/video* for default video device (linux only) (#246 @Ferada)
31
+ * Glob /dev/video for default video device (linux only) (#246 @Ferada)
24
32
 
25
33
  0.5.6 (24 November 2014)
26
34
  * Updates and clean ups on the gemspec (@mroth #228)
@@ -145,7 +153,7 @@
145
153
  * fix bug involving git repositories with spaces in the name
146
154
  * internal refactoring for modularity (thanks @kenmazaika!), should be easier
147
155
  to add new plugin features to lolcommits now.
148
- * add some extremeley basic anonymous usage tracking (if this bugs you, you
156
+ * add some extremely basic anonymous usage tracking (if this bugs you, you
149
157
  can disable via disabling the `statsd` plugin).
150
158
 
151
159
  0.2.0 (6 July 2012)
@@ -197,4 +205,3 @@
197
205
  * wordwrap commit_msg manually, to switch to use imagemagick annotate
198
206
  instead of compositing multiply image Caption objects (this seems to be more
199
207
  reliable to not glitch.)
200
-
@@ -0,0 +1,44 @@
1
+ ### Contributing
2
+
3
+ Pull Requests are welcome! To start helping out on lolcommits:
4
+
5
+ Fork then clone the repository:
6
+
7
+ git clone git@github.com:your-username/acts_as_textcaptcha.git
8
+
9
+ Create your feature branch:
10
+
11
+ git checkout -b my-new-feature
12
+
13
+ When you are happy with your change, run the full test suite:
14
+
15
+ bundle exec rake
16
+
17
+ Please ensure nothing is broken. It'd be awesome if you manually tested for
18
+ regressions as well (since the test suite is far from complete).
19
+
20
+ This default rake task uses [RuboCop](https://github.com/bbatsov/rubocop) to
21
+ ensure Ruby style guidelines. If you want to run tests before conforming to this
22
+ to verify functionality, just run `rake test` and `rake features` manually.
23
+
24
+ With a passing test suite, commit your changes, push and submit a new [Pull
25
+ Request](https://github.com/mroth/lolcomits/compare/):
26
+
27
+ git commit -am 'Added some feature'
28
+ git push origin my-new-feature
29
+
30
+ At this point you'll be waiting for one of our maintainers to review it. We will
31
+ try to reply to new Pull Requests within a few days. We might suggest some
32
+ changes, improvements or alternatives. To increase the chance that your pull
33
+ request gets accepted:
34
+
35
+ * Explain what your are doing (and why) in your Pull Request description.
36
+ * If you are fixing an
37
+ [issue](https://github.com/mroth/lolcomits/issues), link to
38
+ it in your description and [mention
39
+ it](https://help.github.com/articles/closing-issues-via-commit-messages/) in
40
+ the commit message.
41
+ * Write a good [commit
42
+ message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
43
+ * Write tests.
44
+
data/README.md CHANGED
@@ -45,7 +45,7 @@ Install dependencies using your package manager of choice, for example in
45
45
  Ubuntu:
46
46
 
47
47
  sudo apt-get install mplayer imagemagick libmagickwand-dev
48
-
48
+
49
49
  For Ubuntu 14.04 or newer, you need to manually install ffmpeg since it no longer ships with the default Ubuntu sources. [Downloads for ffmpeg](http://ffmpeg.org/download.html)
50
50
 
51
51
  Then install the gem with:
@@ -104,7 +104,6 @@ via environment variables like so;
104
104
  **requires ffmpeg**
105
105
  * `LOLCOMMITS_DELAY` (in seconds) set delay persistently (for slow webcams to
106
106
  warmup)
107
- * `LOLCOMMITS_FONT` set font file location for lolcommit text
108
107
  * `LOLCOMMITS_FORK` fork lolcommit runner (capture command forks to a new
109
108
  process, speedily returning you to your terminal)
110
109
  * `LOLCOMMITS_STEALTH` disable notification messages at commit time
@@ -116,12 +115,16 @@ in your repository's `.git/hooks/post-commit` file).
116
115
  * `--device=DEVICE` or `-d DEVICE`
117
116
  * `--animate=SECONDS` or `-a SECONDS`
118
117
  * `--delay=SECONDS` or `-w SECONDS`
119
- * `--font=FONT_PATH` or `-f FONT_PATH`
120
118
  * `--fork`
121
119
  * `--stealth`
122
120
 
123
- Use `lolcommits --devices` to list all attached video devices available for
124
- capturing. Read how to [configure commit
121
+ To change the font (including point size, position & color), simply configure
122
+ the default loltext plugin with this command:
123
+
124
+ lolcommits --config -p loltext
125
+
126
+ You can use `lolcommits --devices` to list all attached video devices available
127
+ for capturing. Read how to [configure commit
125
128
  capturing](https://github.com/mroth/lolcommits/wiki/Configure-Commit-Capturing)
126
129
  for more details.
127
130
 
@@ -149,9 +152,16 @@ animated lolcommit gif")
149
152
 
150
153
  ### Plugins
151
154
 
152
- There are a growing amount of plugins for lolcommits to enable things like
153
- Twitter upload, translating your commit messages to lolspeak, etc. Check them
154
- out on the [plugins
155
+ A growing number of plugins are now available allowing you to transform or share
156
+ your lolcommits with others. The default plugin simply appends your commit
157
+ message and sha to the captured image. Others can auto post to Twitter, Tumblr
158
+ (and other services), or even translate your commit messages to
159
+ [lolspeak](http://www.urbandictionary.com/define.php?term=lolspeak). They can be
160
+ easily enabled, configured or disabled with our config command:
161
+
162
+ lolcommits --config
163
+
164
+ Check them out on our [plugins
155
165
  page](https://github.com/mroth/lolcommits/wiki/Configuring-Plugins).
156
166
 
157
167
  ## Troubles?
@@ -0,0 +1,41 @@
1
+ version: "{build}"
2
+
3
+ os: Windows Server 2012
4
+ platform:
5
+ - x64
6
+
7
+ environment:
8
+ matrix:
9
+ - ruby_version: "193"
10
+ - ruby_version: "200"
11
+ - ruby_version: "21"
12
+ - ruby_version: "22"
13
+
14
+ clone_folder: c:\projects\lolcommits
15
+ clone_depth: 10
16
+ skip_tags: true
17
+
18
+ branches:
19
+ except:
20
+ - gh-pages
21
+
22
+ init:
23
+ # stub mplayer/ffmpeg so it looks like they are installed
24
+ - mkdir c:\bin
25
+ - fsutil file createnew c:\bin\mplayer 1
26
+ - fsutil file createnew c:\bin\ffmpeg 1
27
+ - setx path "%path%;c:\bin"
28
+
29
+ install:
30
+ - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
31
+ - ruby --version
32
+ - gem --version
33
+ - gem install bundler --quiet --no-ri --no-rdoc
34
+ - bundler --version
35
+ - choco install imagemagick.app -y
36
+
37
+ build_script:
38
+ - bundle install
39
+
40
+ test_script:
41
+ - bundle exec rake
@@ -72,14 +72,12 @@ end
72
72
  def do_capture
73
73
  capture_delay = Choice.choices[:delay] || ENV['LOLCOMMITS_DELAY'] || 0
74
74
  capture_stealth = Choice.choices[:stealth] || ENV['LOLCOMMITS_STEALTH'] || nil
75
- capture_font = Choice.choices[:font] || ENV['LOLCOMMITS_FONT'] || nil
76
75
  capture_device = default_device
77
76
 
78
77
  capture_options = {
79
78
  :capture_delay => capture_delay,
80
79
  :capture_stealth => capture_stealth,
81
80
  :capture_device => capture_device,
82
- :font => capture_font,
83
81
  :capture_animate => capture_animate,
84
82
  :config => configuration
85
83
  }
@@ -267,12 +265,6 @@ Choice.options do
267
265
  desc 'output debugging information'
268
266
  end
269
267
 
270
- option :font do
271
- long '--font=FONT_PATH'
272
- short '-f'
273
- desc 'pass font file location'
274
- end
275
-
276
268
  option :gif do
277
269
  long '--gif'
278
270
  short '-g'
@@ -114,30 +114,49 @@ Feature: Basic UI functionality
114
114
  When I successfully run `lolcommits --plugins`
115
115
  Then the output should contain a list of plugins
116
116
 
117
- Scenario: Configuring plugin
117
+ Scenario: Configuring loltext plugin
118
118
  Given I am in a git repo named "config-test"
119
119
  When I run `lolcommits --config` interactively
120
120
  And I wait for output to contain "Name of plugin to configure:"
121
121
  Then I type "loltext"
122
122
  And I wait for output to contain "enabled:"
123
123
  Then I type "true"
124
+ And I wait for output to contain "color"
125
+ Then I type "red"
126
+ And I wait for output to contain "font"
127
+ Then I type "my-font.ttf"
128
+ And I wait for output to contain "position"
129
+ Then I type "SouthEast"
130
+ And I wait for output to contain "size"
131
+ Then I type "32"
132
+ And I wait for output to contain "stroke color"
133
+ Then I type "white"
134
+ And I wait for output to contain "sha text"
135
+ Then I type ""
136
+ Then I type ""
137
+ Then I type ""
138
+ Then I type ""
139
+ Then I type ""
124
140
  Then the output should contain "Successfully configured plugin: loltext"
125
- And the output should contain a list of plugins
126
- And a file named "~/.lolcommits/config-test/config.yml" should exist
141
+ And the output should contain a list of plugins
142
+ And a file named "~/.lolcommits/config-test/config.yml" should exist
127
143
  When I successfully run `lolcommits --show-config`
128
- Then the output should match /loltext:\s+enabled: true/
129
-
130
- Scenario: Configuring plugin in test mode affects test loldir not repo loldir
144
+ Then the output should match /enabled: true/
145
+ And the output should match /:font: my-font\.ttf/
146
+ And the output should match /:size: 32/
147
+ And the output should match /:position: SouthEast/
148
+ And the output should match /:color: red/
149
+ And the output should match /:stroke_color: white/
150
+
151
+ Scenario: Configuring loltext plugin in test mode affects test loldir not repo loldir
131
152
  Given I am in a git repo named "testmode-config-test"
132
- When I run `lolcommits --config --test` interactively
133
- And I wait for output to contain "Name of plugin to configure:"
134
- Then I type "loltext"
153
+ When I run `lolcommits --config --test -p loltext` interactively
135
154
  And I wait for output to contain "enabled:"
136
- Then I type "true"
155
+ Then I type "false"
137
156
  Then the output should contain "Successfully configured plugin: loltext"
138
157
  And a file named "~/.lolcommits/test/config.yml" should exist
139
158
  When I successfully run `lolcommits --test --show-config`
140
- Then the output should match /loltext:\s+enabled: true/
159
+ Then the output should match /loltext:\s+enabled: false/
141
160
 
142
161
  Scenario: test capture should work regardless of whether in a git repo
143
162
  Given I am in a directory named "nothingtoseehere"
@@ -26,6 +26,7 @@ require 'lolcommits/plugins/uploldz'
26
26
  require 'lolcommits/plugins/lolsrv'
27
27
  require 'lolcommits/plugins/lol_yammer'
28
28
  require 'lolcommits/plugins/lol_protonet'
29
+ require 'lolcommits/plugins/lol_tumblr'
29
30
 
30
31
  # require runner after all the plugins have been required
31
32
  require 'lolcommits/runner'
@@ -3,7 +3,7 @@ module Lolcommits
3
3
  class Capturer
4
4
  include Methadone::CLILogging
5
5
 
6
- attr_accessor :capture_device, :capture_delay, :snapshot_location, :font,
6
+ attr_accessor :capture_device, :capture_delay, :snapshot_location,
7
7
  :video_location, :frames_location, :animated_duration
8
8
 
9
9
  def initialize(attributes = {})
@@ -9,10 +9,10 @@ module Lolcommits
9
9
  delaycmd = " /delay #{capture_delay * 1000}"
10
10
  end
11
11
 
12
- _, r, _ = Open3.popen3("#{executable_path} /filename `cygpath -w #{snapshot_location}`#{delaycmd}")
12
+ _stdin, stdout, _stderr = Open3.popen3("#{executable_path} /filename `cygpath -w #{snapshot_location}`#{delaycmd}")
13
13
 
14
14
  # looks like we still need to read the output for something to happen
15
- r.read
15
+ stdout.read
16
16
  end
17
17
 
18
18
  def executable_path
@@ -21,9 +21,9 @@ module Lolcommits
21
21
 
22
22
  debug 'LinuxCapturer: calling out to mplayer to capture image'
23
23
  # mplayer's output is ugly and useless, let's throw it away
24
- _, r, _ = Open3.popen3("mplayer -vo jpeg:outdir=#{tmpdir} #{capture_device_string} -frames #{frames} -fps #{MPLAYER_FPS} tv://")
24
+ _stdin, stdout, _stderr = Open3.popen3("mplayer -vo jpeg:outdir=#{tmpdir} #{capture_device_string} -frames #{frames} -fps #{MPLAYER_FPS} tv://")
25
25
  # looks like we still need to read the output for something to happen
26
- r.read
26
+ stdout.read
27
27
 
28
28
  debug 'LinuxCapturer: calling out to mplayer to capture image'
29
29
 
@@ -9,10 +9,10 @@ module Lolcommits
9
9
  delaycmd = " /delay #{capture_delay * 1000}"
10
10
  end
11
11
 
12
- _, r, _ = Open3.popen3("#{executable_path} /filename #{snapshot_location}#{delaycmd}")
12
+ _stdin, stdout, _stderr = Open3.popen3("#{executable_path} /filename #{snapshot_location}#{delaycmd}")
13
13
 
14
14
  # looks like we still need to read the output for something to happen
15
- r.read
15
+ stdout.read
16
16
  end
17
17
 
18
18
  def executable_path
@@ -29,8 +29,8 @@ module Lolcommits
29
29
  end
30
30
  end
31
31
 
32
- # make sure we can find the Impact truetype font
33
- unless File.readable? File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'fonts', 'Impact.ttf')
32
+ # make sure we can find the default font
33
+ unless File.readable? Lolcommits::Loltext::DEFAULT_FONT_PATH
34
34
  fatal "Couldn't properly read Impact font from gem package, "\
35
35
  'please file a bug?!'
36
36
  exit 1
@@ -50,8 +50,8 @@ module Lolcommits
50
50
  print "#{option}: "
51
51
  val = parse_user_input(STDIN.gets.strip)
52
52
  # check enabled option isn't a String
53
- if (option == 'enabled') && val.is_a?(String)
54
- puts "Aborting - please enable with 'true' or 'false'"
53
+ if (option == 'enabled') && ![true, false].include?(val)
54
+ puts "Aborting - please respond with 'true' or 'false'"
55
55
  exit 1
56
56
  else
57
57
  acc.merge(option => val)
@@ -60,10 +60,15 @@ module Lolcommits
60
60
  end
61
61
 
62
62
  def parse_user_input(str)
63
+ # cater for bools, strings, ints and blanks
63
64
  if 'true'.casecmp(str) == 0
64
65
  true
65
66
  elsif 'false'.casecmp(str) == 0
66
67
  false
68
+ elsif str =~ /^[0-9]+$/
69
+ str.to_i
70
+ elsif str.strip.empty?
71
+ nil
67
72
  else
68
73
  str
69
74
  end
@@ -0,0 +1,130 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'yaml'
3
+ require 'oauth'
4
+ require 'webrick'
5
+ require 'cgi'
6
+ require 'tumblr_client'
7
+
8
+ module Lolcommits
9
+ class LolTumblr < Plugin
10
+ TUMBLR_API_ENDPOINT = 'https://www.tumblr.com'
11
+ TUMBLR_CONSUMER_KEY = '2FtMEDpEPkxjoUdkpHh42h9wqTu9IVS7Ra0QyNZGixdCvhllN2'
12
+ TUMBLR_CONSUMER_SECRET = 'qWuvxgFUR2YyWKtbWOkDTMAiBEbj7ZGaNLaNQPba0PI1N4JpBs'
13
+
14
+ def run_postcapture
15
+ return unless valid_configuration?
16
+ puts 'Posting to Tumblr'
17
+ r = client.photo(configuration['tumblr_name'], :data => runner.main_image)
18
+ if r.key?('id')
19
+ puts "\t--> Post successful!"
20
+ else
21
+ puts "Tumblr post FAILED! #{r}"
22
+ end
23
+ rescue Faraday::Error => e
24
+ puts "Tumblr post FAILED! #{e.message}"
25
+ end
26
+
27
+ def configure_options!
28
+ options = super
29
+ # ask user to configure tokens if enabling
30
+ if options['enabled']
31
+ auth_config = configure_auth!
32
+ if auth_config
33
+ options = options.merge(auth_config).merge(configure_tumblr_name)
34
+ else
35
+ return # return nil if configure_auth failed
36
+ end
37
+ end
38
+ options
39
+ end
40
+
41
+ def configure_auth!
42
+ puts '---------------------------'
43
+ puts 'Need to grab tumblr tokens'
44
+ puts '---------------------------'
45
+
46
+ request_token = oauth_consumer.get_request_token(:exclude_callback => true)
47
+ print "\n1) Please open this url in your browser to authorize lolcommits:\n\n"
48
+ puts request_token.authorize_url
49
+ print "\n2) Launching a local server to complete the OAuth authentication process:\n\n"
50
+ begin
51
+ server = WEBrick::HTTPServer.new :Port => 3000
52
+ server.mount_proc '/', server_callback(server)
53
+ server.start
54
+ debug "Requesting Tumblr OAuth Token with verifier: #{@verifier}"
55
+ access_token = request_token.get_access_token(:oauth_verifier => @verifier)
56
+ rescue Errno::EADDRINUSE
57
+ puts "\nERROR You have something running on port 3000. Please turn it off to complete the authorization process"
58
+ return
59
+ rescue OAuth::Unauthorized
60
+ puts "\nERROR: Tumblr OAuth verification faile!"
61
+ return
62
+ end
63
+ return unless access_token.token && access_token.secret
64
+ puts ''
65
+ puts '------------------------------'
66
+ puts 'Thanks! Tumblr Auth Succeeded'
67
+ puts '------------------------------'
68
+
69
+ {
70
+ 'access_token' => access_token.token,
71
+ 'secret' => access_token.secret
72
+ }
73
+ end
74
+
75
+ def configure_tumblr_name
76
+ print "\n3) What's your tumblr name? (i.e. 'http://[THIS PART HERE].tumblr.com'): "
77
+ { 'tumblr_name' => STDIN.gets.strip }
78
+ end
79
+
80
+ def configured?
81
+ !configuration['enabled'].nil? &&
82
+ configuration['access_token'] &&
83
+ configuration['secret']
84
+ end
85
+
86
+ def client
87
+ @client ||= Tumblr.new(:consumer_key => TUMBLR_CONSUMER_KEY,
88
+ :consumer_secret => TUMBLR_CONSUMER_SECRET,
89
+ :oauth_token => configuration['access_token'],
90
+ :oauth_token_secret => configuration['secret']
91
+ )
92
+ end
93
+
94
+ def oauth_consumer
95
+ @oauth_consumer ||= OAuth::Consumer.new(TUMBLR_CONSUMER_KEY,
96
+ TUMBLR_CONSUMER_SECRET,
97
+ :site => TUMBLR_API_ENDPOINT,
98
+ :request_endpoint => TUMBLR_API_ENDPOINT,
99
+ :http_methdo => :get
100
+ )
101
+ end
102
+
103
+ def config_with_default(key, default = nil)
104
+ if configuration[key]
105
+ configuration[key].strip.empty? ? default : configuration[key]
106
+ else
107
+ default
108
+ end
109
+ end
110
+
111
+ def self.name
112
+ 'tumblr'
113
+ end
114
+
115
+ def self.runner_order
116
+ :postcapture
117
+ end
118
+
119
+ protected
120
+
121
+ def server_callback(server)
122
+ proc do |req, res|
123
+ q = CGI.parse req.request_uri.query
124
+ @verifier = q['oauth_verifier'][0]
125
+ server.stop
126
+ res.body = 'Lolcommits authorization complete!'
127
+ end
128
+ end
129
+ end
130
+ end
@@ -1,9 +1,10 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Lolcommits
3
3
  class Loltext < Plugin
4
- def initialize(runner)
5
- super
6
- @font_location = runner ? runner.font : nil
4
+ DEFAULT_FONT_PATH = File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'fonts', 'Impact.ttf')
5
+
6
+ def self.name
7
+ 'loltext'
7
8
  end
8
9
 
9
10
  # enabled by default (if no configuration exists)
@@ -12,44 +13,108 @@ module Lolcommits
12
13
  end
13
14
 
14
15
  def run_postcapture
15
- font_location = @font_location || File.join(Configuration::LOLCOMMITS_ROOT,
16
- 'vendor',
17
- 'fonts',
18
- 'Impact.ttf')
19
-
20
16
  debug 'Annotating image via MiniMagick'
21
17
  image = MiniMagick::Image.open(runner.main_image)
18
+ annotate(image, :message, clean_msg(runner.message))
19
+ annotate(image, :sha, runner.sha)
20
+ debug "Writing changed file to #{runner.main_image}"
21
+ image.write runner.main_image
22
+ end
23
+
24
+ def annotate(image, type, string)
25
+ debug("annotating #{type} text to image")
26
+
22
27
  image.combine_options do |c|
23
- c.gravity 'SouthWest'
24
- c.fill 'white'
25
- c.stroke 'black'
26
28
  c.strokewidth '2'
27
- c.pointsize(runner.animate? ? '24' : '48')
28
29
  c.interline_spacing '-9'
29
- c.font font_location
30
- c.annotate '0', clean_msg(runner.message)
30
+ c.stroke config_option(type, :stroke_color)
31
+ c.fill config_option(type, :color)
32
+ c.gravity position_transform(config_option(type, :position))
33
+ c.pointsize runner.animate? ? 24 : config_option(type, :size)
34
+ c.font config_option(type, :font)
35
+ c.annotate '0', string
31
36
  end
37
+ end
32
38
 
33
- image.combine_options do |c|
34
- c.gravity 'NorthEast'
35
- c.fill 'white'
36
- c.stroke 'black'
37
- c.strokewidth '2'
38
- c.pointsize(runner.animate? ? '21' : '32')
39
- c.font font_location
40
- c.annotate '0', runner.sha
39
+ def configure_options!
40
+ options = super
41
+ # ask user to configure text options when enabling
42
+ if options['enabled']
43
+ puts '------------------------------------------------------'
44
+ puts ' Text options '
45
+ puts
46
+ puts ' * blank options use the (default)'
47
+ puts ' * use full absolute path to fonts'
48
+ puts ' * valid positions are NE, NW, SE, SW, C (centered)'
49
+ puts ' * colors can be hex #FC0 value or a string \'white\''
50
+ puts '------------------------------------------------------'
51
+
52
+ options[:message] = configure_sub_options(:message)
53
+ options[:sha] = configure_sub_options(:sha)
41
54
  end
55
+ options
56
+ end
42
57
 
43
- debug "Writing changed file to #{runner.main_image}"
44
- image.write runner.main_image
58
+ # TODO: consider this type of configuration prompting in the base Plugin
59
+ # class, working with hash of defaults
60
+ def configure_sub_options(type)
61
+ print "#{type} text:\n"
62
+ defaults = config_defaults[type]
63
+
64
+ # sort option keys since different `Hash#keys` varys across Ruby versions
65
+ defaults.keys.sort_by(&:to_s).reduce({}) do |acc, opt|
66
+ print " #{opt.to_s.gsub('_', ' ')} (#{defaults[opt]}): "
67
+ val = parse_user_input(STDIN.gets.strip)
68
+ acc.merge(opt => val)
69
+ end
45
70
  end
46
71
 
47
- def self.name
48
- 'loltext'
72
+ def config_defaults
73
+ {
74
+ :message => {
75
+ :font => DEFAULT_FONT_PATH,
76
+ :size => 48,
77
+ :position => 'SW',
78
+ :color => 'white',
79
+ :stroke_color => 'black'
80
+ },
81
+ :sha => {
82
+ :font => DEFAULT_FONT_PATH,
83
+ :size => 32,
84
+ :position => 'NE',
85
+ :color => 'white',
86
+ :stroke_color => 'black'
87
+ }
88
+ }
89
+ end
90
+
91
+ def config_option(type, option)
92
+ default_option = config_defaults[type][option]
93
+ if configuration[type]
94
+ configuration[type][option] || default_option
95
+ else
96
+ default_option
97
+ end
49
98
  end
50
99
 
51
100
  private
52
101
 
102
+ # explode psuedo-names for text position
103
+ def position_transform(position)
104
+ case position
105
+ when 'NE'
106
+ 'NorthEast'
107
+ when 'NW'
108
+ 'NorthWest'
109
+ when 'SE'
110
+ 'SouthEast'
111
+ when 'SW'
112
+ 'SouthWest'
113
+ when 'C'
114
+ 'Center'
115
+ end
116
+ end
117
+
53
118
  # do whatever is required to commit message to get it clean and ready for imagemagick
54
119
  def clean_msg(text)
55
120
  wrapped_text = word_wrap text
@@ -4,7 +4,7 @@ require 'lolcommits/platform'
4
4
  module Lolcommits
5
5
  class Runner
6
6
  attr_accessor :capture_delay, :capture_stealth, :capture_device, :message,
7
- :sha, :snapshot_loc, :main_image, :config, :font, :git_info,
7
+ :sha, :snapshot_loc, :main_image, :config, :git_info,
8
8
  :capture_animate
9
9
 
10
10
  include Methadone::CLILogging
@@ -85,7 +85,6 @@ module Lolcommits
85
85
  :capture_device => capture_device,
86
86
  :capture_delay => capture_delay,
87
87
  :snapshot_location => snapshot_loc,
88
- :font => font,
89
88
  :video_location => config.video_loc,
90
89
  :frames_location => config.frames_loc,
91
90
  :animated_duration => capture_animate
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Lolcommits
3
- VERSION = '0.5.9'
3
+ VERSION = '0.6.0'
4
4
  end
@@ -47,6 +47,7 @@ Gem::Specification.new do |s|
47
47
  s.add_runtime_dependency('yam', '~> 2.4.0') # yammer
48
48
  s.add_runtime_dependency('json', '~> 1.8.1') # lolsrv
49
49
  s.add_runtime_dependency('httmultiparty', '~> 0.3.16') # dot_com
50
+ s.add_runtime_dependency('tumblr_client', '~> 0.8.5') # tumblr
50
51
 
51
52
  # development gems
52
53
  s.add_development_dependency('fivemat', '~> 1.3.1')
@@ -18,7 +18,7 @@ class LolTest < MiniTest::Test
18
18
  # this will test the permissions but only locally, important before building a gem package!
19
19
  #
20
20
  def test_permissions
21
- impact_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'fonts', 'Impact.ttf')).mode & 0777
21
+ impact_perms = File.lstat(Lolcommits::Loltext::DEFAULT_FONT_PATH).mode & 0777
22
22
  imagesnap_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'imagesnap', 'imagesnap')).mode & 0777
23
23
  videosnap_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'videosnap', 'videosnap')).mode & 0777
24
24
  commandcam_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'CommandCam', 'CommandCam.exe')).mode & 0777
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolcommits
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.9
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Rothenberg
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-24 00:00:00.000000000 Z
12
+ date: 2015-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -221,6 +221,20 @@ dependencies:
221
221
  - - ~>
222
222
  - !ruby/object:Gem::Version
223
223
  version: 0.3.16
224
+ - !ruby/object:Gem::Dependency
225
+ name: tumblr_client
226
+ requirement: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - ~>
229
+ - !ruby/object:Gem::Version
230
+ version: 0.8.5
231
+ type: :runtime
232
+ prerelease: false
233
+ version_requirements: !ruby/object:Gem::Requirement
234
+ requirements:
235
+ - - ~>
236
+ - !ruby/object:Gem::Version
237
+ version: 0.8.5
224
238
  - !ruby/object:Gem::Dependency
225
239
  name: fivemat
226
240
  requirement: !ruby/object:Gem::Requirement
@@ -365,12 +379,13 @@ files:
365
379
  - .rubocop.yml
366
380
  - .rubocop_todo.yml
367
381
  - .travis.yml
368
- - CHANGELOG
369
- - CONTRIBUTING
382
+ - CHANGELOG.md
383
+ - CONTRIBUTING.md
370
384
  - Gemfile
371
385
  - LICENSE
372
386
  - README.md
373
387
  - Rakefile
388
+ - appveyor.yml
374
389
  - bin/lolcommits
375
390
  - config/cucumber.yml
376
391
  - features/bugs.feature
@@ -401,6 +416,7 @@ files:
401
416
  - lib/lolcommits/plugin.rb
402
417
  - lib/lolcommits/plugins/dot_com.rb
403
418
  - lib/lolcommits/plugins/lol_protonet.rb
419
+ - lib/lolcommits/plugins/lol_tumblr.rb
404
420
  - lib/lolcommits/plugins/lol_twitter.rb
405
421
  - lib/lolcommits/plugins/lol_yammer.rb
406
422
  - lib/lolcommits/plugins/lolsrv.rb
@@ -1,13 +0,0 @@
1
- GUIDELINES FOR CONTRIBUTING
2
-
3
- 1. Fork it
4
- 2. Create your feature branch (`git checkout -b my-new-feature`)
5
- 3. Commit your changes (`git commit -am 'Added some feature'`)
6
- 4. Push to the branch (`git push origin my-new-feature`)
7
- 5. Create new Pull Request
8
-
9
- You can run the existing test-suite via `rake`. Ensure nothing is broken, but since the test since is far from complete, it'd be awesome if you manually tested for regressions as well.
10
-
11
- Please, if at all possible, write a passing test for the functionality you added.
12
-
13
- The default rake task uses Rubocop on default settings to ensure Ruby Style Guidelines. If you want to run tests before conforming to this to verify functionality you can just run `rake test` and `rake features` manually.