Skip to content

Commit b20767f

Browse files
committed
Merge branch 'master' of github.com:amoniacou/pipedrive.rb
2 parents 11cc4bd + 7eac761 commit b20767f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+535
-226
lines changed

.rubocop.yml

+98-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,105 @@
1+
require:
2+
- rubocop/cop/internal_affairs
3+
- rubocop-performance
4+
- rubocop-rspec
15
AllCops:
2-
Include:
3-
- '**/Rakefile'
6+
NewCops: enable
47
Exclude:
5-
- 'spec/**/*'
6-
Metrics/LineLength:
7-
Max: 99
8-
Naming/FileName:
8+
- "bin/*"
9+
- "vendor/**/*"
10+
- "Rakefile"
11+
- "tmp/**/*"
12+
- ".git/**/*"
13+
TargetRubyVersion: 2.5
14+
Style/Documentation:
15+
Enabled: false
16+
Layout/LineLength:
17+
Max: 1000
18+
Metrics/MethodLength:
19+
Max: 250
20+
Metrics/ClassLength:
21+
Max: 1000
22+
Metrics/AbcSize:
23+
Max: 250
24+
Metrics/BlockLength:
25+
Max: 1500
26+
Metrics/CyclomaticComplexity:
27+
Max: 50
28+
Metrics/PerceivedComplexity:
29+
Max: 50
30+
Style/ClassAndModuleChildren:
931
Enabled: false
1032
Style/ModuleFunction:
1133
Enabled: false
12-
Style/Encoding:
34+
Style/ParallelAssignment:
1335
Enabled: false
14-
Documentation:
36+
Style/SymbolProc:
37+
Enabled: false
38+
Layout/HashAlignment:
39+
Enabled: false
40+
Metrics/BlockNesting:
41+
Enabled: false
42+
Lint/NonLocalExitFromIterator:
43+
Enabled: false
44+
Style/HashEachMethods:
45+
Enabled: true
46+
Style/HashTransformKeys:
47+
Enabled: true
48+
Style/HashTransformValues:
49+
Enabled: true
50+
Style/AndOr:
51+
Enabled: false
52+
RSpec/ExampleLength:
53+
Enabled: false
54+
RSpec/MultipleExpectations:
55+
Enabled: false
56+
RSpec/DescribeClass:
57+
Enabled: false
58+
Style/IfInsideElse:
59+
Enabled: false
60+
Layout/EmptyLinesAroundAttributeAccessor:
61+
Enabled: true
62+
Layout/SpaceAroundMethodCallOperator:
63+
Enabled: true
64+
Lint/DeprecatedOpenSSLConstant:
65+
Enabled: true
66+
Lint/MixedRegexpCaptureTypes:
67+
Enabled: true
68+
Lint/RaiseException:
69+
Enabled: true
70+
Lint/StructNewOverride:
71+
Enabled: true
72+
Style/ExponentialNotation:
73+
Enabled: false
74+
Style/RedundantFetchBlock:
75+
Enabled: true
76+
Style/RedundantRegexpCharacterClass:
77+
Enabled: true
78+
Style/RedundantRegexpEscape:
79+
Enabled: true
80+
Style/SlicingWithRange:
81+
Enabled: true
82+
Style/AccessorGrouping:
83+
Enabled: true
84+
Style/BisectedAttrAccessor:
85+
Enabled: true
86+
Style/RedundantAssignment:
87+
Enabled: true
88+
Performance/AncestorsInclude:
89+
Enabled: true
90+
Performance/BigDecimalWithNumericArgument:
91+
Enabled: true
92+
Performance/RedundantSortBlock:
93+
Enabled: true
94+
Performance/RedundantStringChars:
95+
Enabled: true
96+
Performance/ReverseFirst:
97+
Enabled: true
98+
Performance/SortReverse:
99+
Enabled: true
100+
Performance/Squeeze:
101+
Enabled: true
102+
Performance/StringInclude:
103+
Enabled: true
104+
RSpec/ContextWording:
15105
Enabled: false
16-
Metrics/MethodLength:
17-
Max: 15

.travis.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ language: ruby
22
rvm:
33
- ruby-head
44
- jruby-19mode
5-
- 2.4.6
6-
- 2.5.5
75
- 2.6.3
6+
- 2.7.2
87

98
jdk:
109
- openjdk8
@@ -13,7 +12,6 @@ matrix:
1312
allow_failures:
1413
- rvm: ruby-head
1514
- rvm: jruby-19mode
16-
- rvm: rbx-2
1715

1816
bundler_args: --without local_development
1917

Gemfile

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
# Specify your gem's dependencies in pipedrive.gemspec
46
gemspec
57

68
group :test do
7-
gem 'simplecov', :require => false
8-
gem 'coveralls', :require => false
9+
gem 'coveralls', require: false
10+
gem 'simplecov', require: false
911
end
1012

1113
group :local_development do
12-
gem 'terminal-notifier-guard', require: false if RUBY_PLATFORM.downcase.include?('darwin')
13-
gem 'guard-rspec', '>= 4.3.1' ,require: false
14-
gem 'guard-bundler', require: false
15-
gem 'guard-rubocop', require: false
1614
gem 'pry'
1715
end

Guardfile

-24
This file was deleted.

HISTORY.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [v0.3.0](https://github.com/amoniacou/pipedrive.rb/compare/v0.2.0...v0.3.0) - 2020-10-10
9+
10+
### Merged
11+
12+
- add User endpoints [`#15`](https://github.com/amoniacou/pipedrive.rb/pull/15)
13+
- add pipeline endpoints [`#17`](https://github.com/amoniacou/pipedrive.rb/pull/17)
14+
- add pipeline endpoints [`#2`](https://github.com/amoniacou/pipedrive.rb/pull/2)
15+
16+
### Commits
17+
18+
- Small code improvements [`fb28bb4`](https://github.com/amoniacou/pipedrive.rb/commit/fb28bb4ed3d86c15a4f2a95247e13393d598aad1)
19+
- Fix specs [`e772b83`](https://github.com/amoniacou/pipedrive.rb/commit/e772b837c61150b574ef3f6c95b495e1f2dfda9a)
20+
- Update .travis.yml [`873cea4`](https://github.com/amoniacou/pipedrive.rb/commit/873cea4cfd82806ef71f62a3db823322b168f964)
21+
22+
## [v0.2.0](https://github.com/amoniacou/pipedrive.rb/compare/v0.1.0...v0.2.0) - 2020-01-14
23+
24+
### Merged
25+
26+
- Inflection fix for persons [`#9`](https://github.com/amoniacou/pipedrive.rb/pull/9)
27+
- Move adapter setup to the last line in defining connection [`#7`](https://github.com/amoniacou/pipedrive.rb/pull/7)
28+
- Replace find by find_by_id in the docs [`#5`](https://github.com/amoniacou/pipedrive.rb/pull/5)
29+
- Find by name organisation && update personfields [`#3`](https://github.com/amoniacou/pipedrive.rb/pull/3)
30+
31+
### Commits
32+
33+
- Remove problematic reek and cane [`bf8535c`](https://github.com/amoniacou/pipedrive.rb/commit/bf8535c10d0894fb508828a43aefb036b000c263)
34+
- Fix tests [`bca6171`](https://github.com/amoniacou/pipedrive.rb/commit/bca6171ae43068bd671bf6b8ecf924a7e2ad1af3)
35+
- Fix outdated rubocop, contrain on rake to pass reek [`e799cbc`](https://github.com/amoniacou/pipedrive.rb/commit/e799cbca4eada29582e6c5a1e20e8f97ed709713)
36+
37+
## v0.1.0 - 2014-10-16
38+
39+
### Commits
40+
41+
- Initial commit [`cbd2138`](https://github.com/amoniacou/pipedrive.rb/commit/cbd2138ae11a19f4a398af3c25fac8ed2e6a0e1b)
42+
- Test coverage and small refactoring [`ca0577f`](https://github.com/amoniacou/pipedrive.rb/commit/ca0577fef23f59515cb58ea152e10d3130f26730)
43+
- Add more entities basic support. Add support for field selector [`73b47a4`](https://github.com/amoniacou/pipedrive.rb/commit/73b47a4455b1c50906bbc811bddac7d979fae966)

Rakefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# frozen_string_literal: true
22

33
require 'bundler/gem_tasks'
4-
require 'rspec/core/rake_task'
54

6-
RSpec::Core::RakeTask.new(:spec)
5+
begin
6+
require 'rspec/core/rake_task'
7+
RSpec::Core::RakeTask.new(:spec)
8+
rescue LoadError
9+
end
710

811
# rubocop
912
require 'rubocop/rake_task'

lib/pipedrive.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'logger'
24
require 'active_support/core_ext/hash'
35
require 'active_support/concern'
@@ -33,7 +35,7 @@ def setup
3335
end
3436

3537
def logger
36-
@logger ||= Logger.new(STDOUT)
38+
@logger ||= Logger.new($stdout)
3739
end
3840

3941
reset!
@@ -90,3 +92,9 @@ def logger
9092

9193
# Notes
9294
require 'pipedrive/note'
95+
96+
# Users
97+
require 'pipedrive/user'
98+
99+
# Pipelines
100+
require 'pipedrive/pipeline'

lib/pipedrive/activity.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Pipedrive
24
class Activity < Base
35
include ::Pipedrive::Operations::Create

lib/pipedrive/activity_type.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Pipedrive
24
class ActivityType < Base
35
include ::Pipedrive::Operations::Create

lib/pipedrive/base.rb

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
# frozen_string_literal: true
2+
13
module Pipedrive
24
class Base
35
def initialize(api_token = ::Pipedrive.api_token)
4-
fail 'api_token should be set' unless api_token.present?
6+
raise 'api_token should be set' unless api_token.present?
7+
58
@api_token = api_token
69
end
710

@@ -12,7 +15,8 @@ def connection
1215
def make_api_call(*args)
1316
params = args.extract_options!
1417
method = args[0]
15-
fail 'method param missing' unless method.present?
18+
raise 'method param missing' unless method.present?
19+
1620
url = build_url(args, params.delete(:fields_to_select))
1721
params = params.to_json unless method.to_sym == :get
1822
begin
@@ -27,11 +31,9 @@ def make_api_call(*args)
2731
end
2832

2933
def build_url(args, fields_to_select = nil)
30-
url = "/v1/#{entity_name}"
34+
url = +"/v1/#{entity_name}"
3135
url << "/#{args[1]}" if args[1]
32-
if fields_to_select.is_a?(::Array) && fields_to_select.size > 0
33-
url << ":(#{fields_to_select.join(',')})"
34-
end
36+
url << ":(#{fields_to_select.join(',')})" if fields_to_select.is_a?(::Array) && fields_to_select.size.positive?
3537
url << "?api_token=#{@api_token}"
3638
url
3739
end
@@ -53,16 +55,16 @@ def failed_response(res)
5355
failed: false)
5456
case res.status
5557
when 401
56-
failed_res.merge! not_authorized: true
58+
failed_res[:not_authorized] = true
5759
when 420
58-
failed_res.merge! failed: true
60+
failed_res[:failed] = true
5961
end
6062
failed_res
6163
end
6264

6365
def entity_name
64-
class_name = self.class.name.split("::")[-1].downcase.pluralize
65-
class_names = { "people" => "persons" }
66+
class_name = self.class.name.split('::')[-1].downcase.pluralize
67+
class_names = { 'people' => 'persons' }
6668
class_names[class_name] || class_name
6769
end
6870

@@ -79,7 +81,8 @@ def faraday_options
7981
end
8082

8183
# This method smells of :reek:TooManyStatements
82-
def connection # :nodoc
84+
# :nodoc
85+
def connection
8386
@connection ||= Faraday.new(faraday_options) do |conn|
8487
conn.request :url_encoded
8588
conn.response :mashify

lib/pipedrive/deal.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Pipedrive
24
class Deal < Base
35
include ::Pipedrive::Operations::Create

lib/pipedrive/deal_field.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Pipedrive
24
class DealField < Base
35
include ::Pipedrive::Operations::Create

lib/pipedrive/file.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Pipedrive
24
class File < Base
35
include ::Pipedrive::Operations::Create

lib/pipedrive/filter.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Pipedrive
24
class Filter < Base
35
include ::Pipedrive::Operations::Read

lib/pipedrive/goal.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Pipedrive
24
class Goal < Base
35
include ::Pipedrive::Operations::Create

lib/pipedrive/note.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Pipedrive
24
class Note < Base
35
include ::Pipedrive::Operations::Create

lib/pipedrive/operations/create.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Pipedrive
24
module Operations
35
module Create

lib/pipedrive/operations/delete.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Pipedrive
24
module Operations
35
module Delete

0 commit comments

Comments
 (0)