lolcommits-lolsrv 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97f1e3ad3c3a635858ee9d6dd61305363e6a3decbf8f16933e54ae3234fa3682
4
- data.tar.gz: e966b7bb620479b861548dd96decabd9ad1933af9da1f28ca2143b9538a9aabc
3
+ metadata.gz: e484770b77744bf4d473e5acc417f44fe77f0b3d73c8b62fa03f6b331aa97a5b
4
+ data.tar.gz: 3bf0a9b9cf728e772f8f60e0d7d5a211931e5f046f80359fe96fb26182fc639f
5
5
  SHA512:
6
- metadata.gz: a445b31f7b9fef6f16eaa28cf6ba003760ff1171450ad1a7b9fe5b6b5da591045aa183b6affdd1c82ffe8ebb8d447e20d015974e996ee93edf09af48222c9d1a
7
- data.tar.gz: a2667b0723ec6c487a54d824cf076a4a8dba1732b62bd38a464b8a944fb145e08925f2e3aa815b462b9a04c1ae495164a6543198da809eef9f48e2c1ede90f36
6
+ metadata.gz: 756111ca246deffe418a4170e9421bd9bb4ce2e9dbfca831ba8b97119376576085137b3d1eef667027b2e24c6d719382a2e421a89cb8e78b38f12e96b61c7bd4
7
+ data.tar.gz: e208e42905eaf42a44a92799e812791d41b6f5889a5c1432c927a3cd9b13c530d732d83ef486a7b3eba7909ab9cf53c198879c17e67bdba43147185c82b023f9
@@ -2,13 +2,24 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- The format is based on [Keep a Changelog][KeepAChangelog] and this project
6
- adheres to [Semantic Versioning][Semver].
5
+ The format is based on [Keep a Changelog][KeepAChangelog] and this
6
+ project adheres to [Semantic Versioning][Semver].
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
10
  - Your contribution here!
11
11
 
12
+ ## [0.3.0] - 2019-05-19
13
+ ### Changed
14
+ - lolcommits gem is a runtime dependency
15
+ - Use `lolcommit_path` (instead of `main_image`)
16
+ - Requires at least lolcommits >= `0.14.2`
17
+ - Refactored test to use `TestConfiguration`
18
+ - Updated README
19
+
20
+ ### Removed
21
+ - Support for lolcommits < `0.14.2`
22
+
12
23
  ## [0.2.0] - 2019-04-24
13
24
  ### Removed
14
25
  - Support for Ruby < 2.3 (older rubies no longer supported)
@@ -61,7 +72,8 @@ adheres to [Semantic Versioning][Semver].
61
72
  ### Changed
62
73
  - Initial release
63
74
 
64
- [Unreleased]: https://github.com/lolcommits/lolcommits-lolsrv/compare/v0.2.0...HEAD
75
+ [Unreleased]: https://github.com/lolcommits/lolcommits-lolsrv/compare/v0.3.0...HEAD
76
+ [0.3.0]: https://github.com/lolcommits/lolcommits-lolsrv/compare/v0.2.0...v0.3.0
65
77
  [0.2.0]: https://github.com/lolcommits/lolcommits-lolsrv/compare/v0.1.1...v0.2.0
66
78
  [0.1.1]: https://github.com/lolcommits/lolcommits-lolsrv/compare/v0.1.0...v0.1.1
67
79
  [0.1.0]: https://github.com/lolcommits/lolcommits-lolsrv/compare/v0.0.7...v0.1.0
data/README.md CHANGED
@@ -1,35 +1,36 @@
1
1
  # Lolcommits Lolsrv
2
2
 
3
3
  [![Gem](https://img.shields.io/gem/v/lolcommits-lolsrv.svg?style=flat)](http://rubygems.org/gems/lolcommits-lolsrv)
4
- [![Travis](https://travis-ci.org/lolcommits/lolcommits-lolsrv.svg?branch=master)](https://travis-ci.org/lolcommits/lolcommits-lolsrv)
4
+ [![Travis](https://img.shields.io/travis/com/lolcommits/lolcommits-lolsrv/master.svg?style=flat)](https://travis-ci.com/lolcommits/lolcommits-lolsrv)
5
5
  [![Depfu](https://img.shields.io/depfu/lolcommits/lolcommits-lolsrv.svg?style=flat)](https://depfu.com/github/lolcommits/lolcommits-lolsrv)
6
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/309c4d765a49dddebbc9/maintainability)](https://codeclimate.com/github/lolcommits/lolcommits-lolsrv/maintainability)
7
7
  [![Test Coverage](https://api.codeclimate.com/v1/badges/309c4d765a49dddebbc9/test_coverage)](https://codeclimate.com/github/lolcommits/lolcommits-lolsrv/test_coverage)
8
8
 
9
- [lolcommits](https://lolcommits.github.io/) takes a snapshot with your webcam
10
- every time you git commit code, and archives a lolcat style image with it. Git
11
- blame has never been so much fun!
9
+ [lolcommits](https://lolcommits.github.io/) takes a snapshot with your
10
+ webcam every time you git commit code, and archives a lolcat style image
11
+ with it. Git blame has never been so much fun!
12
12
 
13
- This plugin syncs lolcommits to a remote server. After enabling, your next
14
- lolcommit will be uploaded, along with all existing lolcommits images that
15
- you've already captured. Syncing is then performed after each commit, only
16
- uploading images that have not already been synced.
13
+ This plugin syncs lolcommits to a remote server. After enabling, your
14
+ next lolcommit will be uploaded, along with all existing lolcommits that
15
+ you've already captured. Syncing is then performed after each commit,
16
+ only uploading files that have not already been synced.
17
17
 
18
- You configure the plugin by setting the base url of the remote server. The
19
- server must respond at these paths:
18
+ You configure the plugin by setting the base url of the remote server.
19
+ The server must respond at these paths:
20
20
 
21
21
  **GET /lols**
22
22
 
23
- Returns a JSON array of all lolcommits already synced. The commit `sha` is the
24
- only required JSON attribute (used to identify the already synced image).
23
+ Returns a JSON array of all lolcommits already synced. The commit `sha`
24
+ is the only required JSON attribute (used to identify the already synced
25
+ lolcommit).
25
26
 
26
27
  **POST /uplol**
27
28
 
28
29
  The following upload params are `multipart/form-data` encoded:
29
30
 
30
- * `lol` - captured lolcommit image file
31
+ * `lol` - captured lolcommit file
31
32
  * `url` - remote repository URL (with commit SHA appended)
32
- * `repo` - repository name e.g. mroth/lolcommits
33
+ * `repo` - repository name e.g. lolcommits/lolcommits
33
34
  * `date` - UTC date time for the commit (ISO8601)
34
35
  * `sha` - commit SHA
35
36
 
@@ -52,20 +53,20 @@ Then configure to enable it and set the server url:
52
53
  # set enabled to `true`
53
54
  # set the server base url (must begin with http(s)://)
54
55
 
55
- That's it! Provided the endpoints are responding correctly, your lolcommits will
56
- be synced to the remote server. To disable use:
56
+ That's it! Provided the endpoints are responding correctly, your
57
+ lolcommits will be synced to the remote server. To disable use:
57
58
 
58
59
  $ lolcommits --config -p lolsrv
59
60
  # and set enabled to `false`
60
61
 
61
62
  ## Development
62
63
 
63
- Check out this repo and run `bin/setup`, this will install all dependencies and
64
- generate docs. Run `bundle exec rake` to run all tests and generate a coverage
65
- report.
64
+ Check out this repo and run `bin/setup`, this will install all
65
+ dependencies and generate docs. Run `bundle exec rake` to run all tests
66
+ and generate a coverage report.
66
67
 
67
- You can also run `bin/console` for an interactive prompt that will allow you to
68
- experiment with the gem code.
68
+ You can also run `bin/console` for an interactive prompt that will allow
69
+ you to experiment with the gem code.
69
70
 
70
71
  ## Tests
71
72
 
@@ -87,20 +88,22 @@ a moment to check it hasn't been raised in the past (and possibly closed).
87
88
 
88
89
  ## Contributing
89
90
 
90
- Bug [reports](https://github.com/lolcommits/lolcommits-lolsrv/issues) and [pull
91
- requests](https://github.com/lolcommits/lolcommits-lolsrv/pulls) are welcome on
92
- GitHub.
91
+ Bug [reports](https://github.com/lolcommits/lolcommits-lolsrv/issues)
92
+ and [pull
93
+ requests](https://github.com/lolcommits/lolcommits-lolsrv/pulls) are
94
+ welcome on GitHub.
93
95
 
94
- When submitting pull requests, remember to add tests covering any new behaviour,
95
- and ensure all tests are passing on [Travis
96
- CI](https://travis-ci.org/lolcommits/lolcommits-lolsrv). Read the
96
+ When submitting pull requests, remember to add tests covering any new
97
+ behaviour, and ensure all tests are passing on [Travis
98
+ CI](https://travis-ci.com/lolcommits/lolcommits-lolsrv). Read the
97
99
  [contributing
98
100
  guidelines](https://github.com/lolcommits/lolcommits-lolsrv/blob/master/CONTRIBUTING.md)
99
101
  for more details.
100
102
 
101
- This project is intended to be a safe, welcoming space for collaboration, and
102
- contributors are expected to adhere to the [Contributor
103
- Covenant](http://contributor-covenant.org) code of conduct. See
103
+ This project is intended to be a safe, welcoming space for
104
+ collaboration, and contributors are expected to adhere to the
105
+ [Contributor Covenant](http://contributor-covenant.org) code of conduct.
106
+ See
104
107
  [here](https://github.com/lolcommits/lolcommits-lolsrv/blob/master/CODE_OF_CONDUCT.md)
105
108
  for more details.
106
109
 
@@ -111,7 +114,7 @@ The gem is available as open source under the terms of
111
114
 
112
115
  ## Links
113
116
 
114
- * [Travis CI](https://travis-ci.org/lolcommits/lolcommits-lolsrv)
117
+ * [Travis CI](https://travis-ci.com/lolcommits/lolcommits-lolsrv)
115
118
  * [Code Climate](https://codeclimate.com/github/lolcommits/lolcommits-lolsrv)
116
119
  * [Test Coverage](https://codeclimate.com/github/lolcommits/lolcommits-lolsrv/coverage)
117
120
  * [RDoc](http://rdoc.info/projects/lolcommits/lolcommits-lolsrv)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lolcommits
4
4
  module Lolsrv
5
- VERSION = "0.2.0".freeze
5
+ VERSION = "0.3.0".freeze
6
6
  end
7
7
  end
@@ -9,8 +9,8 @@ module Lolcommits
9
9
 
10
10
  ##
11
11
  # Returns true/false indicating if the plugin has been correctly
12
- # configured. The `server` option must be set with a URL beginning with
13
- # http(s)://
12
+ # configured. The `server` option must be set with a URL beginning
13
+ # with http(s)://
14
14
  #
15
15
  # @return [Boolean] true/false indicating if plugin is correctly
16
16
  # configured
@@ -34,9 +34,9 @@ module Lolcommits
34
34
  puts ''
35
35
  puts ' Handle POST /uplol with these request params'
36
36
  puts ''
37
- puts ' `lol` - captured lolcommit image file'
37
+ puts ' `lol` - captured lolcommit file'
38
38
  puts ' `url` - remote repository URL (with commit SHA appended)'
39
- puts ' `repo` - repository name e.g. mroth/lolcommits'
39
+ puts ' `repo` - repository name e.g. lolcommits/lolcommits'
40
40
  puts ' `date` - UTC date time for the commit (ISO8601)'
41
41
  puts ' `sha` - commit SHA'
42
42
  puts ''
@@ -53,8 +53,7 @@ module Lolcommits
53
53
  ##
54
54
  #
55
55
  # Post-capture hook, runs after lolcommits captures a snapshot.
56
- #
57
- # Syncs lolcommit images to the remote server (forked and detached)
56
+ # Syncs lolcommits to the remote server (forked and detached)
58
57
  #
59
58
  # @return [Integer] forked process id
60
59
  #
@@ -72,12 +71,12 @@ module Lolcommits
72
71
 
73
72
  ##
74
73
  #
75
- # Syncs lolcommmit images to the remote server
74
+ # Syncs lolcommmits to the remote server
76
75
  #
77
- # Fetches from /lols and iterates over shas in the JSON array. For each
78
- # image found in the local loldir folder, check if it has already been
79
- # uploaded. If not, upload the image with a POST request and
80
- # upload_params.
76
+ # Fetches from /lols and iterates over shas in the JSON array. For
77
+ # each file found in the local loldir folder, check if it has
78
+ # already been uploaded. If not, upload the file with a POST
79
+ # request and upload_params.
81
80
  #
82
81
  # Upload requests that fail abort the sync.
83
82
  #
@@ -85,11 +84,13 @@ module Lolcommits
85
84
  print "Syncing lols ... "
86
85
  raise 'failed fetching existing lols' unless existing_shas
87
86
 
88
- Dir[runner.config.loldir + '/*.{jpg,gif}'].each do |image|
89
- sha = File.basename(image, '.*')
90
- unless existing_shas.include?(sha) || sha == 'tmp_snapshot'
91
- response = upload(image, sha)
92
- raise "failed uploading #{image}" if response.nil?
87
+ # puts runner.config.loldir
88
+
89
+ Dir[runner.config.loldir + '/*.{jpg,mp4,gif}'].each do |lolcommit|
90
+ sha = File.basename(lolcommit, '.*')
91
+ unless existing_shas.include?(sha)
92
+ response = upload(lolcommit, sha)
93
+ raise "failed uploading #{lolcommit}" if response.nil?
93
94
  end
94
95
  end
95
96
 
@@ -101,8 +102,9 @@ module Lolcommits
101
102
 
102
103
  ##
103
104
  #
104
- # Fetch and parse JSON response from `server/lols`, returning an array of
105
- # commit SHA's. Logs and returns nil on NET/HTTP and JSON parsing errors.
105
+ # Fetch and parse JSON response from `server/lols`, returning an
106
+ # array of commit SHA's. Logs and returns nil on NET/HTTP and JSON
107
+ # parsing errors.
106
108
  #
107
109
  # @return [Array] containing commit SHA's
108
110
  # @return [Nil] if an error occurred
@@ -119,13 +121,13 @@ module Lolcommits
119
121
 
120
122
  ##
121
123
  #
122
- # Upload the lolcommit image to `server/uplol` with commit params. Logs
123
- # and returns nil on NET/HTTP errors.
124
+ # Upload the lolcommit file to `server/uplol` with commit params.
125
+ # Logs and returns nil on NET/HTTP errors.
124
126
  #
125
127
  # @return [RestClient::Response] response object from POST request
126
128
  #
127
- def upload(image, sha)
128
- RestClient.post(upload_endpoint, upload_params_for(image, sha))
129
+ def upload(file, sha)
130
+ RestClient.post(upload_endpoint, upload_params_for(file, sha))
129
131
  rescue SocketError, RestClient::RequestFailed => e
130
132
  log_error(e, "ERROR: Upload of lol #{sha} to #{upload_endpoint} FAILED #{e.class} - #{e.message}")
131
133
  nil
@@ -133,20 +135,20 @@ module Lolcommits
133
135
 
134
136
  ##
135
137
  #
136
- # Hash of params to send with lolcommit upload. Built from repositiory and
137
- # commit info.
138
+ # Hash of params to send with lolcommit upload. Built from
139
+ # repositiory and commit info.
138
140
  #
139
- # `lol` - captured lolcommit image file
141
+ # `lol` - captured lolcommit file
140
142
  # `url` - remote repository URL (with commit SHA appended)
141
- # `repo` - repository name e.g. mroth/lolcommits
143
+ # `repo` - repository name e.g. lolcommits/lolcommits
142
144
  # `date` - UTC date time for the commit (ISO8601)
143
145
  # `sha` - commit SHA
144
146
  #
145
147
  # @return [Hash]
146
148
  #
147
- def upload_params_for(image, sha)
149
+ def upload_params_for(file, sha)
148
150
  params = {
149
- lol: File.new(image),
151
+ lol: File.new(file),
150
152
  repo: runner.vcs_info.repo,
151
153
  date: runner.vcs_info.commit_date.iso8601,
152
154
  sha: sha
@@ -171,9 +173,9 @@ module Lolcommits
171
173
 
172
174
  ##
173
175
  #
174
- # Endpoint requested for GET-ing lolcommits. It must return a JSON array
175
- # of all lols already uploaded, the commit `sha` is the only required JSON
176
- # attribute.
176
+ # Endpoint requested for GET-ing lolcommits. It must return a JSON
177
+ # array of all lols already uploaded, the commit `sha` is the only
178
+ # required JSON attribute.
177
179
  #
178
180
  # @return [String] `server` config option + '/lols'
179
181
  #
@@ -9,30 +9,23 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ["matt@hiddenloop.com"]
10
10
  spec.summary = %q{Sync lolcommits to a remote server}
11
11
  spec.homepage = "https://github.com/lolcommits/lolcommits-lolsrv"
12
- spec.license = "LGPL-3"
12
+ spec.license = "LGPL-3.0"
13
13
 
14
14
  spec.description = <<-DESC
15
- Sync lolcommits to a remote server. After enabling, your next lolcommit will
16
- be uploaded, along with all existing lolcommits images that you've already
17
- captured. Each lolcommit is then sync'd after capturing.
15
+ Sync lolcommits to a remote server. After enabling, your next
16
+ lolcommit will be uploaded, along with all existing lolcommits images
17
+ that you've already captured. Each lolcommit is then sync'd after
18
+ capturing.
18
19
  DESC
19
20
 
20
21
  spec.metadata = {
21
- "homepage_uri" => "https://github.com/lolcommits/lolcommits-lolsrv",
22
- "changelog_uri" => "https://github.com/lolcommits/lolcommits-lolsrv/blob/master/CHANGELOG.md",
23
- "source_code_uri" => "https://github.com/lolcommits/lolcommits-lolsrv",
24
- "bug_tracker_uri" => "https://github.com/lolcommits/lolcommits-lolsrv/issues",
22
+ "homepage_uri" => "https://github.com/lolcommits/lolcommits-lolsrv",
23
+ "changelog_uri" => "https://github.com/lolcommits/lolcommits-lolsrv/blob/master/CHANGELOG.md",
24
+ "source_code_uri" => "https://github.com/lolcommits/lolcommits-lolsrv",
25
+ "bug_tracker_uri" => "https://github.com/lolcommits/lolcommits-lolsrv/issues",
26
+ "allowed_push_host" => "https://rubygems.org"
25
27
  }
26
28
 
27
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
28
- # to allow pushing to a single host or delete this section to allow pushing to any host.
29
- if spec.respond_to?(:metadata)
30
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
31
- else
32
- raise "RubyGems 2.0 or newer is required to protect against " \
33
- "public gem pushes."
34
- end
35
-
36
29
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(assets|test|features)/}) }
37
30
  spec.test_files = `git ls-files -- {test,features}/*`.split("\n")
38
31
  spec.bindir = "bin"
@@ -42,8 +35,8 @@ Gem::Specification.new do |spec|
42
35
  spec.required_ruby_version = ">= 2.3"
43
36
 
44
37
  spec.add_runtime_dependency "rest-client"
38
+ spec.add_runtime_dependency "lolcommits", ">= 0.14.2"
45
39
 
46
- spec.add_development_dependency "lolcommits", ">= 0.12.0"
47
40
  spec.add_development_dependency "bundler"
48
41
  spec.add_development_dependency "webmock"
49
42
  spec.add_development_dependency "pry"
@@ -12,10 +12,8 @@ describe Lolcommits::Plugin::Lolsrv do
12
12
  def runner
13
13
  # a simple lolcommits runner with an empty configuration Hash
14
14
  @runner ||= Lolcommits::Runner.new(
15
- main_image: Tempfile.new('main_image.jpg'),
16
- config: OpenStruct.new(
17
- loldir: File.expand_path("#{__dir__}../../../images")
18
- )
15
+ lolcommit_path: Tempfile.new('lolcommit.jpg'),
16
+ config: TestConfiguration.new(OpenStruct.new)
19
17
  )
20
18
  end
21
19
 
@@ -56,7 +54,8 @@ describe Lolcommits::Plugin::Lolsrv do
56
54
  stub_request(:get, "https://lolsrv.com/lols").
57
55
  to_return(status: 200, body: [{ sha: existing_sha }].to_json)
58
56
 
59
- stub_request(:post, "https://lolsrv.com/uplol").to_return(status: 200)
57
+ stub_request(:post, "https://lolsrv.com/uplol").
58
+ to_return(status: 200)
60
59
 
61
60
  output = fake_io_capture do
62
61
  plugin.run_capture_ready(do_fork: false)
@@ -118,3 +117,9 @@ describe Lolcommits::Plugin::Lolsrv do
118
117
  end
119
118
  end
120
119
  end
120
+
121
+ class TestConfiguration < Lolcommits::Configuration
122
+ def loldir
123
+ @loldir ||= File.expand_path("#{__dir__}../../../images")
124
+ end
125
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolcommits-lolsrv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Hutchinson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-24 00:00:00.000000000 Z
11
+ date: 2019-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.12.0
34
- type: :development
33
+ version: 0.14.2
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.12.0
40
+ version: 0.14.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -123,9 +123,10 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  description: |2
126
- Sync lolcommits to a remote server. After enabling, your next lolcommit will
127
- be uploaded, along with all existing lolcommits images that you've already
128
- captured. Each lolcommit is then sync'd after capturing.
126
+ Sync lolcommits to a remote server. After enabling, your next
127
+ lolcommit will be uploaded, along with all existing lolcommits images
128
+ that you've already captured. Each lolcommit is then sync'd after
129
+ capturing.
129
130
  email:
130
131
  - matt@hiddenloop.com
131
132
  executables: []
@@ -155,7 +156,7 @@ files:
155
156
  - test/test_helper.rb
156
157
  homepage: https://github.com/lolcommits/lolcommits-lolsrv
157
158
  licenses:
158
- - LGPL-3
159
+ - LGPL-3.0
159
160
  metadata:
160
161
  homepage_uri: https://github.com/lolcommits/lolcommits-lolsrv
161
162
  changelog_uri: https://github.com/lolcommits/lolcommits-lolsrv/blob/master/CHANGELOG.md