dmm-sdk-ruby 0.0.1 → 0.0.2

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: 8e7c7d2600a5e680463b716e987b0d379d4c2cc8
4
- data.tar.gz: f11f5c4f3a1db6b5e1bffccc01dc7c775960cebe
3
+ metadata.gz: de24be485715bce4e0231108745d48e4ba81b675
4
+ data.tar.gz: 1fc4a091932861bc3549d2809732a201b798c558
5
5
  SHA512:
6
- metadata.gz: 6c08c7506e00b85b66b26b29f0acc96d241f007f05a9a6e6a2da57bcabc8dc09f286cf95adc2a73af494a6ecbe31216053f33928b39c4735f107d375a4257612
7
- data.tar.gz: 76f8231aacace24fa1ccab4034943ea2238b06df2f1823860f6f42c8c58d742d2c282acf9477337a3368f8be1a36b9cee718af33520e2b5c3b6a0d76f4bb5495
6
+ metadata.gz: 71a9ebc838284ed6a6f8dfd412893b197355e87d22120ce9c57922d1ac82314f51f43aa36879a450eaee088071c5c8ff1ebbaf60325d5a5bc888d778b40d055a
7
+ data.tar.gz: 2966e96bbdaf0ce7449b5928a656c4086b8e4af6d33011967bb8b9e09a5cc8e0df2ba329c209705a45627f4cc963ac308ff2d12ed8b00b888bff13265ffa3a30
data/dmm-sdk-ruby.gemspec CHANGED
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'dmm/sdk/ruby/version'
4
+ require 'dmm/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "dmm-sdk-ruby"
8
- spec.version = Dmm::Sdk::Ruby::VERSION
8
+ spec.version = Dmm::VERSION
9
9
  spec.authors = ["sutoh"]
10
10
  spec.email = ["sutoh.shohei@human-net.co.jp"]
11
11
  spec.description = %q{ dmm-api はXML取得の為、Ruby用のsdk Library作成 }
data/lib/dmm-sdk.rb ADDED
@@ -0,0 +1 @@
1
+ require 'dmm/core'
data/lib/dmm.rb ADDED
@@ -0,0 +1 @@
1
+ require 'dmm-sdk'
@@ -0,0 +1,7 @@
1
+ module Dmm::api
2
+ class Base
3
+ include Dmm
4
+ DOMAIN='http://affiliate-api.dmm.com/'
5
+ end
6
+ end
7
+
data/lib/dmm/core.rb ADDED
@@ -0,0 +1,77 @@
1
+ require 'aws/version'
2
+ require 'set'
3
+
4
+ module DMM
5
+ class SvcDetails
6
+ def initialize class_name, options
7
+ @class_name = classname
8
+ @full_name = options[:full_name]
9
+ @method_name = options[:method_name]
10
+ @method_alias = options[:method_alias]
11
+ @old_name = @method_alias || @method_name
12
+ end
13
+ attr_render :class_name, :full_name, :method_name, :method_alias, :old_name
14
+ end
15
+
16
+ SERVICES = [
17
+ SvcDetails.new("Com"
18
+ :full_name => "DMM.com",
19
+ :method_name => :com),
20
+ SvcDetails.new("R18"
21
+ :full_name => "DMM.r18",
22
+ :method_name => :r18)
23
+ ].inject({}) { |h,svc| h[svc.class_name] = svc; h }
24
+
25
+ ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
26
+
27
+ module Core
28
+ autoload :Configuration, 'aws/core/configuration'
29
+
30
+ #module XML
31
+ #end
32
+
33
+ #module Http
34
+ #end
35
+ end
36
+
37
+ class << self
38
+
39
+ SERVICES.values.each do |svc|
40
+ define_method(svc.method_name) do |*args|
41
+ AWS.const_get(svc.class_name).new(args.first || {})
42
+ end
43
+ alias_method(svc.method_alias, svc.method_name) if svc.method_alias
44
+ end
45
+
46
+ @@coonfig = nil
47
+
48
+ def config options = {}
49
+ @@config ||= Core::Configuration.new
50
+ @@config = @@config.with(options) unless options.empty?
51
+ @@config
52
+ end
53
+
54
+ # Eagerly loads all DMM classes/modules registered with autoload.
55
+ # @return [void]
56
+ def eager_autoload! klass_or_module = AWS, visited = Set.new
57
+ kalass_or_module.constants.each do |const_name|
58
+ path = klass_or_module.autoload?(const_name)
59
+ require(path) if path
60
+ const = klass_or_module.const_get(const_name)
61
+ if const.is_a?(Module)
62
+ unless visited.include?(const)
63
+ visited << const
64
+ eager_autoload!(const, visited)
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ SERVICES.values.each do |svc|
72
+ autoload(svc.class_name, "aws/"#{svc.old_name}")
73
+ require "aws/#{svc.old_name}/config"
74
+ end
75
+
76
+ end
77
+
@@ -0,0 +1,156 @@
1
+ require 'set'
2
+ require 'uri'
3
+
4
+ module AWS
5
+ module Core
6
+ class Confiduration
7
+
8
+ # Creates a new Configuration object.
9
+ # @param options (see DMM.config)
10
+ # @option options (see DMM.config)
11
+ def initialize options = {}
12
+ @created = options.delete(:__created__) || {}
13
+
14
+ options.each_pair do |opt_name, value|
15
+ opt_name = opt_name.to_sym
16
+ if self.class.accepted_options.include?(opt_name)
17
+ supplied[opt_name] = value
18
+ end
19
+ end
20
+ end
21
+
22
+ # @return [Hash] Returns a hash with your configured credentials.
23
+ def credentials
24
+ credentials = {}
25
+ [:api_id, :affiliate_id].each do |opt|
26
+ if value = credential_provider.send(opt)
27
+ credentials[opt] = value
28
+ end
29
+ end
30
+ credentials
31
+ end
32
+
33
+
34
+ def with options = {}
35
+ # symbolize option keys
36
+ options = options.inject({}) {|h,kv| h[kv.first.to_sym] = kv.last; h }
37
+ values = supplied.merge(options)
38
+ if supplied == values
39
+ self # nothing changed
40
+ else
41
+ self.class.new(values.merge(:__created__ => @created.dup))
42
+ end
43
+ end
44
+
45
+
46
+ # @return [Hash] Returns a hash of all configuration values.
47
+ def to_h
48
+ self.class.accepted_options.inject({}) do |h,k|
49
+ h.merge(k => send(k))
50
+ end
51
+ end
52
+ alias_method :to_hash, :to_h
53
+
54
+
55
+ # @return [Boolean] Returns true if the two configuration objects have
56
+ # the same values.
57
+ def eql? other
58
+ other.is_a?(self.class) and self.supplied == other.supplied
59
+ end
60
+ alias_method :==, :eql?
61
+
62
+
63
+ def inspect
64
+ "<#{self.class.name}>"
65
+ end
66
+
67
+
68
+ protected
69
+
70
+ add_options :api_id
71
+
72
+ add_options :affiliate_id
73
+
74
+ def supplied
75
+ @supplied ||= {}
76
+ end
77
+
78
+ =begin
79
+ class << self
80
+ def accepted_options
81
+ @options ||= Set.new
82
+ end
83
+
84
+
85
+ def add_option name, default_value = nil, options = {}, &transform
86
+ accepted_options << name
87
+ define_method(name) do |&default_override|
88
+ value =
89
+ if supplied.has_key?(name)
90
+ supplied[name]
91
+ elsif default_override
92
+ default_override.call
93
+ else
94
+ default_value
95
+ end
96
+ transform ? transform.call(self, value) : value
97
+ end
98
+ alias_method("#{name}?", name) if options[:boolean]
99
+ end
100
+
101
+
102
+ # Configuration options that have dependencies are re-recreated
103
+ # anytime one of their dependent configuration values are
104
+ # changed.
105
+ # @api private
106
+ def add_option_with_needs name, needs, &create_block
107
+ accepted_options << name
108
+ define_method(name) do
109
+ return supplied[name] if supplied.has_key?(name)
110
+ needed = needs.inject({}) {|h,need| h.merge(need => send(need)) }
111
+ unless @created.key?(name) and @created[name][:needed] == needed
112
+ created = {}
113
+ created[:object] = create_block.call(self,needed)
114
+ created[:needed] = needed
115
+ @created[name] = created
116
+ end
117
+ @created[name][:object]
118
+ end
119
+ end
120
+
121
+ def add_service name, ruby_name, endpoint_pattern = nil, &endpoint_builder
122
+ svc = SERVICES[name]
123
+ svc_opt = svc.method_name
124
+ ruby_name = svc.old_name
125
+ add_option(svc_opt, {})
126
+ needs = [
127
+ :"#{ruby_name}_endpoint",
128
+ :"#{ruby_name}_port",
129
+ :"#{ruby_name}_region",
130
+ :credential_provider,
131
+ :http_handler,
132
+ :http_read_timeout,
133
+ :http_continue_timeout,
134
+ :http_continue_threshold,
135
+ :log_formatter,
136
+ :log_level,
137
+ :logger,
138
+ :proxy_uri,
139
+ :max_retries,
140
+ :stub_requests?,
141
+ :ssl_verify_peer?,
142
+ :ssl_ca_file,
143
+ :ssl_ca_path,
144
+ :use_ssl?,
145
+ :user_agent_prefix,
146
+ ]
147
+ create_block = lambda do |config,client_options|
148
+ AWS.const_get(name)::Client.new(:config => config)
149
+ end
150
+ add_option_with_needs :"#{ruby_name}_client", needs, &create_block
151
+ end
152
+ end
153
+ =end
154
+ end
155
+ end
156
+ end
@@ -0,0 +1,3 @@
1
+ module Dmm
2
+ VERSION = "0.0.2"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dmm-sdk-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - sutoh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-09 00:00:00.000000000 Z
11
+ date: 2013-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -51,8 +51,12 @@ files:
51
51
  - README.md
52
52
  - Rakefile
53
53
  - dmm-sdk-ruby.gemspec
54
- - lib/dmm/sdk/ruby.rb
55
- - lib/dmm/sdk/ruby/version.rb
54
+ - lib/dmm-sdk.rb
55
+ - lib/dmm.rb
56
+ - lib/dmm/api/base.rb
57
+ - lib/dmm/core.rb
58
+ - lib/dmm/core/configuration.rb
59
+ - lib/dmm/version.rb
56
60
  homepage: ''
57
61
  licenses:
58
62
  - MIT
data/lib/dmm/sdk/ruby.rb DELETED
@@ -1,9 +0,0 @@
1
- require "dmm/sdk/ruby/version"
2
-
3
- module Dmm
4
- module Sdk
5
- module Ruby
6
- # Your code goes here...
7
- end
8
- end
9
- end
@@ -1,7 +0,0 @@
1
- module Dmm
2
- module Sdk
3
- module Ruby
4
- VERSION = "0.0.1"
5
- end
6
- end
7
- end