riddl 0.119 → 0.121

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3dedc8b0cb28306e10d9bf69403c7a8e4c1e0101060070b5847b66d58e2b722
4
- data.tar.gz: 4ecde45979b650bd571d79fb05a539370c6019cf2db50761f9a251a5d96f83e2
3
+ metadata.gz: 6a46cd6db2eec8456fcd7aaba057402bbe89f85a34ba6c09920b18c8905238f0
4
+ data.tar.gz: e296f61e327887561525befa6a466eb6d9e77e4f76270c261515d0339ab27143
5
5
  SHA512:
6
- metadata.gz: 57c4af96b9857b1196f1abb9ccbee5e1b56fbfe58753554c47df13ba1e42594a8c58038fc92280365667a1b2ef12f460ac09eb9712a700036eab53c2d370d03c
7
- data.tar.gz: 3275e26d5d59fb90c2ad1088e8d3ec79508a31ce141a117bf6a38992ad8c2bc8d9754fa640d62db118857bc0dc00e6c5bba97c5d054940d5def71320d0fd9e02
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)
@@ -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
- res.resources.delete_if do |k,r|
72
- r.access_methods.length == 0
73
- end
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "riddl"
3
- s.version = "0.119"
3
+ s.version = "0.121"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0"
6
6
  s.summary = "restful interface description and declaration language: tools and client/server libs"
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.119'
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: 2022-11-10 00:00:00.000000000 Z
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.7
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