asana_exception_notifier 0.3.6 → 0.3.7

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
  SHA1:
3
- metadata.gz: b1cb4ae76fceebfea087b47a6d8e8ff3997e29ed
4
- data.tar.gz: 267e2552aec5fdbb6963ee6e91c9d3b186358563
3
+ metadata.gz: 7146f3fe811fe1909ad84cc008c280b582243ac4
4
+ data.tar.gz: ed259cf7bde745cca8e6216f3ed4f74feee61c69
5
5
  SHA512:
6
- metadata.gz: 71f94b10c551a36901915a3f7f9b557c2122187b1712bcd8a2fd542b67c49138c9b799d347b94e7cdce9a39afda9fff8318a6481dae8266d6631b79e2532d011
7
- data.tar.gz: 0f42aa22a72bbcf8d5220d8e01f15837acdb5d309216e35db522e27d627d7d2f306130a850555b7ba11acb34f50ba75af33348c40ab5e9340a0394aacc1dd733
6
+ metadata.gz: 2aa1c417b693b4cd76af610efd4899d549711d528ab29d40a558e503799782a640ebc4caf0400efdc7c22b258bb749b87df33c8dde6045458a9de09b39edd9f9
7
+ data.tar.gz: a5dd37f5b20524553ff4ff1cca5abf304cf9b0333c80a01d8d71cf327f057ef4a24053245a6b066f28245ffb3ba2639f38b3c056e2b7935312b0f0288b1e53f7
data/.rubocop.yml CHANGED
@@ -1,10 +1,11 @@
1
1
  AllCops:
2
2
  Exclude:
3
- - washout_builder.gemspec
3
+ - asana_exception_notifier.gemspec
4
4
  - bin/**/*
5
5
  - Guardfile
6
6
  - vendor/**/*
7
7
  - examples/**/*
8
+ - spec/**/*
8
9
  TargetRubyVersion: 2.1
9
10
 
10
11
  ClassLength:
data/.travis.yml CHANGED
@@ -7,25 +7,10 @@ bundler_args: "--no-deployment"
7
7
  script:
8
8
  - echo $BUNDLE_GEMFILE
9
9
  - bundle exec rake
10
- gemfile:
11
- - gemfiles/rails_4.0.0.gemfile
12
- - gemfiles/rails_4.1.1.gemfile
13
- - gemfiles/rails_4.2.0.gemfile
14
10
  rvm:
15
11
  - 2.0.0
16
12
  - 2.1.5
17
- - 2.1.8
18
- - 2.2.2
19
13
  - 2.2.3
20
- - 2.3.0
21
14
  - 2.3.1
22
- matrix:
23
- exclude:
24
- - rvm: 2.0.0
25
- gemfile: gemfiles/rails_5.0.0.gemfile
26
- - rvm: 2.1.5
27
- gemfile: gemfiles/rails_5.0.0.gemfile
28
- - rvm: 2.1.8
29
- gemfile: gemfiles/rails_5.0.0.gemfile
30
15
  notifications:
31
16
  email: false
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- if RUBY_VERSION >= "2.2.0"
5
+ if RUBY_VERSION >= '2.2.0'
6
6
  gem 'activesupport', '>= 4.0', '>= 4.0'
7
7
  else
8
8
  gem 'activesupport', '>= 4.0', '< 5.0'
data/Rakefile CHANGED
@@ -7,25 +7,25 @@ require 'yard'
7
7
  Coveralls::RakeTask.new
8
8
 
9
9
  RSpec::Core::RakeTask.new(:spec) do |spec|
10
- default_options = ['--colour']
11
- default_options.concat(['--backtrace', '--fail-fast']) if ENV['DEBUG']
12
- spec.rspec_opts = default_options
13
- spec.verbose = true
14
- end
10
+ default_options = ['--colour']
11
+ default_options.concat(['--backtrace', '--fail-fast']) if ENV['DEBUG']
12
+ spec.rspec_opts = default_options
13
+ spec.verbose = true
14
+ end
15
15
 
16
- YARD::Config.options[:load_plugins] = true
17
- YARD::Config.load_plugins
16
+ YARD::Config.options[:load_plugins] = true
17
+ YARD::Config.load_plugins
18
18
 
19
- # dirty hack for YardocTask
20
- ::Rake.application.class.class_eval do
21
- alias_method :last_comment, :last_description
22
- end
19
+ # dirty hack for YardocTask
20
+ ::Rake.application.class.class_eval do
21
+ alias_method :last_comment, :last_description
22
+ end
23
23
 
24
- YARD::Rake::YardocTask.new do |t|
25
- t.files = ['lib/**/*.rb', 'spec/**/*_spec.rb'] # optional
26
- t.options = ['--any', '--extra', '--opts', '--markup-provider=redcarpet', '--markup=markdown', '--debug'] # optional
27
- t.stats_options = ['--list-undoc'] # optional
28
- end
24
+ YARD::Rake::YardocTask.new do |t|
25
+ t.files = ['lib/**/*.rb', 'spec/**/*_spec.rb'] # optional
26
+ t.options = ['--any', '--extra', '--opts', '--markup-provider=redcarpet', '--markup=markdown', '--debug'] # optional
27
+ t.stats_options = ['--list-undoc'] # optional
28
+ end
29
29
 
30
30
  desc 'Default: run the unit tests.'
31
31
  task default: [:all]
@@ -38,10 +38,10 @@ task :all do |_t|
38
38
  if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
39
39
  appraisal_name = ENV['BUNDLE_GEMFILE'].scan(/rails\_(.*)\.gemfile/).flatten.first
40
40
  command_prefix = "appraisal rails-#{appraisal_name}"
41
- exec ("#{command_prefix} bundle install && #{command_prefix} bundle exec rspec && bundle exec rake coveralls:push ")
41
+ exec("#{command_prefix} bundle install && #{command_prefix} bundle exec rspec && bundle exec rake coveralls:push ")
42
42
  else
43
43
  exec(' bundle exec appraisal install && bundle exec rake appraisal spec && bundle exec rake coveralls:push')
44
- end
44
+ end
45
45
  else
46
46
  exec('bundle exec appraisal install && bundle exec rake appraisal spec')
47
47
  end
@@ -38,8 +38,8 @@ class SinatraApp < Sinatra::Base
38
38
  get '/background_notification' do
39
39
  begin
40
40
  1/0
41
- rescue Exception => e
42
- ExceptionNotifier.notify_exception(e, :data => {:msg => "Cannot divide by zero!"})
41
+ rescue Exception => exception
42
+ ExceptionNotifier.notify_exception(exception, :data => {:msg => "Cannot divide by zero!"})
43
43
  end
44
44
  'Check notification at <a href="http://asana.com">Asana</a>.'
45
45
  end
@@ -16,16 +16,19 @@ module ExceptionNotifier
16
16
  parse_options(@initial_options)
17
17
  end
18
18
 
19
-
20
19
  def asana_client
21
- @asana_client = Asana::Client.new do |c|
22
- c.authentication :access_token, asana_api_key
23
- c.debug_mode
24
- c.faraday_adapter :typhoeus
25
- c.configure_faraday do |conn|
26
- conn.request :url_encoded
27
- conn.response :logger
28
- end
20
+ @asana_client = Asana::Client.new do |config|
21
+ config.authentication :access_token, asana_api_key
22
+ config.debug_mode
23
+ config.faraday_adapter :typhoeus
24
+ faraday_configuration(config)
25
+ end
26
+ end
27
+
28
+ def faraday_configuration(config)
29
+ config.configure_faraday do |conn|
30
+ conn.request :url_encoded
31
+ conn.response :logger
29
32
  end
30
33
  end
31
34
 
@@ -90,7 +93,7 @@ module ExceptionNotifier
90
93
  ).symbolize_keys!
91
94
  end
92
95
 
93
- # This method fetches data from Github api and returns the size in
96
+ #
94
97
  #
95
98
  # @return [void]
96
99
  def create_asana_task(error_page)
@@ -109,9 +112,11 @@ module ExceptionNotifier
109
112
 
110
113
  def upload_archive(zip, task)
111
114
  return if task.blank?
112
- attachment = task.attach(filename: zip,
113
- mime: 'application/zip')
114
- FileUtils.rm_rf([zip])
115
+ task.attach(
116
+ filename: zip,
117
+ mime: 'application/zip'
118
+ )
119
+ FileUtils.rm_rf([zip])
115
120
  end
116
121
  end
117
122
  end
@@ -36,7 +36,8 @@ module AsanaExceptionNotifier
36
36
  template_extension: template_extension
37
37
  )
38
38
  end
39
-
39
+
40
+ # :reek:TooManyStatements: { max_statements: 10 }
40
41
  def parse_exception_options
41
42
  @template_params ||= {
42
43
  basic_info: fetch_basic_info,
@@ -77,10 +78,10 @@ module AsanaExceptionNotifier
77
78
  end
78
79
 
79
80
  def exception_service
80
- hash = Hash.new
81
+ hash = {}
81
82
  @exception.instance_variables.select do |ivar|
82
83
  attr_value = @exception.instance_variable_get(ivar)
83
- hash["#{ivar}"] = attr_value if attr_value.present?
84
+ hash[ivar.to_s] = attr_value if attr_value.present?
84
85
  end
85
86
  hash
86
87
  end
@@ -123,21 +124,29 @@ module AsanaExceptionNotifier
123
124
  hash
124
125
  end
125
126
 
126
- def fetch_fieldsets(hash = {})
127
+ def build_template_params_hash(hash)
127
128
  @template_params.each_with_parent do |parent, key, value|
128
129
  next if value.blank? || key.blank?
129
130
  parent_name = set_fieldset_key(hash, parent, 'system_info')
130
131
  hash[parent_name][key] = value
131
132
  end
133
+ end
134
+
135
+ def fetch_fieldsets(hash = {})
136
+ build_template_params_hash(hash)
132
137
  hash.keys.map(&:to_s).sort
133
138
  hash
134
139
  end
135
140
 
141
+ def setup_template_params_for_rendering
142
+ @template_params[:fieldsets] = fieldsets
143
+ @template_params[:fieldsets_links] = fieldsets_links
144
+ end
145
+
136
146
  def render_template(template = nil)
137
147
  execute_with_rescue do
138
148
  current_template = template.present? ? template : @template_path
139
- @template_params[:fieldsets] = fieldsets
140
- @template_params[:fieldsets_links] = fieldsets_links
149
+ setup_template_params_for_rendering
141
150
  Tilt.new(current_template).render(self, @template_params.stringify_keys)
142
151
  end
143
152
  end
@@ -69,7 +69,7 @@ module AsanaExceptionNotifier
69
69
  #
70
70
  # @api public
71
71
  def logger
72
- @logger ||= ( defined?(Rails) && rails_logger.present? ? rails_logger : ExceptionNotifier.logger )
72
+ @logger ||= (defined?(Rails) && rails_logger.present? ? rails_logger : ExceptionNotifier.logger)
73
73
  @logger = @logger.present? ? @logger : Logger.new(STDOUT)
74
74
  end
75
75
 
@@ -192,7 +192,6 @@ module AsanaExceptionNotifier
192
192
  }
193
193
  end
194
194
 
195
-
196
195
  def split_archive(archive, partial_name, segment_size)
197
196
  indexes = Zip::File.split(archive, segment_size, true, partial_name)
198
197
  archives = Array.new(indexes) do |index|
@@ -3,10 +3,14 @@ class Hash
3
3
  def each_with_parent(parent = nil, &block)
4
4
  each do |key, value|
5
5
  if value.is_a?(Hash)
6
- value.each_with_parent(key, &block)
7
- else
6
+ deep_hash_with_parent(value, key, &block)
7
+ elsif block_given?
8
8
  yield(parent, key, value)
9
9
  end
10
10
  end
11
11
  end
12
+
13
+ def deep_hash_with_parent(value, key, &block)
14
+ value.each_with_parent(key, &block)
15
+ end
12
16
  end
@@ -17,7 +17,7 @@ module AsanaExceptionNotifier
17
17
  # minor release version
18
18
  MINOR = 3
19
19
  # tiny release version
20
- TINY = 6
20
+ TINY = 7
21
21
  # prelease version ( set this only if it is a prelease)
22
22
  PRE = nil
23
23
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asana_exception_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-07 00:00:00.000000000 Z
11
+ date: 2016-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -408,9 +408,6 @@ files:
408
408
  - examples/sinatra/README.md
409
409
  - examples/sinatra/config.ru
410
410
  - examples/sinatra/sinatra_app.rb
411
- - gemfiles/rails_4.0.0.gemfile
412
- - gemfiles/rails_4.1.1.gemfile
413
- - gemfiles/rails_4.2.0.gemfile
414
411
  - init.rb
415
412
  - lib/asana_exception_notifier.rb
416
413
  - lib/asana_exception_notifier/classes/asana.rb
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "activesupport", ">= 4.0", ">= 4.0"
6
- gem "rails", "4.0.0"
7
-
8
- gemspec :path => "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "activesupport", ">= 4.0", ">= 4.0"
6
- gem "rails", "4.0.2"
7
-
8
- gemspec :path => "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "activesupport", ">= 4.0", ">= 4.0"
6
- gem "rails", "4.2.0"
7
-
8
- gemspec :path => "../"