lhc 9.4.1 → 9.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +59 -57
  3. data/lhc.gemspec +1 -1
  4. data/lib/lhc/version.rb +1 -1
  5. metadata +6 -4
  6. data/gh-md-toc +0 -228
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 153c47a835c9f4f7e4ac644c18820bc4bb1f87a1f09b5321179fee621bfb42b0
4
- data.tar.gz: 4995637bddf13e0fb48a97d2bb3c592a1ee1346675d38cc219d1f405d93cd35d
3
+ metadata.gz: be1b987dd272ded2704dca72606d5a96ee394ec8e901cb5c72c164bfa4c116fe
4
+ data.tar.gz: 881da124498450bdd8e9b6d4c4ba8244f84f8dbe3918381af320be267069152e
5
5
  SHA512:
6
- metadata.gz: 1c934cbf9f4de81b821d3ae61ff93f9be65ed7700be82b842d697cf978880c4d368b2e0a26ec0bc302ba608ffb52832702069ccdf77d8218e505cf9967196f74
7
- data.tar.gz: 83e666f17c733e063bb5d64e082d47d5a830c48d7bb331dfeee827ec56a18335b64db104f270541e1f88dbf17da5fb05f00ed58872cd51664074a079085c3d13
6
+ metadata.gz: 56a29c2ee5e170542d8ddba9bc4e212b4c29bd1a98b2d88b3484b31caadc8bfc034179d653fa289ff9de3864345ce399e65628f210be92d0f8a2f9bef772b991
7
+ data.tar.gz: 5b0cf0dc644a3f139b64ef50459be033ce9b0cd317782245ebbfc72ec0de57a4714596437819d197e282db85d4ccdb76fe8f0f23d1ead1098479207719649868
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  LHC
2
2
  ===
3
3
 
4
+ 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.
5
+
4
6
  LHC uses [typhoeus](https://github.com/typhoeus/typhoeus) for low level http communication.
5
7
 
6
8
  See [LHS](https://github.com/local-ch/LHS), if you are searching for something more **high level** that can query webservices easily and provides an ActiveRecord like interface.
@@ -28,63 +30,63 @@ use it like:
28
30
  ```
29
31
 
30
32
  ## Table of contents
31
-
32
- * [LHC](#lhc)
33
- * [Quick start guide](#quick-start-guide)
34
- * [Basic methods](#basic-methods)
35
- * [Request](#request)
36
- * [Formats](#formats)
37
- * [Parallel requests](#parallel-requests)
38
- * [Follow redirects](#follow-redirects)
39
- * [Transfer data through the request body](#transfer-data-through-the-request-body)
40
- * [Request parameters](#request-parameters)
41
- * [Array Parameter Encoding](#array-parameter-encoding)
42
- * [Request URL encoding](#request-url-encoding)
43
- * [Request URL-Templates](#request-url-templates)
44
- * [Request timeout](#request-timeout)
45
- * [Response](#response)
46
- * [Accessing response data](#accessing-response-data)
47
- * [Exceptions](#exceptions)
48
- * [Custom error handling](#custom-error-handling)
49
- * [Ignore certain errors](#ignore-certain-errors)
50
- * [Configuration](#configuration)
51
- * [Configuring endpoints](#configuring-endpoints)
52
- * [Configuring placeholders](#configuring-placeholders)
53
- * [Interceptors](#interceptors)
54
- * [Quick start: Configure/Enable Interceptors](#quick-start-configureenable-interceptors)
55
- * [Interceptors on local request level](#interceptors-on-local-request-level)
56
- * [Core Interceptors](#core-interceptors)
57
- * [Authentication Interceptor](#authentication-interceptor)
58
- * [Bearer Authentication](#bearer-authentication)
59
- * [Basic Authentication](#basic-authentication)
60
- * [Reauthenticate](#reauthenticate)
61
- * [Bearer Authentication with client access token](#bearer-authentication-with-client-access-token)
62
- * [Caching Interceptor](#caching-interceptor)
63
- * [Options](#options)
64
- * [Testing](#testing)
65
- * [Default Timeout Interceptor](#default-timeout-interceptor)
66
- * [Overwrite defaults](#overwrite-defaults)
67
- * [Logging Interceptor](#logging-interceptor)
68
- * [Installation](#installation)
69
- * [What and how it logs](#what-and-how-it-logs)
70
- * [Configure](#configure)
71
- * [Monitoring Interceptor](#monitoring-interceptor)
72
- * [Installation](#installation-1)
73
- * [Environment](#environment)
74
- * [What it tracks](#what-it-tracks)
75
- * [Configure](#configure-1)
76
- * [Prometheus Interceptor](#prometheus-interceptor)
77
- * [Retry Interceptor](#retry-interceptor)
78
- * [Limit the amount of retries while making the request](#limit-the-amount-of-retries-while-making-the-request)
79
- * [Change the default maximum of retries of the retry interceptor](#change-the-default-maximum-of-retries-of-the-retry-interceptor)
80
- * [Rollbar Interceptor](#rollbar-interceptor)
81
- * [Forward additional parameters](#forward-additional-parameters)
82
- * [Zipkin](#zipkin)
83
- * [Create an interceptor from scratch](#create-an-interceptor-from-scratch)
84
- * [Interceptor callbacks](#interceptor-callbacks)
85
- * [Interceptor request/response](#interceptor-requestresponse)
86
- * [Provide a response replacement through an interceptor](#provide-a-response-replacement-through-an-interceptor)
87
- * [License](#license)
33
+ * [LHC](#lhc)
34
+ * [Quick start guide](#quick-start-guide)
35
+ * [Table of contents](#table-of-contents)
36
+ * [Basic methods](#basic-methods)
37
+ * [Request](#request)
38
+ * [Formats](#formats)
39
+ * [Parallel requests](#parallel-requests)
40
+ * [Follow redirects](#follow-redirects)
41
+ * [Transfer data through the request body](#transfer-data-through-the-request-body)
42
+ * [Request parameters](#request-parameters)
43
+ * [Array Parameter Encoding](#array-parameter-encoding)
44
+ * [Request URL encoding](#request-url-encoding)
45
+ * [Request URL-Templates](#request-url-templates)
46
+ * [Request timeout](#request-timeout)
47
+ * [Response](#response)
48
+ * [Accessing response data](#accessing-response-data)
49
+ * [Exceptions](#exceptions)
50
+ * [Custom error handling](#custom-error-handling)
51
+ * [Ignore certain errors](#ignore-certain-errors)
52
+ * [Configuration](#configuration)
53
+ * [Configuring endpoints](#configuring-endpoints)
54
+ * [Configuring placeholders](#configuring-placeholders)
55
+ * [Interceptors](#interceptors)
56
+ * [Quick start: Configure/Enable Interceptors](#quick-start-configureenable-interceptors)
57
+ * [Interceptors on local request level](#interceptors-on-local-request-level)
58
+ * [Core Interceptors](#core-interceptors)
59
+ * [Authentication Interceptor](#authentication-interceptor)
60
+ * [Bearer Authentication](#bearer-authentication)
61
+ * [Basic Authentication](#basic-authentication)
62
+ * [Reauthenticate](#reauthenticate)
63
+ * [Bearer Authentication with client access token](#bearer-authentication-with-client-access-token)
64
+ * [Caching Interceptor](#caching-interceptor)
65
+ * [Options](#options)
66
+ * [Testing](#testing)
67
+ * [Default Timeout Interceptor](#default-timeout-interceptor)
68
+ * [Overwrite defaults](#overwrite-defaults)
69
+ * [Logging Interceptor](#logging-interceptor)
70
+ * [Installation](#installation)
71
+ * [What and how it logs](#what-and-how-it-logs)
72
+ * [Configure](#configure)
73
+ * [Monitoring Interceptor](#monitoring-interceptor)
74
+ * [Installation](#installation-1)
75
+ * [Environment](#environment)
76
+ * [What it tracks](#what-it-tracks)
77
+ * [Configure](#configure-1)
78
+ * [Prometheus Interceptor](#prometheus-interceptor)
79
+ * [Retry Interceptor](#retry-interceptor)
80
+ * [Limit the amount of retries while making the request](#limit-the-amount-of-retries-while-making-the-request)
81
+ * [Change the default maximum of retries of the retry interceptor](#change-the-default-maximum-of-retries-of-the-retry-interceptor)
82
+ * [Rollbar Interceptor](#rollbar-interceptor)
83
+ * [Forward additional parameters](#forward-additional-parameters)
84
+ * [Zipkin](#zipkin)
85
+ * [Create an interceptor from scratch](#create-an-interceptor-from-scratch)
86
+ * [Interceptor callbacks](#interceptor-callbacks)
87
+ * [Interceptor request/response](#interceptor-requestresponse)
88
+ * [Provide a response replacement through an interceptor](#provide-a-response-replacement-through-an-interceptor)
89
+ * [License](#license)
88
90
 
89
91
  ## Basic methods
90
92
 
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.email = ['web@localsearch.ch']
12
12
  s.homepage = 'https://github.com/local-ch/lhc'
13
13
  s.summary = 'Advanced HTTP Client for Ruby, fueled with interceptors'
14
- s.description = 'Advanced HTTP Client for Ruby, fueled with interceptors'
14
+ 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.'
15
15
 
16
16
  s.files = `git ls-files`.split("\n")
17
17
  s.test_files = `git ls-files -- spec/*`.split("\n")
@@ -1,3 +1,3 @@
1
1
  module LHC
2
- VERSION ||= '9.4.1'
2
+ VERSION ||= '9.4.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhc
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.4.1
4
+ version: 9.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhc/contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-24 00:00:00.000000000 Z
11
+ date: 2018-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -164,7 +164,10 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
- description: Advanced HTTP Client for Ruby, fueled with interceptors
167
+ description: LHC is an extended/advanced HTTP client. Implementing basic http-communication
168
+ enhancements like interceptors, exception handling, format handling, accessing response
169
+ data, configuring endpoints and placeholders and fully compatible, RFC-compliant
170
+ URL-template support.
168
171
  email:
169
172
  - web@localsearch.ch
170
173
  executables: []
@@ -188,7 +191,6 @@ files:
188
191
  - cider-ci/task_components/rspec.yml
189
192
  - cider-ci/task_components/rubocop.yml
190
193
  - cider-ci/task_components/ruby.yml
191
- - gh-md-toc
192
194
  - lhc.gemspec
193
195
  - lib/lhc.rb
194
196
  - lib/lhc/concerns/lhc/basic_methods_concern.rb
data/gh-md-toc DELETED
@@ -1,228 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- #
4
- # Steps:
5
- #
6
- # 1. Download corresponding html file for some README.md:
7
- # curl -s $1
8
- #
9
- # 2. Discard rows where no substring 'user-content-' (github's markup):
10
- # awk '/user-content-/ { ...
11
- #
12
- # 3.1 Get last number in each row like ' ... </span></a>sitemap.js</h1'.
13
- # It's a level of the current header:
14
- # substr($0, length($0), 1)
15
- #
16
- # 3.2 Get level from 3.1 and insert corresponding number of spaces before '*':
17
- # sprintf("%*s", substr($0, length($0), 1)*3, " ")
18
- #
19
- # 4. Find head's text and insert it inside "* [ ... ]":
20
- # substr($0, match($0, /a>.*<\/h/)+2, RLENGTH-5)
21
- #
22
- # 5. Find anchor and insert it inside "(...)":
23
- # substr($0, match($0, "href=\"[^\"]+?\" ")+6, RLENGTH-8)
24
- #
25
-
26
- gh_toc_version="0.5.0"
27
-
28
- gh_user_agent="gh-md-toc v$gh_toc_version"
29
-
30
- #
31
- # Download rendered into html README.md by its url.
32
- #
33
- #
34
- gh_toc_load() {
35
- local gh_url=$1
36
-
37
- if type curl &>/dev/null; then
38
- curl --user-agent "$gh_user_agent" -s "$gh_url"
39
- elif type wget &>/dev/null; then
40
- wget --user-agent="$gh_user_agent" -qO- "$gh_url"
41
- else
42
- echo "Please, install 'curl' or 'wget' and try again."
43
- exit 1
44
- fi
45
- }
46
-
47
- #
48
- # Converts local md file into html by GitHub
49
- #
50
- # ➥ curl -X POST --data '{"text": "Hello world github/linguist#1 **cool**, and #1!"}' https://api.github.com/markdown
51
- # <p>Hello world github/linguist#1 <strong>cool</strong>, and #1!</p>'"
52
- gh_toc_md2html() {
53
- local gh_file_md=$1
54
- URL=https://api.github.com/markdown/raw
55
- TOKEN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt"
56
- if [ -f "$TOKEN" ]; then
57
- URL="$URL?access_token=$(cat $TOKEN)"
58
- fi
59
- curl -s --user-agent "$gh_user_agent" \
60
- --data-binary @"$gh_file_md" -H "Content-Type:text/plain" \
61
- $URL
62
- }
63
-
64
- #
65
- # Is passed string url
66
- #
67
- gh_is_url() {
68
- case $1 in
69
- https* | http*)
70
- echo "yes";;
71
- *)
72
- echo "no";;
73
- esac
74
- }
75
-
76
- #
77
- # TOC generator
78
- #
79
- gh_toc(){
80
- local gh_src=$1
81
- local gh_src_copy=$1
82
- local gh_ttl_docs=$2
83
- local need_replace=$3
84
-
85
- if [ "$gh_src" = "" ]; then
86
- echo "Please, enter URL or local path for a README.md"
87
- exit 1
88
- fi
89
-
90
-
91
- # Show "TOC" string only if working with one document
92
- if [ "$gh_ttl_docs" = "1" ]; then
93
-
94
- echo "Table of Contents"
95
- echo "================="
96
- echo ""
97
- gh_src_copy=""
98
-
99
- fi
100
-
101
- if [ "$(gh_is_url "$gh_src")" == "yes" ]; then
102
- gh_toc_load "$gh_src" | gh_toc_grab "$gh_src_copy"
103
- if [ "$need_replace" = "yes" ]; then
104
- echo
105
- echo "!! '$gh_src' is not a local file"
106
- echo "!! Can't insert the TOC into it."
107
- echo
108
- fi
109
- else
110
- local toc=`gh_toc_md2html "$gh_src" | gh_toc_grab "$gh_src_copy"`
111
- echo "$toc"
112
- if [ "$need_replace" = "yes" ]; then
113
- local ts="<\!--ts-->"
114
- local te="<\!--te-->"
115
- local dt=`date +'%F_%H%M%S'`
116
- local ext=".orig.${dt}"
117
- local toc_path="${gh_src}.toc.${dt}"
118
- local toc_footer="<!-- Added by: `whoami`, at: `date --iso-8601='minutes'` -->"
119
- # http://fahdshariff.blogspot.ru/2012/12/sed-mutli-line-replacement-between-two.html
120
- # clear old TOC
121
- sed -i${ext} "/${ts}/,/${te}/{//!d;}" "$gh_src"
122
- # create toc file
123
- echo "${toc}" > "${toc_path}"
124
- echo -e "\n${toc_footer}\n" >> "$toc_path"
125
- # insert toc file
126
- if [[ "`uname`" == "Darwin" ]]; then
127
- sed -i "" "/${ts}/r ${toc_path}" "$gh_src"
128
- else
129
- sed -i "/${ts}/r ${toc_path}" "$gh_src"
130
- fi
131
- echo
132
- echo "!! TOC was added into: '$gh_src'"
133
- echo "!! Origin version of the file: '${gh_src}${ext}'"
134
- echo "!! TOC added into a separate file: '${toc_path}'"
135
- echo
136
- fi
137
- fi
138
- }
139
-
140
- #
141
- # Grabber of the TOC from rendered html
142
- #
143
- # $1 — a source url of document.
144
- # It's need if TOC is generated for multiple documents.
145
- #
146
- gh_toc_grab() {
147
- # if closed <h[1-6]> is on the new line, then move it on the prev line
148
- # for example:
149
- # was: The command <code>foo1</code>
150
- # </h1>
151
- # became: The command <code>foo1</code></h1>
152
- sed -e ':a' -e 'N' -e '$!ba' -e 's/\n<\/h/<\/h/g' |
153
- # find strings that corresponds to template
154
- grep -E -o '<a.*id="user-content-[^"]*".*</h[1-6]' |
155
- # remove code tags
156
- sed 's/<code>//' | sed 's/<\/code>//' |
157
- # now all rows are like:
158
- # <a id="user-content-..." href="..."><span ...></span></a> ... </h1
159
- # format result line
160
- # * $0 — whole string
161
- echo -e "$(awk -v "gh_url=$1" '{
162
- print sprintf("%*s", substr($0, length($0), 1)*3, " ") "* [" substr($0, match($0, /a>.*<\/h/)+2, RLENGTH-5)"](" gh_url substr($0, match($0, "href=\"[^\"]+?\" ")+6, RLENGTH-8) ")"}' | sed 'y/+/ /; s/%/\\x/g')"
163
- }
164
-
165
- #
166
- # Returns filename only from full path or url
167
- #
168
- gh_toc_get_filename() {
169
- echo "${1##*/}"
170
- }
171
-
172
- #
173
- # Options hendlers
174
- #
175
- gh_toc_app() {
176
- local app_name="gh-md-toc"
177
- local need_replace="no"
178
-
179
- if [ "$1" = '--help' ] || [ $# -eq 0 ] ; then
180
- echo "GitHub TOC generator ($app_name): $gh_toc_version"
181
- echo ""
182
- echo "Usage:"
183
- echo " $app_name [--insert] src [src] Create TOC for a README file (url or local path)"
184
- echo " $app_name - Create TOC for markdown from STDIN"
185
- echo " $app_name --help Show help"
186
- echo " $app_name --version Show version"
187
- return
188
- fi
189
-
190
- if [ "$1" = '--version' ]; then
191
- echo "$gh_toc_version"
192
- return
193
- fi
194
-
195
- if [ "$1" = "-" ]; then
196
- if [ -z "$TMPDIR" ]; then
197
- TMPDIR="/tmp"
198
- elif [ -n "$TMPDIR" -a ! -d "$TMPDIR" ]; then
199
- mkdir -p "$TMPDIR"
200
- fi
201
- local gh_tmp_md
202
- gh_tmp_md=$(mktemp $TMPDIR/tmp.XXXXXX)
203
- while read input; do
204
- echo "$input" >> "$gh_tmp_md"
205
- done
206
- gh_toc_md2html "$gh_tmp_md" | gh_toc_grab ""
207
- return
208
- fi
209
-
210
- if [ "$1" = '--insert' ]; then
211
- need_replace="yes"
212
- shift
213
- fi
214
-
215
- for md in "$@"
216
- do
217
- echo ""
218
- gh_toc "$md" "$#" "$need_replace"
219
- done
220
-
221
- echo ""
222
- echo "Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)"
223
- }
224
-
225
- #
226
- # Entry point
227
- #
228
- gh_toc_app "$@"