nard-appi 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 165c29d46409d87030350c7625a4849227da3375
4
- data.tar.gz: 48a07542b233dae0ba6cee6f950e18bdfc091c2f
3
+ metadata.gz: fd1d5e188752b5ac1db8b30fc8ef7ebf441b813e
4
+ data.tar.gz: 52f8962dfbf0498e4276bdd9eba15582ac98fb49
5
5
  SHA512:
6
- metadata.gz: 2852994a67ddfc592ed22b83377232b75ff04ee51c95dade20ac5cb4b03f664b8e8ee309d97aee9892ea026b634e68b180fc1b4c63737b6031eaed52bcbe6550
7
- data.tar.gz: 16751de92c26754306d43851c48fa57489b712479b1dd99cb1330f5a6a404fda2c56f349a4446608f9cff23c18eaab47c41c74eebb513855b94a4b6f397642b4
6
+ metadata.gz: bf4dd2403403efbedc3b7aff3f82e09a4ab452b5cb335d75fa2d3b5b39964085f9a267a814fa3cb6a4dd28637ec70a91964b8e65290679d43dee155d57c2d0fc
7
+ data.tar.gz: 0db077d150356a8f4215fbc8259923549c446ccd5a67a9225f3fce84e731f36088a5bcc68c0dbc05129502f78b985691fef8d46ff728c673f5877255440ee8af
@@ -0,0 +1,58 @@
1
+ require 'active_support'
2
+ require 'active_support/core_ext'
3
+
4
+ module Nard
5
+
6
+ module Appi
7
+
8
+ class Client
9
+
10
+ # Nard::Appi::Client の補助的な機能を格納する名前空間
11
+ module Util
12
+
13
+ # API へ送る情報を処理するクラス
14
+ class ArgsNormalizer
15
+
16
+ def self.execute( *args )
17
+ new( *args ).to_a
18
+ end
19
+
20
+ def initialize( *args )
21
+ @args = [ args ].flatten
22
+ @options = @args.extract_options!
23
+
24
+ process_instance_variables unless has_options?
25
+ end
26
+
27
+ def to_a
28
+ [ @args, @options ]
29
+ end
30
+
31
+ private
32
+
33
+ def has_options?
34
+ @options.present?
35
+ end
36
+
37
+ def process_instance_variables
38
+ _args = @args.dup
39
+ last_arg = @args.pop
40
+ if last_arg.present?
41
+ uri = URI.parse( last_arg.to_s )
42
+ @args = [ @args, uri.path ].flatten
43
+ @options = options_from_uri( uri )
44
+ else
45
+ @args = _args
46
+ end
47
+ end
48
+
49
+ def options_from_uri( uri )
50
+ uri.query.present? ? Hash[ URI::decode_www_form( uri.query ) ] : {}
51
+ end
52
+
53
+ end
54
+
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,4 +1,4 @@
1
- require_relative './module/args_normalizer'
1
+ require_relative './args_normalizer'
2
2
  require_relative './module/path_normalizer'
3
3
  require_relative './module/options_normalizer'
4
4
  require_relative './module/boolean_normalizer'
@@ -15,7 +15,6 @@ module Nard
15
15
  # API へ送る情報を処理するクラス(基底クラス)
16
16
  class BaseNormalizer
17
17
 
18
- include Module::ArgsNormalizer
19
18
  include Module::PathNormalizer
20
19
  include Module::OptionsNormalizer
21
20
  include Module::BooleanNormalizer
@@ -25,7 +24,7 @@ module Nard
25
24
  end
26
25
 
27
26
  def initialize( *args )
28
- args, options = normalize_args( args )
27
+ args, options = ArgsNormalizer.execute( *args )
29
28
 
30
29
  @path = normalize_path( args )
31
30
 
@@ -30,7 +30,7 @@ module Nard
30
30
  h = {}
31
31
 
32
32
  options.each do | k, v |
33
- h[k] = normalize_value(v)
33
+ h[k] = normalize_value(v) if active_value?(v)
34
34
  end
35
35
 
36
36
  return h
@@ -44,6 +44,10 @@ module Nard
44
44
  raise NotImplementedError
45
45
  end
46
46
 
47
+ def active_value?( value )
48
+ true
49
+ end
50
+
47
51
  end
48
52
 
49
53
  end
@@ -1,5 +1,5 @@
1
1
  module Nard
2
2
  module Appi
3
- VERSION = '0.1.3'.freeze
3
+ VERSION = '0.1.4'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nard-appi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shu Fujita
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-04 00:00:00.000000000 Z
11
+ date: 2016-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -126,8 +126,8 @@ files:
126
126
  - lib/nard/appi/api_ext/initializer.rb
127
127
  - lib/nard/appi/api_ext/version.rb
128
128
  - lib/nard/appi/client.rb
129
+ - lib/nard/appi/client/util/args_normalizer.rb
129
130
  - lib/nard/appi/client/util/base_normalizer.rb
130
- - lib/nard/appi/client/util/module/args_normalizer.rb
131
131
  - lib/nard/appi/client/util/module/boolean_normalizer.rb
132
132
  - lib/nard/appi/client/util/module/options_normalizer.rb
133
133
  - lib/nard/appi/client/util/module/path_normalizer.rb
@@ -1,31 +0,0 @@
1
- require 'active_support'
2
- require 'active_support/core_ext'
3
-
4
- module Nard
5
-
6
- module Appi
7
-
8
- class Client
9
-
10
- # Nard::Appi::Client の補助的な機能を格納する名前空間
11
- module Util
12
-
13
- module Module
14
-
15
- module ArgsNormalizer
16
-
17
- private
18
-
19
- def normalize_args( args )
20
- args = [ args ].flatten
21
- options = args.extract_options!
22
- [ args, options.with_indifferent_access ]
23
- end
24
-
25
- end
26
-
27
- end
28
- end
29
- end
30
- end
31
- end