lazy_ant 0.6.2 → 0.7.0
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -1
- data/.travis.yml +3 -3
- data/Guardfile +1 -1
- data/README.md +3 -0
- data/lazy_ant.gemspec +1 -1
- data/lib/lazy_ant/config.rb +11 -1
- data/lib/lazy_ant/dsl.rb +4 -1
- data/lib/lazy_ant/dsl/connection.rb +10 -2
- data/lib/lazy_ant/dsl/grouping.rb +1 -1
- data/lib/lazy_ant/endpoint.rb +2 -2
- data/lib/lazy_ant/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 598e3d76854ce65e8fadb525903fbd19e1e866d6
|
4
|
+
data.tar.gz: 3f9584c20b54c99e57dc5d9ba16e31683bb4ef1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e9843c42f93a4b4b0d1f5fe4d5a6454d5261014423bcc1cbea5180866376a45f0d3a98782d737ddbe52819e15a89076153cd6c91b02de7ccacfbec0b150dc37
|
7
|
+
data.tar.gz: 3f56b1754d512ef6fb3664847e0147e5f31b3593e0621ffac9a373654cd96a1006497ddc0b37d84473ffe336ea6e83b75c6dfe6c76d2d4cf094a9fc398e04fec
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/Guardfile
CHANGED
@@ -15,7 +15,7 @@ guard :rspec, cmd: 'bundle exec rspec' do
|
|
15
15
|
dsl.watch_spec_files_for(ruby.lib_files)
|
16
16
|
end
|
17
17
|
|
18
|
-
guard :rubocop, cli: '--auto-correct' do
|
18
|
+
guard :rubocop, cli: '--auto-correct -D --except Lint/Debugger' do
|
19
19
|
watch(/.+\.rb$/)
|
20
20
|
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
21
21
|
end
|
data/README.md
CHANGED
data/lazy_ant.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
if spec.respond_to?(:metadata)
|
20
20
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
21
|
else
|
22
|
-
|
22
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
23
23
|
end
|
24
24
|
|
25
25
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
data/lib/lazy_ant/config.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
module LazyAnt
|
2
2
|
class Config
|
3
|
+
attr_reader :connection_callbacks
|
4
|
+
|
3
5
|
def initialize
|
4
6
|
self.class.keys.each do |var, options|
|
5
7
|
instance_variable_set(var, options[:default])
|
6
8
|
end
|
9
|
+
@connection_callbacks = []
|
7
10
|
end
|
8
11
|
|
9
12
|
def deprecated(method, instead)
|
@@ -16,7 +19,14 @@ module LazyAnt
|
|
16
19
|
end
|
17
20
|
|
18
21
|
def validate(val)
|
19
|
-
|
22
|
+
raise ArgumentError unless val == true || val == false
|
23
|
+
end
|
24
|
+
|
25
|
+
def logger(instance = nil, options = {})
|
26
|
+
@connection_callbacks << lambda do |con|
|
27
|
+
args = [:logger, instance, options].compact
|
28
|
+
con.send(:response, *args)
|
29
|
+
end
|
20
30
|
end
|
21
31
|
|
22
32
|
class << self
|
data/lib/lazy_ant/dsl.rb
CHANGED
@@ -9,9 +9,12 @@ module LazyAnt
|
|
9
9
|
include Endpoint
|
10
10
|
include Connection
|
11
11
|
|
12
|
-
def initialize
|
12
|
+
def initialize
|
13
13
|
yield config if block_given?
|
14
14
|
config.freeze
|
15
|
+
config.connection_callbacks.each do |callback|
|
16
|
+
instance_callbacks.push callback
|
17
|
+
end
|
15
18
|
end
|
16
19
|
|
17
20
|
module ClassMethods
|
@@ -5,7 +5,6 @@ module LazyAnt
|
|
5
5
|
module DSL
|
6
6
|
module Connection
|
7
7
|
extend ActiveSupport::Concern
|
8
|
-
attr_reader :default_params
|
9
8
|
|
10
9
|
def connection
|
11
10
|
return @connection if @connection
|
@@ -14,11 +13,15 @@ module LazyAnt
|
|
14
13
|
use_converter(con)
|
15
14
|
con.response response_type
|
16
15
|
con.response :raise_error
|
16
|
+
callbacks.each { |callback| instance_exec(con, &callback) }
|
17
17
|
con.adapter Faraday.default_adapter
|
18
|
-
instance_exec(con, &default_callback) if default_callback
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
21
|
+
def callbacks
|
22
|
+
([default_callback] + instance_callbacks).compact
|
23
|
+
end
|
24
|
+
|
22
25
|
def use_converter(con)
|
23
26
|
if converter_block
|
24
27
|
con.use LazyAnt::Converter, &converter_block
|
@@ -57,6 +60,11 @@ module LazyAnt
|
|
57
60
|
@parent && @parent.response_type || :json
|
58
61
|
end
|
59
62
|
|
63
|
+
def instance_callbacks
|
64
|
+
@instance_callbacks ||=
|
65
|
+
@parent && @parent.instance_callbacks || []
|
66
|
+
end
|
67
|
+
|
60
68
|
module ClassMethods
|
61
69
|
def base_url(url = nil, &block)
|
62
70
|
if block_given?
|
@@ -5,7 +5,7 @@ module LazyAnt
|
|
5
5
|
|
6
6
|
module ClassMethods
|
7
7
|
def group(name, &block)
|
8
|
-
base =
|
8
|
+
base = respond_to?(:name) ? self.name : nil
|
9
9
|
group_name = [base, name].compact.join('.')
|
10
10
|
group_class = Class.new(LazyAnt::Group) do
|
11
11
|
self.name = group_name
|
data/lib/lazy_ant/endpoint.rb
CHANGED
@@ -31,7 +31,7 @@ module LazyAnt
|
|
31
31
|
|
32
32
|
def validate!
|
33
33
|
params.select { |_k, v| v[:required] }.each do |k, _v|
|
34
|
-
|
34
|
+
raise ArgumentError, "params[:#{k}] is required!" unless @query[k]
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -41,7 +41,7 @@ module LazyAnt
|
|
41
41
|
arg_names = url.scan(/:([\w_]+)/).map(&:first)
|
42
42
|
arg_names.each do |k|
|
43
43
|
arg = args.shift
|
44
|
-
|
44
|
+
raise ArgumentError, "missing required key :#{k}" unless arg
|
45
45
|
url.gsub!(/:#{k}/, arg.to_s)
|
46
46
|
end
|
47
47
|
url
|
data/lib/lazy_ant/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazy_ant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- masarakki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
272
|
version: '0'
|
273
273
|
requirements: []
|
274
274
|
rubyforge_project:
|
275
|
-
rubygems_version: 2.
|
275
|
+
rubygems_version: 2.5.1
|
276
276
|
signing_key:
|
277
277
|
specification_version: 4
|
278
278
|
summary: Generate an api client easily.
|