rollbar-api 0.4.0 → 0.4.1

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: e665e6b1e2ae7787d23bd6256a93b0608259bf87a603b5d35db1710f3ea86fc6
4
- data.tar.gz: b8f2cca220d11020b07f65867159f3b8653840c3ec2291dc6dcb3a1e77bca8fe
3
+ metadata.gz: cb40f1378bac899e1145acb3ac7f53306441009a9a7755eb695216d4eee2789b
4
+ data.tar.gz: 5126b037b0cec8efd7d427489ab9ccbf40fc0c04f26c95e969ac552ce13050b5
5
5
  SHA512:
6
- metadata.gz: d0637c7c7a2fa9a592d33362b3b596dbeb2dbcb1b1df9aaba957d871130be5dfec937fc5a99f77cb6b8fce45767ddfa8f154cb64d7d387455a0027a2f69a7027
7
- data.tar.gz: 5a0dfffa08725053fda0987b4b3283a52111dc144bb2946ce987e85e3f8d4cb3c03df006f2b98b41160c93ea559c8075e7f52f9720b433d5315199256ab09d73
6
+ metadata.gz: 52369017d084475f588ed01a980227d34a9180d93f6169e76d96f9293724f55aba2a7ad9b645d85c0543bee80f72efc4945610da0aa6c01fcc94991030101ebe
7
+ data.tar.gz: d8cb7dbd5c01d5900ec49db6bb25b107b44b15af598f88ae7811d3379cb79bd8451e614df224982d39d314bab1cf1cb39ca2d01e9997cb45c643e963d7f18c9f
@@ -0,0 +1 @@
1
+ * @wealthsimple/developer-tools
@@ -0,0 +1,31 @@
1
+ ---
2
+ name: Pipeline
3
+ on: push
4
+ jobs:
5
+ build:
6
+ name: Build
7
+ runs-on: ubuntu-20.04
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - uses: ruby/setup-ruby@v1
11
+ with:
12
+ bundler-cache: true
13
+ - name: Lint
14
+ run: bundle exec rubocop
15
+ - name: Test
16
+ run: bundle exec rspec
17
+ - name: Release the gem
18
+ if: ${{ github.ref == 'refs/heads/main' }}
19
+ run: |
20
+ mkdir -p ~/.gem
21
+ cat << EOF > ~/.gem/credentials
22
+ ---
23
+ :github: Bearer ${GITHUB_TOKEN}
24
+ :rubygems_api_key: ${RUBYGEMS_API_KEY}
25
+ EOF
26
+ chmod 0600 ~/.gem/credentials
27
+ git config user.email "noreply@wealthsimple.com"
28
+ git config user.name "Wolfbot"
29
+ bundle exec rake release
30
+ env:
31
+ RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ inherit_gem:
2
+ ws-style:
3
+ - default.yml
4
+
5
+ Naming/FileName:
6
+ Exclude:
7
+ - lib/rollbar-api.rb
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.3
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in rollbar-api.gemspec
4
6
  gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,119 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rollbar-api (0.4.1)
5
+ activesupport (>= 4)
6
+ faraday (< 1.0)
7
+ recursive-open-struct
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activesupport (6.1.3.1)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ zeitwerk (~> 2.3)
18
+ addressable (2.7.0)
19
+ public_suffix (>= 2.0.2, < 5.0)
20
+ ast (2.4.2)
21
+ concurrent-ruby (1.1.8)
22
+ crack (0.4.5)
23
+ rexml
24
+ diff-lcs (1.4.4)
25
+ dotenv (2.7.6)
26
+ faraday (0.17.4)
27
+ multipart-post (>= 1.2, < 3)
28
+ hashdiff (1.0.1)
29
+ i18n (1.8.10)
30
+ concurrent-ruby (~> 1.0)
31
+ minitest (5.14.4)
32
+ multipart-post (2.1.1)
33
+ parallel (1.20.1)
34
+ parser (3.0.1.1)
35
+ ast (~> 2.4.1)
36
+ public_suffix (4.0.6)
37
+ rack (2.2.3)
38
+ rainbow (3.0.0)
39
+ rake (10.5.0)
40
+ recursive-open-struct (1.1.3)
41
+ regexp_parser (2.1.1)
42
+ rexml (3.2.5)
43
+ rspec (3.10.0)
44
+ rspec-core (~> 3.10.0)
45
+ rspec-expectations (~> 3.10.0)
46
+ rspec-mocks (~> 3.10.0)
47
+ rspec-collection_matchers (1.2.0)
48
+ rspec-expectations (>= 2.99.0.beta1)
49
+ rspec-core (3.10.1)
50
+ rspec-support (~> 3.10.0)
51
+ rspec-expectations (3.10.1)
52
+ diff-lcs (>= 1.2.0, < 2.0)
53
+ rspec-support (~> 3.10.0)
54
+ rspec-its (1.3.0)
55
+ rspec-core (>= 3.0.0)
56
+ rspec-expectations (>= 3.0.0)
57
+ rspec-mocks (3.10.2)
58
+ diff-lcs (>= 1.2.0, < 2.0)
59
+ rspec-support (~> 3.10.0)
60
+ rspec-support (3.10.2)
61
+ rspec_junit_formatter (0.4.1)
62
+ rspec-core (>= 2, < 4, != 2.12.0)
63
+ rubocop (1.13.0)
64
+ parallel (~> 1.10)
65
+ parser (>= 3.0.0.0)
66
+ rainbow (>= 2.2.2, < 4.0)
67
+ regexp_parser (>= 1.8, < 3.0)
68
+ rexml
69
+ rubocop-ast (>= 1.2.0, < 2.0)
70
+ ruby-progressbar (~> 1.7)
71
+ unicode-display_width (>= 1.4.0, < 3.0)
72
+ rubocop-ast (1.5.0)
73
+ parser (>= 3.0.1.1)
74
+ rubocop-performance (1.11.1)
75
+ rubocop (>= 1.7.0, < 2.0)
76
+ rubocop-ast (>= 0.4.0)
77
+ rubocop-rails (2.9.1)
78
+ activesupport (>= 4.2.0)
79
+ rack (>= 1.1)
80
+ rubocop (>= 0.90.0, < 2.0)
81
+ rubocop-rspec (2.3.0)
82
+ rubocop (~> 1.0)
83
+ rubocop-ast (>= 1.1.0)
84
+ rubocop-vendor (0.6.0)
85
+ rubocop (>= 0.53.0)
86
+ ruby-progressbar (1.11.0)
87
+ tzinfo (2.0.4)
88
+ concurrent-ruby (~> 1.0)
89
+ unicode-display_width (2.0.0)
90
+ webmock (3.12.2)
91
+ addressable (>= 2.3.6)
92
+ crack (>= 0.3.2)
93
+ hashdiff (>= 0.4.0, < 2.0.0)
94
+ ws-style (6.9.0)
95
+ rubocop (>= 1.12.1)
96
+ rubocop-performance (>= 1.10.2)
97
+ rubocop-rails (>= 2.9.1)
98
+ rubocop-rspec (>= 2.2.0)
99
+ rubocop-vendor (>= 0.6.0)
100
+ zeitwerk (2.4.2)
101
+
102
+ PLATFORMS
103
+ ruby
104
+
105
+ DEPENDENCIES
106
+ bundler
107
+ dotenv
108
+ rake (~> 10.0)
109
+ rollbar-api!
110
+ rspec (~> 3.0)
111
+ rspec-collection_matchers
112
+ rspec-its
113
+ rspec_junit_formatter (~> 0.2)
114
+ rubocop
115
+ webmock (~> 3.0)
116
+ ws-style
117
+
118
+ BUNDLED WITH
119
+ 2.2.16
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # rollbar-api [![CircleCI](https://circleci.com/gh/wealthsimple/rollbar-api.svg?style=svg)](https://circleci.com/gh/wealthsimple/rollbar-api) [![Gem Version](https://badge.fury.io/rb/rollbar-api.svg)](https://rubygems.org/gems/rollbar-api)
1
+ # rollbar-api
2
+ [![GitHub Actions Badge](https://github.com/wealthsimple/rollbar-api/actions/workflows/main.yml/badge.svg)](https://github.com/wealthsimple/rollbar-api/actions)
2
3
 
3
4
  Rubygem for accessing Rollbar's full REST and RQL APIs.
4
5
 
@@ -22,7 +23,7 @@ Next, configure each project:
22
23
 
23
24
  ```ruby
24
25
  # config/initializers/rollbar-api.rb in a Rails project
25
- require 'rollbar-api'
26
+ require 'rollbar_api'
26
27
 
27
28
  # Add as many projects as you need. Each should have a unique access token.
28
29
  RollbarApi::Project.configure("my-project", ENV["MY_PROJECT_ACCESS_TOKEN"])
@@ -77,8 +78,8 @@ First, generate access tokens for each account you need access to by navigating
77
78
  Next, configure each account:
78
79
 
79
80
  ```ruby
80
- # config/initializers/rollbar-api.rb in a Rails project
81
- require 'rollbar-api'
81
+ # config/initializers/rollbar_api.rb in a Rails project
82
+ require 'rollbar_api'
82
83
 
83
84
  # Add as many accounts as you need (normally just one). Each should have a unique access token.
84
85
  RollbarApi::Account.configure("my-organization", ENV["ROLLBAR_ACCOUNT_ACCESS_TOKEN"])
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "rollbar-api"
4
+ require 'bundler/setup'
5
+ require 'rollbar_api'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "rollbar-api"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
data/catalog-info.yaml ADDED
@@ -0,0 +1,12 @@
1
+ ---
2
+ apiVersion: backstage.io/v1alpha1
3
+ kind: Component
4
+ metadata:
5
+ name: rollbar-api
6
+ description: Rollbar API client
7
+ tags:
8
+ - ruby
9
+ - open-source
10
+ spec:
11
+ type: library
12
+ lifecycle: production
@@ -1,15 +1,20 @@
1
- require "dotenv/load"
2
- require "bundler/setup"
3
- require "rollbar-api"
1
+ # frozen_string_literal: true
4
2
 
5
- account_name = ENV["ROLLBAR_ACCOUNT_NAME"] or raise "Must specify ROLLBAR_ACCOUNT_NAME in .env"
6
- account_access_token = ENV["ROLLBAR_ACCOUNT_ACCESS_TOKEN"] or raise "Must specify ROLLBAR_ACCOUNT_ACCESS_TOKEN in .env"
3
+ require 'dotenv/load'
4
+ require 'bundler/setup'
5
+ require 'rollbar_api'
6
+
7
+ account_name = ENV['ROLLBAR_ACCOUNT_NAME']
8
+ raise 'must specify ROLLBAR_ACCOUNT_NAME in .env' if account_name.blank?
9
+
10
+ account_access_token = ENV['ROLLBAR_ACCOUNT_ACCESS_TOKEN']
11
+ raise 'Must specify ROLLBAR_ACCOUNT_ACCESS_TOKEN in .env' if account_access_token.blank?
7
12
 
8
13
  RollbarApi.logger = Logger.new(nil)
9
14
 
10
15
  account = RollbarApi::Account.configure(account_name, account_access_token)
11
16
 
12
- users = account.get("/api/1/users")
17
+ users = account.get('/api/1/users')
13
18
  users.result.users.first(5).each do |user|
14
19
  p user
15
20
  end
@@ -1,17 +1,22 @@
1
- require "dotenv/load"
2
- require "bundler/setup"
3
- require "rollbar-api"
1
+ # frozen_string_literal: true
4
2
 
5
- project_name = ENV["ROLLBAR_PROJECT_NAME"] or raise "Must specify ROLLBAR_PROJECT_NAME in .env"
6
- project_access_token = ENV["ROLLBAR_PROJECT_ACCESS_TOKEN"] or raise "Must specify ROLLBAR_PROJECT_ACCESS_TOKEN in .env"
3
+ require 'dotenv/load'
4
+ require 'bundler/setup'
5
+ require 'rollbar_api'
6
+
7
+ project_name = ENV['ROLLBAR_PROJECT_NAME']
8
+ project_access_token = ENV['ROLLBAR_PROJECT_ACCESS_TOKEN']
9
+
10
+ raise 'Must specify ROLLBAR_PROJECT_NAME in .env' if project_name.blank?
11
+ raise 'Must specify ROLLBAR_ACCOUNT_ACCESS_TOKEN in .env' if project_access_token.blank?
7
12
 
8
13
  project = RollbarApi::Project.configure(project_name, project_access_token)
9
14
 
10
15
  # Fetch all items
11
- items = project.get("/api/1/items")
16
+ items = project.get('/api/1/items')
12
17
 
13
18
  # Print out the first 5 items
14
19
  items.result.items.first(5).each do |item|
15
20
  p item
16
- puts "=" * 80
21
+ puts '=' * 80
17
22
  end
@@ -1,22 +1,27 @@
1
- require "dotenv/load"
2
- require "bundler/setup"
3
- require "rollbar-api"
1
+ # frozen_string_literal: true
4
2
 
5
- project_name = ENV["ROLLBAR_PROJECT_NAME"] or raise "Must specify ROLLBAR_PROJECT_NAME in .env"
6
- project_access_token = ENV["ROLLBAR_PROJECT_ACCESS_TOKEN"] or raise "Must specify ROLLBAR_PROJECT_ACCESS_TOKEN in .env"
3
+ require 'dotenv/load'
4
+ require 'bundler/setup'
5
+ require 'rollbar_api'
6
+
7
+ project_name = ENV['ROLLBAR_PROJECT_NAME']
8
+ project_access_token = ENV['ROLLBAR_PROJECT_ACCESS_TOKEN']
9
+
10
+ raise 'Must specify ROLLBAR_PROJECT_NAME in .env' if project_name.blank?
11
+ raise 'Must specify ROLLBAR_ACCOUNT_ACCESS_TOKEN in .env' if project_access_token.blank?
7
12
 
8
13
  project = RollbarApi::Project.configure(project_name, project_access_token)
9
14
 
10
15
  # Create the job
11
- rql_job = project.post("/api/1/rql/jobs", {
12
- query_string: "select * from item_occurrence where item.counter=1",
16
+ rql_job = project.post('/api/1/rql/jobs', {
17
+ query_string: 'select * from item_occurrence where item.counter=1',
13
18
  })
14
19
 
15
20
  # Fetch job status
16
21
  rql_job = project.get("/api/1/rql/job/#{rql_job.result.id}")
17
22
  p rql_job
18
23
 
19
- if rql_job.result.status == "success"
24
+ if rql_job.result.status == 'success'
20
25
  # Print out succeeded job result
21
26
  p project.get("/api/1/rql/job/#{rql_job.result.id}/result")
22
27
  end
@@ -1,18 +1,23 @@
1
- require "dotenv/load"
2
- require "bundler/setup"
3
- require "rollbar-api"
1
+ # frozen_string_literal: true
4
2
 
5
- project_name = ENV["ROLLBAR_PROJECT_NAME"] or raise "Must specify ROLLBAR_PROJECT_NAME in .env"
6
- project_access_token = ENV["ROLLBAR_PROJECT_ACCESS_TOKEN"] or raise "Must specify ROLLBAR_PROJECT_ACCESS_TOKEN in .env"
3
+ require 'dotenv/load'
4
+ require 'bundler/setup'
5
+ require 'rollbar_api'
6
+
7
+ project_name = ENV['ROLLBAR_PROJECT_NAME']
8
+ project_access_token = ENV['ROLLBAR_PROJECT_ACCESS_TOKEN']
9
+
10
+ raise 'Must specify ROLLBAR_PROJECT_NAME in .env' if project_PROJECT_NAME.blank?
11
+ raise 'Must specify ROLLBAR_ACCOUNT_ACCESS_TOKEN in .env' if project_access_token.blank?
7
12
 
8
13
  project = RollbarApi::Project.configure(project_name, project_access_token)
9
14
 
10
- top_active_items = project.get("/api/1/reports/top_active_items", {
11
- hours: "24",
12
- environments: "production,staging",
15
+ top_active_items = project.get('/api/1/reports/top_active_items', {
16
+ hours: '24',
17
+ environments: 'production,staging',
13
18
  })
14
19
 
15
20
  top_active_items.result.first(5).each_with_index do |item, i|
16
21
  p i, item
17
- puts "=" * 80
22
+ puts '=' * 80
18
23
  end
data/lib/rollbar-api.rb CHANGED
@@ -1,15 +1,2 @@
1
- require "active_support"
2
- require "active_support/core_ext"
3
- require "faraday"
4
- require "json"
5
- require "recursive-open-struct"
6
-
7
- require "rollbar-api/account"
8
- require "rollbar-api/logger"
9
- require "rollbar-api/project"
10
- require "rollbar-api/request"
11
- require "rollbar-api/resource"
12
- require "rollbar-api/version"
13
-
14
- module RollbarApi
15
- end
1
+ # backwards-compatble way to migrate from `require 'rollbar-api'`
2
+ require 'rollbar_api'
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support'
4
+ require 'active_support/core_ext'
5
+ require 'faraday'
6
+ require 'json'
7
+ require 'recursive-open-struct'
8
+
9
+ require 'rollbar_api/account'
10
+ require 'rollbar_api/logger'
11
+ require 'rollbar_api/project'
12
+ require 'rollbar_api/request'
13
+ require 'rollbar_api/resource'
14
+ require 'rollbar_api/version'
15
+
16
+ module RollbarApi
17
+ end
@@ -1,32 +1,35 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RollbarApi
2
4
  class Account
3
- @@accounts = {}
5
+ @accounts = {}
4
6
 
5
7
  def self.configure(account_name, account_access_token)
6
- @@accounts[account_name] = account_access_token
8
+ @accounts[account_name] = account_access_token
7
9
  find(account_name)
8
10
  end
9
11
 
10
12
  def self.find(account_name)
11
- account_access_token = @@accounts[account_name]
13
+ account_access_token = @accounts[account_name]
12
14
  new(account_name, account_access_token) if account_access_token.present?
13
15
  end
14
16
 
15
17
  def self.all
16
- @@accounts.map { |account_name, _| find(account_name) }
18
+ @accounts.map { |account_name, _| find(account_name) }
17
19
  end
18
20
 
19
21
  def self.delete_all
20
- @@accounts = {}
22
+ @accounts = {}
21
23
  end
22
24
 
23
25
  attr_reader :name, :access_token
26
+
24
27
  def initialize(name, access_token)
25
28
  @name = name
26
29
  @access_token = access_token
27
30
  end
28
31
 
29
- %i(get post put delete head patch).each do |http_method|
32
+ %i[get post put delete head patch].each do |http_method|
30
33
  define_method(http_method) do |path, params = {}|
31
34
  params[:access_token] = access_token
32
35
  response = Request.new(method: http_method, path: path, params: params).execute
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RollbarApi
4
+ @logger = Logger.new($stdout)
5
+ def self.logger=(logger)
6
+ @logger = logger
7
+ end
8
+
9
+ def self.logger
10
+ @logger
11
+ end
12
+ end
@@ -1,32 +1,35 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RollbarApi
2
4
  class Project
3
- @@projects = {}
5
+ @projects = {}
4
6
 
5
7
  def self.configure(project_name, project_access_token)
6
- @@projects[project_name] = project_access_token
8
+ @projects[project_name] = project_access_token
7
9
  find(project_name)
8
10
  end
9
11
 
10
12
  def self.find(project_name)
11
- project_access_token = @@projects[project_name]
13
+ project_access_token = @projects[project_name]
12
14
  new(project_name, project_access_token) if project_access_token.present?
13
15
  end
14
16
 
15
17
  def self.all
16
- @@projects.map { |project_name, _| find(project_name) }
18
+ @projects.map { |project_name, _| find(project_name) }
17
19
  end
18
20
 
19
21
  def self.delete_all
20
- @@projects = {}
22
+ @projects = {}
21
23
  end
22
24
 
23
25
  attr_reader :name, :access_token
26
+
24
27
  def initialize(name, access_token)
25
28
  @name = name
26
29
  @access_token = access_token
27
30
  end
28
31
 
29
- %i(get post put delete head patch).each do |http_method|
32
+ %i[get post put delete head patch].each do |http_method|
30
33
  define_method(http_method) do |path, params = {}|
31
34
  params[:access_token] = access_token
32
35
  response = Request.new(method: http_method, path: path, params: params).execute
@@ -1,9 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RollbarApi
2
4
  class Request
3
5
  attr_reader :method, :path, :params
6
+
4
7
  def initialize(method:, path:, params:)
5
8
  @method = method
6
- path = "/#{path}" unless path.start_with?("/")
9
+ path = "/#{path}" unless path.start_with?('/')
7
10
  @path = path
8
11
  @params = params
9
12
  end
@@ -18,17 +21,17 @@ module RollbarApi
18
21
  end
19
22
 
20
23
  request.headers.merge!({
21
- "Accept" => "application/json",
22
- "Content-Type" => "application/json",
24
+ 'Accept' => 'application/json',
25
+ 'Content-Type' => 'application/json',
23
26
  })
24
27
  request
25
28
  end
26
29
  end
27
30
 
28
- private
31
+ private
29
32
 
30
33
  def connection
31
- Faraday.new(url: "https://api.rollbar.com") do |faraday|
34
+ Faraday.new(url: 'https://api.rollbar.com') do |faraday|
32
35
  faraday.use Faraday::Response::RaiseError
33
36
  faraday.response :logger, RollbarApi.logger, bodies: false
34
37
  faraday.adapter Faraday.default_adapter
@@ -36,11 +39,9 @@ module RollbarApi
36
39
  end
37
40
 
38
41
  def body_to_json(body)
39
- if body
40
- body.is_a?(Array) || body.is_a?(Hash) ? body.to_json : body
41
- else
42
- nil
43
- end
42
+ return if body.blank?
43
+
44
+ body.is_a?(Array) || body.is_a?(Hash) ? body.to_json : body
44
45
  end
45
46
  end
46
47
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RollbarApi
4
+ class Resource
5
+ attr_reader :response_json
6
+
7
+ def initialize(response)
8
+ response = response.body if response.is_a?(Faraday::Response)
9
+ @response_json = if response.is_a?(String)
10
+ JSON.parse(response)
11
+ else
12
+ response
13
+ end
14
+ @struct = ResourceStruct.new(@response_json, { recurse_over_arrays: true })
15
+ end
16
+ delegate :inspect, to: :@struct
17
+
18
+ def as_json(_options = {})
19
+ @response_json
20
+ end
21
+
22
+ def method_missing(name, *args)
23
+ @struct.send(name, *args)
24
+ end
25
+
26
+ def respond_to_missing?(method_name, _include_private = false)
27
+ @struct.respond_to?(method_name)
28
+ end
29
+ end
30
+
31
+ class ResourceStruct < RecursiveOpenStruct
32
+ def inspect
33
+ %(#<RollbarApi::Resource: #{JSON.pretty_generate(@table)}>)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RollbarApi
4
+ VERSION = '0.4.1'
5
+ end
data/rollbar-api.gemspec CHANGED
@@ -1,36 +1,41 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "rollbar-api/version"
5
+ require 'rollbar_api/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "rollbar-api"
8
+ spec.name = 'rollbar-api'
8
9
  spec.version = RollbarApi::VERSION
9
- spec.authors = ["Peter Graham"]
10
- spec.email = ["peter@wealthsimple.com"]
10
+ spec.authors = ['Peter Graham']
11
+ spec.email = ['peter@wealthsimple.com']
11
12
 
12
- spec.summary = %q{Rubygem for Rollbar REST and RQL APIs}
13
- spec.description = %q{Rubygem for accessing Rollbar's full REST and RQL APIs.}
14
- spec.homepage = "https://github.com/wealthsimple/rollbar-api"
13
+ spec.summary = 'Rubygem for Rollbar REST and RQL APIs'
14
+ spec.description = "Rubygem for accessing Rollbar's full REST and RQL APIs."
15
+ spec.homepage = 'https://github.com/wealthsimple/rollbar-api'
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
18
  f.match(%r{^(test|spec|features)/})
18
19
  end
19
- spec.bindir = "exe"
20
+ spec.bindir = 'exe'
20
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ["lib"]
22
- spec.license = "MIT"
22
+ spec.require_paths = ['lib']
23
+ spec.license = 'MIT'
24
+
25
+ spec.required_ruby_version = '>= 2.7.3'
23
26
 
24
- spec.add_dependency "activesupport", ">= 4"
25
- spec.add_dependency "faraday", "< 1.0"
26
- spec.add_dependency "recursive-open-struct"
27
+ spec.add_dependency 'activesupport', '>= 4'
28
+ spec.add_dependency 'faraday', '< 1.0'
29
+ spec.add_dependency 'recursive-open-struct'
27
30
 
28
- spec.add_development_dependency "bundler", "~> 1.14"
29
- spec.add_development_dependency "rake", "~> 10.0"
30
- spec.add_development_dependency "rspec", "~> 3.0"
31
- spec.add_development_dependency "rspec-its"
32
- spec.add_development_dependency "rspec-collection_matchers"
33
- spec.add_development_dependency "rspec_junit_formatter", "~> 0.2"
34
- spec.add_development_dependency "webmock", "~> 3.0"
35
- spec.add_development_dependency "dotenv"
31
+ spec.add_development_dependency 'bundler'
32
+ spec.add_development_dependency 'dotenv'
33
+ spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'rspec', '~> 3.0'
35
+ spec.add_development_dependency 'rspec-collection_matchers'
36
+ spec.add_development_dependency 'rspec-its'
37
+ spec.add_development_dependency 'rspec_junit_formatter', '~> 0.2'
38
+ spec.add_development_dependency 'rubocop'
39
+ spec.add_development_dependency 'webmock', '~> 3.0'
40
+ spec.add_development_dependency 'ws-style'
36
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollbar-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Graham
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-27 00:00:00.000000000 Z
11
+ date: 2021-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -56,16 +56,30 @@ dependencies:
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1.14'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: dotenv
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: '1.14'
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rake
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -95,7 +109,7 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '3.0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: rspec-its
112
+ name: rspec-collection_matchers
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - ">="
@@ -109,7 +123,7 @@ dependencies:
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
- name: rspec-collection_matchers
126
+ name: rspec-its
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - ">="
@@ -136,6 +150,20 @@ dependencies:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0.2'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
139
167
  - !ruby/object:Gem::Dependency
140
168
  name: webmock
141
169
  requirement: !ruby/object:Gem::Requirement
@@ -151,7 +179,7 @@ dependencies:
151
179
  - !ruby/object:Gem::Version
152
180
  version: '3.0'
153
181
  - !ruby/object:Gem::Dependency
154
- name: dotenv
182
+ name: ws-style
155
183
  requirement: !ruby/object:Gem::Requirement
156
184
  requirements:
157
185
  - - ">="
@@ -171,25 +199,31 @@ executables: []
171
199
  extensions: []
172
200
  extra_rdoc_files: []
173
201
  files:
174
- - ".circleci/config.yml"
202
+ - ".github/CODEOWNERS"
203
+ - ".github/workflows/main.yml"
175
204
  - ".gitignore"
176
205
  - ".rspec"
206
+ - ".rubocop.yml"
207
+ - ".ruby-version"
177
208
  - Gemfile
209
+ - Gemfile.lock
178
210
  - README.md
179
211
  - Rakefile
180
212
  - bin/console
181
213
  - bin/setup
214
+ - catalog-info.yaml
182
215
  - examples/list_account_users.rb
183
216
  - examples/list_items.rb
184
217
  - examples/rql_query.rb
185
218
  - examples/top_active_items.rb
186
219
  - lib/rollbar-api.rb
187
- - lib/rollbar-api/account.rb
188
- - lib/rollbar-api/logger.rb
189
- - lib/rollbar-api/project.rb
190
- - lib/rollbar-api/request.rb
191
- - lib/rollbar-api/resource.rb
192
- - lib/rollbar-api/version.rb
220
+ - lib/rollbar_api.rb
221
+ - lib/rollbar_api/account.rb
222
+ - lib/rollbar_api/logger.rb
223
+ - lib/rollbar_api/project.rb
224
+ - lib/rollbar_api/request.rb
225
+ - lib/rollbar_api/resource.rb
226
+ - lib/rollbar_api/version.rb
193
227
  - rollbar-api.gemspec
194
228
  homepage: https://github.com/wealthsimple/rollbar-api
195
229
  licenses:
@@ -203,14 +237,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
203
237
  requirements:
204
238
  - - ">="
205
239
  - !ruby/object:Gem::Version
206
- version: '0'
240
+ version: 2.7.3
207
241
  required_rubygems_version: !ruby/object:Gem::Requirement
208
242
  requirements:
209
243
  - - ">="
210
244
  - !ruby/object:Gem::Version
211
245
  version: '0'
212
246
  requirements: []
213
- rubygems_version: 3.0.3
247
+ rubygems_version: 3.1.6
214
248
  signing_key:
215
249
  specification_version: 4
216
250
  summary: Rubygem for Rollbar REST and RQL APIs
data/.circleci/config.yml DELETED
@@ -1,69 +0,0 @@
1
- version: 2
2
-
3
- defaults: &defaults
4
- working_directory: ~/wealthsimple
5
- docker:
6
- - image: circleci/ruby:2.5.5
7
-
8
- references:
9
- attach_code_workspace: &attach_code_workspace
10
- attach_workspace:
11
- at: ~/wealthsimple
12
-
13
- restore_bundle_dependencies: &restore_bundle_dependencies
14
- run:
15
- name: Restore bundle dependencies from workspace
16
- command: bundle --path vendor/bundle
17
-
18
- jobs:
19
- checkout_and_bundle:
20
- <<: *defaults
21
- steps:
22
- - checkout
23
- - run: bundle install --jobs=4 --retry=3 --path vendor/bundle
24
- - persist_to_workspace:
25
- root: .
26
- paths: .
27
-
28
- rspec:
29
- <<: *defaults
30
- steps:
31
- - *attach_code_workspace
32
- - *restore_bundle_dependencies
33
- - run: bundle exec rspec
34
-
35
- release:
36
- <<: *defaults
37
- steps:
38
- - add_ssh_keys:
39
- fingerprints:
40
- - "46:b5:cb:ee:57:dc:14:95:31:be:12:13:4f:11:94:a4"
41
- - *attach_code_workspace
42
- - *restore_bundle_dependencies
43
- - run:
44
- name: Release to rubygems.org
45
- command: |
46
- mkdir -p ~/.ssh
47
- touch ~/.ssh/known_hosts
48
- echo "github.com,192.30.253.112 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~/.ssh/known_hosts
49
- mkdir ~/.gem
50
- echo ":rubygems_api_key: ${RUBYGEMS_API_KEY}" >> ~/.gem/credentials
51
- chmod 600 ~/.gem/credentials
52
- bundle exec rake release
53
-
54
- workflows:
55
- version: 2
56
- build:
57
- jobs:
58
- - checkout_and_bundle:
59
- context: wealthsimple
60
- - rspec:
61
- requires:
62
- - checkout_and_bundle
63
- - release:
64
- context: wealthsimple
65
- filters:
66
- branches:
67
- only: master
68
- requires:
69
- - rspec
@@ -1,10 +0,0 @@
1
- module RollbarApi
2
- @@logger = Logger.new(STDOUT)
3
- def self.logger=(logger)
4
- @@logger = logger
5
- end
6
-
7
- def self.logger
8
- @@logger
9
- end
10
- end
@@ -1,30 +0,0 @@
1
- module RollbarApi
2
- class Resource
3
- attr_reader :response_json
4
-
5
- def initialize(response)
6
- response = response.body if response.is_a?(Faraday::Response)
7
- @response_json = if response.is_a?(String)
8
- JSON.parse(response)
9
- else
10
- response
11
- end
12
- @struct = ResourceStruct.new(@response_json, {recurse_over_arrays: true})
13
- end
14
- delegate :inspect, to: :@struct
15
-
16
- def as_json(options = {})
17
- @response_json
18
- end
19
-
20
- def method_missing(name, *args)
21
- @struct.send(name, *args)
22
- end
23
- end
24
-
25
- class ResourceStruct < RecursiveOpenStruct
26
- def inspect
27
- %{#<RollbarApi::Resource: #{JSON.pretty_generate(@table)}>}
28
- end
29
- end
30
- end
@@ -1,3 +0,0 @@
1
- module RollbarApi
2
- VERSION = "0.4.0"
3
- end