arstotzka 1.4.3 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/arstotzka/class_methods.rb +8 -8
- data/lib/arstotzka/crawler.rb +47 -8
- data/lib/arstotzka/fetcher/cache.rb +5 -4
- data/lib/arstotzka/type_cast.rb +12 -0
- data/lib/arstotzka/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f520b5c22013f3c900e0a89109e817cbab2b274df08162d3759e02141f56de17
|
4
|
+
data.tar.gz: ffb858a6d0e8c3256f6bd08454bee2d6990b9b0222c11676a192003dc81fc3d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50a60125621d7512905a788f477f40d0eca7c5d8aa1640153498c9e4838e2ecf5afbf56fb728587483d2beb9a7d47563ff174c2be074697f139ebfddcfc50148
|
7
|
+
data.tar.gz: 4ff99c27757f48240bd0ab3b13acb8a5741fb35a7dd6b1a3c1945ec054653cce9a1db5a97a9f5ac9e169696ccde6be2a2d9aa5cdb5cb0b18034b6d356a0d6740
|
data/README.md
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
Arstotzka
|
2
2
|
========
|
3
|
+
[![Build Status](https://circleci.com/gh/darthjee/arstotzka.svg?style=shield)](https://circleci.com/gh/darthjee/arstotzka)
|
3
4
|
[![Code Climate](https://codeclimate.com/github/darthjee/arstotzka/badges/gpa.svg)](https://codeclimate.com/github/darthjee/arstotzka)
|
4
5
|
[![Test Coverage](https://codeclimate.com/github/darthjee/arstotzka/badges/coverage.svg)](https://codeclimate.com/github/darthjee/arstotzka/coverage)
|
5
6
|
[![Issue Count](https://codeclimate.com/github/darthjee/arstotzka/badges/issue_count.svg)](https://codeclimate.com/github/darthjee/arstotzka)
|
6
7
|
[![Gem Version](https://badge.fury.io/rb/arstotzka.svg)](https://badge.fury.io/rb/arstotzka)
|
8
|
+
[![Inline docs](http://inch-ci.org/github/darthjee/arstotzka.svg)](http://inch-ci.org/github/darthjee/arstotzka)
|
9
|
+
[![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)
|
7
10
|
|
8
11
|
![arstotzka](https://raw.githubusercontent.com/darthjee/arstotzka/master/arstotzka.jpg)
|
9
12
|
|
@@ -19,7 +22,7 @@ JSON keys)
|
|
19
22
|
|
20
23
|
Yard Documentation
|
21
24
|
-------------------
|
22
|
-
https://www.rubydoc.info/gems/arstotzka/1.4.
|
25
|
+
[https://www.rubydoc.info/gems/arstotzka/1.4.4](https://www.rubydoc.info/gems/arstotzka/1.4.4)
|
23
26
|
|
24
27
|
Instalation
|
25
28
|
---------------
|
@@ -127,6 +127,14 @@ module Arstotzka
|
|
127
127
|
# - +string+
|
128
128
|
# - +float+
|
129
129
|
#
|
130
|
+
# @return [Array<Sinclair::MethodDefinition>]
|
131
|
+
#
|
132
|
+
# @see Config
|
133
|
+
# @see MethodBuilder Arstotzka::MethodBuilder
|
134
|
+
# @see
|
135
|
+
# https://www.rubydoc.info/gems/activesupport/5.2.2/ActiveSupport/Concern
|
136
|
+
# ActiveSupport::Concern
|
137
|
+
#
|
130
138
|
# @example
|
131
139
|
# class MyModel
|
132
140
|
# include Arstotzka
|
@@ -150,14 +158,6 @@ module Arstotzka
|
|
150
158
|
# instance.first_name # returns 'John'
|
151
159
|
# instance.age # returns 20
|
152
160
|
# instance.cars # returns 2
|
153
|
-
#
|
154
|
-
# @return [Array<Sinclair::MethodDefinition>]
|
155
|
-
#
|
156
|
-
# @see Config
|
157
|
-
# @see MethodBuilder Arstotzka::MethodBuilder
|
158
|
-
# @see
|
159
|
-
# https://www.rubydoc.info/gems/activesupport/5.2.2/ActiveSupport/Concern
|
160
|
-
# ActiveSupport::Concern
|
161
161
|
def expose(*attr_names, **options_hash)
|
162
162
|
MethodBuilder.new(attr_names.map(&:to_sym), self, options_hash).build
|
163
163
|
end
|
data/lib/arstotzka/crawler.rb
CHANGED
@@ -20,20 +20,26 @@ module Arstotzka
|
|
20
20
|
|
21
21
|
# Creates a new instance of Crawler
|
22
22
|
#
|
23
|
-
# @param block [Proc] block to be ran over the fetched value before returning it
|
24
|
-
#
|
25
23
|
# @overload initialize(options_hash={}, &block)
|
26
|
-
# @param
|
27
|
-
# @option
|
28
|
-
# @option
|
24
|
+
# @param options_hash [Hash] options of initialization
|
25
|
+
# @option options_hash keys [Array] keys of keys to be crawled
|
26
|
+
# @option options_hash case [Symbol] case type of the keys
|
29
27
|
# - snake: snake_cased keys
|
30
28
|
# - lower_camel: lowerCamelCased keys
|
31
29
|
# - upper_camel: UperCamelCased keys
|
32
|
-
# @option
|
33
|
-
#
|
30
|
+
# @option options_hash compact [TrueClass,FalseClass] flag signallying if
|
31
|
+
# nil values should be removed of array
|
32
|
+
# @option options_hash default [Object] default value to be returned when
|
33
|
+
# failing to fetch a value
|
34
|
+
# @param block [Proc] block to be ran over the
|
35
|
+
# fetched value before returning it
|
34
36
|
#
|
35
37
|
# @overload initialize(options, &block)
|
36
38
|
# @param options [Arstotzka::Options] options of initialization object
|
39
|
+
# @param block [Proc] block to be ran over the
|
40
|
+
# fetched value before returning it
|
41
|
+
#
|
42
|
+
# @example (see Arstotzka::Crawler)
|
37
43
|
def initialize(options = {}, &block)
|
38
44
|
self.options = options
|
39
45
|
@block = block
|
@@ -92,9 +98,42 @@ module Arstotzka
|
|
92
98
|
|
93
99
|
private
|
94
100
|
|
95
|
-
# @private
|
96
101
|
attr_reader :block, :options
|
102
|
+
# @method block
|
103
|
+
# @api private
|
104
|
+
# @private
|
105
|
+
#
|
106
|
+
# Proc to be ran over the fetched value before returning it
|
107
|
+
#
|
108
|
+
# @return [Proc]
|
109
|
+
|
110
|
+
# @method options
|
111
|
+
# @api private
|
112
|
+
# @private
|
113
|
+
#
|
114
|
+
# Options of initialization object
|
115
|
+
#
|
116
|
+
# @return [Arstotzka::Options]
|
117
|
+
|
97
118
|
delegate :compact, :default, to: :options
|
119
|
+
# @method compact
|
120
|
+
# @api private
|
121
|
+
# @private
|
122
|
+
#
|
123
|
+
# Flag for compacting the resulting array
|
124
|
+
#
|
125
|
+
# When this flag is true, all nil elements are removed
|
126
|
+
# from the resulting array
|
127
|
+
#
|
128
|
+
# @return [TrueClass,FalseClass]
|
129
|
+
|
130
|
+
# @method default
|
131
|
+
# @api private
|
132
|
+
# @private
|
133
|
+
#
|
134
|
+
# Default value to be returned when failing to fetch a value
|
135
|
+
#
|
136
|
+
# @return [Object]
|
98
137
|
|
99
138
|
# Fetch the value from hash by crawling the keys
|
100
139
|
#
|
@@ -13,15 +13,16 @@ module Arstotzka
|
|
13
13
|
class Cache
|
14
14
|
include Base
|
15
15
|
|
16
|
-
# @param block [Proc] block to be executed in case
|
17
|
-
# variable is not cached
|
18
|
-
#
|
19
16
|
# @overload initialize(options, &block)
|
20
17
|
# @param options [Arstotzka::Options] options passed
|
21
|
-
#
|
18
|
+
# as options object
|
19
|
+
# @param block [Proc] block to be executed in case
|
20
|
+
# variable is not cached
|
22
21
|
#
|
23
22
|
# @overload initialize(options_hash, &block)
|
24
23
|
# @param options_hash [Hash] opttions passed as hash
|
24
|
+
# @param block [Proc] block to be executed in case
|
25
|
+
# variable is not cached
|
25
26
|
def initialize(options_hash = {}, &block)
|
26
27
|
self.options = options_hash
|
27
28
|
@block = block
|
data/lib/arstotzka/type_cast.rb
CHANGED
@@ -71,6 +71,9 @@ module Arstotzka
|
|
71
71
|
|
72
72
|
# Converts a value to integer
|
73
73
|
#
|
74
|
+
# @param value [Object] object to be converted
|
75
|
+
# to integer
|
76
|
+
#
|
74
77
|
# @return [Integer]
|
75
78
|
#
|
76
79
|
# @example Casting to Integer
|
@@ -95,6 +98,9 @@ module Arstotzka
|
|
95
98
|
|
96
99
|
# Converts value to string
|
97
100
|
#
|
101
|
+
# @param value [Object] object to be converted
|
102
|
+
# to string
|
103
|
+
#
|
98
104
|
# @return [String]
|
99
105
|
#
|
100
106
|
# @example Casting to String
|
@@ -121,6 +127,9 @@ module Arstotzka
|
|
121
127
|
|
122
128
|
# Converts value to float
|
123
129
|
#
|
130
|
+
# @param value [Object] object to be converted
|
131
|
+
# to float
|
132
|
+
#
|
124
133
|
# @return [Float]
|
125
134
|
#
|
126
135
|
# @example Casting to Float
|
@@ -145,6 +154,9 @@ module Arstotzka
|
|
145
154
|
|
146
155
|
# Converts value to Symbol
|
147
156
|
#
|
157
|
+
# @param value [Object] object to be converted
|
158
|
+
# to symbol
|
159
|
+
#
|
148
160
|
# @return [Symbol]
|
149
161
|
#
|
150
162
|
# @example Casting to Symbol
|
data/lib/arstotzka/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arstotzka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darthjee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|