bitly 2.0.2 → 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: 8f5ca773433a54eb91817b7a7167b625d04cb33701afbb97a5bc4df3831dd429
4
- data.tar.gz: 8b97a419154acad1eeb030c8f918c85022ad7a607db44d379cc0ef4cf4f737f7
3
+ metadata.gz: e0a2dd617bd9c23263a1db205f8ea95359c34273df7eecc5ca9565536a03c802
4
+ data.tar.gz: 4f0dac7f35a238a61b9ec36390df824170b576f15e8f111203bf83a8f600993d
5
5
  SHA512:
6
- metadata.gz: 52a578ae00f4b4d1016202cb9212fbf8af3fbc1b8d99161b03fe7f97dd383677bdf6f867ff44d19575e566932727e932ba06d8c39883a2a2ff48daec968b5525
7
- data.tar.gz: 73053a5be2a75f261d1036893e1e3159abc822829455fa890956cfb8818c08c57d5000dcdcf8d32719c156d65a52b7d26ab8de046f202c7ceb120f0cdae39b22
6
+ metadata.gz: cc10e4a46caeb7155292380f8c61feec74cf19ce9da36ee49c9b7dbff763b5c4703b58c9e2ded557cfb6426fa7f68532914a49350bc9f5e4f8c25a57ff7d3e82
7
+ data.tar.gz: 1935c386fc1d489a532de2459222f9a069a3a6f0a258d58178c16694e131d8be246226464fe1f2f83a40db1c333c0422d1c60905c0ec1dfb23492ae927db2c93
@@ -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 }}
data/History.txt CHANGED
@@ -2,6 +2,12 @@
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
+
5
11
  === 2.0.2 / 2022-10-18
6
12
 
7
13
  * Allows oauth2 gem version 2
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://github.com/philnash/bitly/workflows/tests/badge.svg) [![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
@@ -35,7 +35,8 @@ Gem::Specification.new do |spec|
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.2"
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitly
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phil Nash
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-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
@@ -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
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: 0.17.1
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'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '0.1'
89
103
  - !ruby/object:Gem::Dependency
90
104
  name: webmock
91
105
  requirement: !ruby/object:Gem::Requirement
@@ -137,6 +151,7 @@ extensions: []
137
151
  extra_rdoc_files: []
138
152
  files:
139
153
  - ".github/FUNDING.yml"
154
+ - ".github/workflows/sonarcloud.yml"
140
155
  - ".github/workflows/tests.yml"
141
156
  - ".gitignore"
142
157
  - ".rspec"
@@ -156,6 +171,7 @@ files:
156
171
  - lib/bitly/api/bitlink/deeplink.rb
157
172
  - lib/bitly/api/bitlink/link_click.rb
158
173
  - lib/bitly/api/bitlink/paginated_list.rb
174
+ - lib/bitly/api/bitlink/utils.rb
159
175
  - lib/bitly/api/bsd.rb
160
176
  - lib/bitly/api/click_metric.rb
161
177
  - lib/bitly/api/client.rb
@@ -175,6 +191,7 @@ files:
175
191
  - lib/bitly/http/response.rb
176
192
  - lib/bitly/oauth.rb
177
193
  - lib/bitly/version.rb
194
+ - sonar-project.properties
178
195
  homepage: https://github.com/philnash/bitly
179
196
  licenses:
180
197
  - MIT