cloudstrg 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +38 -0
- data/lib/cloudstrg/cloudstrg.rb +122 -0
- data/lib/cloudstrg/cloudstrg.rb~ +122 -0
- data/lib/cloudstrg/version.rb +3 -0
- data/lib/cloudstrg.rb +2 -0
- data/lib/generators/cloudstrg_generator.rb +19 -0
- data/lib/generators/cloudstrg_generator.rb~ +19 -0
- data/lib/tasks/cloudstrg_tasks.rake +4 -0
- data/lib/templates/cloudstrgdata.rb~ +3 -0
- data/lib/templates/cloudstrglist.rb +3 -0
- data/lib/templates/cloudstrglist.rb~ +3 -0
- data/lib/templates/cloudstrguser.rb +3 -0
- data/lib/templates/cloudstrguser.rb~ +0 -0
- data/lib/templates/create_cloudstrgdata.rb~ +0 -0
- data/lib/templates/create_cloudstrglist.rb~ +13 -0
- data/lib/templates/create_cloudstrglists.rb +13 -0
- data/lib/templates/create_cloudstrgusers.rb +13 -0
- data/lib/templates/create_cloudstrgusers.rb~ +0 -0
- data/test/cloudstrg_test.rb +7 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/cloudstrglist.rb +3 -0
- data/test/dummy/app/models/cloudstrglist.rb~ +3 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/migrate/20120928105006_create_cloudstrglist.rb +13 -0
- data/test/dummy/db/migrate/20120928111625_create_cloudstrglists.rb +13 -0
- data/test/dummy/db/schema.rb +28 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/test_helper.rb +15 -0
- metadata +167 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'Cloudstrg'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
|
30
|
+
Rake::TestTask.new(:test) do |t|
|
31
|
+
t.libs << 'lib'
|
32
|
+
t.libs << 'test'
|
33
|
+
t.pattern = 'test/**/*_test.rb'
|
34
|
+
t.verbose = false
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
task :default => :test
|
@@ -0,0 +1,122 @@
|
|
1
|
+
module CloudStrg
|
2
|
+
|
3
|
+
##
|
4
|
+
# This method returns an instance of an specified driver
|
5
|
+
#
|
6
|
+
# Params: the "params" variable must contain the following fields
|
7
|
+
# type: the name of the selected driver.
|
8
|
+
#
|
9
|
+
# Returns:
|
10
|
+
# An instance of the specified driver.
|
11
|
+
#
|
12
|
+
def self.new_driver params
|
13
|
+
type = params[:type]
|
14
|
+
require "#{type}strg/#{type}strg"
|
15
|
+
return Kernel.const_get("#{type.capitalize}Strg").new(params)
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
##
|
20
|
+
# This method returns a list of the available storage drivers.
|
21
|
+
#
|
22
|
+
def self.driver_list
|
23
|
+
l = Cloudstrglist.find(:all)
|
24
|
+
l.sort!
|
25
|
+
return l
|
26
|
+
end
|
27
|
+
|
28
|
+
###
|
29
|
+
# This class must be inherited by every single driver definition in order to preserve
|
30
|
+
# the coherence between them.
|
31
|
+
#
|
32
|
+
class CloudStorage
|
33
|
+
|
34
|
+
###
|
35
|
+
# This method performs the previous configuration that the current driver needs to work.
|
36
|
+
#
|
37
|
+
# Params: the "params" variable must contain the following fields
|
38
|
+
# redirect: the name of the selected driver,
|
39
|
+
# username: the name of the selected driver,
|
40
|
+
# session: the name of the selected driver.
|
41
|
+
#
|
42
|
+
# Returns:
|
43
|
+
# This method returns two parameters:
|
44
|
+
# session: the session variable with the new parameters added,
|
45
|
+
# uri: the uri where the user will allow the application to use the desired service,
|
46
|
+
# or false if the configuration was completed successfully.
|
47
|
+
#
|
48
|
+
def config params
|
49
|
+
raise NotImplementedError
|
50
|
+
end
|
51
|
+
|
52
|
+
###
|
53
|
+
# This method performs the creation of a file.
|
54
|
+
#
|
55
|
+
# Params: the "params" variable must contain the following fields
|
56
|
+
# filename: the name of the file to create,
|
57
|
+
# file_content: the content of the file.
|
58
|
+
#
|
59
|
+
# Returns:
|
60
|
+
# This method returns true if the operation success, otherwise it returns false.
|
61
|
+
#
|
62
|
+
def create_file params
|
63
|
+
raise NotImplementedError
|
64
|
+
end
|
65
|
+
|
66
|
+
#def create_folder params
|
67
|
+
# raise NotImplementedError
|
68
|
+
#end
|
69
|
+
|
70
|
+
###
|
71
|
+
# This method performs the request to obtain a desired file content
|
72
|
+
#
|
73
|
+
# Params: the "params" variable must contain the following fields
|
74
|
+
# fileid: the id of the selected file.
|
75
|
+
#
|
76
|
+
# Returns:
|
77
|
+
# This method returns three parameters:
|
78
|
+
# filename: the name of the file,
|
79
|
+
# fileid: the id of the file,
|
80
|
+
# file_content: the content of the file.
|
81
|
+
#
|
82
|
+
def get_file params
|
83
|
+
raise NotImplementedError
|
84
|
+
end
|
85
|
+
|
86
|
+
###
|
87
|
+
# This method performs the update of a file.
|
88
|
+
#
|
89
|
+
# Params: the "params" variable must contain the following fields
|
90
|
+
# filename: the name of the file to edit,
|
91
|
+
# fileid: the id of the file,
|
92
|
+
# file_content: the content of the file.
|
93
|
+
#
|
94
|
+
# Returns:
|
95
|
+
# This method returns true if the operation success, otherwise it returns false.
|
96
|
+
#
|
97
|
+
def update_file params
|
98
|
+
raise NotImplementedError
|
99
|
+
end
|
100
|
+
|
101
|
+
###
|
102
|
+
# This method performs the remove of a file.
|
103
|
+
#
|
104
|
+
# Params: the "params" variable must contain the following fields
|
105
|
+
# fileid: the id of the file.
|
106
|
+
#
|
107
|
+
def remove_file params
|
108
|
+
raise NotImplementedError
|
109
|
+
end
|
110
|
+
|
111
|
+
###
|
112
|
+
# This method returns a list of the available files created by the application.
|
113
|
+
#
|
114
|
+
# Returns:
|
115
|
+
# This method returns a list of tuples, containing: [[filename, fileid], ...]
|
116
|
+
#
|
117
|
+
def list_files
|
118
|
+
raise NotImplementedError
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
module CloudStrg
|
2
|
+
|
3
|
+
##
|
4
|
+
# This method returns an instance of an specified driver
|
5
|
+
#
|
6
|
+
# Params: the "params" variable must contain the following fields
|
7
|
+
# type: the name of the selected driver.
|
8
|
+
#
|
9
|
+
# Returns:
|
10
|
+
# An instance of the specified driver.
|
11
|
+
#
|
12
|
+
def self.new_driver params
|
13
|
+
type = params[:type]
|
14
|
+
require "#{type}strg"
|
15
|
+
return Kernel.const_get("#{type.capitalize}Strg").new(params)
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
##
|
20
|
+
# This method returns a list of the available storage drivers.
|
21
|
+
#
|
22
|
+
def self.driver_list
|
23
|
+
l = Cloudstrglist.find(:all)
|
24
|
+
l.sort!
|
25
|
+
return l
|
26
|
+
end
|
27
|
+
|
28
|
+
###
|
29
|
+
# This class must be inherited by every single driver definition in order to preserve
|
30
|
+
# the coherence between them.
|
31
|
+
#
|
32
|
+
class CloudStorage
|
33
|
+
|
34
|
+
###
|
35
|
+
# This method performs the previous configuration that the current driver needs to work.
|
36
|
+
#
|
37
|
+
# Params: the "params" variable must contain the following fields
|
38
|
+
# redirect: the name of the selected driver,
|
39
|
+
# username: the name of the selected driver,
|
40
|
+
# session: the name of the selected driver.
|
41
|
+
#
|
42
|
+
# Returns:
|
43
|
+
# This method returns two parameters:
|
44
|
+
# session: the session variable with the new parameters added,
|
45
|
+
# uri: the uri where the user will allow the application to use the desired service,
|
46
|
+
# or false if the configuration was completed successfully.
|
47
|
+
#
|
48
|
+
def config params
|
49
|
+
raise NotImplementedError
|
50
|
+
end
|
51
|
+
|
52
|
+
###
|
53
|
+
# This method performs the creation of a file.
|
54
|
+
#
|
55
|
+
# Params: the "params" variable must contain the following fields
|
56
|
+
# filename: the name of the file to create,
|
57
|
+
# file_content: the content of the file.
|
58
|
+
#
|
59
|
+
# Returns:
|
60
|
+
# This method returns true if the operation success, otherwise it returns false.
|
61
|
+
#
|
62
|
+
def create_file params
|
63
|
+
raise NotImplementedError
|
64
|
+
end
|
65
|
+
|
66
|
+
#def create_folder params
|
67
|
+
# raise NotImplementedError
|
68
|
+
#end
|
69
|
+
|
70
|
+
###
|
71
|
+
# This method performs the request to obtain a desired file content
|
72
|
+
#
|
73
|
+
# Params: the "params" variable must contain the following fields
|
74
|
+
# fileid: the id of the selected file.
|
75
|
+
#
|
76
|
+
# Returns:
|
77
|
+
# This method returns three parameters:
|
78
|
+
# filename: the name of the file,
|
79
|
+
# fileid: the id of the file,
|
80
|
+
# file_content: the content of the file.
|
81
|
+
#
|
82
|
+
def get_file params
|
83
|
+
raise NotImplementedError
|
84
|
+
end
|
85
|
+
|
86
|
+
###
|
87
|
+
# This method performs the update of a file.
|
88
|
+
#
|
89
|
+
# Params: the "params" variable must contain the following fields
|
90
|
+
# filename: the name of the file to edit,
|
91
|
+
# fileid: the id of the file,
|
92
|
+
# file_content: the content of the file.
|
93
|
+
#
|
94
|
+
# Returns:
|
95
|
+
# This method returns true if the operation success, otherwise it returns false.
|
96
|
+
#
|
97
|
+
def update_file params
|
98
|
+
raise NotImplementedError
|
99
|
+
end
|
100
|
+
|
101
|
+
###
|
102
|
+
# This method performs the remove of a file.
|
103
|
+
#
|
104
|
+
# Params: the "params" variable must contain the following fields
|
105
|
+
# fileid: the id of the file.
|
106
|
+
#
|
107
|
+
def remove_file params
|
108
|
+
raise NotImplementedError
|
109
|
+
end
|
110
|
+
|
111
|
+
###
|
112
|
+
# This method returns a list of the available files created by the application.
|
113
|
+
#
|
114
|
+
# Returns:
|
115
|
+
# This method returns a list of tuples, containing: [[filename, fileid], ...]
|
116
|
+
#
|
117
|
+
def list_files
|
118
|
+
raise NotImplementedError
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
data/lib/cloudstrg.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
class CloudstrgGenerator < Rails::Generators::Base
|
5
|
+
include Rails::Generators::Migration
|
6
|
+
source_root File.expand_path('../../templates', __FILE__)
|
7
|
+
|
8
|
+
def self.next_migration_number(path)
|
9
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S%6N")
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_model_file
|
13
|
+
template "cloudstrglist.rb", "app/models/cloudstrglist.rb"
|
14
|
+
template "cloudstrguser.rb", "app/models/cloudstrguser.rb"
|
15
|
+
migration_template "create_cloudstrglists.rb", "db/migrate/create_cloudstrglists.rb"
|
16
|
+
migration_template "create_cloudstrgusers.rb", "db/migrate/create_cloudstrgusers.rb"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
class CloudstrgGenerator < Rails::Generators::Base
|
5
|
+
include Rails::Generators::Migration
|
6
|
+
source_root File.expand_path('../../templates', __FILE__)
|
7
|
+
|
8
|
+
def self.next_migration_number(path)
|
9
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S%6N")
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_model_file
|
13
|
+
template "cloudstrglist.rb", "app/models/cloudstrglist.rb"
|
14
|
+
template "cloudstrguser.rb", "app/models/cloudstrguser.rb"
|
15
|
+
migration_template "create_cloudstrglists.rb", "db/migrate/create_cloudstrglists.rb"
|
16
|
+
migration_template "create_cloudstrgusers.rb", "db/migrate/create_cloudstrguser.rb"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
File without changes
|
File without changes
|
File without changes
|