rongcloud-ruby 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1547deb97904a6ec6dbbb21c5d488d860ed93570
4
+ data.tar.gz: 73dbe236f3b1a6720a006e9969cd050abcf4b6ff
5
+ SHA512:
6
+ metadata.gz: fc60f89afd24abafc6dac5909de9ee453d6e85894d2fbdf34ce2b92c7229df600ecf333a0933413b67075f02871ff7b447378fa3a1a4f81c6e6a2527647e26c2
7
+ data.tar.gz: 83850e42956f4da1a103c01b6a494244c5336a8f618d2a17abda7239fe116bffa084820fc11b7cd5a1e4c1227914c2abdff7b613a5f5f41a46987871a304d3d7
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.2
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rongcloud-ruby.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Hging
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Rongcloud::Ruby
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rongcloud/ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'rongcloud-ruby'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install rongcloud-ruby
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rongcloud-ruby.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rongcloud/ruby"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/rongcloud.rb ADDED
@@ -0,0 +1,59 @@
1
+ # Version
2
+ require "rongcloud/version"
3
+
4
+ # Http client
5
+ require 'unirest'
6
+
7
+ # API operations
8
+ require 'rongcloud/api_operations/create'
9
+ require 'rongcloud/api_operations/update'
10
+ require 'rongcloud/api_operations/delete'
11
+ require 'rongcloud/api_operations/list'
12
+ require 'rongcloud/api_operations/show'
13
+
14
+ # Resources
15
+ require 'rongcloud/base'
16
+ require 'rongcloud/token'
17
+
18
+ module Rongcloud
19
+ class << self
20
+ API_HOST = 'https://api.cn.rong.io'
21
+ attr_accessor :app_key, :app_secret, :api_host
22
+ # attr_writer :debug_mode
23
+
24
+ def api_host
25
+ unless @api_host
26
+ return API_HOST
27
+ end
28
+ @api_host
29
+ end
30
+
31
+ def generate_nonce
32
+ SecureRandom.hex
33
+ end
34
+
35
+ def generate_timestrap
36
+ Time.now.to_i.to_s
37
+ end
38
+
39
+ def generate_http_head
40
+ nonce = generate_nonce
41
+ timestrap = generate_timestrap
42
+ signature = Digest::SHA1.hexdigest(app_secret + nonce + timestrap)
43
+ {
44
+ 'App-Key' => app_key,
45
+ 'Nonce' => nonce,
46
+ 'Timestamp' => timestrap,
47
+ 'Signature' => signature
48
+ }
49
+ end
50
+
51
+ def request(method='get', url=api_host, params={})
52
+ Unirest.send(method, api_host + url, headers: generate_http_head, parameters: params)
53
+ end
54
+
55
+ # def debug_mode?
56
+ # @debug_mode.nil? ? true : !!@debug_mode
57
+ # end
58
+ end
59
+ end
@@ -0,0 +1,15 @@
1
+ module Rongcloud
2
+ module APIOperations
3
+ module Create
4
+ module ClassMethods
5
+ def create(params={})
6
+ response = Rongcloud.request(:post, self.create_url, params)
7
+ end
8
+ end
9
+
10
+ def self.included(base)
11
+ base.extend(ClassMethods)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Rongcloud
2
+ module APIOperations
3
+ module Delete
4
+ module ClassMethods
5
+ def delete(params={})
6
+ response = Rongcloud.request(:post, self.delete_url, params)
7
+ end
8
+ end
9
+
10
+ def self.included(base)
11
+ base.extend(ClassMethods)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Rongcloud
2
+ module APIOperations
3
+ module List
4
+ module ClassMethods
5
+ def all(params={})
6
+ response = Rongcloud.request(:post, self.list_url, params)
7
+ end
8
+ end
9
+
10
+ def self.included(base)
11
+ base.extend(ClassMethods)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Rongcloud
2
+ module APIOperations
3
+ module Show
4
+ module ClassMethods
5
+ def where(params={})
6
+ response = Rongcloud.request(:post, self.show_url, params)
7
+ end
8
+ end
9
+
10
+ def self.included(base)
11
+ base.extend(ClassMethods)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Rongcloud
2
+ module APIOperations
3
+ module Update
4
+ module ClassMethods
5
+ def update(params={})
6
+ response = Rongcloud.request(:put, self.list_url, params)
7
+ end
8
+ end
9
+
10
+ def self.included(base)
11
+ base.extend(ClassMethods)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ module Rongcloud
2
+ class Base
3
+
4
+ #code
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ module Rongcloud
2
+ class Token < Base
3
+ include Rongcloud::APIOperations::Show
4
+
5
+ def self.show_url
6
+ '/user/getToken.json'
7
+ end
8
+
9
+ end
10
+ #code
11
+ end
@@ -0,0 +1,17 @@
1
+ module Rongcloud
2
+ class User < Base
3
+ include Rongcloud::APIOperations::Update
4
+ include Rongcloud::APIOperations::Show
5
+
6
+ def self.update_url
7
+ '/user/refresh.json'
8
+ end
9
+
10
+ def self.show_url
11
+ '/user/checkOnline.json'
12
+ #code
13
+ end
14
+
15
+ end
16
+ #code
17
+ end
@@ -0,0 +1,3 @@
1
+ module Rongcloud
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rongcloud/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rongcloud-ruby"
8
+ spec.version = Rongcloud::VERSION
9
+ spec.authors = ["Hging"]
10
+ spec.email = ["hging3@gmail.com"]
11
+
12
+ spec.summary = %q{Rongcloud ruby client SDK}
13
+ spec.description = %q{Rongcloud ruby client SDK}
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.12"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ spec.add_dependency "unirest", "~> 1.1"
34
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rongcloud-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Hging
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-07-25 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.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: unirest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.1'
69
+ description: Rongcloud ruby client SDK
70
+ email:
71
+ - hging3@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - lib/rongcloud.rb
86
+ - lib/rongcloud/api_operations/create.rb
87
+ - lib/rongcloud/api_operations/delete.rb
88
+ - lib/rongcloud/api_operations/list.rb
89
+ - lib/rongcloud/api_operations/show.rb
90
+ - lib/rongcloud/api_operations/update.rb
91
+ - lib/rongcloud/base.rb
92
+ - lib/rongcloud/token.rb
93
+ - lib/rongcloud/user.rb
94
+ - lib/rongcloud/version.rb
95
+ - rongcloud-ruby.gemspec
96
+ homepage: ''
97
+ licenses:
98
+ - MIT
99
+ metadata:
100
+ allowed_push_host: https://rubygems.org
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.4.8
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Rongcloud ruby client SDK
121
+ test_files: []