riddl 0.120 → 0.122
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/protocols/http/generator.rb +8 -8
- data/lib/ruby/riddl/server.rb +4 -0
- 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: 75fec6d0144b07c49d0dd3f8eaf5a1479cf1c58203004be9b683382b80f2d6eb
|
4
|
+
data.tar.gz: 5968e301387da3c302025e46e24b925637c4d5b781bd157d8f32a2ef60e28c84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c0a833780ed1a15f41449a2c2f32f2e382461557df450711b41b173b56358d3199ba5ac7dd71c80f375d4571acec7824727469b1d45af97bdc5cd1192fe2e76
|
7
|
+
data.tar.gz: 106ea5c867914b5404e7a5f336c7775c0000cc7dd31376d2c2a3efb7f257b43fb48d24e713d646ed81a35b309b275f4e4dac46301456f1c6e0c7bf1055e305b2
|
@@ -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)
|
@@ -85,25 +85,25 @@ module Riddl
|
|
85
85
|
@params.each do |r|
|
86
86
|
case r
|
87
87
|
when Riddl::Parameter::Simple
|
88
|
-
tmp.write
|
89
|
-
tmp.write
|
88
|
+
tmp.write '--' + BOUNDARY + EOL
|
89
|
+
tmp.write 'RIDDL-TYPE: simple' + EOL
|
90
90
|
tmp.write "Content-Disposition: #{mode == :input ? 'form-data' : 'riddl-data'}; name=\"#{r.name}\"" + EOL
|
91
91
|
tmp.write EOL
|
92
92
|
tmp.write r.value
|
93
93
|
tmp.write EOL
|
94
94
|
when Riddl::Parameter::Complex
|
95
|
-
tmp.write
|
96
|
-
tmp.write
|
95
|
+
tmp.write '--' + BOUNDARY + EOL
|
96
|
+
tmp.write 'RIDDL-TYPE: complex' + EOL
|
97
97
|
tmp.write "Content-Disposition: #{mode == :input ? 'form-data' : 'riddl-data'}; name=\"#{r.name}\""
|
98
|
-
tmp.write r.filename.nil? ?
|
99
|
-
tmp.write
|
100
|
-
tmp.write
|
98
|
+
tmp.write r.filename.nil? ? '; filename=""' : "; filename=\"#{r.filename}\"" + EOL
|
99
|
+
tmp.write 'Content-Transfer-Encoding: binary' + EOL
|
100
|
+
tmp.write 'Content-Type: ' + r.mimetype + r.mimextra + EOL
|
101
101
|
tmp.write EOL
|
102
102
|
tmp.write(r.value.respond_to?(:read) ? r.value.read : r.value)
|
103
103
|
tmp.write EOL
|
104
104
|
end
|
105
105
|
end
|
106
|
-
tmp.write
|
106
|
+
tmp.write '--' + BOUNDARY + '--' + EOL
|
107
107
|
end
|
108
108
|
end
|
109
109
|
tmp.flush
|
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
|
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.122'
|
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-31 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
|