driver 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59a3aa15e02608b6e50a9f9a645ddaa5b9e1cf2c
4
- data.tar.gz: cc6b150d10e15b62307e73c2d8da36d93a9d60fe
3
+ metadata.gz: 16a546a1af3242718533322c30f6f874bf630a25
4
+ data.tar.gz: 78e06e8d34e281e4c35d4af25b58ffdade3d9f7f
5
5
  SHA512:
6
- metadata.gz: e4f2f0ef025a4deaf5e5764377a87282493f3654ada5dccbd6d80bac416d6ef88b595ae4b904a9ade8985f3561a7e6d556015283f9f5e61a833c6ef393162051
7
- data.tar.gz: 6f9e2174fa375ac03889906a592448d01b314b79bed15c2eb3e5d271936e85988eef8e6014438ddd05fe6474b821f76d580f95898dc0e062505454f4da857190
6
+ metadata.gz: 1e1c825e26466fbbce8c6ccc4d65e23545360657db4d871710e2b5033effe82b997beec42cd7a77fd270d6a2c038459b96e4fc37412f8b88b4e58b3668688b36
7
+ data.tar.gz: f046d98f722409c20a28ed0559a78b17057674c66caf019ac49d1536cfcf40e6e5530220b4174cf48b7f838493eb46e82f3847f26586e215baeb75817d374645
data/driver.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "driver"
7
- spec.version = "0.0.1"
7
+ spec.version = "0.0.2"
8
8
  spec.authors = ["hiro-su"]
9
9
  spec.email = ["h.sugipon@gmail.com"]
10
10
  spec.summary = %q{Simple Framework for API Client.}
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.homepage = "https://github.com/hiro-su/driver"
13
13
  spec.license = "MIT"
14
14
 
15
- spec.files = `git ls-files -z`.split("\x0")
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|sample|APIClient\.png)}) }
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
data/lib/driver/api.rb CHANGED
@@ -5,7 +5,7 @@ module Driver
5
5
  name
6
6
  end
7
7
 
8
- def drive(*modules)
8
+ def api(*modules)
9
9
  modules.each_with_index do |m, i|
10
10
  api = "#{self}::#{m.to_s.demodulize}"
11
11
  autoload m.to_s.demodulize, api.underscore
data/lib/driver/client.rb CHANGED
@@ -13,15 +13,19 @@ module Driver
13
13
  # client
14
14
  autoload m, "#{self}::#{m}".underscore
15
15
 
16
- # model
17
- module_name = self.to_s.sub("::#{self.to_s.demodulize}", '').constantize
18
- module_name.autoload m, "#{self}::Model::#{m}".underscore
19
-
20
16
  modules[i] = "#{self}::#{m}".constantize
21
17
  end
22
18
 
23
19
  include *modules
24
20
  end
21
+
22
+ def model(*modules)
23
+ modules.each_with_index do |m, i|
24
+ # model
25
+ module_name = self.to_s.sub("::#{self.to_s.demodulize}", '').constantize
26
+ module_name.autoload m, "#{self}::Model::#{m}".underscore
27
+ end
28
+ end
25
29
  end
26
30
 
27
31
  attr_reader :api
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: driver
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
  - hiro-su
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-12 00:00:00.000000000 Z
11
+ date: 2015-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -75,7 +75,6 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
77
  - ".rspec"
78
- - APIClient.png
79
78
  - Gemfile
80
79
  - LICENSE.txt
81
80
  - README.md
@@ -85,16 +84,6 @@ files:
85
84
  - lib/driver/api.rb
86
85
  - lib/driver/client.rb
87
86
  - lib/driver/model.rb
88
- - spec/driver_spec.rb
89
- - spec/dummy/bin/dummy
90
- - spec/dummy/lib/dummy.rb
91
- - spec/dummy/lib/dummy/client.rb
92
- - spec/dummy/lib/dummy/client/api.rb
93
- - spec/dummy/lib/dummy/client/api/database.rb
94
- - spec/dummy/lib/dummy/client/api/table.rb
95
- - spec/dummy/lib/dummy/client/database.rb
96
- - spec/dummy/lib/dummy/client/model/database.rb
97
- - spec/spec_helper.rb
98
87
  homepage: https://github.com/hiro-su/driver
99
88
  licenses:
100
89
  - MIT
@@ -119,15 +108,4 @@ rubygems_version: 2.4.5
119
108
  signing_key:
120
109
  specification_version: 4
121
110
  summary: Simple Framework for API Client.
122
- test_files:
123
- - spec/driver_spec.rb
124
- - spec/dummy/bin/dummy
125
- - spec/dummy/lib/dummy.rb
126
- - spec/dummy/lib/dummy/client.rb
127
- - spec/dummy/lib/dummy/client/api.rb
128
- - spec/dummy/lib/dummy/client/api/database.rb
129
- - spec/dummy/lib/dummy/client/api/table.rb
130
- - spec/dummy/lib/dummy/client/database.rb
131
- - spec/dummy/lib/dummy/client/model/database.rb
132
- - spec/spec_helper.rb
133
- has_rdoc:
111
+ test_files: []
data/APIClient.png DELETED
Binary file
data/spec/driver_spec.rb DELETED
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Driver do
4
- let(:client) { Dummy::Client.new('apikey', 'secret') }
5
-
6
- describe "Dummy Client" do
7
- it "return Dummy::Client instance" do
8
- expect(client.class).to eq Dummy::Client
9
- expect(client.apikey).to eq "apikey"
10
- expect(client.secret).to eq "secret"
11
- end
12
-
13
- it "return Dummy::Client::API instance" do
14
- expect(client.api.class).to eq Dummy::Client::API
15
- expect(client.api.create_database("test")).to eq "create_database: test"
16
- expect(client.api.drop_table("test")).to eq "drop_table: test"
17
- end
18
-
19
- it "return Dummy::Database instance" do
20
- expect(client.db.class).to eq Dummy::Database
21
- expect(client.db.create("test")).to eq "create_database: test"
22
- expect(client.db.delete("test")).to eq "drop_table: test"
23
- end
24
- end
25
- end
data/spec/dummy/bin/dummy DELETED
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'pathname'
4
- $LOAD_PATH << Pathname.new(__FILE__).dirname.join('..', '..', '..', 'lib').expand_path.to_s
5
- $LOAD_PATH << Pathname.new(__FILE__).dirname.join('..', 'lib').expand_path.to_s
6
-
7
- require 'dummy'
8
-
9
- client = Dummy::Client.new('apikey', 'secret')
10
- puts client.db.create("testdb")
11
- puts client.db.delete("testdb")
@@ -1,9 +0,0 @@
1
- module Dummy
2
- class Client::API
3
- module Database
4
- def create_database(name)
5
- "#{__method__}: #{name}"
6
- end
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module Dummy
2
- class Client::API
3
- module Table
4
- def drop_table(name)
5
- "#{__method__}: #{name}"
6
- end
7
- end
8
- end
9
- end
@@ -1,15 +0,0 @@
1
- module Dummy
2
- class Client
3
- class API < Driver::API
4
- drive Database, Table
5
-
6
- def initialize(apikey, secret, options = {})
7
- @apikey = apikey
8
- @secret = secret
9
- @options = options
10
- end
11
-
12
- attr_accessor :apikey, :secret, :options
13
- end
14
- end
15
- end
@@ -1,9 +0,0 @@
1
- module Dummy
2
- class Client
3
- module Database
4
- def db
5
- Dummy::Database.new(@api)
6
- end
7
- end
8
- end
9
- end
@@ -1,11 +0,0 @@
1
- module Dummy
2
- class Database < Driver::Model
3
- def create(name)
4
- @api.create_database(name)
5
- end
6
-
7
- def delete(name)
8
- @api.drop_table(name)
9
- end
10
- end
11
- end
@@ -1,14 +0,0 @@
1
- module Dummy
2
- class Client < Driver::Client
3
- drive Database
4
-
5
- def initialize(apikey, secret, options = {})
6
- @apikey = apikey
7
- @secret = secret
8
-
9
- @api = API.new(@apikey, @secret)
10
- end
11
-
12
- attr_reader :apikey, :secret
13
- end
14
- end
@@ -1,2 +0,0 @@
1
- require "driver"
2
- require "dummy/client"
data/spec/spec_helper.rb DELETED
@@ -1,84 +0,0 @@
1
- require "bundler/setup"
2
- Bundler.require :default
3
-
4
- $LOAD_PATH.unshift(File.dirname(__FILE__))
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), %w(.. lib)))
6
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), %w(dummy lib)))
7
-
8
- require 'driver'
9
- require 'dummy'
10
- require 'rspec'
11
-
12
- RSpec.configure do |config|
13
- # rspec-expectations config goes here. You can use an alternate
14
- # assertion/expectation library such as wrong or the stdlib/minitest
15
- # assertions if you prefer.
16
- config.expect_with :rspec do |expectations|
17
- # This option will default to `true` in RSpec 4. It makes the `description`
18
- # and `failure_message` of custom matchers include text for helper methods
19
- # defined using `chain`, e.g.:
20
- # be_bigger_than(2).and_smaller_than(4).description
21
- # # => "be bigger than 2 and smaller than 4"
22
- # ...rather than:
23
- # # => "be bigger than 2"
24
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
25
- end
26
-
27
- # rspec-mocks config goes here. You can use an alternate test double
28
- # library (such as bogus or mocha) by changing the `mock_with` option here.
29
- config.mock_with :rspec do |mocks|
30
- # Prevents you from mocking or stubbing a method that does not exist on
31
- # a real object. This is generally recommended, and will default to
32
- # `true` in RSpec 4.
33
- mocks.verify_partial_doubles = true
34
- end
35
-
36
- # The settings below are suggested to provide a good initial experience
37
- # with RSpec, but feel free to customize to your heart's content.
38
- =begin
39
- # These two settings work together to allow you to limit a spec run
40
- # to individual examples or groups you care about by tagging them with
41
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
42
- # get run.
43
- config.filter_run :focus
44
- config.run_all_when_everything_filtered = true
45
-
46
- # Limits the available syntax to the non-monkey patched syntax that is
47
- # recommended. For more details, see:
48
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
49
- # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
50
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
51
- config.disable_monkey_patching!
52
-
53
- # This setting enables warnings. It's recommended, but in some cases may
54
- # be too noisy due to issues in dependencies.
55
- config.warnings = true
56
-
57
- # Many RSpec users commonly either run the entire suite or an individual
58
- # file, and it's useful to allow more verbose output when running an
59
- # individual spec file.
60
- if config.files_to_run.one?
61
- # Use the documentation formatter for detailed output,
62
- # unless a formatter has already been configured
63
- # (e.g. via a command-line flag).
64
- config.default_formatter = 'doc'
65
- end
66
-
67
- # Print the 10 slowest examples and example groups at the
68
- # end of the spec run, to help surface which specs are running
69
- # particularly slow.
70
- config.profile_examples = 10
71
-
72
- # Run specs in random order to surface order dependencies. If you find an
73
- # order dependency and want to debug it, you can fix the order by providing
74
- # the seed, which is printed after each run.
75
- # --seed 1234
76
- config.order = :random
77
-
78
- # Seed global randomization in this process using the `--seed` CLI option.
79
- # Setting this allows you to use `--seed` to deterministically reproduce
80
- # test failures related to randomization by passing the same `--seed` value
81
- # as the one that triggered the failure.
82
- Kernel.srand config.seed
83
- =end
84
- end