lhc 12.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +37 -0
  3. data/.rubocop.localch.yml +325 -0
  4. data/.rubocop.yml +61 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +13 -0
  7. data/Gemfile.activesupport4 +4 -0
  8. data/Gemfile.activesupport5 +4 -0
  9. data/Gemfile.activesupport6 +4 -0
  10. data/LICENSE +674 -0
  11. data/README.md +984 -0
  12. data/Rakefile +25 -0
  13. data/cider-ci.yml +6 -0
  14. data/cider-ci/bin/bundle +51 -0
  15. data/cider-ci/bin/ruby_install +8 -0
  16. data/cider-ci/bin/ruby_version +25 -0
  17. data/cider-ci/jobs/rspec-activesupport-4.yml +28 -0
  18. data/cider-ci/jobs/rspec-activesupport-5.yml +27 -0
  19. data/cider-ci/jobs/rspec-activesupport-6.yml +28 -0
  20. data/cider-ci/jobs/rubocop.yml +18 -0
  21. data/cider-ci/task_components/bundle.yml +22 -0
  22. data/cider-ci/task_components/rspec.yml +36 -0
  23. data/cider-ci/task_components/rubocop.yml +29 -0
  24. data/cider-ci/task_components/ruby.yml +15 -0
  25. data/friday.yml +3 -0
  26. data/lhc.gemspec +39 -0
  27. data/lib/core_ext/hash/deep_transform_values.rb +48 -0
  28. data/lib/lhc.rb +136 -0
  29. data/lib/lhc/concerns/lhc/basic_methods_concern.rb +42 -0
  30. data/lib/lhc/concerns/lhc/configuration_concern.rb +20 -0
  31. data/lib/lhc/concerns/lhc/fix_invalid_encoding_concern.rb +42 -0
  32. data/lib/lhc/concerns/lhc/formats_concern.rb +25 -0
  33. data/lib/lhc/concerns/lhc/request/user_agent_concern.rb +25 -0
  34. data/lib/lhc/config.rb +47 -0
  35. data/lib/lhc/endpoint.rb +119 -0
  36. data/lib/lhc/error.rb +80 -0
  37. data/lib/lhc/errors/client_error.rb +73 -0
  38. data/lib/lhc/errors/parser_error.rb +4 -0
  39. data/lib/lhc/errors/server_error.rb +28 -0
  40. data/lib/lhc/errors/timeout.rb +4 -0
  41. data/lib/lhc/errors/unknown_error.rb +4 -0
  42. data/lib/lhc/format.rb +18 -0
  43. data/lib/lhc/formats.rb +8 -0
  44. data/lib/lhc/formats/form.rb +45 -0
  45. data/lib/lhc/formats/json.rb +55 -0
  46. data/lib/lhc/formats/multipart.rb +45 -0
  47. data/lib/lhc/formats/plain.rb +42 -0
  48. data/lib/lhc/interceptor.rb +32 -0
  49. data/lib/lhc/interceptors.rb +26 -0
  50. data/lib/lhc/interceptors/auth.rb +98 -0
  51. data/lib/lhc/interceptors/caching.rb +127 -0
  52. data/lib/lhc/interceptors/default_timeout.rb +16 -0
  53. data/lib/lhc/interceptors/logging.rb +37 -0
  54. data/lib/lhc/interceptors/monitoring.rb +63 -0
  55. data/lib/lhc/interceptors/prometheus.rb +51 -0
  56. data/lib/lhc/interceptors/retry.rb +41 -0
  57. data/lib/lhc/interceptors/rollbar.rb +36 -0
  58. data/lib/lhc/interceptors/throttle.rb +81 -0
  59. data/lib/lhc/interceptors/zipkin.rb +110 -0
  60. data/lib/lhc/railtie.rb +10 -0
  61. data/lib/lhc/request.rb +157 -0
  62. data/lib/lhc/response.rb +60 -0
  63. data/lib/lhc/response/data.rb +28 -0
  64. data/lib/lhc/response/data/base.rb +22 -0
  65. data/lib/lhc/response/data/collection.rb +16 -0
  66. data/lib/lhc/response/data/item.rb +29 -0
  67. data/lib/lhc/rspec.rb +12 -0
  68. data/lib/lhc/test/cache_helper.rb +3 -0
  69. data/lib/lhc/version.rb +5 -0
  70. data/script/ci/build.sh +19 -0
  71. data/spec/basic_methods/delete_spec.rb +34 -0
  72. data/spec/basic_methods/get_spec.rb +49 -0
  73. data/spec/basic_methods/post_spec.rb +42 -0
  74. data/spec/basic_methods/put_spec.rb +48 -0
  75. data/spec/basic_methods/request_spec.rb +19 -0
  76. data/spec/basic_methods/request_without_rails_spec.rb +29 -0
  77. data/spec/config/endpoints_spec.rb +63 -0
  78. data/spec/config/placeholders_spec.rb +32 -0
  79. data/spec/core_ext/hash/deep_transform_values_spec.rb +24 -0
  80. data/spec/dummy/README.rdoc +28 -0
  81. data/spec/dummy/Rakefile +8 -0
  82. data/spec/dummy/app/assets/config/manifest.js +3 -0
  83. data/spec/dummy/app/assets/images/.keep +0 -0
  84. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  85. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  86. data/spec/dummy/app/controllers/application_controller.rb +7 -0
  87. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  88. data/spec/dummy/app/helpers/application_helper.rb +4 -0
  89. data/spec/dummy/app/mailers/.keep +0 -0
  90. data/spec/dummy/app/models/.keep +0 -0
  91. data/spec/dummy/app/models/concerns/.keep +0 -0
  92. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  93. data/spec/dummy/bin/bundle +5 -0
  94. data/spec/dummy/bin/rails +6 -0
  95. data/spec/dummy/bin/rake +6 -0
  96. data/spec/dummy/config.ru +6 -0
  97. data/spec/dummy/config/application.rb +16 -0
  98. data/spec/dummy/config/boot.rb +7 -0
  99. data/spec/dummy/config/environment.rb +7 -0
  100. data/spec/dummy/config/environments/development.rb +36 -0
  101. data/spec/dummy/config/environments/production.rb +77 -0
  102. data/spec/dummy/config/environments/test.rb +41 -0
  103. data/spec/dummy/config/initializers/assets.rb +10 -0
  104. data/spec/dummy/config/initializers/backtrace_silencers.rb +9 -0
  105. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  106. data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
  107. data/spec/dummy/config/initializers/inflections.rb +18 -0
  108. data/spec/dummy/config/initializers/mime_types.rb +6 -0
  109. data/spec/dummy/config/initializers/session_store.rb +5 -0
  110. data/spec/dummy/config/initializers/wrap_parameters.rb +11 -0
  111. data/spec/dummy/config/locales/en.yml +23 -0
  112. data/spec/dummy/config/routes.rb +58 -0
  113. data/spec/dummy/config/secrets.yml +22 -0
  114. data/spec/dummy/lib/assets/.keep +0 -0
  115. data/spec/dummy/log/.keep +0 -0
  116. data/spec/dummy/public/404.html +67 -0
  117. data/spec/dummy/public/422.html +67 -0
  118. data/spec/dummy/public/500.html +66 -0
  119. data/spec/dummy/public/favicon.ico +0 -0
  120. data/spec/endpoint/compile_spec.rb +35 -0
  121. data/spec/endpoint/match_spec.rb +41 -0
  122. data/spec/endpoint/placeholders_spec.rb +30 -0
  123. data/spec/endpoint/remove_interpolated_params_spec.rb +17 -0
  124. data/spec/endpoint/values_as_params_spec.rb +31 -0
  125. data/spec/error/dup_spec.rb +12 -0
  126. data/spec/error/find_spec.rb +57 -0
  127. data/spec/error/response_spec.rb +17 -0
  128. data/spec/error/timeout_spec.rb +14 -0
  129. data/spec/error/to_s_spec.rb +80 -0
  130. data/spec/formats/form_spec.rb +27 -0
  131. data/spec/formats/json_spec.rb +66 -0
  132. data/spec/formats/multipart_spec.rb +26 -0
  133. data/spec/formats/plain_spec.rb +29 -0
  134. data/spec/interceptors/after_request_spec.rb +20 -0
  135. data/spec/interceptors/after_response_spec.rb +39 -0
  136. data/spec/interceptors/auth/basic_auth_spec.rb +17 -0
  137. data/spec/interceptors/auth/bearer_spec.rb +19 -0
  138. data/spec/interceptors/auth/reauthentication_configuration_spec.rb +61 -0
  139. data/spec/interceptors/auth/reauthentication_spec.rb +44 -0
  140. data/spec/interceptors/before_request_spec.rb +21 -0
  141. data/spec/interceptors/before_response_spec.rb +20 -0
  142. data/spec/interceptors/caching/hydra_spec.rb +26 -0
  143. data/spec/interceptors/caching/main_spec.rb +73 -0
  144. data/spec/interceptors/caching/methods_spec.rb +42 -0
  145. data/spec/interceptors/caching/options_spec.rb +89 -0
  146. data/spec/interceptors/caching/parameters_spec.rb +24 -0
  147. data/spec/interceptors/caching/response_status_spec.rb +29 -0
  148. data/spec/interceptors/caching/to_cache_spec.rb +16 -0
  149. data/spec/interceptors/default_interceptors_spec.rb +15 -0
  150. data/spec/interceptors/default_timeout/main_spec.rb +34 -0
  151. data/spec/interceptors/define_spec.rb +29 -0
  152. data/spec/interceptors/dup_spec.rb +19 -0
  153. data/spec/interceptors/logging/main_spec.rb +37 -0
  154. data/spec/interceptors/monitoring/main_spec.rb +97 -0
  155. data/spec/interceptors/prometheus_spec.rb +54 -0
  156. data/spec/interceptors/response_competition_spec.rb +41 -0
  157. data/spec/interceptors/retry/main_spec.rb +73 -0
  158. data/spec/interceptors/return_response_spec.rb +38 -0
  159. data/spec/interceptors/rollbar/invalid_encoding_spec.rb +43 -0
  160. data/spec/interceptors/rollbar/main_spec.rb +57 -0
  161. data/spec/interceptors/throttle/main_spec.rb +106 -0
  162. data/spec/interceptors/throttle/reset_track_spec.rb +53 -0
  163. data/spec/interceptors/zipkin/distributed_tracing_spec.rb +135 -0
  164. data/spec/rails_helper.rb +6 -0
  165. data/spec/request/body_spec.rb +39 -0
  166. data/spec/request/encoding_spec.rb +37 -0
  167. data/spec/request/error_handling_spec.rb +88 -0
  168. data/spec/request/headers_spec.rb +12 -0
  169. data/spec/request/ignore_errors_spec.rb +73 -0
  170. data/spec/request/option_dup_spec.rb +13 -0
  171. data/spec/request/parallel_requests_spec.rb +59 -0
  172. data/spec/request/params_encoding_spec.rb +26 -0
  173. data/spec/request/request_without_rails_spec.rb +15 -0
  174. data/spec/request/url_patterns_spec.rb +54 -0
  175. data/spec/request/user_agent_spec.rb +26 -0
  176. data/spec/request/user_agent_without_rails_spec.rb +27 -0
  177. data/spec/response/body_spec.rb +16 -0
  178. data/spec/response/code_spec.rb +16 -0
  179. data/spec/response/data_accessor_spec.rb +29 -0
  180. data/spec/response/data_spec.rb +61 -0
  181. data/spec/response/effective_url_spec.rb +16 -0
  182. data/spec/response/headers_spec.rb +18 -0
  183. data/spec/response/options_spec.rb +18 -0
  184. data/spec/response/success_spec.rb +13 -0
  185. data/spec/response/time_spec.rb +21 -0
  186. data/spec/spec_helper.rb +8 -0
  187. data/spec/support/fixtures/json/feedback.json +11 -0
  188. data/spec/support/fixtures/json/feedbacks.json +164 -0
  189. data/spec/support/fixtures/json/localina_content_ad.json +23 -0
  190. data/spec/support/load_json.rb +5 -0
  191. data/spec/support/reset_config.rb +7 -0
  192. data/spec/support/zipkin_mock.rb +113 -0
  193. data/spec/timeouts/no_signal_spec.rb +13 -0
  194. data/spec/timeouts/timings_spec.rb +55 -0
  195. metadata +534 -0
@@ -0,0 +1,25 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'LHC'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ begin
18
+ require 'rspec/core/rake_task'
19
+ RSpec::Core::RakeTask.new(:spec)
20
+ task :default => :spec
21
+ rescue LoadError
22
+ # no rspec available
23
+ end
24
+
25
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,6 @@
1
+ jobs:
2
+ include:
3
+ - cider-ci/jobs/rspec-activesupport-4.yml
4
+ - cider-ci/jobs/rspec-activesupport-5.yml
5
+ - cider-ci/jobs/rspec-activesupport-6.yml
6
+ - cider-ci/jobs/rubocop.yml
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env bash
2
+ set -eux
3
+
4
+ export PATH=~/.rubies/$RUBY/bin:$PATH
5
+ rm -f .bundle/config
6
+
7
+ if [ ! -f ~/.rubies/$RUBY/bin/bundle ]; then
8
+ gem install bundler
9
+ fi
10
+
11
+ # install bundler v. 1.17.3 in order to be able to run the tests with
12
+ # ACTIVESUPPORT=4 because rails (= 4.2.0) depends on bundler (< 2.0, >= 1.3.0)
13
+ gem install bundler:1.17.3
14
+
15
+ sed "s/^source 'https:\/\/rubygems\.intra\.local\.ch'*/source 'http\:\/\/52.29.7.59:9292'/g" Gemfile > Gemfile.tmp
16
+ mv Gemfile.tmp Gemfile
17
+
18
+ DIGEST=$(git ls-tree HEAD --\
19
+ cider-ci.yml cider-ci Gemfile.lock \
20
+ | openssl dgst -sha1 | cut -d ' ' -f 2)
21
+
22
+ if [ ! -z ${ACTIVESUPPORT:-} ]; then
23
+ DIGEST=$(echo "$DIGEST $ACTIVESUPPORT")
24
+ fi
25
+
26
+ DIGEST=$(echo "$DIGEST $PATH" \
27
+ | openssl dgst -sha1 | cut -d ' ' -f 2)
28
+
29
+ echo "DIGEST"
30
+ echo "${DIGEST}"
31
+
32
+ CACHE_SIGNATURE_FILE="/tmp/bundle_cache_signature_${DIGEST}"
33
+
34
+ if [ ! -f $CACHE_SIGNATURE_FILE ] ; then
35
+ if [ ! -z ${ACTIVESUPPORT:-} ]; then
36
+ if [ ! -z ${BUNDLER:-} ]; then
37
+ echo "BUNDLE_GEMFILE=Gemfile.activesupport$ACTIVESUPPORT bundle $BUNDLER install"
38
+ BUNDLE_GEMFILE=Gemfile.activesupport$ACTIVESUPPORT bundle $BUNDLER install
39
+ else
40
+ echo "BUNDLE_GEMFILE=Gemfile.activesupport$ACTIVESUPPORT bundle install"
41
+ BUNDLE_GEMFILE=Gemfile.activesupport$ACTIVESUPPORT bundle install
42
+ fi
43
+ else
44
+ echo "bundle install"
45
+ bundle $BUNDLER install
46
+ fi
47
+ touch $CACHE_SIGNATURE_FILE
48
+ fi
49
+
50
+ echo "bundle install"
51
+ bundle $BUNDLER install
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -eux
3
+
4
+ export PATH=~/.rubies/$RUBY/bin:$PATH
5
+
6
+ if [ ! -d ~/.rubies/$RUBY ]; then
7
+ ruby-install --no-install-deps $RUBY
8
+ fi
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env bash
2
+ set -eux
3
+
4
+ if [ -f ./.ruby-version ]; then
5
+ echo ".ruby-version file found"
6
+ fi
7
+
8
+ if [ ! -f ./.ruby-version ]; then
9
+ echo ".ruby-version file not found"
10
+ exit 1
11
+ fi
12
+
13
+ IFS='-' read -ra EXPLODED_RUBY <<< "$RUBY"
14
+
15
+ if [ "${#EXPLODED_RUBY[@]}" == "1" ]; then
16
+ echo 'No engine/version separator "-" found in .ruby-version file.'
17
+ exit 1
18
+ fi
19
+
20
+ if [ "${#EXPLODED_RUBY[@]}" != "1" ] && [ "${#EXPLODED_RUBY[@]}" != "2" ]; then
21
+ echo "Unknown format of .ruby-version file"
22
+ exit 1
23
+ fi
24
+
25
+ echo $RUBY
@@ -0,0 +1,28 @@
1
+ rspec-active-support-v4:
2
+ name: 'rspec with ActiveSupport v4'
3
+
4
+ run_when:
5
+ 'some HEAD has been updated':
6
+ type: branch
7
+ include_match: ^.*$
8
+
9
+ context:
10
+
11
+ script_defaults:
12
+ template_environment_variables: true
13
+
14
+ task_defaults:
15
+ environment_variables:
16
+ ACTIVESUPPORT: '4'
17
+ BUNDLER: '_1.17.3_'
18
+
19
+ max_trials: 2
20
+ dispatch_storm_delay_duration: 1 Seconds
21
+ include:
22
+ - cider-ci/task_components/ruby.yml
23
+ - cider-ci/task_components/bundle.yml
24
+ - cider-ci/task_components/rspec.yml
25
+
26
+ tasks:
27
+ all-rspec:
28
+ name: All rspec tests, using ActiveSupport v4
@@ -0,0 +1,27 @@
1
+ rspec-active-support-v5:
2
+ name: 'rspec with ActiveSupport v5'
3
+
4
+ run_when:
5
+ 'some HEAD has been updated':
6
+ type: branch
7
+ include_match: ^.*$
8
+
9
+ context:
10
+
11
+ script_defaults:
12
+ template_environment_variables: true
13
+
14
+ task_defaults:
15
+ environment_variables:
16
+ ACTIVESUPPORT: '5'
17
+
18
+ max_trials: 2
19
+ dispatch_storm_delay_duration: 1 Seconds
20
+ include:
21
+ - cider-ci/task_components/ruby.yml
22
+ - cider-ci/task_components/bundle.yml
23
+ - cider-ci/task_components/rspec.yml
24
+
25
+ tasks:
26
+ all-rspec:
27
+ name: All rspec tests, using ActiveSupport v5
@@ -0,0 +1,28 @@
1
+ rspec-active-support-v6:
2
+ name: 'rspec with ActiveSupport v6'
3
+
4
+ run_when:
5
+ 'some HEAD has been updated':
6
+ type: branch
7
+ include_match: ^.*$
8
+
9
+ context:
10
+
11
+ script_defaults:
12
+ template_environment_variables: true
13
+
14
+ task_defaults:
15
+ environment_variables:
16
+ ACTIVESUPPORT: '6'
17
+ RUBY: 'ruby-2.6.3'
18
+
19
+ max_trials: 2
20
+ dispatch_storm_delay_duration: 1 Seconds
21
+ include:
22
+ - cider-ci/task_components/ruby.yml
23
+ - cider-ci/task_components/bundle.yml
24
+ - cider-ci/task_components/rspec.yml
25
+
26
+ tasks:
27
+ all-rspec:
28
+ name: All rspec tests, using ActiveSupport v6
@@ -0,0 +1,18 @@
1
+ rubocop:
2
+ name: 'Rubocop'
3
+
4
+ run_when:
5
+ 'some HEAD has been updated':
6
+ type: branch
7
+ include_match: ^.*$
8
+
9
+ context:
10
+
11
+ tasks:
12
+
13
+ rubocop:
14
+
15
+ include:
16
+ - cider-ci/task_components/ruby.yml
17
+ - cider-ci/task_components/bundle.yml
18
+ - cider-ci/task_components/rubocop.yml
@@ -0,0 +1,22 @@
1
+ traits:
2
+ ruby-install: true
3
+ Bash: true
4
+
5
+ trial_attachments:
6
+ gemfile:
7
+ include_match: Gemfile
8
+ content_type: text/plain
9
+
10
+ environment_variables:
11
+ BUNDLER: '_1.17.3_'
12
+
13
+ scripts:
14
+
15
+ bundle:
16
+ exclusive_executor_resource: ruby-install_{{$RUBY}}
17
+ timeout: 20 Minutes
18
+ body: cider-ci/bin/bundle
19
+ start_when:
20
+ 'ruby installed':
21
+ script_key: ruby-install
22
+
@@ -0,0 +1,36 @@
1
+ ports:
2
+ CAPYBARA_PORT:
3
+ min: 8000
4
+ max: 8999
5
+ PHANTOMJS_PORT:
6
+ min: 44600
7
+ max: 44999
8
+
9
+ environment_variables:
10
+ RUBY:
11
+ read_and_replace_with: .ruby-version
12
+ RAILS_ENV: 'test'
13
+
14
+ scripts:
15
+ rspec:
16
+ body: |
17
+ #!/usr/bin/env bash
18
+ set -eux
19
+ mkdir -p tmp/cache
20
+ export PATH=~/.rubies/$RUBY/bin:$PATH
21
+ if [ ! -z ${ACTIVESUPPORT:-} ]; then BUNDLE_GEMFILE=Gemfile.activesupport$ACTIVESUPPORT bundle $BUNDLER exec rspec; else bundle exec rspec; fi
22
+
23
+ start_when:
24
+ 'bundled':
25
+ script_key: bundle
26
+
27
+ trial_attachments:
28
+ logs:
29
+ include_match: log\/.*\.log$
30
+ content_type: text/plain
31
+ image-screenshots:
32
+ include_match: tmp\/capybara\/.*\.png$
33
+ content_type: image/png
34
+ html-screenshots:
35
+ include_match: tmp\/capybara\/.*\.html$
36
+ content_type: text/html
@@ -0,0 +1,29 @@
1
+ trial_attachments:
2
+ logs:
3
+ include_match: tmp\/checkstyle.json$
4
+ content_type: application/json
5
+
6
+ tree_attachments:
7
+ logs:
8
+ include_match: tmp\/checkstyle.json$
9
+ content_type: application/json
10
+
11
+ environment_variables:
12
+ RUBY:
13
+ read_and_replace_with: .ruby-version
14
+ RESULT_PATH: 'tmp/checkstyle.json'
15
+
16
+ max_trials: 1
17
+
18
+ scripts:
19
+ rubocop:
20
+ start_when:
21
+ 'bundled':
22
+ script_key: bundle
23
+ body: |
24
+ #!/usr/bin/env bash
25
+ set -eux
26
+ mkdir -p tmp/cache
27
+ export PATH=~/.rubies/$RUBY/bin:$PATH
28
+ bundle exec rubocop --config .rubocop.yml \
29
+ --format json --out $RESULT_PATH --format progress
@@ -0,0 +1,15 @@
1
+ environment_variables:
2
+ RUBY:
3
+ read_and_replace_with: .ruby-version
4
+
5
+ scripts:
6
+ ruby-version:
7
+ body: cider-ci/bin/ruby_version
8
+ ruby-install:
9
+ exclusive_executor_resource: ruby-install_{{$RUBY}}
10
+ timeout: 20 Minutes
11
+ body: cider-ci/bin/ruby_install
12
+ start_when:
13
+ 'ruby version checked':
14
+ script_key: ruby-version
15
+
@@ -0,0 +1,3 @@
1
+ ---
2
+ request_reviews: true
3
+ cleanup_stale_branches: 8.days
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path("../lib", __FILE__)
4
+
5
+ # Maintain your gem's version:
6
+ require "lhc/version"
7
+
8
+ # Describe your gem and declare its dependencies:
9
+ Gem::Specification.new do |s|
10
+ s.name = "lhc"
11
+ s.version = LHC::VERSION
12
+ s.authors = ['https://github.com/local-ch/lhc/contributors']
13
+ s.email = ['web@localsearch.ch']
14
+ s.homepage = 'https://github.com/local-ch/lhc'
15
+ s.summary = 'Advanced HTTP Client for Ruby, fueled with interceptors'
16
+ s.description = 'LHC is an extended/advanced HTTP client. Implementing basic http-communication enhancements like interceptors, exception handling, format handling, accessing response data, configuring endpoints and placeholders and fully compatible, RFC-compliant URL-template support.'
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- spec/*`.split("\n")
20
+ s.require_paths = ['lib']
21
+
22
+ s.requirements << 'Ruby >= 2.0.0'
23
+
24
+ s.add_dependency 'activesupport', '>= 4.2'
25
+ s.add_dependency 'addressable'
26
+ s.add_dependency 'typhoeus', '>= 0.11'
27
+
28
+ s.add_development_dependency 'geminabox'
29
+ s.add_development_dependency 'prometheus-client', '~> 0.7.1'
30
+ s.add_development_dependency 'pry'
31
+ s.add_development_dependency 'rails', '>= 4.2'
32
+ s.add_development_dependency 'rspec-rails', '>= 3.0.0'
33
+ s.add_development_dependency 'rubocop', '~> 0.57.1'
34
+ s.add_development_dependency 'rubocop-rspec', '~> 1.26.0'
35
+ s.add_development_dependency 'timecop'
36
+ s.add_development_dependency 'webmock'
37
+
38
+ s.license = 'GPL-3'
39
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This was copied from: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/hash/deep_transform_values.rb
4
+ class Hash
5
+ # Returns a new hash with all values converted by the block operation.
6
+ # This includes the values from the root hash and from all
7
+ # nested hashes and arrays.
8
+ #
9
+ # hash = { person: { name: 'Rob', age: '28' } }
10
+ #
11
+ # hash.deep_transform_values{ |value| value.to_s.upcase }
12
+ # # => {person: {name: "ROB", age: "28"}}
13
+ def deep_transform_values(&block)
14
+ _deep_transform_values_in_object(self, &block)
15
+ end
16
+
17
+ # Destructively converts all values by using the block operation.
18
+ # This includes the values from the root hash and from all
19
+ # nested hashes and arrays.
20
+ def deep_transform_values!(&block)
21
+ _deep_transform_values_in_object!(self, &block)
22
+ end
23
+
24
+ private
25
+
26
+ # support methods for deep transforming nested hashes and arrays
27
+ def _deep_transform_values_in_object(object, &block)
28
+ case object
29
+ when Hash
30
+ object.transform_values { |value| _deep_transform_values_in_object(value, &block) }
31
+ when Array
32
+ object.map { |e| _deep_transform_values_in_object(e, &block) }
33
+ else
34
+ yield(object)
35
+ end
36
+ end
37
+
38
+ def _deep_transform_values_in_object!(object, &block)
39
+ case object
40
+ when Hash
41
+ object.transform_values! { |value| _deep_transform_values_in_object!(value, &block) }
42
+ when Array
43
+ object.map! { |e| _deep_transform_values_in_object!(e, &block) }
44
+ else
45
+ yield(object)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,136 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'typhoeus'
4
+ require 'active_support/core_ext/object/blank'
5
+ require 'active_support/core_ext/hash/keys'
6
+
7
+ module LHC
8
+ autoload :BasicMethodsConcern,
9
+ 'lhc/concerns/lhc/basic_methods_concern'
10
+ autoload :ConfigurationConcern,
11
+ 'lhc/concerns/lhc/configuration_concern'
12
+ autoload :FixInvalidEncodingConcern,
13
+ 'lhc/concerns/lhc/fix_invalid_encoding_concern'
14
+ autoload :FormatsConcern,
15
+ 'lhc/concerns/lhc/formats_concern'
16
+
17
+ include BasicMethodsConcern
18
+ include ConfigurationConcern
19
+ include FormatsConcern
20
+
21
+ autoload :Auth,
22
+ 'lhc/interceptors/auth'
23
+ autoload :Caching,
24
+ 'lhc/interceptors/caching'
25
+ autoload :DefaultTimeout,
26
+ 'lhc/interceptors/default_timeout'
27
+ autoload :Logging,
28
+ 'lhc/interceptors/logging'
29
+ autoload :Prometheus,
30
+ 'lhc/interceptors/prometheus'
31
+ autoload :Retry,
32
+ 'lhc/interceptors/retry'
33
+ autoload :Throttle,
34
+ 'lhc/interceptors/throttle'
35
+
36
+ autoload :Config,
37
+ 'lhc/config'
38
+ autoload :Endpoint,
39
+ 'lhc/endpoint'
40
+
41
+ autoload :Error,
42
+ 'lhc/error'
43
+ autoload :ClientError,
44
+ 'lhc/errors/client_error'
45
+ autoload :BadRequest,
46
+ 'lhc/errors/client_error'
47
+ autoload :Unauthorized,
48
+ 'lhc/errors/client_error'
49
+ autoload :PaymentRequired,
50
+ 'lhc/errors/client_error'
51
+ autoload :Forbidden,
52
+ 'lhc/errors/client_error'
53
+ autoload :Forbidden,
54
+ 'lhc/errors/client_error'
55
+ autoload :NotFound,
56
+ 'lhc/errors/client_error'
57
+ autoload :MethodNotAllowed,
58
+ 'lhc/errors/client_error'
59
+ autoload :NotAcceptable,
60
+ 'lhc/errors/client_error'
61
+ autoload :ProxyAuthenticationRequired,
62
+ 'lhc/errors/client_error'
63
+ autoload :RequestTimeout,
64
+ 'lhc/errors/client_error'
65
+ autoload :Conflict,
66
+ 'lhc/errors/client_error'
67
+ autoload :Gone,
68
+ 'lhc/errors/client_error'
69
+ autoload :LengthRequired,
70
+ 'lhc/errors/client_error'
71
+ autoload :PreconditionFailed,
72
+ 'lhc/errors/client_error'
73
+ autoload :RequestEntityTooLarge,
74
+ 'lhc/errors/client_error'
75
+ autoload :RequestUriToLong,
76
+ 'lhc/errors/client_error'
77
+ autoload :UnsupportedMediaType,
78
+ 'lhc/errors/client_error'
79
+ autoload :RequestedRangeNotSatisfiable,
80
+ 'lhc/errors/client_error'
81
+ autoload :ExpectationFailed,
82
+ 'lhc/errors/client_error'
83
+ autoload :UnprocessableEntity,
84
+ 'lhc/errors/client_error'
85
+ autoload :Locked,
86
+ 'lhc/errors/client_error'
87
+ autoload :FailedDependency,
88
+ 'lhc/errors/client_error'
89
+ autoload :UpgradeRequired,
90
+ 'lhc/errors/client_error'
91
+ autoload :ParserError,
92
+ 'lhc/errors/parser_error'
93
+ autoload :ServerError,
94
+ 'lhc/errors/server_error'
95
+ autoload :InternalServerError,
96
+ 'lhc/errors/server_error'
97
+ autoload :NotImplemented,
98
+ 'lhc/errors/server_error'
99
+ autoload :BadGateway,
100
+ 'lhc/errors/server_error'
101
+ autoload :ServiceUnavailable,
102
+ 'lhc/errors/server_error'
103
+ autoload :GatewayTimeout,
104
+ 'lhc/errors/server_error'
105
+ autoload :HttpVersionNotSupported,
106
+ 'lhc/errors/server_error'
107
+ autoload :InsufficientStorage,
108
+ 'lhc/errors/server_error'
109
+ autoload :NotExtended,
110
+ 'lhc/errors/server_error'
111
+ autoload :Timeout,
112
+ 'lhc/errors/timeout'
113
+ autoload :UnknownError,
114
+ 'lhc/errors/unknown_error'
115
+
116
+ autoload :Interceptor,
117
+ 'lhc/interceptor'
118
+ autoload :Interceptors,
119
+ 'lhc/interceptors'
120
+ autoload :Formats,
121
+ 'lhc/formats'
122
+ autoload :Format,
123
+ 'lhc/format'
124
+ autoload :Monitoring,
125
+ 'lhc/interceptors/monitoring'
126
+ autoload :Request,
127
+ 'lhc/request'
128
+ autoload :Response,
129
+ 'lhc/response'
130
+ autoload :Rollbar,
131
+ 'lhc/interceptors/rollbar'
132
+ autoload :Zipkin,
133
+ 'lhc/interceptors/zipkin'
134
+
135
+ require 'lhc/railtie' if defined?(Rails)
136
+ end