bitly 2.0.1 → 2.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33a5d90e877bdac9ea6991afe188e198302be52327b36dd4ee7fc99970b23b2d
4
- data.tar.gz: 46dd90271942653821d355f3c670237593f492f7d9a3c57562c2057189b332ff
3
+ metadata.gz: e0a2dd617bd9c23263a1db205f8ea95359c34273df7eecc5ca9565536a03c802
4
+ data.tar.gz: 4f0dac7f35a238a61b9ec36390df824170b576f15e8f111203bf83a8f600993d
5
5
  SHA512:
6
- metadata.gz: 8ddc083e1ad6b75fb88772688e70c8d9d65c221d6d8744f637ba05cd8b5b00fbf864847ba4b29d61e2f904e1315d0f3086b0f6e3338fc3d6d20ef5e13c769bc1
7
- data.tar.gz: 249edc58187a0c701e8fbc337e80aaa89361b3115816394b48e22a194070a7f472a382ebbabc1bcb964cffac9abd4300b4e2b006b8cf7ed14a505f0ac634301e
6
+ metadata.gz: cc10e4a46caeb7155292380f8c61feec74cf19ce9da36ee49c9b7dbff763b5c4703b58c9e2ded557cfb6426fa7f68532914a49350bc9f5e4f8c25a57ff7d3e82
7
+ data.tar.gz: 1935c386fc1d489a532de2459222f9a069a3a6f0a258d58178c16694e131d8be246226464fe1f2f83a40db1c333c0422d1c60905c0ec1dfb23492ae927db2c93
@@ -0,0 +1 @@
1
+ github: philnash
@@ -0,0 +1,34 @@
1
+ on:
2
+ push:
3
+ branches:
4
+ - main
5
+ pull_request:
6
+ types: [opened, synchronize, reopened]
7
+ name: SonarCloud Analysis
8
+ jobs:
9
+ sonarcloud:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ with:
14
+ # Disabling shallow clone is recommended for improving relevancy of reporting
15
+ fetch-depth: 0
16
+ - name: Set up Ruby ${{ matrix.ruby }}
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: "3.1"
20
+ - name: "Install dependencies"
21
+ run: bundle install
22
+ - name: Run tests for coverage
23
+ run: bundle exec rspec
24
+ env:
25
+ COVERAGE: json
26
+ - name: fix code coverage paths
27
+ working-directory: ./coverage
28
+ run: |
29
+ sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.json
30
+ - name: SonarCloud Scan
31
+ uses: sonarsource/sonarcloud-github-action@master
32
+ env:
33
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
@@ -0,0 +1,22 @@
1
+ name: tests
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby: [2.5, 2.6, 2.7, "3.0", 3.1, head]
12
+ continue-on-error: ${{ endsWith(matrix.ruby, 'head') }}
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Set up Ruby ${{ matrix.ruby }}
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: ${{ matrix.ruby }}
19
+ - name: "Install dependencies"
20
+ run: bundle install
21
+ - name: Run tests
22
+ run: bundle exec rspec
data/History.txt CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ...
4
4
 
5
+ === 2.1.0 / 2022-10-21
6
+
7
+ * Strips protocol from the start of a bitlink when fetching/expanding (fixes #80)
8
+ * Adds SonarCloud quality check GitHub Action
9
+ * Uses verifying doubles in tests over generic doubles
10
+
11
+ === 2.0.2 / 2022-10-18
12
+
13
+ * Allows oauth2 gem version 2
14
+
5
15
  === 2.0.1 / 2020-06-18
6
16
 
7
17
  * Fixes sending parameters in ClicksSummary (thanks @CodingFu)
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A Ruby gem for using the version 4 [Bitly API](https://dev.bitly.com/) to shorten links, expand short links and view metrics across users, links and organizations.
4
4
 
5
- [![Gem Version](https://badge.fury.io/rb/bitly.svg)](https://rubygems.org/gems/bitly) [![Build Status](https://travis-ci.org/philnash/bitly.svg?branch=master)](https://travis-ci.org/philnash/bitly) [![Maintainability](https://api.codeclimate.com/v1/badges/f8e078b468c1f2aeca53/maintainability)](https://codeclimate.com/github/philnash/bitly/maintainability) [![Inline docs](https://inch-ci.org/github/philnash/bitly.svg?branch=master)](https://inch-ci.org/github/philnash/bitly)
5
+ [![Gem version](https://badge.fury.io/rb/bitly.svg)](https://rubygems.org/gems/bitly) ![Build status](https://github.com/philnash/bitly/workflows/tests/badge.svg) [![Maintainability](https://api.codeclimate.com/v1/badges/f8e078b468c1f2aeca53/maintainability)](https://codeclimate.com/github/philnash/bitly/maintainability) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=philnash_bitly&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=philnash_bitly) [![Inline docs](https://inch-ci.org/github/philnash/bitly.svg?branch=master)](https://inch-ci.org/github/philnash/bitly)
6
6
 
7
7
  * [Installation](#installation)
8
8
  * [Usage](#usage)
data/bitly.gemspec CHANGED
@@ -30,12 +30,13 @@ Gem::Specification.new do |spec|
30
30
 
31
31
  spec.required_ruby_version = ">= 2.3.0"
32
32
 
33
- spec.add_runtime_dependency "oauth2", "< 2.0", ">= 0.5.0"
33
+ spec.add_runtime_dependency "oauth2", "< 2.1", ">= 0.5.0"
34
34
 
35
35
  spec.add_development_dependency "bundler", "~> 2.0"
36
36
  spec.add_development_dependency "rake", "~> 13.0"
37
37
  spec.add_development_dependency "rspec", "~> 3.0"
38
- spec.add_development_dependency "simplecov", "~> 0.17.1"
38
+ spec.add_development_dependency "simplecov", "~> 0.21"
39
+ spec.add_development_dependency "simplecov_json_formatter", "~> 0.1"
39
40
  spec.add_development_dependency "webmock", "~> 3.7.6"
40
41
  spec.add_development_dependency "vcr"
41
42
  spec.add_development_dependency "envyable"
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  require_relative "../base"
3
+ require_relative "./utils"
3
4
 
4
5
  module Bitly
5
6
  module API
@@ -8,6 +9,7 @@ module Bitly
8
9
  include Base
9
10
 
10
11
  def self.fetch(client:, bitlink:, unit: nil, units: nil, unit_reference: nil, size: nil)
12
+ bitlink = Utils.normalise_bitlink(bitlink: bitlink)
11
13
  response = client.request(
12
14
  path: "/bitlinks/#{bitlink}/clicks/summary",
13
15
  params: {
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
  require "time"
3
3
  require_relative "../base"
4
- require_relative '../list'
4
+ require_relative "../list"
5
+ require_relative "./utils"
5
6
 
6
7
  module Bitly
7
8
  module API
@@ -38,6 +39,7 @@ module Bitly
38
39
  #
39
40
  # @return [Bitly::API::Bitlink::LinkClick::List]
40
41
  def self.list(client:, bitlink:, unit: nil, units: nil, size: nil, unit_reference: nil)
42
+ bitlink = Utils.normalise_bitlink(bitlink: bitlink)
41
43
  response = client.request(
42
44
  path: "/bitlinks/#{bitlink}/clicks",
43
45
  params: {
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bitly
4
+ module API
5
+ class Bitlink
6
+ module Utils
7
+ def self.normalise_bitlink(bitlink:)
8
+ bitlink.gsub(/^https?:\/\//, "")
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  require_relative "./base"
3
3
  require_relative "./list"
4
+ require_relative "./bitlink/utils"
4
5
 
5
6
  module Bitly
6
7
  module API
@@ -90,6 +91,7 @@ module Bitly
90
91
  #
91
92
  # @return [Bitly::API::Bitlink]
92
93
  def self.fetch(client:, bitlink:)
94
+ bitlink = Utils.normalise_bitlink(bitlink: bitlink)
93
95
  response = client.request(path: "/bitlinks/#{bitlink}")
94
96
  new(data: response.body, client: client, response: response)
95
97
  end
@@ -106,6 +108,7 @@ module Bitly
106
108
  #
107
109
  # @return [Bitly::API::Bitlink]
108
110
  def self.expand(client:, bitlink:)
111
+ bitlink = Utils.normalise_bitlink(bitlink: bitlink)
109
112
  response = client.request(path: "/expand", method: "POST", params: { "bitlink_id" => bitlink })
110
113
  new(data: response.body, client: client, response: response)
111
114
  end
@@ -241,6 +244,7 @@ module Bitly
241
244
 
242
245
  def initialize(data:, client:, response: nil, clicks: nil)
243
246
  assign_attributes(data)
247
+ @id = Utils.normalise_bitlink(bitlink: @id)
244
248
  if data["deeplinks"]
245
249
  @deeplinks = data["deeplinks"].map { |data| Deeplink.new(data: data) }
246
250
  else
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
  require "time"
3
3
  require_relative "./base"
4
- require_relative './list'
4
+ require_relative "./list"
5
+ require_relative "./bitlink/utils"
5
6
 
6
7
  module Bitly
7
8
  module API
@@ -88,6 +89,7 @@ module Bitly
88
89
  end
89
90
 
90
91
  def self.list_referrers(client:, bitlink:, unit: nil, units: nil, size: nil, unit_reference: nil)
92
+ bitlink = Bitlink::Utils.normalise_bitlink(bitlink: bitlink)
91
93
  list_metrics(
92
94
  client: client,
93
95
  path: "/bitlinks/#{bitlink}/referrers",
@@ -99,6 +101,7 @@ module Bitly
99
101
  end
100
102
 
101
103
  def self.list_countries_by_bitlink(client:, bitlink:, unit: nil, units: nil, size: nil, unit_reference: nil)
104
+ bitlink = Bitlink::Utils.normalise_bitlink(bitlink: bitlink)
102
105
  list_metrics(
103
106
  client: client,
104
107
  path: "/bitlinks/#{bitlink}/countries",
@@ -110,6 +113,7 @@ module Bitly
110
113
  end
111
114
 
112
115
  def self.list_referring_domains(client:, bitlink:, unit: nil, units: nil, size: nil, unit_reference: nil)
116
+ bitlink = Bitlink::Utils.normalise_bitlink(bitlink: bitlink)
113
117
  list_metrics(
114
118
  client: client,
115
119
  path: "/bitlinks/#{bitlink}/referring_domains",
@@ -121,6 +125,7 @@ module Bitly
121
125
  end
122
126
 
123
127
  def self.list_referrers_by_domain(client:, bitlink:, unit: nil, units: nil, size: nil, unit_reference: nil)
128
+ bitlink = Bitlink::Utils.normalise_bitlink(bitlink: bitlink)
124
129
  response = client.request(
125
130
  path: "/bitlinks/#{bitlink}/referrers_by_domains",
126
131
  params: {
data/lib/bitly/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bitly
4
- VERSION = "2.0.1"
4
+ VERSION = "2.1.0"
5
5
  end
@@ -0,0 +1,6 @@
1
+ sonar.organization=philnash
2
+ sonar.projectKey=philnash_bitly
3
+
4
+ sonar.sources=lib
5
+ sonar.tests=spec
6
+ sonar.ruby.coverage.reportPaths=coverage/coverage.json
metadata CHANGED
@@ -1,35 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitly
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phil Nash
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-18 00:00:00.000000000 Z
11
+ date: 2022-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
+ - - "<"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.1'
17
20
  - - ">="
18
21
  - !ruby/object:Gem::Version
19
22
  version: 0.5.0
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '2.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
+ - - "<"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.1'
27
30
  - - ">="
28
31
  - !ruby/object:Gem::Version
29
32
  version: 0.5.0
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '2.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -78,14 +78,28 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: 0.17.1
81
+ version: '0.21'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '0.21'
89
+ - !ruby/object:Gem::Dependency
90
+ name: simplecov_json_formatter
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '0.1'
82
96
  type: :development
83
97
  prerelease: false
84
98
  version_requirements: !ruby/object:Gem::Requirement
85
99
  requirements:
86
100
  - - "~>"
87
101
  - !ruby/object:Gem::Version
88
- version: 0.17.1
102
+ version: '0.1'
89
103
  - !ruby/object:Gem::Dependency
90
104
  name: webmock
91
105
  requirement: !ruby/object:Gem::Requirement
@@ -136,9 +150,11 @@ executables: []
136
150
  extensions: []
137
151
  extra_rdoc_files: []
138
152
  files:
153
+ - ".github/FUNDING.yml"
154
+ - ".github/workflows/sonarcloud.yml"
155
+ - ".github/workflows/tests.yml"
139
156
  - ".gitignore"
140
157
  - ".rspec"
141
- - ".travis.yml"
142
158
  - CODE_OF_CONDUCT.md
143
159
  - Gemfile
144
160
  - History.txt
@@ -155,6 +171,7 @@ files:
155
171
  - lib/bitly/api/bitlink/deeplink.rb
156
172
  - lib/bitly/api/bitlink/link_click.rb
157
173
  - lib/bitly/api/bitlink/paginated_list.rb
174
+ - lib/bitly/api/bitlink/utils.rb
158
175
  - lib/bitly/api/bsd.rb
159
176
  - lib/bitly/api/click_metric.rb
160
177
  - lib/bitly/api/client.rb
@@ -174,6 +191,7 @@ files:
174
191
  - lib/bitly/http/response.rb
175
192
  - lib/bitly/oauth.rb
176
193
  - lib/bitly/version.rb
194
+ - sonar-project.properties
177
195
  homepage: https://github.com/philnash/bitly
178
196
  licenses:
179
197
  - MIT
@@ -183,7 +201,7 @@ metadata:
183
201
  documentation_uri: https://www.rubydoc.info/gems/bitly/
184
202
  homepage_uri: https://github.com/philnash/bitly
185
203
  source_code_uri: https://github.com/philnash/bitly
186
- post_install_message:
204
+ post_install_message:
187
205
  rdoc_options: []
188
206
  require_paths:
189
207
  - lib
@@ -198,8 +216,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
216
  - !ruby/object:Gem::Version
199
217
  version: '0'
200
218
  requirements: []
201
- rubygems_version: 3.0.3
202
- signing_key:
219
+ rubygems_version: 3.3.3
220
+ signing_key:
203
221
  specification_version: 4
204
222
  summary: Use the Bitly API to shorten or expand URLs
205
223
  test_files: []
data/.travis.yml DELETED
@@ -1,22 +0,0 @@
1
- language: ruby
2
- sudo: required
3
- dist: trusty
4
- before_install:
5
- - gem update --system
6
- - gem install bundler
7
- rvm:
8
- - 2.7
9
- - 2.6
10
- - 2.5
11
- - 2.4
12
- - 2.3
13
- - ruby-head
14
- - jruby-19mode
15
- - jruby-head
16
- - rbx-3
17
- matrix:
18
- allow_failures:
19
- - rvm: ruby-head
20
- - rvm: jruby-19mode
21
- - rvm: jruby-head
22
- - rvm: rbx-3