nard-appi 0.1.0 → 0.1.1
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/lib/nard/appi.rb +1 -0
- data/lib/nard/appi/api_ext/environment.rb +40 -0
- data/lib/nard/appi/client.rb +16 -2
- data/lib/nard/appi/environment.rb +60 -0
- data/lib/nard/appi/version.rb +1 -1
- data/nard-appi.gemspec +5 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4abd92ee266b691b35db9c57d256d4b457ab928
|
4
|
+
data.tar.gz: 5a0f66c5c123c258f3183599731b9145cd4dd81e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c9ecdebd9f1029d955de1d65f637a7ac20f46de1c71655dff56b1227dc80c39a8809489149fd7327234037d9b37937c9bdcb1c3fa9a48275c51c7d61d56d657
|
7
|
+
data.tar.gz: 31a614639a2b3ccf80caaf52e7338d68188fd6edfd6064b23645a0caf06277ed1295157afd1180b94d11591f7bef7212588f1d14f15ac921e9333b18d3bdf62b
|
data/lib/nard/appi.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/core_ext'
|
3
|
+
|
4
|
+
require_relative './../environment'
|
5
|
+
|
6
|
+
module Nard
|
7
|
+
module Appi
|
8
|
+
|
9
|
+
module ApiExt
|
10
|
+
|
11
|
+
module Environment
|
12
|
+
|
13
|
+
extend ActiveSupport::Concern
|
14
|
+
|
15
|
+
module ClassMethods
|
16
|
+
|
17
|
+
# @return [Symbol]
|
18
|
+
def environment
|
19
|
+
env.to_sym
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Nard::Appi::Environment]
|
23
|
+
def env
|
24
|
+
@env ||= Nard::Appi::Environment.instance
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Symbol]
|
28
|
+
def environment=( arg )
|
29
|
+
env.update!( arg )
|
30
|
+
end
|
31
|
+
|
32
|
+
alias :env= :environment=
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/nard/appi/client.rb
CHANGED
@@ -12,8 +12,8 @@ module Nard
|
|
12
12
|
def initialize( gem_top_namespace, options = {} )
|
13
13
|
options_keys = gem_top_namespace::OPTIONS_KEYS
|
14
14
|
|
15
|
-
self.class.
|
16
|
-
|
15
|
+
self.class.instance_eval do
|
16
|
+
set_attr_accessors( options_keys )
|
17
17
|
end
|
18
18
|
|
19
19
|
options = gem_top_namespace.options.merge( options ).with_indifferent_access
|
@@ -23,6 +23,20 @@ module Nard
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
def self.set_attr_accessors( options_keys )
|
27
|
+
return if @_attr_accessors_defined
|
28
|
+
|
29
|
+
options_keys.each do | option_key |
|
30
|
+
getter_method = option_key.to_sym
|
31
|
+
setter_method = "#{ option_key }=".to_sym
|
32
|
+
writer = option_key.to_sym
|
33
|
+
attr_reader getter_method unless getter_method.in?( self.class.instance_methods )
|
34
|
+
attr_writer writer unless setter_method.in?( self.class.instance_methods )
|
35
|
+
end
|
36
|
+
|
37
|
+
@_attr_accessors_defined = true
|
38
|
+
end
|
39
|
+
|
26
40
|
end
|
27
41
|
end
|
28
42
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module Nard
|
4
|
+
module Appi
|
5
|
+
|
6
|
+
class Environment
|
7
|
+
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
default_environment = :production
|
12
|
+
@env = default_environment
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_sym
|
16
|
+
@env
|
17
|
+
end
|
18
|
+
|
19
|
+
def update!( env )
|
20
|
+
@env = env.to_sym
|
21
|
+
end
|
22
|
+
|
23
|
+
def reset!
|
24
|
+
update!( :production )
|
25
|
+
end
|
26
|
+
|
27
|
+
def development?
|
28
|
+
@env == :development
|
29
|
+
end
|
30
|
+
|
31
|
+
def production?
|
32
|
+
@env == :production
|
33
|
+
end
|
34
|
+
|
35
|
+
def test?
|
36
|
+
@env == :test
|
37
|
+
end
|
38
|
+
|
39
|
+
def staging?
|
40
|
+
@env == :staging
|
41
|
+
end
|
42
|
+
|
43
|
+
def method_missing( method_name, *args, &block )
|
44
|
+
condition = respond_to?( method_name ) and args.length == 0 and !( block_given? )
|
45
|
+
if condition
|
46
|
+
/\A(.+)\?\Z/ === method_name.to_s
|
47
|
+
@env.to_s == $1
|
48
|
+
else
|
49
|
+
super
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def respond_to?( method_name, include_all = false )
|
54
|
+
return super || /\A(.+)\?\Z/ === method_name.to_s
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
data/lib/nard/appi/version.rb
CHANGED
data/nard-appi.gemspec
CHANGED
@@ -22,6 +22,10 @@ Gem::Specification.new do |spec|
|
|
22
22
|
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
23
|
# "public gem pushes."
|
24
24
|
# end
|
25
|
+
unless spec.respond_to?(:metadata)
|
26
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
"public gem pushes."
|
28
|
+
end
|
25
29
|
|
26
30
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
31
|
f.match(%r{^(test|spec|features)/})
|
@@ -36,4 +40,5 @@ Gem::Specification.new do |spec|
|
|
36
40
|
spec.add_development_dependency 'bundler', '~> 1.13'
|
37
41
|
spec.add_development_dependency 'rake', '~> 10.0'
|
38
42
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
43
|
+
spec.add_development_dependency 'pry'
|
39
44
|
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.
|
4
|
+
version: 0.1.1
|
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-
|
11
|
+
date: 2016-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -86,6 +86,20 @@ dependencies:
|
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '3.0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: pry
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
89
103
|
description: This gem 'nard-appi' enables you to access to APIs more easily. You can
|
90
104
|
make API wrapper by using classes and modules contained in this gem.
|
91
105
|
email:
|
@@ -108,6 +122,7 @@ files:
|
|
108
122
|
- lib/nard/appi/api_ext/client.rb
|
109
123
|
- lib/nard/appi/api_ext/configuration.rb
|
110
124
|
- lib/nard/appi/api_ext/default_configuration.rb
|
125
|
+
- lib/nard/appi/api_ext/environment.rb
|
111
126
|
- lib/nard/appi/api_ext/initializer.rb
|
112
127
|
- lib/nard/appi/api_ext/version.rb
|
113
128
|
- lib/nard/appi/client.rb
|
@@ -117,6 +132,7 @@ files:
|
|
117
132
|
- lib/nard/appi/client/util/module/options_normalizer.rb
|
118
133
|
- lib/nard/appi/client/util/module/path_normalizer.rb
|
119
134
|
- lib/nard/appi/client_ext/request.rb
|
135
|
+
- lib/nard/appi/environment.rb
|
120
136
|
- lib/nard/appi/version.rb
|
121
137
|
- nard-appi.gemspec
|
122
138
|
homepage: https://github.com/nard-tech/nard-appi
|