cloudstrg 0.0.3 → 0.0.4

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.
@@ -20,7 +20,7 @@ module CloudStrg
20
20
  # This method returns a list of the available storage drivers.
21
21
  #
22
22
  def self.driver_list
23
- l = Cloudstrglist.select('plugin_name')
23
+ l = Cloudstrgplugin.select('plugin_name')
24
24
  l.sort!
25
25
  return l
26
26
  end
@@ -118,5 +118,26 @@ module CloudStrg
118
118
  raise NotImplementedError
119
119
  end
120
120
 
121
+ def save_hash(username, filename, filecontent)
122
+ plugin_name = self.class.to_s.split('Strg')[0].downcase
123
+
124
+ if Cloudstrgfile.where(:username => username, :strgdriver => plugin_name, :filename => filename).size > 0
125
+ Cloudstrgfile.delete_all(:username => username, :strgdriver => plugin_name, :filename => filename)
126
+ end
127
+ Cloudstrgfile.create :username => username, :filename => filename, :filehash => filecontent.hash.to_s, :strgdriver => plugin_name
128
+ true
129
+ end
130
+
131
+ def check_hash(username, filename, filecontent)
132
+ plugin_name = self.class.to_s.split('Strg')[0].downcase
133
+
134
+ l = Cloudstrgfile.where(:username => username, :strgdriver => plugin_name, :filename => filename)
135
+ if l.size != 1
136
+ return l[0].filehash == filecontent.hash.to_s
137
+ else
138
+ false
139
+ end
140
+ end
141
+
121
142
  end
122
143
  end
@@ -20,7 +20,7 @@ module CloudStrg
20
20
  # This method returns a list of the available storage drivers.
21
21
  #
22
22
  def self.driver_list
23
- l = Cloudstrglist.find(:all).select('plugin_name')
23
+ l = Cloudstrgplugin.select('plugin_name')
24
24
  l.sort!
25
25
  return l
26
26
  end
@@ -118,5 +118,26 @@ module CloudStrg
118
118
  raise NotImplementedError
119
119
  end
120
120
 
121
+ def save_hash(username, filename, filecontent)
122
+ plugin_name = self.class.to_s.split('Strg')[0].downcase
123
+
124
+ if Cloudstrgfile.where(:username => username, :strgdriver => plugin_name, :filename => filename).size > 0
125
+ Cloudstrgfile.delete_all(:username => username, :strgdriver => plugin_name, :filename => filename)
126
+ end
127
+ Cloudstrgfile.create :username => username, :filename => filename, :filehash => filecontent.hash.to_s, :strgdriver => plugin_name
128
+ true
129
+ end
130
+
131
+ def check_hash(username, filename, filecontent)
132
+ plugin_name = self.class.to_s.split('Strg')[0].downcase
133
+
134
+ l = Cloudstrgfile.where(:username => username, :strgdriver => plugin_name, :filename => filename)
135
+ if l.size != 1
136
+ return l[0].filehash == filecontent.hash.to_s
137
+ else
138
+ false
139
+ end
140
+ end
141
+
121
142
  end
122
143
  end
@@ -1,3 +1,3 @@
1
1
  module Cloudstrg
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module Cloudstrg
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -10,10 +10,12 @@ class CloudstrgGenerator < Rails::Generators::Base
10
10
  end
11
11
 
12
12
  def create_model_file
13
- template "cloudstrglist.rb", "app/models/cloudstrglist.rb"
13
+ template "cloudstrgplugin.rb", "app/models/cloudstrgplugin.rb"
14
14
  template "cloudstrguser.rb", "app/models/cloudstrguser.rb"
15
- migration_template "create_cloudstrglists.rb", "db/migrate/create_cloudstrglists.rb"
15
+ template "cloudstrgfile.rb", "app/models/cloudstrgfile.rb"
16
+ migration_template "create_cloudstrgplugins.rb", "db/migrate/create_cloudstrgplugins.rb"
16
17
  migration_template "create_cloudstrgusers.rb", "db/migrate/create_cloudstrgusers.rb"
18
+ migration_template "create_cloudstrgfiles.rb", "db/migrate/create_cloudstrgfiles.rb"
17
19
  end
18
20
  end
19
21
 
@@ -13,7 +13,7 @@ class CloudstrgGenerator < Rails::Generators::Base
13
13
  template "cloudstrglist.rb", "app/models/cloudstrglist.rb"
14
14
  template "cloudstrguser.rb", "app/models/cloudstrguser.rb"
15
15
  migration_template "create_cloudstrglists.rb", "db/migrate/create_cloudstrglists.rb"
16
- migration_template "create_cloudstrgusers.rb", "db/migrate/create_cloudstrguser.rb"
16
+ migration_template "create_cloudstrgusers.rb", "db/migrate/create_cloudstrgusers.rb"
17
17
  end
18
18
  end
19
19
 
@@ -0,0 +1,3 @@
1
+ class Cloudstrgfile < ActiveRecord::Base
2
+ attr_accessible :username, :strgdriver, :filename, :filehash
3
+ end
@@ -0,0 +1,3 @@
1
+ class Cloudstrgfile < ActiveRecord::Base
2
+ attr_accessible :userid, :strgdriver, :filename, :filehash
3
+ end
@@ -1,3 +1,3 @@
1
- class CloudstrgList < ActiveRecord::Base
1
+ class Cloudstrglist < ActiveRecord::Base
2
2
  attr_accessible :plugin_name
3
3
  end
@@ -0,0 +1,3 @@
1
+ class Cloudstrgplugin < ActiveRecord::Base
2
+ attr_accessible :plugin_name
3
+ end
@@ -0,0 +1,16 @@
1
+ class CreateCloudstrgfiles < ActiveRecord::Migration
2
+ def up
3
+ create_table :cloudstrgfiles do |t|
4
+ t.string :username
5
+ t.string :strgdriver
6
+ t.string :filename
7
+ t.string :filehash
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+
13
+ def down
14
+ drop_table :cloudstrgfiles
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ class CreateCloudstrgfiles < ActiveRecord::Migration
2
+ def up
3
+ create_table :cloudstrgfiles do |t|
4
+ t.string :username
5
+ t.fixnum :strgdriver
6
+ t.string :filename
7
+ t.string :filehash
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+
13
+ def down
14
+ drop_table :cloudstrgfiles
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ class CreateCloudstrgplugins < ActiveRecord::Migration
2
+ def up
3
+ create_table :cloudstrgplugins do |t|
4
+ t.string :plugin_name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+
10
+ def down
11
+ drop_table :cloudstrgplugins
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ class Cloudstrgfile < ActiveRecord::Base
2
+ attr_accessible :username, :strgdriver, :filename, :filehash
3
+ end
@@ -0,0 +1,3 @@
1
+ class Cloudstrgplugin < ActiveRecord::Base
2
+ attr_accessible :plugin_name
3
+ end
@@ -0,0 +1,3 @@
1
+ class Cloudstrguser < ActiveRecord::Base
2
+ attr_accessible :userid
3
+ end
Binary file
@@ -0,0 +1,13 @@
1
+ class CreateCloudstrgplugins < ActiveRecord::Migration
2
+ def up
3
+ create_table :cloudstrgplugins do |t|
4
+ t.string :plugin_name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+
10
+ def down
11
+ drop_table :cloudstrgplugins
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class CreateCloudstrgusers < ActiveRecord::Migration
2
+ def up
3
+ create_table :cloudstrgusers do |t|
4
+ t.string :username
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+
10
+ def down
11
+ drop_table :cloudstrgusers
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ class CreateCloudstrgfiles < ActiveRecord::Migration
2
+ def up
3
+ create_table :cloudstrgfiles do |t|
4
+ t.string :username
5
+ t.string :strgdriver
6
+ t.string :filename
7
+ t.string :filehash
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+
13
+ def down
14
+ drop_table :cloudstrgfiles
15
+ end
16
+ end
@@ -11,7 +11,16 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20120928111625) do
14
+ ActiveRecord::Schema.define(:version => 20121010105501570549) do
15
+
16
+ create_table "cloudstrgfiles", :force => true do |t|
17
+ t.string "username"
18
+ t.string "strgdriver"
19
+ t.string "filename"
20
+ t.string "filehash"
21
+ t.datetime "created_at", :null => false
22
+ t.datetime "updated_at", :null => false
23
+ end
15
24
 
16
25
  create_table "cloudstrglist", :force => true do |t|
17
26
  t.string "plugin_name"
@@ -25,4 +34,16 @@ ActiveRecord::Schema.define(:version => 20120928111625) do
25
34
  t.datetime "updated_at", :null => false
26
35
  end
27
36
 
37
+ create_table "cloudstrgplugins", :force => true do |t|
38
+ t.string "plugin_name"
39
+ t.datetime "created_at", :null => false
40
+ t.datetime "updated_at", :null => false
41
+ end
42
+
43
+ create_table "cloudstrgusers", :force => true do |t|
44
+ t.string "username"
45
+ t.datetime "created_at", :null => false
46
+ t.datetime "updated_at", :null => false
47
+ end
48
+
28
49
  end
@@ -0,0 +1,41 @@
1
+ Connecting to database specified by database.yml
2
+ Connecting to database specified by database.yml
3
+  (0.2ms) select sqlite_version(*)
4
+  (168.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
5
+  (0.2ms) PRAGMA index_list("schema_migrations")
6
+  (110.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
7
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
8
+ Migrating to CreateCloudstrglist (20120928105006)
9
+  (0.1ms) begin transaction
10
+  (0.8ms) CREATE TABLE "cloudstrglist" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "plugin_name" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
11
+  (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ('20120928105006')
12
+  (132.5ms) commit transaction
13
+ Migrating to CreateCloudstrglists (20120928111625)
14
+  (0.1ms) begin transaction
15
+  (0.6ms) CREATE TABLE "cloudstrglists" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "plugin_name" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
16
+  (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ('20120928111625')
17
+  (101.7ms) commit transaction
18
+ Migrating to CreateCloudstrgplugins (20121010105501567910)
19
+  (0.2ms) begin transaction
20
+  (0.9ms) CREATE TABLE "cloudstrgplugins" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "plugin_name" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
21
+  (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ('20121010105501567910')
22
+  (214.0ms) commit transaction
23
+ Migrating to CreateCloudstrgusers (20121010105501569078)
24
+  (0.1ms) begin transaction
25
+  (0.9ms) CREATE TABLE "cloudstrgusers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
26
+  (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ('20121010105501569078')
27
+  (122.9ms) commit transaction
28
+ Migrating to CreateCloudstrgfiles (20121010105501570549)
29
+  (0.1ms) begin transaction
30
+  (0.7ms) CREATE TABLE "cloudstrgfiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar(255), "strgdriver" varchar(255), "filename" varchar(255), "filehash" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
31
+  (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ('20121010105501570549')
32
+  (87.2ms) commit transaction
33
+  (0.9ms) select sqlite_version(*)
34
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
35
+  (0.1ms) PRAGMA index_list("cloudstrgfiles")
36
+  (0.1ms) PRAGMA index_list("cloudstrglist")
37
+  (0.1ms) PRAGMA index_list("cloudstrglists")
38
+  (0.1ms) PRAGMA index_list("cloudstrgplugins")
39
+  (0.1ms) PRAGMA index_list("cloudstrgusers")
40
+ Connecting to database specified by database.yml
41
+ Connecting to database specified by database.yml
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudstrg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-05 00:00:00.000000000 Z
12
+ date: 2012-10-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -58,14 +58,19 @@ files:
58
58
  - lib/generators/cloudstrg_generator.rb
59
59
  - lib/generators/cloudstrg_generator.rb~
60
60
  - lib/templates/create_cloudstrgdata.rb~
61
+ - lib/templates/cloudstrgplugin.rb
62
+ - lib/templates/create_cloudstrgfiles.rb
61
63
  - lib/templates/cloudstrguser.rb~
64
+ - lib/templates/cloudstrgfile.rb
62
65
  - lib/templates/create_cloudstrgusers.rb~
66
+ - lib/templates/create_cloudstrgfiles.rb~
67
+ - lib/templates/create_cloudstrgplugins.rb
63
68
  - lib/templates/cloudstrguser.rb
64
69
  - lib/templates/cloudstrglist.rb~
70
+ - lib/templates/create_cloudstrgplugins.rb~
65
71
  - lib/templates/cloudstrgdata.rb~
66
- - lib/templates/cloudstrglist.rb
67
72
  - lib/templates/create_cloudstrglist.rb~
68
- - lib/templates/create_cloudstrglists.rb
73
+ - lib/templates/cloudstrgfile.rb~
69
74
  - lib/templates/create_cloudstrgusers.rb
70
75
  - lib/cloudstrg.rb
71
76
  - MIT-LICENSE
@@ -75,6 +80,9 @@ files:
75
80
  - test/dummy/script/rails
76
81
  - test/dummy/config.ru
77
82
  - test/dummy/app/helpers/application_helper.rb
83
+ - test/dummy/app/models/cloudstrgplugin.rb
84
+ - test/dummy/app/models/cloudstrgfile.rb
85
+ - test/dummy/app/models/cloudstrguser.rb
78
86
  - test/dummy/app/models/cloudstrglist.rb~
79
87
  - test/dummy/app/models/cloudstrglist.rb
80
88
  - test/dummy/app/assets/stylesheets/application.css
@@ -87,7 +95,11 @@ files:
87
95
  - test/dummy/public/favicon.ico
88
96
  - test/dummy/db/schema.rb
89
97
  - test/dummy/db/migrate/20120928111625_create_cloudstrglists.rb
98
+ - test/dummy/db/migrate/20121010105501569078_create_cloudstrgusers.rb
90
99
  - test/dummy/db/migrate/20120928105006_create_cloudstrglist.rb
100
+ - test/dummy/db/migrate/20121010105501570549_create_cloudstrgfiles.rb
101
+ - test/dummy/db/migrate/20121010105501567910_create_cloudstrgplugins.rb
102
+ - test/dummy/db/development.sqlite3
91
103
  - test/dummy/config/boot.rb
92
104
  - test/dummy/config/routes.rb
93
105
  - test/dummy/config/database.yml
@@ -104,6 +116,7 @@ files:
104
116
  - test/dummy/config/environments/production.rb
105
117
  - test/dummy/config/environments/test.rb
106
118
  - test/dummy/Rakefile
119
+ - test/dummy/log/development.log
107
120
  - test/dummy/README.rdoc
108
121
  - test/cloudstrg_test.rb
109
122
  homepage: http://git.libresoft.es/cloudstrg/
@@ -135,6 +148,9 @@ test_files:
135
148
  - test/dummy/script/rails
136
149
  - test/dummy/config.ru
137
150
  - test/dummy/app/helpers/application_helper.rb
151
+ - test/dummy/app/models/cloudstrgplugin.rb
152
+ - test/dummy/app/models/cloudstrgfile.rb
153
+ - test/dummy/app/models/cloudstrguser.rb
138
154
  - test/dummy/app/models/cloudstrglist.rb~
139
155
  - test/dummy/app/models/cloudstrglist.rb
140
156
  - test/dummy/app/assets/stylesheets/application.css
@@ -147,7 +163,11 @@ test_files:
147
163
  - test/dummy/public/favicon.ico
148
164
  - test/dummy/db/schema.rb
149
165
  - test/dummy/db/migrate/20120928111625_create_cloudstrglists.rb
166
+ - test/dummy/db/migrate/20121010105501569078_create_cloudstrgusers.rb
150
167
  - test/dummy/db/migrate/20120928105006_create_cloudstrglist.rb
168
+ - test/dummy/db/migrate/20121010105501570549_create_cloudstrgfiles.rb
169
+ - test/dummy/db/migrate/20121010105501567910_create_cloudstrgplugins.rb
170
+ - test/dummy/db/development.sqlite3
151
171
  - test/dummy/config/boot.rb
152
172
  - test/dummy/config/routes.rb
153
173
  - test/dummy/config/database.yml
@@ -164,5 +184,6 @@ test_files:
164
184
  - test/dummy/config/environments/production.rb
165
185
  - test/dummy/config/environments/test.rb
166
186
  - test/dummy/Rakefile
187
+ - test/dummy/log/development.log
167
188
  - test/dummy/README.rdoc
168
189
  - test/cloudstrg_test.rb
@@ -1,3 +0,0 @@
1
- class Cloudstrglist < ActiveRecord::Base
2
- attr_accessible :plugin_name
3
- end