clone 1.0.0.beta → 1.0.0.beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -2
  3. data/VERSION +1 -1
  4. data/samples/grape/init/Gemfile +2 -2
  5. data/samples/grape/init/{docs → doc}/grape/documentation.txt +0 -0
  6. data/samples/grape/init/lib/grape.rb +12 -2
  7. data/samples/grape/init/lib/grape/mount/rest_api.rb +22 -0
  8. data/samples/grape/vendor/lib/grape/vendors/{v1/rest.rb → v1.rb} +4 -2
  9. data/samples/helper/init/Gemfile +5 -0
  10. data/samples/helper/init/lib/boot.rb +23 -0
  11. data/samples/mongoid/init/Gemfile +1 -3
  12. data/samples/mongoid/init/lib/mongoid.rb +9 -40
  13. data/samples/mongoid/init/lib/mongoid/meta/{mongoid.yml → config.yml} +0 -0
  14. data/samples/rack/init/Gemfile +1 -4
  15. data/samples/rack/init/lib/rack.rb +1 -1
  16. metadata +8 -44
  17. data/samples/blather/restlike/Gemfile +0 -4
  18. data/samples/blather/restlike/cmd.yml +0 -1
  19. data/samples/blather/restlike/lib/blather.rb +0 -9
  20. data/samples/blather/restlike/lib/blather/dsl/api.rb +0 -78
  21. data/samples/blather/restlike/lib/blather/dsl/call.rb +0 -13
  22. data/samples/blather/restlike/lib/blather/dsl/client.rb +0 -58
  23. data/samples/blather/restlike/lib/blather/dsl/config.rb +0 -11
  24. data/samples/blather/restlike/lib/blather/dsl/extraDSL.rb +0 -163
  25. data/samples/blather/restlike/lib/blather/meta/require.rb +0 -8
  26. data/samples/blather/restlike/lib/blather/meta/xmpp.yml +0 -5
  27. data/samples/blather/restlike/lib/blather/vendors/xmpp_default.rb +0 -27
  28. data/samples/blather/restlike/readme +0 -2
  29. data/samples/grape/init/docs/grape/generate_rest_routes.rb +0 -37
  30. data/samples/grape/init/docs/grape/ls_routes.rb +0 -31
  31. data/samples/grape/init/lib/grape/meta/subclasses.rb +0 -20
  32. data/samples/grape/init/lib/grape/xpath/app.rb +0 -30
  33. data/samples/grape/init/lib/grape/xpath/ruotes.rb +0 -6
  34. data/samples/mongoid/cmd.yml +0 -1
  35. data/samples/mongoid/init/docs/mongoid/ModelsRelations.rb +0 -11
  36. data/samples/mongoid/init/docs/mongoid/generate_modelsToDocs.rb +0 -25
  37. data/samples/mongoid/init/docs/mongoid/modelsToDocs.rb +0 -25
  38. data/samples/mongoid/init/lib/mongoid/dsl/extraDSL_CRUD.rb +0 -446
  39. data/samples/mongoid/init/lib/mongoid/dsl/extraDSL_MP.rb +0 -517
  40. data/samples/mongoid/init/lib/mongoid/dsl/init.rb +0 -37
  41. data/samples/mongoid/init/lib/mongoid/dsl/params.rb +0 -67
  42. data/samples/mongoid/init/lib/mongoid/meta/banned.rb +0 -147
  43. data/samples/mongoid/init/lib/mongoid/meta/control.yml +0 -13
  44. data/samples/mongoid/init/lib/mongoid/meta/mpatch.rb +0 -14
  45. data/samples/rack/init/lib/rack/meta/webserver/thin.rb +0 -45
  46. data/samples/rack/init/lib/rack/meta/webserver/thin.yml +0 -6
  47. data/samples/rack/init/server.rb +0 -0
  48. data/samples/rest_client/init/Gemfile +0 -5
  49. data/samples/rest_client/init/boot.rb +0 -2
  50. data/samples/rest_client/init/cmd.yml +0 -1
  51. data/samples/rest_client/init/config/rest_client/defaults.rb +0 -16
  52. data/samples/rest_client/init/docs/rest_client/simple overlook +0 -251
  53. data/samples/rest_client/init/test/rest_client/rest_dsl.rb +0 -5
  54. data/samples/rest_client/readme +0 -7
@@ -1,37 +0,0 @@
1
- def filling(hash)
2
- if hash.class == Array
3
- hash=Hash[*hash]
4
- end
5
-
6
- ### hash data converting
7
- hash.each do |key,value|
8
-
9
- case value.to_s.downcase
10
-
11
- when "string"
12
- hash[key]=RND.string(18,2)
13
-
14
- when "date"
15
- hash[key]=RND.date
16
-
17
- when "datetime"
18
- hash[key]=RND.datetime
19
-
20
- when "time"
21
- hash[key]=RND.time
22
-
23
- when "integer","float"
24
- hash[key]=RND.integer(11)
25
-
26
- when "boolean"
27
- hash[key]=RND.boolean
28
-
29
- when "moped::bson::objectid","object"
30
- hash.delete key
31
-
32
- end
33
-
34
- end
35
-
36
- return hash
37
- end
@@ -1,67 +0,0 @@
1
- class Hash
2
- def find_hashize
3
- return_hash = self
4
- return_hash.delete 'route_info'
5
- return_hash.delete 'method'
6
- return_hash.delete 'path'
7
-
8
- #%w[ id ].each do |one_key|
9
- # if !return_hash[one_key].nil?
10
- # return_hash['_id']= return_hash[one_key]
11
- # return_hash.delete one_key
12
- # end
13
- #end
14
-
15
- return_hash.each do |key,value|
16
- if value.class == String
17
- return_hash[key]=value.duck
18
- end
19
- end
20
-
21
- return_hash.each do |key,value|
22
- if key.to_s == '_id'
23
- return_hash[key]= Moped::BSON::ObjectId.from_string(value.to_s)
24
- end
25
- end
26
-
27
-
28
- return return_hash
29
- end
30
- def new_hashize
31
- return_hash = self
32
- %w[route_info method path _id id parentid parent_id].each do |one_element|
33
- return_hash.delete one_element
34
- end
35
- return_hash.each do |key,value|
36
- if value.class == String
37
- return_hash[key]=value.duck
38
- end
39
- end
40
- return return_hash
41
- end
42
- def extraction_next_item(oth_str,offsets=2)
43
- extracted_string= String.new
44
- position_nmbr= 0
45
- loop do
46
- begin
47
- new_indx= (self.inspect.positions(oth_str).last+offsets)+position_nmbr
48
- new_element= self.inspect[new_indx]
49
- if new_element == ' ' || new_element == ','
50
- break
51
- else
52
- extracted_string+= new_element
53
- position_nmbr+= 1
54
- end
55
- rescue Exception
56
- break
57
- end
58
- end
59
-
60
- if extracted_string.include?('(.:format)>')
61
- index_nbr= extracted_string.length-1
62
- extracted_string= extracted_string[0..(index_nbr-('(.:format)>'.length))]
63
- end
64
-
65
- return extracted_string
66
- end
67
- end
@@ -1,147 +0,0 @@
1
- module Mongoid
2
- module Banned
3
- class Elements
4
- ### Elements output Format: [*String]
5
- @@elements_list ||= Array.new
6
- class << self
7
- def add(input)
8
- case input.class.to_s.downcase
9
- when "class"
10
- @@elements_list.push input.to_s
11
- when "string"
12
- @@elements_list.push input
13
- when "array"
14
- input.each do |one_element|
15
- @@elements_list.push one_element.to_s
16
- end
17
- else
18
- @@elements_list.push input.to_s
19
- end
20
- end
21
- def list
22
- return @@elements_list
23
- end
24
- end
25
- end
26
- class ModelElements
27
- ### modelElements output Format: [*Class => String]
28
- @@element_list ||= Array.new
29
- class << self
30
- def add(hash)
31
-
32
- if hash.class == Array
33
- hash= Hash[*hash]
34
- end
35
-
36
- tmp_array= Array.new
37
- tmp_hash= Hash.new
38
- hash.each do |key,value|
39
- if key.class != Class
40
- tmp_hash[key.to_s]= value
41
- else
42
- tmp_hash[key]= value
43
- end
44
- end
45
- tmp_hash.each do |key,value|
46
-
47
- case value.class.to_s.downcase
48
-
49
- when "string"
50
- tmp_array.push( { key => value })
51
-
52
- when "array"
53
- value.each do |one_element|
54
- tmp_array.push( {key => value.to_s})
55
- end
56
-
57
- else
58
- tmp_array.push( {key => value.to_s})
59
-
60
- end
61
-
62
- end
63
-
64
- tmp_array.each do |one_element|
65
- @@element_list.push one_element
66
- end
67
- end
68
- def list
69
- return @@element_list
70
- end
71
- end
72
- end
73
- class Models
74
- ### Models output Format: [*Class]
75
- @@model_list ||= Array.new
76
- class << self
77
- def add(input)
78
- case input.class.to_s.downcase
79
- when "class"
80
- @@model_list.push input
81
- when "string"
82
- @@model_list.push input.to_s
83
- when "array"
84
- input.each do |one_element|
85
- @@model_list.push one_element.to_s
86
- end
87
- else
88
- @@model_list.push input.to_s
89
- end
90
- end
91
- def list
92
- return @@model_list
93
- end
94
- end
95
- end
96
- class ProtocolElements
97
- ### Elements output Format: [*String]
98
- @@elements_list ||= Array.new
99
- class << self
100
- def add(input)
101
- case input.class.to_s.downcase
102
- when "class"
103
- @@elements_list.push input.to_s
104
- when "string"
105
- @@elements_list.push input
106
- when "array"
107
- input.each do |one_element|
108
- @@elements_list.push one_element.to_s
109
- end
110
- else
111
- @@elements_list.push input.to_s
112
- end
113
- end
114
- def list
115
- return @@elements_list
116
- end
117
- end
118
- end
119
- class << self
120
- def list
121
- tmp_hash= Hash.new
122
- tmp_hash[:Elements]= self::Elements.list
123
- tmp_hash[:ModelElements]= self::ModelElements.list
124
- tmp_hash[:Models]= self::Models.list
125
- tmp_hash[:ProtocolElements]= self::ProtocolElements.list
126
-
127
- return tmp_hash
128
- end
129
- end
130
- end
131
- end
132
-
133
- begin
134
- CONFIG.data['mongoid']['control']['banned'].each do |key,value|
135
- case key.to_s.downcase
136
- when "modelelements","model_elements","modelelement","model_element"
137
- Mongoid::Banned::ModelElements.add value
138
- when "elements","element"
139
- Mongoid::Banned::Elements.add value
140
- when "protocol","protocolelements"
141
- Mongoid::Banned::ProtocolElements.add value
142
- when "models","model"
143
- Mongoid::Banned::Models.add value
144
- end
145
- end
146
- rescue Exception
147
- end
@@ -1,13 +0,0 @@
1
- banned:
2
- Elements:
3
- - test
4
-
5
- Models:
6
- - OUR::Test
7
-
8
- ModelElements:
9
- - OUR::Test: test
10
- Protocol:
11
- - route_info
12
- - method
13
- - path
@@ -1,14 +0,0 @@
1
- module Mongoid
2
- module Document
3
-
4
- def self.included(base)
5
- @classes ||= Array.new
6
- @classes.push base.name
7
- end
8
-
9
- def self.classes
10
- @classes
11
- end
12
-
13
- end
14
- end
@@ -1,45 +0,0 @@
1
- require "yaml"
2
- THIN_CONFIG= YAML.load_file(File.expand_path(File.join(File.dirname(__FILE__),'thin.yml')))
3
-
4
- module Thin
5
- class Server
6
- def initialize(*args, &block)
7
- host, port, options = DEFAULT_HOST, DEFAULT_PORT, {}
8
-
9
- # Guess each parameter by its type so they can be
10
- # received in any order.
11
- args.each do |arg|
12
- case arg
13
- when Fixnum, /^\d+$/ then port = arg.to_i
14
- when String then host = arg
15
- when Hash then options = arg
16
- else
17
- @app = arg if arg.respond_to?(:call)
18
- end
19
- end
20
-
21
- # Set tag if needed
22
- self.tag = options[:tag]
23
-
24
- # Try to intelligently select which backend to use.
25
- @backend = select_backend(host, port, options)
26
-
27
- load_cgi_multipart_eof_fix
28
-
29
- @backend.server = self
30
-
31
- # Set defaults
32
- @backend.maximum_connections = THIN_CONFIG['DEFAULT_MAXIMUM_CONNECTIONS'].to_i
33
- @backend.maximum_persistent_connections = THIN_CONFIG['DEFAULT_MAXIMUM_PERSISTENT_CONNECTIONS'].to_i
34
- @backend.timeout = THIN_CONFIG['DEFAULT_TIMEOUT'].to_i
35
-
36
- # Allow using Rack builder as a block
37
- @app = Rack::Builder.new(&block).to_app if block
38
-
39
- # If in debug mode, wrap in logger adapter
40
- @app = Rack::CommonLogger.new(@app) if Logging.debug?
41
-
42
- setup_signals unless options[:signals].class == FalseClass
43
- end
44
- end
45
- end
@@ -1,6 +0,0 @@
1
- DEFAULT_MAXIMUM_CONNECTIONS: 1001
2
- DEFAULT_MAXIMUM_PERSISTENT_CONNECTIONS: 1001
3
- DEFAULT_TIMEOUT: 30
4
- tcp:
5
- min: 10000
6
- max: 10099
File without changes
@@ -1,5 +0,0 @@
1
-
2
- #A simple HTTP and REST client for Ruby,
3
- #inspired by the Sinatra microframework
4
- #style of specifying actions: get, put, post, delete
5
- gem "rest-client"
@@ -1,2 +0,0 @@
1
- # Load rest-client parts
2
- require_relative_directory File.join "config","rest_client"
@@ -1 +0,0 @@
1
- helper: init
@@ -1,16 +0,0 @@
1
- module REST
2
- class Client
3
-
4
- class << self
5
- attr_accessor :target,
6
- :port
7
- end
8
-
9
- def after_initialize
10
- return unless new_record?
11
- self.target = "0.0.0.0"
12
- self.port = "8080"
13
- end
14
-
15
- end
16
- end
@@ -1,251 +0,0 @@
1
- REST Client – simple DSL for accessing HTTP and REST resources
2
- Build status:
3
-
4
- A simple HTTP and REST client for Ruby, inspired by the Sinatra’s microframework style of specifying actions: get, put, post, delete.
5
-
6
- Main page: github.com/rest-client/rest-client
7
-
8
- Mailing list: rest.client@librelist.com (send a mail to subscribe).
9
-
10
- Usage: Raw URL
11
-
12
- require 'rest_client'
13
-
14
- RestClient.get 'http://example.com/resource'
15
-
16
- RestClient.get 'http://example.com/resource', {:params => {:id => 50, 'foo' => 'bar'}}
17
-
18
- RestClient.get 'https://user:password@example.com/private/resource', {:accept => :json}
19
-
20
- RestClient.post 'http://example.com/resource', :param1 => 'one', :nested => { :param2 => 'two' }
21
-
22
- RestClient.post "http://example.com/resource", { 'x' => 1 }.to_json, :content_type => :json, :accept => :json
23
-
24
- RestClient.delete 'http://example.com/resource'
25
-
26
- response = RestClient.get 'http://example.com/resource'
27
- response.code
28
- ➔ 200
29
- response.cookies
30
- ➔ {"Foo"=>"BAR", "QUUX"=>"QUUUUX"}
31
- response.headers
32
- ➔ {:content_type=>"text/html; charset=utf-8", :cache_control=>"private" ...
33
- response.to_str
34
- ➔ \n<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n \"http://www.w3.org/TR/html4/strict.dtd\">\n\n<html ....
35
-
36
- RestClient.post( url,
37
- {
38
- :transfer => {
39
- :path => '/foo/bar',
40
- :owner => 'that_guy',
41
- :group => 'those_guys'
42
- },
43
- :upload => {
44
- :file => File.new(path, 'rb')
45
- }
46
- })
47
- Multipart
48
-
49
- Yeah, that’s right! This does multipart sends for you!
50
-
51
- RestClient.post '/data', :myfile => File.new("/path/to/image.jpg", 'rb')
52
- This does two things for you:
53
-
54
- Auto-detects that you have a File value sends it as multipart
55
-
56
- Auto-detects the mime of the file and sets it in the HEAD of the payload for each entry
57
-
58
- If you are sending params that do not contain a File object but the payload needs to be multipart then:
59
-
60
- RestClient.post '/data', {:foo => 'bar', :multipart => true}
61
- Usage: ActiveResource-Style
62
-
63
- resource = RestClient::Resource.new 'http://example.com/resource'
64
- resource.get
65
-
66
- private_resource = RestClient::Resource.new 'https://example.com/private/resource', 'user', 'pass'
67
- private_resource.put File.read('pic.jpg'), :content_type => 'image/jpg'
68
- See RestClient::Resource module docs for details.
69
-
70
- Usage: Resource Nesting
71
-
72
- site = RestClient::Resource.new('http://example.com')
73
- site['posts/1/comments'].post 'Good article.', :content_type => 'text/plain'
74
- See RestClient::Resource docs for details.
75
-
76
- Exceptions (see www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)
77
-
78
- for results code between 200 and 207 a RestClient::Response will be returned
79
-
80
- for results code 301, 302 or 307 the redirection will be followed if the request is a get or a head
81
-
82
- for result code 303 the redirection will be followed and the request transformed into a get
83
-
84
- for other cases a RestClient::Exception holding the Response will be raised, a specific exception class will be thrown for know error codes
85
-
86
- RestClient.get 'http://example.com/resource'
87
- ➔ RestClient::ResourceNotFound: RestClient::ResourceNotFound
88
-
89
- begin
90
- RestClient.get 'http://example.com/resource'
91
- rescue => e
92
- e.response
93
- end
94
- ➔ 404 Resource Not Found | text/html 282 bytes
95
- Result handling
96
-
97
- A block can be passed to the RestClient method, this block will then be called with the Response. Response.return! can be called to invoke the default response’s behavior.
98
-
99
- # Don't raise exceptions but return the response
100
- RestClient.get('http://example.com/resource'){|response, request, result| response }
101
- ➔ 404 Resource Not Found | text/html 282 bytes
102
-
103
- # Manage a specific error code
104
- RestClient.get('http://my-rest-service.com/resource'){ |response, request, result, &block|
105
- case response.code
106
- when 200
107
- p "It worked !"
108
- response
109
- when 423
110
- raise SomeCustomExceptionIfYouWant
111
- else
112
- response.return!(request, result, &block)
113
- end
114
- }
115
-
116
- # Follow redirections for all request types and not only for get and head
117
- # RFC : "If the 301, 302 or 307 status code is received in response to a request other than GET or HEAD,
118
- # the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user,
119
- # since this might change the conditions under which the request was issued."
120
- RestClient.get('http://my-rest-service.com/resource'){ |response, request, result, &block|
121
- if [301, 302, 307].include? response.code
122
- response.follow_redirection(request, result, &block)
123
- else
124
- response.return!(request, result, &block)
125
- end
126
- }
127
- Non-normalized URIs.
128
-
129
- If you want to use non-normalized URIs, you can normalize them with the addressable gem (addressable.rubyforge.org/api/).
130
-
131
- require 'addressable/uri'
132
- RestClient.get(Addressable::URI.parse("http://www.詹姆斯.com/").normalize.to_str)
133
- Lower-level access
134
-
135
- For cases not covered by the general API, you can use the RestClient::Request class which provide a lower-level API.
136
-
137
- You can:
138
-
139
- specify ssl parameters
140
-
141
- override cookies
142
-
143
- manually handle the response (so you can operate on the response stream than reading it fully in memory)
144
-
145
- see the class’ rdoc for more information.
146
-
147
- Shell
148
-
149
- The restclient shell command gives an IRB session with RestClient already loaded:
150
-
151
- $ restclient
152
- >> RestClient.get 'http://example.com'
153
- Specify a URL argument for get/post/put/delete on that resource:
154
-
155
- $ restclient http://example.com
156
- >> put '/resource', 'data'
157
- Add a user and password for authenticated resources:
158
-
159
- $ restclient https://example.com user pass
160
- >> delete '/private/resource'
161
- Create ~/.restclient for named sessions:
162
-
163
- sinatra:
164
- url: http://localhost:4567
165
- rack:
166
- url: http://localhost:9292
167
- private_site:
168
- url: http://example.com
169
- username: user
170
- password: pass
171
- Then invoke:
172
-
173
- $ restclient private_site
174
- Use as a one-off, curl-style:
175
-
176
- $ restclient get http://example.com/resource > output_body
177
-
178
- $ restclient put http://example.com/resource < input_body
179
- Logging
180
-
181
- To enable logging you can
182
-
183
- set RestClient.log with a ruby Logger
184
-
185
- or set an environment variable to avoid modifying the code (in this case you can use a file name, “stdout” or “stderr”):
186
-
187
- $ RESTCLIENT_LOG=stdout path/to/my/program
188
- Either produces logs like this:
189
-
190
- RestClient.get "http://some/resource"
191
- # => 200 OK | text/html 250 bytes
192
- RestClient.put "http://some/resource", "payload"
193
- # => 401 Unauthorized | application/xml 340 bytes
194
- Note that these logs are valid Ruby, so you can paste them into the restclient shell or a script to replay your sequence of rest calls.
195
-
196
- Proxy
197
-
198
- All calls to RestClient, including Resources, will use the proxy specified by RestClient.proxy:
199
-
200
- RestClient.proxy = "http://proxy.example.com/"
201
- RestClient.get "http://some/resource"
202
- # => response from some/resource as proxied through proxy.example.com
203
- Often the proxy url is set in an environment variable, so you can do this to use whatever proxy the system is configured to use:
204
-
205
- RestClient.proxy = ENV['http_proxy']
206
- Query parameters
207
-
208
- Request objects know about query parameters and will automatically add them to the url for GET, HEAD and DELETE requests and escape the keys and values as needed:
209
-
210
- RestClient.get 'http://example.com/resource', :params => {:foo => 'bar', :baz => 'qux'}
211
- # will GET http://example.com/resource?foo=bar&baz=qux
212
- Cookies
213
-
214
- Request and Response objects know about HTTP cookies, and will automatically extract and set headers for them as needed:
215
-
216
- response = RestClient.get 'http://example.com/action_which_sets_session_id'
217
- response.cookies
218
- # => {"_applicatioN_session_id" => "1234"}
219
-
220
- response2 = RestClient.post(
221
- 'http://localhost:3000/',
222
- {:param1 => "foo"},
223
- {:cookies => {:session_id => "1234"}}
224
- )
225
- # ...response body
226
- SSL Client Certificates
227
-
228
- RestClient::Resource.new(
229
- 'https://example.com',
230
- :ssl_client_cert => OpenSSL::X509::Certificate.new(File.read("cert.pem")),
231
- :ssl_client_key => OpenSSL::PKey::RSA.new(File.read("key.pem"), "passphrase, if any"),
232
- :ssl_ca_file => "ca_certificate.pem",
233
- :verify_ssl => OpenSSL::SSL::VERIFY_PEER
234
- ).get
235
- Self-signed certificates can be generated with the openssl command-line tool.
236
-
237
- Hook
238
-
239
- RestClient.add_before_execution_proc add a Proc to be called before each execution, it’s handy if you need a direct access to the http request.
240
-
241
- Example:
242
-
243
- # Add oath support using the oauth gem
244
- require 'oauth'
245
- access_token = ...
246
-
247
- RestClient.add_before_execution_proc do |req, params|
248
- access_token.sign! req
249
- end
250
-
251
- RestClient.get 'http://example.com'