clone 1.0.0.alpha → 1.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile +1 -0
- data/LICENSE.txt +22 -0
- data/README.md +22 -1
- data/VERSION +1 -1
- data/bin/clone +7 -0
- data/clone.gemspec +4 -0
- data/docs/readme +16 -0
- data/docs/readme.txt +5 -0
- data/lib/clone.rb +13 -2
- data/lib/clone/config/config.rb +19 -0
- data/lib/clone/config/config.yml +22 -0
- data/lib/clone/config/default_config.yml +20 -0
- data/lib/clone/config/require.rb +3 -0
- data/lib/clone/config/version.rb +10 -0
- data/lib/clone/config/yml.rb +22 -0
- data/lib/clone/config/z_defaults.rb +28 -0
- data/lib/clone/generator/engine.rb +581 -0
- data/lib/clone/generator/terminal.rb +104 -0
- data/lib/clone/helpers/helper_methods.rb +251 -0
- data/lib/clone/helpers/local_methods.rb +150 -0
- data/lib/clone/helpers/require.rb +37 -0
- data/module/Marshal.4.8 +0 -0
- data/module/Marshal.4.8.Z +0 -0
- data/module/gems/commander-4.1.3/.gitignore +6 -0
- data/module/gems/commander-4.1.3/.travis.yml +11 -0
- data/module/gems/commander-4.1.3/DEVELOPMENT +15 -0
- data/module/gems/commander-4.1.3/Gemfile +3 -0
- data/module/gems/commander-4.1.3/History.rdoc +345 -0
- data/module/gems/commander-4.1.3/Manifest +38 -0
- data/module/gems/commander-4.1.3/README.rdoc +375 -0
- data/module/gems/commander-4.1.3/Rakefile +10 -0
- data/module/gems/commander-4.1.3/bin/commander +55 -0
- data/module/gems/commander-4.1.3/commander.gemspec +26 -0
- data/module/gems/commander-4.1.3/lib/commander.rb +32 -0
- data/module/gems/commander-4.1.3/lib/commander/blank.rb +8 -0
- data/module/gems/commander-4.1.3/lib/commander/command.rb +213 -0
- data/module/gems/commander-4.1.3/lib/commander/core_ext.rb +3 -0
- data/module/gems/commander-4.1.3/lib/commander/core_ext/array.rb +26 -0
- data/module/gems/commander-4.1.3/lib/commander/core_ext/object.rb +11 -0
- data/module/gems/commander-4.1.3/lib/commander/delegates.rb +13 -0
- data/module/gems/commander-4.1.3/lib/commander/help_formatters.rb +8 -0
- data/module/gems/commander-4.1.3/lib/commander/help_formatters/base.rb +18 -0
- data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal.rb +20 -0
- data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal/command_help.erb +35 -0
- data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal/help.erb +36 -0
- data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal_compact.rb +12 -0
- data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal_compact/command_help.erb +27 -0
- data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal_compact/help.erb +29 -0
- data/module/gems/commander-4.1.3/lib/commander/import.rb +10 -0
- data/module/gems/commander-4.1.3/lib/commander/platform.rb +8 -0
- data/module/gems/commander-4.1.3/lib/commander/runner.rb +411 -0
- data/module/gems/commander-4.1.3/lib/commander/user_interaction.rb +521 -0
- data/module/gems/commander-4.1.3/lib/commander/version.rb +3 -0
- data/module/gems/commander-4.1.3/spec/command_spec.rb +157 -0
- data/module/gems/commander-4.1.3/spec/core_ext/array_spec.rb +20 -0
- data/module/gems/commander-4.1.3/spec/core_ext/object_spec.rb +21 -0
- data/module/gems/commander-4.1.3/spec/help_formatters/terminal_spec.rb +67 -0
- data/module/gems/commander-4.1.3/spec/runner_spec.rb +526 -0
- data/module/gems/commander-4.1.3/spec/spec_helper.rb +59 -0
- data/module/gems/commander-4.1.3/spec/ui_spec.rb +30 -0
- data/module/gems/hello.rb +1 -0
- data/module/gems/highline-1.6.19/.gitignore +2 -0
- data/module/gems/highline-1.6.19/AUTHORS +3 -0
- data/module/gems/highline-1.6.19/CHANGELOG +346 -0
- data/module/gems/highline-1.6.19/COPYING +340 -0
- data/module/gems/highline-1.6.19/INSTALL +55 -0
- data/module/gems/highline-1.6.19/LICENSE +7 -0
- data/module/gems/highline-1.6.19/README.rdoc +63 -0
- data/module/gems/highline-1.6.19/Rakefile +50 -0
- data/module/gems/highline-1.6.19/TODO +6 -0
- data/module/gems/highline-1.6.19/examples/ansi_colors.rb +38 -0
- data/module/gems/highline-1.6.19/examples/asking_for_arrays.rb +18 -0
- data/module/gems/highline-1.6.19/examples/basic_usage.rb +75 -0
- data/module/gems/highline-1.6.19/examples/color_scheme.rb +32 -0
- data/module/gems/highline-1.6.19/examples/get_character.rb +12 -0
- data/module/gems/highline-1.6.19/examples/limit.rb +12 -0
- data/module/gems/highline-1.6.19/examples/menus.rb +65 -0
- data/module/gems/highline-1.6.19/examples/overwrite.rb +19 -0
- data/module/gems/highline-1.6.19/examples/page_and_wrap.rb +322 -0
- data/module/gems/highline-1.6.19/examples/password.rb +7 -0
- data/module/gems/highline-1.6.19/examples/repeat_entry.rb +21 -0
- data/module/gems/highline-1.6.19/examples/trapping_eof.rb +22 -0
- data/module/gems/highline-1.6.19/examples/using_readline.rb +17 -0
- data/module/gems/highline-1.6.19/highline.gemspec +37 -0
- data/module/gems/highline-1.6.19/lib/highline.rb +1012 -0
- data/module/gems/highline-1.6.19/lib/highline/color_scheme.rb +134 -0
- data/module/gems/highline-1.6.19/lib/highline/compatibility.rb +16 -0
- data/module/gems/highline-1.6.19/lib/highline/import.rb +41 -0
- data/module/gems/highline-1.6.19/lib/highline/menu.rb +398 -0
- data/module/gems/highline-1.6.19/lib/highline/question.rb +475 -0
- data/module/gems/highline-1.6.19/lib/highline/simulate.rb +48 -0
- data/module/gems/highline-1.6.19/lib/highline/string_extensions.rb +131 -0
- data/module/gems/highline-1.6.19/lib/highline/style.rb +181 -0
- data/module/gems/highline-1.6.19/lib/highline/system_extensions.rb +222 -0
- data/module/gems/highline-1.6.19/setup.rb +1360 -0
- data/module/gems/highline-1.6.19/site/.cvsignore +1 -0
- data/module/gems/highline-1.6.19/site/highline.css +65 -0
- data/module/gems/highline-1.6.19/site/images/logo.png +0 -0
- data/module/gems/highline-1.6.19/site/index.html +58 -0
- data/module/gems/highline-1.6.19/test/string_methods.rb +32 -0
- data/module/gems/highline-1.6.19/test/tc_color_scheme.rb +96 -0
- data/module/gems/highline-1.6.19/test/tc_highline.rb +1128 -0
- data/module/gems/highline-1.6.19/test/tc_import.rb +52 -0
- data/module/gems/highline-1.6.19/test/tc_menu.rb +439 -0
- data/module/gems/highline-1.6.19/test/tc_string_extension.rb +20 -0
- data/module/gems/highline-1.6.19/test/tc_string_highline.rb +38 -0
- data/module/gems/highline-1.6.19/test/tc_style.rb +567 -0
- data/module/gems/highline-1.6.19/test/ts_all.rb +16 -0
- data/module/latest_specs.4.8 +0 -0
- data/module/latest_specs.4.8.gz +0 -0
- data/module/prerelease_specs.4.8 +0 -0
- data/module/prerelease_specs.4.8.gz +0 -0
- data/module/specs.4.8 +0 -0
- data/module/specs.4.8.gz +0 -0
- data/samples/blather/restlike/Gemfile +4 -0
- data/samples/blather/restlike/cmd.yml +1 -0
- data/samples/blather/restlike/lib/blather.rb +9 -0
- data/samples/blather/restlike/lib/blather/dsl/api.rb +78 -0
- data/samples/blather/restlike/lib/blather/dsl/call.rb +13 -0
- data/samples/blather/restlike/lib/blather/dsl/client.rb +58 -0
- data/samples/blather/restlike/lib/blather/dsl/config.rb +11 -0
- data/samples/blather/restlike/lib/blather/dsl/extraDSL.rb +163 -0
- data/samples/blather/restlike/lib/blather/meta/require.rb +8 -0
- data/samples/blather/restlike/lib/blather/meta/xmpp.yml +5 -0
- data/samples/blather/restlike/lib/blather/vendors/xmpp_default.rb +27 -0
- data/samples/blather/restlike/readme +2 -0
- data/samples/grape/init/Gemfile +2 -0
- data/samples/grape/init/cmd.yml +3 -0
- data/samples/grape/init/config.ru +2 -0
- data/samples/grape/init/docs/grape/documentation.txt +939 -0
- data/samples/grape/init/docs/grape/generate_rest_routes.rb +37 -0
- data/samples/grape/init/docs/grape/ls_routes.rb +31 -0
- data/samples/grape/init/lib/grape.rb +4 -0
- data/samples/grape/init/lib/grape/meta/subclasses.rb +20 -0
- data/samples/grape/init/lib/grape/xpath/app.rb +30 -0
- data/samples/grape/init/lib/grape/xpath/ruotes.rb +6 -0
- data/samples/grape/init/readme +1 -0
- data/samples/grape/readme +29 -0
- data/samples/grape/vendor/lib/grape/vendors/v1/rest.rb +57 -0
- data/samples/mongoid/cmd.yml +1 -0
- data/samples/mongoid/init/Gemfile +3 -0
- data/samples/mongoid/init/cmd.yml +2 -0
- data/samples/mongoid/init/docs/mongoid/ModelsRelations.rb +11 -0
- data/samples/mongoid/init/docs/mongoid/documents.xls +0 -0
- data/samples/mongoid/init/docs/mongoid/generate_modelsToDocs.rb +25 -0
- data/samples/mongoid/init/docs/mongoid/modelsToDocs.rb +25 -0
- data/samples/mongoid/init/docs/mongoid/relations.txt +1354 -0
- data/samples/mongoid/init/lib/mongoid.rb +44 -0
- data/samples/mongoid/init/lib/mongoid/dsl/extraDSL_CRUD.rb +446 -0
- data/samples/mongoid/init/lib/mongoid/dsl/extraDSL_MP.rb +517 -0
- data/samples/mongoid/init/lib/mongoid/dsl/init.rb +37 -0
- data/samples/mongoid/init/lib/mongoid/dsl/params.rb +67 -0
- data/samples/mongoid/init/lib/mongoid/meta/banned.rb +147 -0
- data/samples/mongoid/init/lib/mongoid/meta/control.yml +13 -0
- data/samples/mongoid/init/lib/mongoid/meta/mongoid.yml +6 -0
- data/samples/mongoid/init/lib/mongoid/meta/mpatch.rb +14 -0
- data/samples/mongoid/model/lib/mongoid/models/model.rb +28 -0
- data/samples/mongoid/readme +33 -0
- data/samples/rack/init/Gemfile +10 -0
- data/samples/rack/init/cmd.yml +2 -0
- data/samples/rack/init/config.ru +1 -0
- data/samples/rack/init/docs/rack/rake introducing.txt +60 -0
- data/samples/rack/init/docs/rack/webservers/Thin +43 -0
- data/samples/rack/init/docs/rack/webservers/ebb +72 -0
- data/samples/rack/init/docs/rack/webservers/fcgi +103 -0
- data/samples/rack/init/docs/rack/webservers/mongrel +74 -0
- data/samples/rack/init/docs/rack/webservers/passenger +37 -0
- data/samples/rack/init/docs/rack/webservers/scgi +188 -0
- data/samples/rack/init/lib/rack.rb +1 -0
- data/samples/rack/init/lib/rack/meta/webserver/thin.rb +45 -0
- data/samples/rack/init/lib/rack/meta/webserver/thin.yml +6 -0
- data/samples/rack/init/server.rb +0 -0
- data/samples/rack/readme +13 -0
- data/samples/rest_client/init/Gemfile +5 -0
- data/samples/rest_client/init/boot.rb +2 -0
- data/samples/rest_client/init/cmd.yml +1 -0
- data/samples/rest_client/init/config/rest_client/defaults.rb +16 -0
- data/samples/rest_client/init/docs/rest_client/simple overlook +251 -0
- data/samples/rest_client/init/test/rest_client/rest_dsl.rb +5 -0
- data/samples/rest_client/readme +7 -0
- data/samples/scripts/lines_counter/lines_number.rb +32 -0
- data/samples/scripts/lines_counter/readme +5 -0
- data/samples/scripts/readme +1 -0
- metadata +197 -7
- data/lib/clone/cms.rb +0 -56
- data/lib/clone/ext.rb +0 -77
- data/sample/test.rb +0 -30
@@ -0,0 +1,37 @@
|
|
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
|
@@ -0,0 +1,67 @@
|
|
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
|
@@ -0,0 +1,147 @@
|
|
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
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module MODULE
|
2
|
+
class CLASS
|
3
|
+
include Mongoid::Document #; include Mongoid::Timestamps #; include Mongoid::Paranoia
|
4
|
+
|
5
|
+
store_in :collection => (self.to_s.split('::').last) #, :session => "default"
|
6
|
+
|
7
|
+
#embeds_many :target_class_name
|
8
|
+
#embeds_one :target_class_name
|
9
|
+
|
10
|
+
#field :name,
|
11
|
+
# :type => String,
|
12
|
+
# :default => "Hello World!"
|
13
|
+
|
14
|
+
#validates :name,
|
15
|
+
# :presence => true
|
16
|
+
|
17
|
+
|
18
|
+
### you can validate here the fields
|
19
|
+
#self.fields.keys.each do |key|
|
20
|
+
# validates key.to_sym,
|
21
|
+
# presence: true
|
22
|
+
#end
|
23
|
+
|
24
|
+
### you can set here that only fields can be saved to db
|
25
|
+
#attr_accessible *fields.keys
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
MongoDB Controller
|
2
|
+
Adatbazis modellezo es segito eszkoz
|
3
|
+
|
4
|
+
Mongoid is an ODM (Object Document Mapper)
|
5
|
+
Framework for MongoDB, written in Ruby.
|
6
|
+
|
7
|
+
Mongoid (pronounced mann-goyd) is an Object-Document-Mapper
|
8
|
+
(ODM) for MongoDB written in Ruby. It was conceived in August,
|
9
|
+
2009 during a whiskey-induced evening at the infamous Oasis
|
10
|
+
in Florida, USA by Durran Jordan.
|
11
|
+
|
12
|
+
The philosophy of Mongoid is to provide a familiar API to
|
13
|
+
Ruby developers who have been using Active Record or Data Mapper,
|
14
|
+
while leveraging the power of MongoDB's schemaless and performant
|
15
|
+
document-based design, dynamic queries, and atomic modifier operations.
|
16
|
+
|
17
|
+
Sample Syntax:
|
18
|
+
|
19
|
+
class Artist
|
20
|
+
include Mongoid::Document
|
21
|
+
field :name, type: String
|
22
|
+
embeds_many :instruments
|
23
|
+
end
|
24
|
+
|
25
|
+
class Instrument
|
26
|
+
include Mongoid::Document
|
27
|
+
field :name, type: String
|
28
|
+
embedded_in :artist
|
29
|
+
end
|
30
|
+
|
31
|
+
syd = Artist.where(name: "Syd Vicious").between(age: 18..25).first
|
32
|
+
syd.instruments.create(name: "Bass")
|
33
|
+
syd.with(database: "bands", session: "backup").save!
|
@@ -0,0 +1 @@
|
|
1
|
+
require './server.rb'
|
@@ -0,0 +1,60 @@
|
|
1
|
+
Introducing Rack
|
2
|
+
|
3
|
+
|
4
|
+
Dabbling in my own web framework experiments, I noticed that there is a lot of code duplication among frameworks since they essentially all do the same things. And still, every Ruby web framework developer is writing his own handlers for every webserver he wants to use. Hopefully, the framework users are satisfied with that choice.
|
5
|
+
|
6
|
+
However, in essence, dealing with HTTP is rather easy. In the end, you get a request and return a response. Let’s do the easiest thing possible: The canonical format of a HTTP request probably is a hash of a CGI-like environment (that’s what most frameworks I’ve looked at deal with, internally), and a response consists of three parts: a status, a set of headers, and a body.
|
7
|
+
|
8
|
+
This could be easily mapped onto a method call in Ruby, looking like this:
|
9
|
+
class HelloWorld
|
10
|
+
def call(env)
|
11
|
+
[200, {"Content-Type" => "text/plain"}, ["Hello world!"]]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
You’ve just seen the most simple Rack application.
|
17
|
+
|
18
|
+
Rack aims to provide a minimal API for connecting web servers and web frameworks.
|
19
|
+
|
20
|
+
Informally, a Rack application is a thing that responds to #call and takes a hash as argument, returning an array of status, headers and a body. The body needs to respond to #each and then successively return strings that represent the response body. The hash given contains a CGI-ish set of environment variables and some special values, like the body stream of the request (env['rack.input']), or information about the run-time environment (e.g. env['rack.run_once']).
|
21
|
+
|
22
|
+
Please note that this API is mainly used by framework developers and usually will not be exposed to framework users. It may seem a bit clumsy at first, or you may have expected a more “polished” API, but the important thing is that the API is very simple (notice that it even can be satisfied by a lambda) and not hard to adopt. (The Camping adapter is a mere five lines of code.)
|
23
|
+
|
24
|
+
On top of this minimal API, there are libraries for commonly used things like query parsing or cookie handling and provide more convenience (Rack::Request and Rack::Response) that you are free to use if you wish.
|
25
|
+
|
26
|
+
But the really cool thing about Rack is that it provides an extremely easy way to combine these web applications. After all, they are only Ruby objects with a single method that matters. And the thing that calls you must not really be a web server, but could as well be a different application! Let me show you a few Rack filters (or “middleware”) that already exist:
|
27
|
+
•
|
28
|
+
Rack::ShowExceptions catches all thrown exceptions and wraps them nicely in an helpful 500-page adapted from Django.
|
29
|
+
|
30
|
+
•
|
31
|
+
Rack::CommonLogger does Apache-style logs.
|
32
|
+
|
33
|
+
•
|
34
|
+
Rack::URLMap redirects to different Rack applications depending on the path and host (a very simple router).
|
35
|
+
|
36
|
+
|
37
|
+
There is another tool, Rack::Lint that checks if your applications and filters play nicely with others so everything ought to work together.
|
38
|
+
|
39
|
+
What do you gain if your web framework/server/application supports Rack?
|
40
|
+
•
|
41
|
+
Handlers for WEBrick, Mongrel and plain CGI (soon FastCGI, too), and every new webserver that provides a Rack handler. (Let n and m be the amount of servers and frameworks, without Rack it’s n*m, but with it’s n+m, which means less work for everyone.)
|
42
|
+
|
43
|
+
•
|
44
|
+
The possibility to run several applications inside a single webserver without external configuration.
|
45
|
+
|
46
|
+
•
|
47
|
+
Easier (integration and functional) testing, since everything can easily be mocked. (Helpers for this are coming soon, too.)
|
48
|
+
|
49
|
+
•
|
50
|
+
A greater diversity among frameworks, since writers now can concentrate on the parts that make it special and stop wasting their time on boring things.
|
51
|
+
|
52
|
+
•
|
53
|
+
More synergistic effects: Compare “That upload handler you wrote for IOWA is really great, too bad I use Camping.” with “That upload handler you wrote for Rack works great for me too!”
|
54
|
+
|
55
|
+
|
56
|
+
Currently, Rack is supported by Camping (adapter included with Rack) and Ramaze, more adapters are in the works (a Rails one would be a really cool contribution, hint, hint).
|
57
|
+
|
58
|
+
(If you are into Python, you’ll notice a lot of similarities between Rack and WSGI and Paste. That’s fully intended, as I think WSGI helped the Python web landscape really a lot.)
|
59
|
+
|
60
|
+
A Rubyforge project has been requested, and a first release will happen really soon. If you’d like to help, contact me by mail or via IRC (chris2@#ruby-lang on FreeNode).
|
@@ -0,0 +1,43 @@
|
|
1
|
+
Thin
|
2
|
+
Tiny, fast & funny HTTP server
|
3
|
+
|
4
|
+
Thin is a Ruby web server that glues together 3 of the best Ruby libraries in web history:
|
5
|
+
|
6
|
+
The Mongrel parser: the root of Mongrel speed and security
|
7
|
+
Event Machine: a network I/O library with extremely high scalability, performance and stability
|
8
|
+
Rack: a minimal interface between webservers and Ruby frameworks
|
9
|
+
Which makes it, with all humility, the most secure, stable, fast and extensible Ruby web server bundled in an easy to use gem for your own pleasure.
|
10
|
+
|
11
|
+
Site: http://code.macournoyer.com/thin/
|
12
|
+
Group: http://groups.google.com/group/thin-ruby/topics
|
13
|
+
Bugs: http://github.com/macournoyer/thin/issues
|
14
|
+
Code: http://github.com/macournoyer/thin
|
15
|
+
IRC: #thin on freenode
|
16
|
+
Installation
|
17
|
+
For the latest stable version:
|
18
|
+
|
19
|
+
gem install thin
|
20
|
+
|
21
|
+
Or from source:
|
22
|
+
|
23
|
+
git clone git://github.com/macournoyer/thin.git
|
24
|
+
cd thin
|
25
|
+
rake install
|
26
|
+
Usage
|
27
|
+
A +thin+ script offers an easy way to start your Rack application:
|
28
|
+
|
29
|
+
cd to/your/app
|
30
|
+
thin start
|
31
|
+
When using with Rails and Bundler, make sure to add gem 'thin' to your Gemfile.
|
32
|
+
|
33
|
+
See example directory for samples and run 'thin -h' for usage.
|
34
|
+
|
35
|
+
License
|
36
|
+
Ruby License, http://www.ruby-lang.org/en/LICENSE.txt.
|
37
|
+
|
38
|
+
Credits
|
39
|
+
The parser was stolen from Mongrel http://mongrel.rubyforge.org by Zed Shaw. Mongrel is copyright 2007 Zed A. Shaw and contributors. It is licensed under the Ruby license and the GPL2.
|
40
|
+
|
41
|
+
Thin is copyright Marc-Andre Cournoyer macournoyer@gmail.com
|
42
|
+
|
43
|
+
Get help at http://groups.google.com/group/thin-ruby/ Report bugs at https://github.com/macournoyer/thin/issues and major security issues directly to me macournoyer@gmail.com.
|