asana 2.0.1 → 2.0.2

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +38 -3
  3. data/Appraisals +7 -6
  4. data/Gemfile +5 -3
  5. data/Gemfile.lock +22 -12
  6. data/Guardfile +12 -10
  7. data/README.md +3 -1
  8. data/Rakefile +14 -17
  9. data/VERSION +1 -1
  10. data/asana.gemspec +19 -17
  11. data/lib/asana/authentication/oauth2/access_token_authentication.rb +2 -0
  12. data/lib/asana/authentication/oauth2/bearer_token_authentication.rb +2 -0
  13. data/lib/asana/authentication/oauth2/client.rb +2 -0
  14. data/lib/asana/authentication/oauth2.rb +6 -4
  15. data/lib/asana/authentication/token_authentication.rb +2 -0
  16. data/lib/asana/authentication.rb +2 -0
  17. data/lib/asana/client/configuration.rb +6 -5
  18. data/lib/asana/client.rb +13 -11
  19. data/lib/asana/errors.rb +16 -11
  20. data/lib/asana/http_client/environment_info.rb +9 -8
  21. data/lib/asana/http_client/error_handling.rb +24 -23
  22. data/lib/asana/http_client/response.rb +2 -0
  23. data/lib/asana/http_client.rb +58 -60
  24. data/lib/asana/resource_includes/attachment_uploading.rb +2 -4
  25. data/lib/asana/resource_includes/collection.rb +4 -4
  26. data/lib/asana/resource_includes/event.rb +2 -0
  27. data/lib/asana/resource_includes/event_subscription.rb +2 -0
  28. data/lib/asana/resource_includes/events.rb +4 -1
  29. data/lib/asana/resource_includes/registry.rb +2 -0
  30. data/lib/asana/resource_includes/resource.rb +8 -5
  31. data/lib/asana/resource_includes/response_helper.rb +2 -0
  32. data/lib/asana/resources/audit_log_api.rb +42 -0
  33. data/lib/asana/resources/gen/attachments_base.rb +1 -1
  34. data/lib/asana/resources/gen/audit_log_api_base.rb +1 -1
  35. data/lib/asana/resources/gen/memberships_base.rb +71 -0
  36. data/lib/asana/resources/gen/tasks_base.rb +1 -1
  37. data/lib/asana/resources/goal.rb +54 -0
  38. data/lib/asana/resources/goal_relationship.rb +32 -0
  39. data/lib/asana/resources/membership.rb +20 -0
  40. data/lib/asana/resources/project_brief.rb +30 -0
  41. data/lib/asana/resources/project_template.rb +36 -0
  42. data/lib/asana/resources/status_update.rb +54 -0
  43. data/lib/asana/resources/time_period.rb +30 -0
  44. data/lib/asana/resources/typeahead.rb +1 -1
  45. data/lib/asana/resources.rb +4 -4
  46. data/lib/asana/ruby2_0_0_compatibility.rb +2 -0
  47. data/lib/asana/version.rb +1 -1
  48. data/lib/asana.rb +2 -0
  49. data/samples/memberships_sample.yaml +41 -0
  50. metadata +49 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c78f9f4dcaa8199ba6ba6422dc0691255e5c2f27688b2a4dd0a25839dc18d1e
4
- data.tar.gz: 8bc1e52ce2cf1644a96e6d7a57a1d01e894e299d1af3c9dc6dbc1550015fe17b
3
+ metadata.gz: 17dd95f3708910e6ac5e5fe3c342c26e1c26a93ddc2fe7609b3798fb4650f47d
4
+ data.tar.gz: 68d454cad1b9f85e93f2ab8ed3f20ddc24f8989fafb12bbe7f19bfc30aefd9c9
5
5
  SHA512:
6
- metadata.gz: c8a8b9ab41a2587fe635037c180c6c68e945e5cab02f260c8d171cd8915247f5ea0195c24245ab59861a8d165f462acaf8cc8daaec6b59d965eedce338ba3416
7
- data.tar.gz: 155604a2b12f2962685b5ebd35319ef19e5cc9b01d71bfb4fcbdf687b19623d0ba038853897011e9ade58c40e3611fac1307bf4f2937d6114517912636ad383e
6
+ metadata.gz: c04179f61fe4f7520853c24db93ab47db57de5b25a7751c982ced551613badfbd84a5408d7ff82bb6669a3057a417c6680e58a35787ec6f1fbc57f53ca788b7a
7
+ data.tar.gz: 35d8d1daa0c43915b6959735ca69b65fba2cab1936e44719082e6d52baadeb33e1770b6ba0b38d8e46cfedfd3e86864152a6591fe30f643b8e386217756bc932
data/.rubocop.yml CHANGED
@@ -1,14 +1,49 @@
1
+ require: rubocop-rspec
2
+
1
3
  AllCops:
2
- Include:
3
- - '**/Rakefile'
4
+ TargetRubyVersion: 2.7
5
+ NewCops: enable
4
6
  Exclude:
5
7
  - 'bin/**/*'
6
8
  - 'examples/**/*'
7
9
  - 'lib/asana/resources/*'
10
+ - 'lib/asana/resources/gen/**/*'
8
11
  - 'spec/templates/unicorn.rb'
9
12
  - 'spec/templates/world.rb'
10
13
  - 'test.rb'
11
14
 
12
15
  LineLength:
13
16
  Max: 120
14
- require: rubocop-rspec
17
+
18
+ Metrics/ParameterLists:
19
+ Enabled: false
20
+
21
+ Metrics/ClassLength:
22
+ Enabled: false
23
+
24
+ Metrics/MethodLength:
25
+ Max: 20
26
+
27
+ Metrics/CyclomaticComplexity:
28
+ Max: 20
29
+
30
+ Metrics/PerceivedComplexity:
31
+ Max: 20
32
+
33
+ RSpec/ContextWording:
34
+ Enabled: false
35
+
36
+ RSpec/ExampleLength:
37
+ Enabled: false
38
+
39
+ RSpec/MultipleExpectations:
40
+ Enabled: false
41
+
42
+ RSpec/NestedGroups:
43
+ Enabled: false
44
+
45
+ RSpec/FilePath:
46
+ CustomTransform: {'OAuth2': 'oauth2'}
47
+
48
+ RSpec/MultipleMemoizedHelpers:
49
+ Enabled: false
data/Appraisals CHANGED
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
1
2
 
2
- appraise "faraday-2.7.0" do
3
- gem "faraday", "2.7.0"
4
- end
3
+ appraise 'faraday-2.7.0' do
4
+ gem 'faraday', '2.7.0'
5
+ end
5
6
 
6
- appraise "faraday-2.6.0" do
7
- gem "faraday", "2.6.0"
8
- end
7
+ appraise 'faraday-2.6.0' do
8
+ gem 'faraday', '2.6.0'
9
+ end
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in asana.gemspec
@@ -9,8 +11,8 @@ group :tools do
9
11
  # routinely adds new checks which can cause our build to "break" even when no
10
12
  # changes have been made. In this situation it's better to intentionally
11
13
  # upgrade Rubocop and fix issues at that time.
12
- gem 'rubocop', '~> 0.52.1'
13
- gem 'rubocop-rspec', '~> 1.22.2'
14
+ gem 'rubocop', '~> 1.47.0'
15
+ gem 'rubocop-rspec', '~> 2.18.1'
14
16
 
15
17
  gem 'oauth2', '~> 2.0.3'
16
18
 
@@ -26,5 +28,5 @@ group :tools do
26
28
 
27
29
  gem 'simplecov', require: false
28
30
 
29
- gem "rack-protection", "1.5.5"
31
+ gem 'rack-protection', '1.5.5'
30
32
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- asana (2.0.1)
4
+ asana (2.0.2)
5
5
  faraday (~> 2.0)
6
6
  faraday-follow_redirects
7
7
  faraday-multipart
@@ -50,6 +50,7 @@ GEM
50
50
  guard (>= 1.1.0)
51
51
  yard (>= 0.7.0)
52
52
  hashie (5.0.0)
53
+ json (2.6.3)
53
54
  jwt (2.7.0)
54
55
  listen (3.8.0)
55
56
  rb-fsevent (~> 0.10, >= 0.10.3)
@@ -70,9 +71,8 @@ GEM
70
71
  snaky_hash (~> 2.0)
71
72
  version_gem (~> 1.1)
72
73
  parallel (1.22.1)
73
- parser (2.7.2.0)
74
+ parser (3.2.1.0)
74
75
  ast (~> 2.4.1)
75
- powerpack (0.1.3)
76
76
  pry (0.14.2)
77
77
  coderay (~> 1.1)
78
78
  method_source (~> 1.0)
@@ -84,6 +84,8 @@ GEM
84
84
  rb-fsevent (0.11.2)
85
85
  rb-inotify (0.10.1)
86
86
  ffi (~> 1.0)
87
+ regexp_parser (2.7.0)
88
+ rexml (3.2.5)
87
89
  rspec (3.12.0)
88
90
  rspec-core (~> 3.12.0)
89
91
  rspec-expectations (~> 3.12.0)
@@ -97,15 +99,23 @@ GEM
97
99
  diff-lcs (>= 1.2.0, < 2.0)
98
100
  rspec-support (~> 3.12.0)
99
101
  rspec-support (3.12.0)
100
- rubocop (0.52.1)
102
+ rubocop (1.47.0)
103
+ json (~> 2.3)
101
104
  parallel (~> 1.10)
102
- parser (>= 2.4.0.2, < 3.0)
103
- powerpack (~> 0.1)
105
+ parser (>= 3.2.0.0)
104
106
  rainbow (>= 2.2.2, < 4.0)
107
+ regexp_parser (>= 1.8, < 3.0)
108
+ rexml (>= 3.2.5, < 4.0)
109
+ rubocop-ast (>= 1.26.0, < 2.0)
105
110
  ruby-progressbar (~> 1.7)
106
- unicode-display_width (~> 1.0, >= 1.0.1)
107
- rubocop-rspec (1.22.2)
108
- rubocop (>= 0.52.1)
111
+ unicode-display_width (>= 2.4.0, < 3.0)
112
+ rubocop-ast (1.27.0)
113
+ parser (>= 3.2.1.0)
114
+ rubocop-capybara (2.17.1)
115
+ rubocop (~> 1.41)
116
+ rubocop-rspec (2.18.1)
117
+ rubocop (~> 1.33)
118
+ rubocop-capybara (~> 2.17)
109
119
  ruby-progressbar (1.13.0)
110
120
  ruby2_keywords (0.0.5)
111
121
  shellany (0.0.1)
@@ -120,7 +130,7 @@ GEM
120
130
  version_gem (~> 1.1, >= 1.1.1)
121
131
  thor (1.2.1)
122
132
  tomparse (0.4.2)
123
- unicode-display_width (1.8.0)
133
+ unicode-display_width (2.4.2)
124
134
  version_gem (1.1.1)
125
135
  webrick (1.7.0)
126
136
  yard (0.9.28)
@@ -146,8 +156,8 @@ DEPENDENCIES
146
156
  rack-protection (= 1.5.5)
147
157
  rake (~> 13.0)
148
158
  rspec (~> 3.2)
149
- rubocop (~> 0.52.1)
150
- rubocop-rspec (~> 1.22.2)
159
+ rubocop (~> 1.47.0)
160
+ rubocop-rspec (~> 2.18.1)
151
161
  simplecov
152
162
  yard
153
163
  yard-tomdoc
data/Guardfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # A sample Guardfile
2
4
  # More info at https://github.com/guard/guard#readme
3
5
 
@@ -23,7 +25,7 @@
23
25
  #
24
26
  # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
25
27
 
26
- # Note: The cmd option is now required due to the increasing number of ways
28
+ # NOTE: The cmd option is now required due to the increasing number of ways
27
29
  # rspec may be run, below are examples of the most common uses.
28
30
  # * bundler: 'bundle exec rspec'
29
31
  # * bundler binstubs: 'bin/rspec'
@@ -32,8 +34,8 @@
32
34
  # * zeus: 'zeus rspec' (requires the server to be started separately)
33
35
  # * 'just' rspec: 'rspec'
34
36
 
35
- guard :rspec, cmd: "bundle exec rspec" do
36
- require "guard/rspec/dsl"
37
+ guard :rspec, cmd: 'bundle exec rspec' do
38
+ require 'guard/rspec/dsl'
37
39
  dsl = Guard::RSpec::Dsl.new(self)
38
40
 
39
41
  # Feel free to open issues for suggestions and improvements
@@ -47,15 +49,15 @@ guard :rspec, cmd: "bundle exec rspec" do
47
49
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
48
50
 
49
51
  # Rails files
50
- rails = dsl.rails(view_extensions: %w(erb haml slim))
52
+ rails = dsl.rails(view_extensions: %w[erb haml slim])
51
53
  dsl.watch_spec_files_for(rails.app_files)
52
54
  dsl.watch_spec_files_for(rails.views)
53
55
 
54
56
  watch(rails.controllers) do |m|
55
57
  [
56
- rspec.spec.("routing/#{m[1]}_routing"),
57
- rspec.spec.("controllers/#{m[1]}_controller"),
58
- rspec.spec.("acceptance/#{m[1]}")
58
+ rspec.spec.call("routing/#{m[1]}_routing"),
59
+ rspec.spec.call("controllers/#{m[1]}_controller"),
60
+ rspec.spec.call("acceptance/#{m[1]}")
59
61
  ]
60
62
  end
61
63
 
@@ -65,17 +67,17 @@ guard :rspec, cmd: "bundle exec rspec" do
65
67
  watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
66
68
 
67
69
  # Capybara features specs
68
- watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
70
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
69
71
 
70
72
  # Turnip features and steps
71
73
  watch(%r{^spec/acceptance/(.+)\.feature$})
72
74
  watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
73
- Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
75
+ Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
74
76
  end
75
77
  end
76
78
 
77
79
  guard :rubocop do
78
- watch(%r{.+\.rb$})
80
+ watch(/.+\.rb$/)
79
81
  watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
80
82
  end
81
83
 
data/README.md CHANGED
@@ -9,7 +9,9 @@ A Ruby client for the 1.0 version of the Asana API.
9
9
 
10
10
  Supported rubies:
11
11
 
12
- * MRI 2.0.0 up to 2.2.x stable
12
+ * MRI 2.7.x
13
+ * MRI 3.0.x
14
+ * MRI 3.1.x
13
15
 
14
16
  ## Gem Installation
15
17
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/setup'
2
4
  require 'bundler/gem_tasks'
3
5
  require 'appraisal'
@@ -19,6 +21,7 @@ task :codegen do
19
21
  `node spec/support/codegen.js`
20
22
  end
21
23
 
24
+ # rubocop:disable Metrics/BlockLength
22
25
  namespace :bump do
23
26
  def read_version
24
27
  File.readlines('./lib/asana/version.rb')
@@ -27,23 +30,17 @@ namespace :bump do
27
30
  .map { |n| Integer(n) }
28
31
  end
29
32
 
30
- # rubocop:disable Metrics/MethodLength
31
33
  def write_version(major, minor, patch)
34
+ File.write('VERSION', "#{major}.#{minor}.#{patch}")
32
35
 
33
- File.open('VERSION', 'w') do |f|
34
- f.write "#{major}.#{minor}.#{patch}"
35
- end
36
-
37
- str = <<-EOS
38
- #:nodoc:
39
- module Asana
40
- # Public: Version of the gem.
41
- VERSION = '#{major}.#{minor}.#{patch}'
42
- end
43
- EOS
44
- File.open('./lib/asana/version.rb', 'w') do |f|
45
- f.write str
46
- end
36
+ str = <<~RUBY
37
+ #:nodoc:
38
+ module Asana
39
+ # Public: Version of the gem.
40
+ VERSION = '#{major}.#{minor}.#{patch}'
41
+ end
42
+ RUBY
43
+ File.write('./lib/asana/version.rb', str)
47
44
 
48
45
  new_version = "#{major}.#{minor}.#{patch}"
49
46
  system('bundle lock --update')
@@ -73,10 +70,10 @@ EOS
73
70
  write_version major + 1, 0, 0
74
71
  end
75
72
  end
73
+ # rubocop:enable Metrics/BlockLength
76
74
 
77
75
  desc 'Default: run the unit tests.'
78
- task default: [:all, :rubocop, :yard]
79
-
76
+ task default: %i[all rubocop yard]
80
77
 
81
78
  desc 'Test the plugin under all supported Rails versions.'
82
79
  task :all do |_t|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.1
1
+ 2.0.2
data/asana.gemspec CHANGED
@@ -1,32 +1,34 @@
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
5
  require 'asana/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "asana"
8
+ spec.name = 'asana'
8
9
  spec.version = Asana::VERSION
9
- spec.authors = ["Txus"]
10
- spec.email = ["me@txus.io"]
10
+ spec.authors = ['Txus']
11
+ spec.email = ['me@txus.io']
11
12
 
12
- spec.summary = %q{Official Ruby client for the Asana API}
13
- spec.description = %q{Official Ruby client for the Asana API}
14
- spec.homepage = "https://github.com/asana/ruby-asana"
15
- spec.license = "MIT"
13
+ spec.summary = 'Official Ruby client for the Asana API'
14
+ spec.description = 'Official Ruby client for the Asana API'
15
+ spec.homepage = 'https://github.com/asana/ruby-asana'
16
+ spec.license = 'MIT'
16
17
 
17
18
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
19
+ spec.bindir = 'exe'
19
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
21
+ spec.require_paths = ['lib']
21
22
 
22
23
  spec.required_ruby_version = '>= 2.7'
23
24
 
24
- spec.add_dependency "oauth2", ">= 1.4", '< 3'
25
- spec.add_dependency "faraday", "~> 2.0"
26
- spec.add_dependency "faraday-follow_redirects"
27
- spec.add_dependency "faraday-multipart"
25
+ spec.add_dependency 'faraday', '~> 2.0'
26
+ spec.add_dependency 'faraday-follow_redirects'
27
+ spec.add_dependency 'faraday-multipart'
28
+ spec.add_dependency 'oauth2', '>= 1.4', '< 3'
28
29
 
29
- spec.add_development_dependency "rake", "~> 13.0"
30
- spec.add_development_dependency "rspec", "~> 3.2"
31
30
  spec.add_development_dependency 'appraisal', '~> 2.1', '>= 2.1'
31
+ spec.add_development_dependency 'rake', '~> 13.0'
32
+ spec.add_development_dependency 'rspec', '~> 3.2'
33
+ spec.metadata['rubygems_mfa_required'] = 'true'
32
34
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Asana
2
4
  module Authentication
3
5
  module OAuth2
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Asana
2
4
  module Authentication
3
5
  module OAuth2
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'oauth2'
2
4
 
3
5
  module Asana
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'oauth2/bearer_token_authentication'
2
4
  require_relative 'oauth2/access_token_authentication'
3
5
  require_relative 'oauth2/client'
@@ -31,10 +33,10 @@ module Asana
31
33
  client = Client.new(client_id: client_id,
32
34
  client_secret: client_secret,
33
35
  redirect_uri: 'urn:ietf:wg:oauth:2.0:oob')
34
- STDOUT.puts '1. Go to the following URL to authorize the ' \
35
- " application: #{client.authorize_url}"
36
- STDOUT.puts '2. Paste the authorization code here: '
37
- auth_code = STDIN.gets.chomp
36
+ $stdout.puts '1. Go to the following URL to authorize the ' \
37
+ "application: #{client.authorize_url}"
38
+ $stdout.puts '2. Paste the authorization code here: '
39
+ auth_code = $stdin.gets.chomp
38
40
  client.token_from_auth_code(auth_code)
39
41
  end
40
42
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Asana
2
4
  module Authentication
3
5
  # Public: Represents an API token authentication mechanism.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'authentication/oauth2'
2
4
  require_relative 'authentication/token_authentication'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Asana
2
4
  class Client
3
5
  # Internal: Represents a configuration DSL for an Asana::Client.
@@ -17,7 +19,7 @@ module Asana
17
19
  # Public: Initializes an empty configuration object.
18
20
  def initialize
19
21
  @configuration = {
20
- :log_asana_change_warnings => true
22
+ log_asana_change_warnings: true
21
23
  }
22
24
  end
23
25
 
@@ -100,7 +102,6 @@ module Asana
100
102
  #
101
103
  # Raises ArgumentError if the OAuth2 configuration arguments are invalid.
102
104
  #
103
- # rubocop:disable Metrics/MethodLength
104
105
  def oauth2(value)
105
106
  case value
106
107
  when ::OAuth2::AccessToken
@@ -111,8 +112,8 @@ module Asana
111
112
  from_bearer_token(value[:bearer_token])
112
113
  else
113
114
  error 'Invalid OAuth2 configuration: pass in either an ' \
114
- '::OAuth2::AccessToken object of your own or a hash ' \
115
- 'containing :refresh_token or :bearer_token.'
115
+ '::OAuth2::AccessToken object of your own or a hash ' \
116
+ 'containing :refresh_token or :bearer_token.'
116
117
  end
117
118
  end
118
119
 
@@ -158,7 +159,7 @@ module Asana
158
159
  end
159
160
 
160
161
  def requiring(hash, *keys)
161
- missing_keys = keys.select { |k| !hash.key?(k) }
162
+ missing_keys = keys.reject { |k| hash.key?(k) }
162
163
  missing_keys.any? && error("Missing keys: #{missing_keys.join(', ')}")
163
164
  keys.map { |k| hash[k] }
164
165
  end
data/lib/asana/client.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'authentication'
2
4
  require_relative 'client/configuration'
3
5
  require_relative 'resources'
@@ -59,12 +61,12 @@ module Asana
59
61
  @resource = resource
60
62
  end
61
63
 
62
- def method_missing(m, *args, **kwargs, &block)
63
- @resource.public_send(m, *([@client] + args), **kwargs, &block)
64
+ def method_missing(method_name, *args, **kwargs, &block)
65
+ @resource.public_send(method_name, *([@client] + args), **kwargs, &block)
64
66
  end
65
67
 
66
- def respond_to_missing?(m, *)
67
- @resource.respond_to?(m)
68
+ def respond_to_missing?(method_name, *)
69
+ @resource.respond_to?(method_name)
68
70
  end
69
71
  end
70
72
 
@@ -72,15 +74,15 @@ module Asana
72
74
  #
73
75
  # Yields a {Asana::Client::Configuration} object as a configuration
74
76
  # DSL. See {Asana::Client} for usage examples.
75
- def initialize
76
- config = Configuration.new.tap { |c| yield c }.to_h
77
+ def initialize(&block)
78
+ config = Configuration.new.tap(&block).to_h
77
79
  @http_client =
78
- HttpClient.new(authentication: config.fetch(:authentication),
79
- adapter: config[:faraday_adapter],
80
- user_agent: config[:user_agent],
81
- debug_mode: config[:debug_mode],
80
+ HttpClient.new(authentication: config.fetch(:authentication),
81
+ adapter: config[:faraday_adapter],
82
+ user_agent: config[:user_agent],
83
+ debug_mode: config[:debug_mode],
82
84
  log_asana_change_warnings: config[:log_asana_change_warnings],
83
- default_headers: config[:default_headers],
85
+ default_headers: config[:default_headers],
84
86
  &config[:faraday_configuration])
85
87
  end
86
88
 
data/lib/asana/errors.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Asana
2
4
  # Public: Defines the different errors that the Asana API may throw, which the
3
5
  # client code may want to catch.
@@ -19,8 +21,8 @@ module Asana
19
21
  # user could not be authenticated.
20
22
  NotAuthorized = Class.new(APIError) do
21
23
  def to_s
22
- 'Valid credentials were not provided with the request, so the API could '\
23
- 'not associate a user with the request.'
24
+ 'Valid credentials were not provided with the request, so the API could ' \
25
+ 'not associate a user with the request.'
24
26
  end
25
27
  end
26
28
 
@@ -28,8 +30,8 @@ module Asana
28
30
  # that requires a premium account (Payment Required).
29
31
  PremiumOnly = Class.new(APIError) do
30
32
  def to_s
31
- 'The endpoint that is being requested is only available to premium '\
32
- 'users.'
33
+ 'The endpoint that is being requested is only available to premium ' \
34
+ 'users.'
33
35
  end
34
36
  end
35
37
 
@@ -37,18 +39,18 @@ module Asana
37
39
  # access the requested resource or to perform the requested action on it.
38
40
  Forbidden = Class.new(APIError) do
39
41
  def to_s
40
- 'The authorization and request syntax was valid but the server is refusing '\
41
- 'to complete the request. This can happen if you try to read or write '\
42
- 'to objects or properties that the user does not have access to.'
42
+ 'The authorization and request syntax was valid but the server is refusing ' \
43
+ 'to complete the request. This can happen if you try to read or write ' \
44
+ 'to objects or properties that the user does not have access to.'
43
45
  end
44
46
  end
45
47
 
46
48
  # Public: A 404 error. Raised when the requested resource doesn't exist.
47
49
  NotFound = Class.new(APIError) do
48
50
  def to_s
49
- 'Either the request method and path supplied do not specify a known '\
50
- 'action in the API, or the object specified by the request does not '\
51
- 'exist.'
51
+ 'Either the request method and path supplied do not specify a known ' \
52
+ 'action in the API, or the object specified by the request does not ' \
53
+ 'exist.'
52
54
  end
53
55
  end
54
56
 
@@ -59,11 +61,12 @@ module Asana
59
61
  attr_accessor :phrase
60
62
 
61
63
  def initialize(phrase)
64
+ super()
62
65
  @phrase = phrase
63
66
  end
64
67
 
65
68
  def to_s
66
- "There has been an error on Asana's end. Use this unique phrase to "\
69
+ "There has been an error on Asana's end. Use this unique phrase to " \
67
70
  'identify the problem when contacting support: ' + %("#{@phrase}")
68
71
  end
69
72
  end
@@ -74,6 +77,7 @@ module Asana
74
77
  attr_accessor :errors
75
78
 
76
79
  def initialize(errors)
80
+ super()
77
81
  @errors = errors
78
82
  end
79
83
 
@@ -89,6 +93,7 @@ module Asana
89
93
  attr_accessor :retry_after_seconds
90
94
 
91
95
  def initialize(retry_after_seconds)
96
+ super()
92
97
  @retry_after_seconds = retry_after_seconds
93
98
  end
94
99
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../version'
2
4
  require 'openssl'
3
5
 
@@ -6,7 +8,7 @@ module Asana
6
8
  # Internal: Adds environment information to a Faraday request.
7
9
  class EnvironmentInfo
8
10
  # Internal: The default user agent to use in all requests to the API.
9
- USER_AGENT = "ruby-asana v#{Asana::VERSION}".freeze
11
+ USER_AGENT = "ruby-asana v#{Asana::VERSION}"
10
12
 
11
13
  def initialize(user_agent = nil)
12
14
  @user_agent = user_agent || USER_AGENT
@@ -19,7 +21,7 @@ module Asana
19
21
  # environment.
20
22
  def configure(builder)
21
23
  builder.headers[:user_agent] = @user_agent
22
- builder.headers[:"X-Asana-Client-Lib"] = header
24
+ builder.headers[:'X-Asana-Client-Lib'] = header
23
25
  end
24
26
 
25
27
  private
@@ -33,21 +35,20 @@ module Asana
33
35
  .map { |k, v| "#{k}=#{v}" }.join('&')
34
36
  end
35
37
 
36
- # rubocop:disable Metrics/MethodLength
37
38
  def os
38
- if RUBY_PLATFORM =~ /win32/ || RUBY_PLATFORM =~ /mingw/
39
+ case RUBY_PLATFORM
40
+ when /win32/, /mingw/
39
41
  'windows'
40
- elsif RUBY_PLATFORM =~ /linux/
42
+ when /linux/
41
43
  'linux'
42
- elsif RUBY_PLATFORM =~ /darwin/
44
+ when /darwin/
43
45
  'darwin'
44
- elsif RUBY_PLATFORM =~ /freebsd/
46
+ when /freebsd/
45
47
  'freebsd'
46
48
  else
47
49
  'unknown'
48
50
  end
49
51
  end
50
- # rubocop:enable Metrics/MethodLength
51
52
  end
52
53
  end
53
54
  end