ncore 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +36 -0
- data/Rakefile +1 -0
- data/example/lib/my_api.rb +12 -0
- data/example/lib/my_api/api_config.rb +33 -0
- data/example/lib/my_api/customer.rb +8 -0
- data/example/lib/my_api/rails/log_subscriber.rb +10 -0
- data/example/lib/my_api/rails/railtie.rb +13 -0
- data/example/lib/my_api/version.rb +3 -0
- data/lib/ncore.rb +14 -0
- data/lib/ncore/associations.rb +81 -0
- data/lib/ncore/attributes.rb +157 -0
- data/lib/ncore/base.rb +35 -0
- data/lib/ncore/builder.rb +34 -0
- data/lib/ncore/client.rb +301 -0
- data/lib/ncore/collection.rb +11 -0
- data/lib/ncore/configuration.rb +56 -0
- data/lib/ncore/exceptions.rb +45 -0
- data/lib/ncore/identity.rb +26 -0
- data/lib/ncore/lifecycle.rb +36 -0
- data/lib/ncore/methods/all.rb +30 -0
- data/lib/ncore/methods/build.rb +16 -0
- data/lib/ncore/methods/count.rb +13 -0
- data/lib/ncore/methods/create.rb +33 -0
- data/lib/ncore/methods/delete.rb +19 -0
- data/lib/ncore/methods/delete_single.rb +19 -0
- data/lib/ncore/methods/find.rb +26 -0
- data/lib/ncore/methods/find_single.rb +34 -0
- data/lib/ncore/methods/update.rb +29 -0
- data/lib/ncore/rails/active_model.rb +44 -0
- data/lib/ncore/rails/log_subscriber.rb +116 -0
- data/lib/ncore/singleton_base.rb +33 -0
- data/lib/ncore/ssl/ca-certificates.crt +4027 -0
- data/lib/ncore/util.rb +61 -0
- data/lib/ncore/version.rb +3 -0
- data/ncore.gemspec +27 -0
- metadata +158 -0
data/lib/ncore/util.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
module NCore
|
2
|
+
module Util
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
def self.deep_clone(value)
|
6
|
+
case value
|
7
|
+
when Hash
|
8
|
+
cl = value.clone
|
9
|
+
value.each{|k,v| cl[k] = deep_clone(v)}
|
10
|
+
cl
|
11
|
+
when Array
|
12
|
+
cl = value.clone
|
13
|
+
cl.clear
|
14
|
+
value.each{|v| cl << deep_clone(v)}
|
15
|
+
cl
|
16
|
+
when NilClass, Numeric, TrueClass, FalseClass
|
17
|
+
value
|
18
|
+
else
|
19
|
+
value.clone rescue value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
module ClassMethods
|
25
|
+
|
26
|
+
def interpret_type(val_or_enum, api_creds)
|
27
|
+
case val_or_enum
|
28
|
+
when Hash
|
29
|
+
if key = val_or_enum[:object]
|
30
|
+
discover_class(key).new val_or_enum, api_creds
|
31
|
+
else
|
32
|
+
val_or_enum
|
33
|
+
end
|
34
|
+
when Array
|
35
|
+
val_or_enum.map{|v| interpret_type v, api_creds }
|
36
|
+
else
|
37
|
+
val_or_enum
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def discover_class(key, default_klass=parent::GenericObject)
|
45
|
+
klass_name = key.to_s.camelize.singularize
|
46
|
+
begin
|
47
|
+
"#{module_name}::#{klass_name}".constantize
|
48
|
+
rescue NameError => e
|
49
|
+
default_klass
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def inspect
|
57
|
+
"#<#{self.class}:0x#{self.object_id.to_s(16)}> id: #{id.inspect}, attribs: #{@attribs.except(:id).inspect}, metadata: #{metadata.inspect}"
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
data/ncore.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ncore/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ncore"
|
8
|
+
spec.version = NCore::VERSION
|
9
|
+
spec.authors = ["thomas morgan"]
|
10
|
+
spec.email = ["tm@notioneer.com"]
|
11
|
+
spec.description = %q{NCore - Ruby gem useful for building REST API clients}
|
12
|
+
spec.summary = %q{NCore - Gem for building REST API clients}
|
13
|
+
spec.homepage = "https://github.com/notioneer/ncore-ruby"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'activesupport', '>= 3.2', '< 5.0'
|
22
|
+
spec.add_dependency 'excon', '~> 0.32'
|
23
|
+
spec.add_dependency 'multi_json', '~> 1.7'
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ncore
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- thomas morgan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
- - <
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.2'
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: excon
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ~>
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.32'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.32'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: multi_json
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.7'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.7'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: bundler
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.3'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.3'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rake
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
description: NCore - Ruby gem useful for building REST API clients
|
90
|
+
email:
|
91
|
+
- tm@notioneer.com
|
92
|
+
executables: []
|
93
|
+
extensions: []
|
94
|
+
extra_rdoc_files: []
|
95
|
+
files:
|
96
|
+
- .gitignore
|
97
|
+
- Gemfile
|
98
|
+
- LICENSE
|
99
|
+
- README.md
|
100
|
+
- Rakefile
|
101
|
+
- example/lib/my_api.rb
|
102
|
+
- example/lib/my_api/api_config.rb
|
103
|
+
- example/lib/my_api/customer.rb
|
104
|
+
- example/lib/my_api/rails/log_subscriber.rb
|
105
|
+
- example/lib/my_api/rails/railtie.rb
|
106
|
+
- example/lib/my_api/version.rb
|
107
|
+
- lib/ncore.rb
|
108
|
+
- lib/ncore/associations.rb
|
109
|
+
- lib/ncore/attributes.rb
|
110
|
+
- lib/ncore/base.rb
|
111
|
+
- lib/ncore/builder.rb
|
112
|
+
- lib/ncore/client.rb
|
113
|
+
- lib/ncore/collection.rb
|
114
|
+
- lib/ncore/configuration.rb
|
115
|
+
- lib/ncore/exceptions.rb
|
116
|
+
- lib/ncore/identity.rb
|
117
|
+
- lib/ncore/lifecycle.rb
|
118
|
+
- lib/ncore/methods/all.rb
|
119
|
+
- lib/ncore/methods/build.rb
|
120
|
+
- lib/ncore/methods/count.rb
|
121
|
+
- lib/ncore/methods/create.rb
|
122
|
+
- lib/ncore/methods/delete.rb
|
123
|
+
- lib/ncore/methods/delete_single.rb
|
124
|
+
- lib/ncore/methods/find.rb
|
125
|
+
- lib/ncore/methods/find_single.rb
|
126
|
+
- lib/ncore/methods/update.rb
|
127
|
+
- lib/ncore/rails/active_model.rb
|
128
|
+
- lib/ncore/rails/log_subscriber.rb
|
129
|
+
- lib/ncore/singleton_base.rb
|
130
|
+
- lib/ncore/ssl/ca-certificates.crt
|
131
|
+
- lib/ncore/util.rb
|
132
|
+
- lib/ncore/version.rb
|
133
|
+
- ncore.gemspec
|
134
|
+
homepage: https://github.com/notioneer/ncore-ruby
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
metadata: {}
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 2.0.6
|
155
|
+
signing_key:
|
156
|
+
specification_version: 4
|
157
|
+
summary: NCore - Gem for building REST API clients
|
158
|
+
test_files: []
|