pushybullet 0.1.1 → 0.1.2

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: eb9f14cc25a605fa81f01e30057db0e23cb2408e2e0b55154e6a71f9c458786e
4
- data.tar.gz: 6b576942ce2c85bd4116458f289aab1320c60481813aee46a957572946a712da
3
+ metadata.gz: 169778e7ef203599479b119c582ca0c6b4dc7ec6baf563d058ab47a9ca525c2f
4
+ data.tar.gz: a88193e8e7310d3b577858573a403355fd40d96582b9cc0d3780828c0486345e
5
5
  SHA512:
6
- metadata.gz: a81f59b2e5fa62da009bab4b04008692dba2331b98813481f3688890b57a1dac0b7a566c5439302011b749cc9ad8fd8c31785ebd1dfc3da3ae0e704065f0777f
7
- data.tar.gz: '083bdc8b7de67f786a88fd9c08babb3ccbcfa1637eea42b523d737227f95af21d6d9e3bf93d73dc7d5544b3ff7dae0da77093d6b4490387c7a122b0db18bf408'
6
+ metadata.gz: 5c3d586bd928430d8fe3a1d2f9eccf327cd0c9e970b81f50b986f23ad06e366ad9a4d3778484b3dd8267972aa9d9f70d9a11c33ed736de75699262c93a0efe93
7
+ data.tar.gz: f7ef362d45a01a9511edfa52e5a87d58daaa62c24f3c5a705eb726c596b9e47ebb9fbe0ce52fc1cc45d411f741171384dc64c07c5db0abf9974b27ef708530db
@@ -0,0 +1,30 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Build and test
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+ name: Build + Test
19
+ runs-on: ubuntu-latest
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: 2.6.6
27
+ - name: Install dependencies
28
+ run: bundle install
29
+ - name: Run tests
30
+ run: bundle exec rake
@@ -0,0 +1,41 @@
1
+ name: Push gem
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v*
7
+
8
+ jobs:
9
+ build:
10
+ name: Build + Publish
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Set up Ruby 2.6
16
+ uses: actions/setup-ruby@v1
17
+ with:
18
+ ruby-version: 2.6.6
19
+
20
+ - name: Publish to GPR
21
+ run: |
22
+ mkdir -p $HOME/.gem
23
+ touch $HOME/.gem/credentials
24
+ chmod 0600 $HOME/.gem/credentials
25
+ printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
26
+ gem build *.gemspec
27
+ gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
28
+ env:
29
+ GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
30
+ OWNER: ${{ github.repository_owner }}
31
+
32
+ - name: Publish to RubyGems
33
+ run: |
34
+ mkdir -p $HOME/.gem
35
+ touch $HOME/.gem/credentials
36
+ chmod 0600 $HOME/.gem/credentials
37
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
38
+ gem build *.gemspec
39
+ gem push *.gem
40
+ env:
41
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
@@ -11,4 +11,12 @@ inherit_from: .rubocop_todo.yml
11
11
  #
12
12
  # See https://docs.rubocop.org/rubocop/configuration
13
13
  AllCops:
14
- NewCops: enable
14
+ NewCops: enable
15
+
16
+ Metrics/BlockLength:
17
+ Exclude:
18
+ - 'spec/**/*'
19
+
20
+ Style/Documentation:
21
+ Exclude:
22
+ - 'spec/**/*'
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-11-17 17:08:45 UTC using RuboCop version 1.3.1.
3
+ # on 2020-11-18 18:57:39 UTC using RuboCop version 1.3.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.1.2] - 2020-11-18
10
+ ### Added
11
+ - Added PushRequest type
12
+
13
+ ### Fixed
14
+ - Fixed bug where unhandled http errors were being suppressed
15
+
9
16
  ## [0.1.1] - 2020-11-18
10
17
  ### Added
11
18
  - Added changelog
@@ -1,70 +1,70 @@
1
- PATH
2
- remote: .
3
- specs:
4
- pushybullet (0.1.1)
5
- faraday (~> 1.1.0)
6
- faraday_middleware (~> 1.0.0)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- ast (2.4.1)
12
- diff-lcs (1.4.4)
13
- docile (1.3.2)
14
- faraday (1.1.0)
15
- multipart-post (>= 1.2, < 3)
16
- ruby2_keywords
17
- faraday_middleware (1.0.0)
18
- faraday (~> 1.0)
19
- multipart-post (2.1.1)
20
- parallel (1.20.0)
21
- parser (2.7.2.0)
22
- ast (~> 2.4.1)
23
- rainbow (3.0.0)
24
- rake (12.3.3)
25
- regexp_parser (1.8.2)
26
- rexml (3.2.4)
27
- rspec (3.10.0)
28
- rspec-core (~> 3.10.0)
29
- rspec-expectations (~> 3.10.0)
30
- rspec-mocks (~> 3.10.0)
31
- rspec-core (3.10.0)
32
- rspec-support (~> 3.10.0)
33
- rspec-expectations (3.10.0)
34
- diff-lcs (>= 1.2.0, < 2.0)
35
- rspec-support (~> 3.10.0)
36
- rspec-mocks (3.10.0)
37
- diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.10.0)
39
- rspec-support (3.10.0)
40
- rubocop (1.3.1)
41
- parallel (~> 1.10)
42
- parser (>= 2.7.1.5)
43
- rainbow (>= 2.2.2, < 4.0)
44
- regexp_parser (>= 1.8)
45
- rexml
46
- rubocop-ast (>= 1.1.1)
47
- ruby-progressbar (~> 1.7)
48
- unicode-display_width (>= 1.4.0, < 2.0)
49
- rubocop-ast (1.1.1)
50
- parser (>= 2.7.1.5)
51
- ruby-progressbar (1.10.1)
52
- ruby2_keywords (0.0.2)
53
- simplecov (0.19.1)
54
- docile (~> 1.1)
55
- simplecov-html (~> 0.11)
56
- simplecov-html (0.12.3)
57
- unicode-display_width (1.7.0)
58
-
59
- PLATFORMS
60
- x64-mingw32
61
-
62
- DEPENDENCIES
63
- pushybullet!
64
- rake (~> 12.0)
65
- rspec (~> 3.0)
66
- rubocop (~> 1.3)
67
- simplecov (~> 0.19)
68
-
69
- BUNDLED WITH
70
- 2.1.4
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pushybullet (0.1.2)
5
+ faraday (~> 1.1.0)
6
+ faraday_middleware (~> 1.0.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.1)
12
+ diff-lcs (1.4.4)
13
+ docile (1.3.2)
14
+ faraday (1.1.0)
15
+ multipart-post (>= 1.2, < 3)
16
+ ruby2_keywords
17
+ faraday_middleware (1.0.0)
18
+ faraday (~> 1.0)
19
+ multipart-post (2.1.1)
20
+ parallel (1.20.0)
21
+ parser (2.7.2.0)
22
+ ast (~> 2.4.1)
23
+ rainbow (3.0.0)
24
+ rake (12.3.3)
25
+ regexp_parser (1.8.2)
26
+ rexml (3.2.4)
27
+ rspec (3.10.0)
28
+ rspec-core (~> 3.10.0)
29
+ rspec-expectations (~> 3.10.0)
30
+ rspec-mocks (~> 3.10.0)
31
+ rspec-core (3.10.0)
32
+ rspec-support (~> 3.10.0)
33
+ rspec-expectations (3.10.0)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.10.0)
36
+ rspec-mocks (3.10.0)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.10.0)
39
+ rspec-support (3.10.0)
40
+ rubocop (1.3.1)
41
+ parallel (~> 1.10)
42
+ parser (>= 2.7.1.5)
43
+ rainbow (>= 2.2.2, < 4.0)
44
+ regexp_parser (>= 1.8)
45
+ rexml
46
+ rubocop-ast (>= 1.1.1)
47
+ ruby-progressbar (~> 1.7)
48
+ unicode-display_width (>= 1.4.0, < 2.0)
49
+ rubocop-ast (1.1.1)
50
+ parser (>= 2.7.1.5)
51
+ ruby-progressbar (1.10.1)
52
+ ruby2_keywords (0.0.2)
53
+ simplecov (0.19.1)
54
+ docile (~> 1.1)
55
+ simplecov-html (~> 0.11)
56
+ simplecov-html (0.12.3)
57
+ unicode-display_width (1.7.0)
58
+
59
+ PLATFORMS
60
+ x64-mingw32
61
+
62
+ DEPENDENCIES
63
+ pushybullet!
64
+ rake (~> 12.0)
65
+ rspec (~> 3.0)
66
+ rubocop (~> 1.3)
67
+ simplecov (~> 0.19)
68
+
69
+ BUNDLED WITH
70
+ 2.1.4
data/README.md CHANGED
@@ -2,10 +2,6 @@
2
2
 
3
3
  A ruby gem for pushbullet.
4
4
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pushybullet`. To experiment with that code, run `bin/console` for an interactive prompt.
6
-
7
- TODO: Delete this and the text above, and describe your gem
8
-
9
5
  ## Installation
10
6
 
11
7
  Add this line to your application's Gemfile:
@@ -34,7 +30,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
34
30
 
35
31
  ## Contributing
36
32
 
37
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pushybullet. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/arcticfoxnv/pushybullet/blob/master/CODE_OF_CONDUCT.md).
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/arcticfoxnv/pushybullet-gem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/arcticfoxnv/pushybullet-gem/blob/master/CODE_OF_CONDUCT.md).
38
34
 
39
35
 
40
36
  ## License
@@ -43,4 +39,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
43
39
 
44
40
  ## Code of Conduct
45
41
 
46
- Everyone interacting in the Pushybullet project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/arcticfoxnv/pushybullet/blob/master/CODE_OF_CONDUCT.md).
42
+ Everyone interacting in the Pushybullet project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/arcticfoxnv/pushybullet-gem/blob/master/CODE_OF_CONDUCT.md).
@@ -23,29 +23,29 @@ module Pushybullet
23
23
  devs
24
24
  end
25
25
 
26
- def create_push(push)
27
- payload = JSON.dump(push.to_hash)
26
+ def create_push(push_request)
27
+ payload = JSON.dump(push_request.to_hash)
28
28
  resp = conn.post('v2/pushes', payload, 'Content-Type' => 'application/json')
29
29
  Pushybullet::Types::Push.from_hash(resp.body)
30
30
  end
31
31
 
32
32
  def push_link(title, body, url, target)
33
- push = Pushybullet::Types::Push.from_hash({
34
- type: :link,
35
- title: title,
36
- body: body,
37
- url: url
38
- })
33
+ push = Pushybullet::Types::PushRequest.from_hash({
34
+ type: :link,
35
+ title: title,
36
+ body: body,
37
+ url: url
38
+ })
39
39
  push.target = target
40
40
  create_push(push)
41
41
  end
42
42
 
43
43
  def push_note(title, body, target)
44
- push = Pushybullet::Types::Push.from_hash({
45
- type: :note,
46
- title: title,
47
- body: body
48
- })
44
+ push = Pushybullet::Types::PushRequest.from_hash({
45
+ type: :note,
46
+ title: title,
47
+ body: body
48
+ })
49
49
  push.target = target
50
50
  create_push(push)
51
51
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Pushybullet
2
4
  module Concerns
3
5
  module FromHash
@@ -8,18 +8,27 @@ module Pushybullet
8
8
  protected
9
9
 
10
10
  def exc_msg_and_response(exc, response = nil)
11
- headers = response[:headers]
11
+ headers = response_headers exc, response
12
12
 
13
13
  if headers['Content-Type'] =~ /\bjson$/
14
14
  err = JSON.parse(response[:body])
15
- @type = err[:error][:type]
16
- @message = err[:error][:message]
17
- @cat = err[:error][:cat]
15
+ @type = err['error']['type']
16
+ @message = err['error']['message']
17
+ @cat = err['error']['cat']
18
18
  end
19
19
 
20
20
  super
21
21
  end
22
+
23
+ def response_headers(exc, response = nil)
24
+ if response.nil? && exc.respond_to?(:each_key)
25
+ exc[:headers]
26
+ else
27
+ response[:headers]
28
+ end
29
+ end
22
30
  end
31
+
23
32
  class Unauthorized < ClientError; end
24
33
  class Forbidden < ClientError; end
25
34
  class TooManyRequests < ClientError; end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'pushybullet/errors'
4
+
3
5
  module Pushybullet
4
6
  module Middleware
5
7
  class Error < Faraday::Response::RaiseError
@@ -11,6 +13,8 @@ module Pushybullet
11
13
  raise Errors::Forbidden, response_values(env)
12
14
  when 429
13
15
  raise Errors::TooManyRequests, response_values(env)
16
+ else
17
+ super
14
18
  end
15
19
  end
16
20
  end
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'types/device'
2
4
  require_relative 'types/push'
5
+ require_relative 'types/push_request'
3
6
  require_relative 'types/push_target'
4
7
 
5
8
  module Pushybullet
@@ -6,7 +6,6 @@ module Pushybullet
6
6
  module Types
7
7
  class Push
8
8
  extend Pushybullet::Concerns::FromHash
9
- include Pushybullet::Concerns::ToHash
10
9
 
11
10
  # strings
12
11
  attr_accessor :iden, :type, :guid, :direction,
@@ -26,10 +25,6 @@ module Pushybullet
26
25
 
27
26
  # ints
28
27
  attr_accessor :image_width, :image_height
29
-
30
- def target=(target)
31
- instance_variable_set("@#{target.key}", target.value) unless target.nil?
32
- end
33
28
  end
34
29
  end
35
30
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pushybullet/concerns'
4
+
5
+ module Pushybullet
6
+ module Types
7
+ class PushRequest
8
+ include Pushybullet::Concerns::FromHash
9
+ include Pushybullet::Concerns::ToHash
10
+
11
+ # strings
12
+ attr_accessor :type, :title, :body, :url, :file_name, :file_type, :file_url,
13
+ :source_device_iden, :device_iden, :client_iden, :channel_tag,
14
+ :email, :guid
15
+
16
+ def target=(target)
17
+ instance_variable_set("@#{target.key}", target.value) unless target.nil?
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Pushybullet
2
4
  module Types
3
5
  class PushTarget
4
6
  ID_TYPES = {
5
- device: 'device_iden',
6
- email: 'email',
7
7
  channel: 'channel_tag',
8
- client: 'client_iden'
8
+ client: 'client_iden',
9
+ device: 'device_iden',
10
+ email: 'email'
9
11
  }.freeze
10
12
 
11
13
  def initialize(type, id)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pushybullet
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushybullet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick King
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-18 00:00:00.000000000 Z
11
+ date: 2020-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -45,6 +45,8 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".github/workflows/build_and_test.yml"
49
+ - ".github/workflows/push_gem.yml"
48
50
  - ".gitignore"
49
51
  - ".rspec"
50
52
  - ".rubocop.yml"
@@ -67,6 +69,7 @@ files:
67
69
  - lib/pushybullet/types.rb
68
70
  - lib/pushybullet/types/device.rb
69
71
  - lib/pushybullet/types/push.rb
72
+ - lib/pushybullet/types/push_request.rb
70
73
  - lib/pushybullet/types/push_target.rb
71
74
  - lib/pushybullet/version.rb
72
75
  - pushybullet.gemspec