ob 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 126d2e6a5cc52b3babf5ff50f440b9f24a99b972
4
+ data.tar.gz: 2dd3171d84234c2b54c540c17a56b07f30d6d3ba
5
+ SHA512:
6
+ metadata.gz: b79905db8f8a50830fcd6c3417d63377924abdc7195a7e65ffd86128beb7065d336fbeb5720fe1cb469c73e5875685e988523dd2944d4564caf202ce75748f4c
7
+ data.tar.gz: bddf3c271d59f60dca5a0eac9c55418ce8e1131146475c27c657aa8145472087268e1fafe446e228aab786da5e199b45d772eb11b85b7b1b45b4365f24ba820a
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ob.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Ob
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ob'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ob
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/ob/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,6 @@
1
+ module Ob
2
+ class MaterialMgmtStorageDetail < Resource
3
+ include Ob::Operations::Find
4
+ include Ob::Operations::Where
5
+ end
6
+ end
@@ -0,0 +1,20 @@
1
+ module Ob
2
+ class ObObject < Hash
3
+ attr_reader :id
4
+ attr_reader :values
5
+
6
+ def initialize(id = nil)
7
+ @values = Hash.new
8
+ @id = id.to_s
9
+ end
10
+ def set_val(k,v)
11
+ @values[k] = v
12
+ end
13
+ def unset_key(k)
14
+ @values.delete(k)
15
+ end
16
+ def self.class_name
17
+ self.name.split('::')[-1]
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ module Ob
2
+ module Operations
3
+ module Find
4
+ module ClassMethods
5
+ def find(id)
6
+ instance = self.new(id)
7
+ response = Requestor.new.request(:get, instance.url)
8
+ response
9
+ end
10
+ end
11
+ def self.included(base)
12
+ base.extend(ClassMethods)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module Ob
2
+ module Operations
3
+ module Where
4
+ module ClassMethods
5
+ def where(params=nil)
6
+ instance = ObObject.new
7
+ response = Requestor.new.request(:get, url, params)
8
+ response
9
+ end
10
+ end
11
+ def self.included(base)
12
+ base.extend(ClassMethods)
13
+ end
14
+ end
15
+ end
16
+ end
data/lib/ob/product.rb ADDED
@@ -0,0 +1,12 @@
1
+ module Ob
2
+ class Product < Resource
3
+ include Ob::Operations::Find
4
+ include Ob::Operations::Where
5
+ #include RubyOb::Operationsa::Create
6
+ #include RubyOb::Operations::Delete
7
+ #include RubyOb::Operations::Update
8
+ #include RubyOb::Operations::CustumAction
9
+ #include RubyOb::Operations::CreateMember
10
+
11
+ end
12
+ end
@@ -0,0 +1,45 @@
1
+ require 'faraday'
2
+ require 'base64'
3
+ require 'json'
4
+
5
+ module Ob
6
+ class Requestor
7
+ #require 'sys/uname'
8
+ #include Sys
9
+
10
+ attr_reader :user
11
+ attr_reader :password
12
+
13
+ def initialize()
14
+ @user = Ob.user
15
+ @password = Ob.password
16
+ end
17
+ def api_url(url = '')
18
+ api_base = Ob.api_base
19
+ api_base + url
20
+ end
21
+ def request(meth, url, params=nil)
22
+ url = self.api_url(url)
23
+ meth = meth.downcase
24
+
25
+ begin
26
+ conn = Faraday.new :url => url do |faraday|
27
+ faraday.adapter Faraday.default_adapter
28
+ faraday.basic_auth(self.user, self.password)
29
+ end
30
+
31
+ if params
32
+ conn.params = params
33
+ end
34
+ response = conn.method(meth).call
35
+
36
+ rescue Exception => e
37
+ puts e
38
+ end
39
+ if response.status != 200
40
+ puts "error status code is #{response.status}"
41
+ end
42
+ return JSON.parse(response.body)
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,10 @@
1
+ module Ob
2
+ class Resource < ObObject
3
+ def self.url()
4
+ "/#{CGI.escape(self.class_name)}"
5
+ end
6
+ def url
7
+ return [self.class.url, id].join('/')
8
+ end
9
+ end
10
+ end
data/lib/ob/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Ob
2
+ VERSION = "0.0.1.1"
3
+ end
data/lib/ob.rb ADDED
@@ -0,0 +1,39 @@
1
+ require "ob/version"
2
+
3
+ require 'cgi'
4
+
5
+ require "ob/operations/find"
6
+ require "ob/operations/where"
7
+
8
+ require "ob/ob_object"
9
+ require "ob/resource"
10
+ require "ob/product"
11
+ require "ob/material_mgmt_storage_detail"
12
+ require "ob/requestor"
13
+
14
+ module Ob
15
+ def self.api_base
16
+ @api_base
17
+ end
18
+ def self.api_base=(api_base)
19
+ @api_base = api_base
20
+ end
21
+ def self.api_version
22
+ @api_version
23
+ end
24
+ def self.api_version=(api_version)
25
+ @api_version = @api_version
26
+ end
27
+ def self.user
28
+ @user
29
+ end
30
+ def self.user=(user)
31
+ @user = user
32
+ end
33
+ def self.password
34
+ @password
35
+ end
36
+ def self.password=(password)
37
+ @password = password
38
+ end
39
+ end
data/ob.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ob/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ob"
8
+ spec.version = Ob::VERSION
9
+ spec.authors = ["Jesus Lerma Sanchez"]
10
+ spec.email = ["shuyojl@gmail.com"]
11
+ spec.summary = %q{Ruby library for ob services.}
12
+ spec.description = %q{This librario provides ob services operations.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_dependency "json", '~> 1.8.1', '>= 1.8.1'
24
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ob
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Jesus Lerma Sanchez
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.8.1
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 1.8.1
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: 1.8.1
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.8.1
61
+ description: This librario provides ob services operations.
62
+ email:
63
+ - shuyojl@gmail.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - ".gitignore"
69
+ - Gemfile
70
+ - LICENSE.txt
71
+ - README.md
72
+ - Rakefile
73
+ - lib/ob.rb
74
+ - lib/ob/material_mgmt_storage_detail.rb
75
+ - lib/ob/ob_object.rb
76
+ - lib/ob/operations/find.rb
77
+ - lib/ob/operations/where.rb
78
+ - lib/ob/product.rb
79
+ - lib/ob/requestor.rb
80
+ - lib/ob/resource.rb
81
+ - lib/ob/version.rb
82
+ - ob.gemspec
83
+ homepage: ''
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.4.5
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Ruby library for ob services.
107
+ test_files: []