riddl 0.119 → 0.121
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/twitter/timeline.rb +76 -0
- data/lib/ruby/riddl/server.rb +4 -0
- data/lib/ruby/riddl/wrapper/declaration/tile.rb +4 -3
- data/riddl.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a46cd6db2eec8456fcd7aaba057402bbe89f85a34ba6c09920b18c8905238f0
|
4
|
+
data.tar.gz: e296f61e327887561525befa6a466eb6d9e77e4f76270c261515d0339ab27143
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15dc0331f01d342112bbce69cc1ddf59bddd1a77bab8b54f470a713011a711611e5dab87b461ca95b8094292c86bb4b2cb4b4930ec71f54db31005337a44ac47
|
7
|
+
data.tar.gz: c49cdd10df6667212c32862572cc206e8f66bb48f041363f20b1c7e8ba06b72154418eb06295a9cf8b512abff177cb449f3b0f78978e1a3cf19ded57279e136e
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require '../../lib/ruby/riddl/client'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
twitter = Riddl::Client.interface("https://api.twitter.com/","twitter.xml")
|
6
|
+
|
7
|
+
### Base
|
8
|
+
consumer_key = File.read(File.expand_path(File.dirname(__FILE__) + '/.twitter.consumer_key')).strip
|
9
|
+
consumer_secret = File.read(File.expand_path(File.dirname(__FILE__) + '/.twitter.consumer_secret')).strip
|
10
|
+
file_user_id = File.expand_path(File.dirname(__FILE__) + '/.twitter.user_id')
|
11
|
+
file_token = File.expand_path(File.dirname(__FILE__) + '/.twitter.token')
|
12
|
+
file_token_secret = File.expand_path(File.dirname(__FILE__) + '/.twitter.token_secret')
|
13
|
+
|
14
|
+
### When token and secret already saved, skip this part
|
15
|
+
if !File.exists?(file_token) && !File.exists?(file_token_secret)
|
16
|
+
### go to request token resource and set necessary role options
|
17
|
+
resource = twitter.resource("/oauth/request_token")
|
18
|
+
params = [
|
19
|
+
Riddl::Option.new(:consumer_key,consumer_key),
|
20
|
+
Riddl::Option.new(:consumer_secret,consumer_secret)
|
21
|
+
]
|
22
|
+
|
23
|
+
### simulate request token
|
24
|
+
# puts resource.simulate_post(params).read
|
25
|
+
|
26
|
+
### get request token and save it to variables
|
27
|
+
status, response, headers = resource.post params
|
28
|
+
token = response.oauth_token
|
29
|
+
token_secret = response.oauth_token_secret
|
30
|
+
|
31
|
+
### send user away for authorization
|
32
|
+
puts "Authorize at https://twitter.com/oauth/authorize?oauth_token=#{token}"
|
33
|
+
print "Insert verifier here: "
|
34
|
+
verifier = STDIN.gets.strip # wait for verifier
|
35
|
+
|
36
|
+
### exchange the token for an access token and save the results
|
37
|
+
resource = twitter.resource("/oauth/access_token")
|
38
|
+
status, response, headers = resource.post [
|
39
|
+
Riddl::Option.new(:consumer_key,consumer_key),
|
40
|
+
Riddl::Option.new(:consumer_secret,consumer_secret),
|
41
|
+
Riddl::Option.new(:token,token),
|
42
|
+
Riddl::Option.new(:verifier,verifier),
|
43
|
+
Riddl::Option.new(:token_secret,token_secret)
|
44
|
+
]
|
45
|
+
user_id = response.user_id
|
46
|
+
token = response.oauth_token
|
47
|
+
token_secret = response.oauth_token_secret
|
48
|
+
|
49
|
+
File.open(file_user_id,'w'){|f|f.write response.oauth_token}
|
50
|
+
File.open(file_token,'w'){|f|f.write response.oauth_token}
|
51
|
+
File.open(file_token_secret,'w'){|f|f.write response.oauth_token_secret}
|
52
|
+
else
|
53
|
+
user_id = File.read(file_user_id).strip
|
54
|
+
token = File.read(file_token).strip
|
55
|
+
token_secret = File.read(file_token_secret).strip
|
56
|
+
end
|
57
|
+
|
58
|
+
### Show single tweet
|
59
|
+
#tweet = 258251258941554688 # some stuff
|
60
|
+
#status, res = twitter.resource("/1.1/statuses/show.json").get [
|
61
|
+
# Riddl::Parameter::Simple.new("id",tweet),
|
62
|
+
# Riddl::Option.new(:consumer_key,consumer_key),
|
63
|
+
# Riddl::Option.new(:consumer_secret,consumer_secret),
|
64
|
+
# Riddl::Option.new(:token,token),
|
65
|
+
# Riddl::Option.new(:token_secret,token_secret)
|
66
|
+
#]
|
67
|
+
#puts status
|
68
|
+
|
69
|
+
### Show timeline
|
70
|
+
status, res = twitter.resource("/1.1/statuses/user_timeline.json").get [
|
71
|
+
Riddl::Option.new(:consumer_key,consumer_key),
|
72
|
+
Riddl::Option.new(:consumer_secret,consumer_secret),
|
73
|
+
Riddl::Option.new(:token,token),
|
74
|
+
Riddl::Option.new(:token_secret,token_secret)
|
75
|
+
]
|
76
|
+
tweets = JSON::parse(res[0].value.read)
|
data/lib/ruby/riddl/server.rb
CHANGED
@@ -109,6 +109,7 @@ module Riddl
|
|
109
109
|
:server => 'thin',
|
110
110
|
:signals => false
|
111
111
|
)
|
112
|
+
@riddl_opts[:startup].call if @riddl_opts[:startup]
|
112
113
|
if @riddl_opts[:custom_protocol] && !@riddl_opts[:http_only]
|
113
114
|
@riddl_opts[:custom_protocol] = @riddl_opts[:custom_protocol].new(@riddl_opts)
|
114
115
|
puts @riddl_opts[:custom_protocol].support if @riddl_opts[:custom_protocol].support
|
@@ -159,6 +160,9 @@ module Riddl
|
|
159
160
|
def parallel(&blk)
|
160
161
|
@riddl_opts[:parallel] = blk
|
161
162
|
end
|
163
|
+
def startup(&blk)
|
164
|
+
@riddl_opts[:startup] = blk
|
165
|
+
end
|
162
166
|
def cleanup(&blk)
|
163
167
|
@riddl_opts[:cleanup] = blk
|
164
168
|
end
|
@@ -68,9 +68,10 @@ module Riddl
|
|
68
68
|
def compose!(res=@base_path)
|
69
69
|
#{{{
|
70
70
|
# delete empty resources
|
71
|
-
|
72
|
-
|
73
|
-
|
71
|
+
# THIS is a stupid idea, just not show it in the resulting xml! TODO
|
72
|
+
# res.resources.delete_if do |k,r|
|
73
|
+
# r.access_methods.length == 0
|
74
|
+
# end
|
74
75
|
# compose
|
75
76
|
res.compose!
|
76
77
|
res.resources.each do |k,r|
|
data/riddl.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riddl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.121'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juergen 'eTM' Mangler
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: tools
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-01-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: daemonite
|
@@ -411,6 +411,7 @@ files:
|
|
411
411
|
- examples/twitter/README
|
412
412
|
- examples/twitter/client.rb
|
413
413
|
- examples/twitter/declaration.xml
|
414
|
+
- examples/twitter/timeline.rb
|
414
415
|
- examples/twitter/twitpic.xml
|
415
416
|
- examples/twitter/twitter.xml
|
416
417
|
- examples/websocket/client.rb
|
@@ -548,7 +549,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
548
549
|
- !ruby/object:Gem::Version
|
549
550
|
version: '0'
|
550
551
|
requirements: []
|
551
|
-
rubygems_version: 3.3.
|
552
|
+
rubygems_version: 3.3.26
|
552
553
|
signing_key:
|
553
554
|
specification_version: 4
|
554
555
|
summary: 'restful interface description and declaration language: tools and client/server
|