smart_campus 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/smart_campus/api_v1/ap.rb +13 -0
- data/lib/smart_campus/api_v1/base.rb +22 -0
- data/lib/smart_campus/client.rb +5 -0
- data/lib/smart_campus/sign/sha1.rb +15 -0
- data/lib/smart_campus/sign.rb +18 -0
- data/lib/smart_campus/utils.rb +11 -0
- data/lib/smart_campus/version.rb +3 -0
- data/lib/smart_campus.rb +15 -0
- data/smart_campus.gemspec +33 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c422f7cd72994b2dd36807acde900d48153abed2
|
4
|
+
data.tar.gz: 4a2ea35cf0eead830247ac82ced9aa1bc750895d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5619c89823ba92902eaa9decd65e3c3686edf6527cae3b522790ea31d18250baa27dceaeb0e0b7dd3eda64ec5c98756c03888db5b33586520d288e7c7925d8af
|
7
|
+
data.tar.gz: 484dcd041950fe2fed3643198216464aa94f0a6b8f54b40f1c58ec52eff6bdf8b062e52461b0cdca6f71e7bca4817a24d336c296c08113133b3ca9c2c27ee509
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# SmartCampus
|
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/smart_campus`. 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 'smart_campus'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install smart_campus
|
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]/smart_campus.
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "smart_campus"
|
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,22 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
module SmartCampus
|
3
|
+
module ApiV1
|
4
|
+
class Base
|
5
|
+
include HTTParty
|
6
|
+
attr_accessor :token, :params
|
7
|
+
def initialize(params, options= {})
|
8
|
+
base_uri = options[:host] || SmartCampus.api_url
|
9
|
+
self.class.base_uri(base_uri)
|
10
|
+
app_key = options[:key] || SmartCampus.app_key
|
11
|
+
app_secret = options[:secret] || SmartCampus.app_secret
|
12
|
+
ts = options[:ts] || Time.now.to_i
|
13
|
+
token = SmartCampus::Sign.generate_str("#{app_key}#{ts}#{app_secret}")
|
14
|
+
@params = {
|
15
|
+
key: app_key,
|
16
|
+
ts: ts,
|
17
|
+
token: token
|
18
|
+
}.merge(params)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module SmartCampus
|
2
|
+
module Sign
|
3
|
+
|
4
|
+
def self.generate_str(token_opt='')
|
5
|
+
SHA1.sign(token_opt)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.generate(token_opt={})
|
9
|
+
params = Utils.stringify_keys(token_opt)
|
10
|
+
sort_str = params_to_string(params)
|
11
|
+
SHA1.sign(sort_str)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.params_to_string(params)
|
15
|
+
params.sort.map { |item| item.join('=') }.join('&')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/smart_campus.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'cgi'
|
3
|
+
require "smart_campus/version"
|
4
|
+
require "smart_campus/utils"
|
5
|
+
require 'smart_campus/api_v1/base'
|
6
|
+
require 'smart_campus/api_v1/ap'
|
7
|
+
require 'smart_campus/sign/sha1'
|
8
|
+
require 'smart_campus/sign'
|
9
|
+
require 'smart_campus/client'
|
10
|
+
|
11
|
+
module SmartCampus
|
12
|
+
class << self
|
13
|
+
attr_accessor :app_key, :app_secret, :api_url
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'smart_campus/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "smart_campus"
|
8
|
+
spec.version = SmartCampus::VERSION
|
9
|
+
spec.authors = ["jack"]
|
10
|
+
spec.email = ["qinshenyong@socialdatamax.com"]
|
11
|
+
|
12
|
+
spec.summary = "a gem to help api integration for Newdemo (http://newdemo.aggso.com/developer)"
|
13
|
+
spec.description = "his gem is an adaptation of John Nunemaker's Twitter gem. I modified it to make api integration for newdemo(t.sina.com.cn) easier."
|
14
|
+
spec.homepage = "http://newdemo.aggso.com"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
32
|
+
spec.add_development_dependency "httparty", "~> 0.14.0"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: smart_campus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jack
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-02 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: httparty
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.14.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.14.0
|
69
|
+
description: his gem is an adaptation of John Nunemaker's Twitter gem. I modified
|
70
|
+
it to make api integration for newdemo(t.sina.com.cn) easier.
|
71
|
+
email:
|
72
|
+
- qinshenyong@socialdatamax.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
|
+
- Gemfile
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- lib/smart_campus.rb
|
86
|
+
- lib/smart_campus/api_v1/ap.rb
|
87
|
+
- lib/smart_campus/api_v1/base.rb
|
88
|
+
- lib/smart_campus/client.rb
|
89
|
+
- lib/smart_campus/sign.rb
|
90
|
+
- lib/smart_campus/sign/sha1.rb
|
91
|
+
- lib/smart_campus/utils.rb
|
92
|
+
- lib/smart_campus/version.rb
|
93
|
+
- smart_campus.gemspec
|
94
|
+
homepage: http://newdemo.aggso.com
|
95
|
+
licenses: []
|
96
|
+
metadata:
|
97
|
+
allowed_push_host: https://rubygems.org
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.5.1
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: a gem to help api integration for Newdemo (http://newdemo.aggso.com/developer)
|
118
|
+
test_files: []
|