yasha 0.0.1 → 0.0.2
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.
- data/lib/yasha.rb +20 -56
- metadata +4 -4
data/lib/yasha.rb
CHANGED
@@ -7,7 +7,7 @@ class Yasha
|
|
7
7
|
|
8
8
|
attr_accessor :database, :table, :database_id, :table_id, :counter_key, :host, :port, :redis_connection, :table_struct
|
9
9
|
|
10
|
-
def
|
10
|
+
def self.initialize_yasha
|
11
11
|
@database = nil
|
12
12
|
@database_id = nil
|
13
13
|
@table = nil
|
@@ -17,7 +17,6 @@ class Yasha
|
|
17
17
|
@redis_connection = nil
|
18
18
|
@table_struct = nil
|
19
19
|
@counter_key = nil
|
20
|
-
self.initial_check
|
21
20
|
end
|
22
21
|
|
23
22
|
###CHECKS###
|
@@ -27,16 +26,17 @@ class Yasha
|
|
27
26
|
end
|
28
27
|
|
29
28
|
def self.initial_check
|
29
|
+
self.initialize_yasha
|
30
30
|
@redis_connection = Redis.new(:host => @host,:port => @port)
|
31
31
|
self.initialize_redis if @redis_connection.get("YashA:DataBases").nil?
|
32
32
|
end
|
33
33
|
|
34
|
-
def self.
|
34
|
+
def self.database? name
|
35
35
|
self.initial_check
|
36
36
|
JSON.parse(@redis_connection.get("YashA:DataBases")).include? name
|
37
37
|
end
|
38
38
|
|
39
|
-
def self.
|
39
|
+
def self.table? table, database
|
40
40
|
JSON.parse(@redis_connection.get("YashA:#{database}")).include? table
|
41
41
|
end
|
42
42
|
|
@@ -66,15 +66,15 @@ class Yasha
|
|
66
66
|
|
67
67
|
###SETTING###
|
68
68
|
|
69
|
-
def self.
|
69
|
+
def self.host host
|
70
70
|
@host = host
|
71
71
|
end
|
72
72
|
|
73
|
-
def self.
|
73
|
+
def self.port port
|
74
74
|
@port = port
|
75
75
|
end
|
76
76
|
|
77
|
-
def self.
|
77
|
+
def self.database name
|
78
78
|
self.initial_check
|
79
79
|
@database = name
|
80
80
|
|
@@ -82,11 +82,9 @@ class Yasha
|
|
82
82
|
@database_id = yasha_databases.index(name)
|
83
83
|
end
|
84
84
|
|
85
|
-
def self.
|
85
|
+
def self.table name
|
86
86
|
@table = name
|
87
87
|
|
88
|
-
p "YashA:#{@database}"
|
89
|
-
|
90
88
|
tables = JSON.parse(@redis_connection.get("YashA:#{@database}"))
|
91
89
|
@table_id = tables.index(name)
|
92
90
|
|
@@ -300,51 +298,17 @@ class Yasha
|
|
300
298
|
|
301
299
|
end
|
302
300
|
|
301
|
+
class Generals < Yasha
|
302
|
+
if self.is_database 'history' #Checks if database exist
|
303
|
+
self.database_is 'history'
|
304
|
+
else
|
305
|
+
self.create_database 'history' #Creates database
|
306
|
+
end
|
303
307
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
# if self.is_database 'history'
|
311
|
-
# puts "DB Exists"
|
312
|
-
# self.database_is 'history'
|
313
|
-
# else
|
314
|
-
# puts "DB Dosent Exist"
|
315
|
-
# self.create_database 'history'
|
316
|
-
# end
|
317
|
-
|
318
|
-
# if self.is_table 'generals', 'history'
|
319
|
-
# puts "Table Exists"
|
320
|
-
# self.table_is 'generals'
|
321
|
-
# else
|
322
|
-
# puts "Table Dosent Exist"
|
323
|
-
# self.create_table 'generals', 'name', 'alias', 'nationality'
|
324
|
-
# end
|
325
|
-
#end
|
326
|
-
|
327
|
-
#Job.details
|
328
|
-
|
329
|
-
#Job.insert({"name" => "VasiliChuikov", "alias" => "SaviorStalingrad", "nationality" => "Russian"}) #WF
|
330
|
-
#Job.insert({"name" => "MontGomery", "alias" => "DesertStorm", "nationality" => "British"}) #WF
|
331
|
-
#Job.insert({"name" => "Fermanshtine", "alias" => "BerlinGuard", "nationality" => "German"}) #WF
|
332
|
-
#Job.insert({"name" => "DouglasMcAurthor", "alias" => "BeBack", "nationality" => "USA"}) #WF
|
333
|
-
#Job.insert({"name" => "ErwinRomell", "alias" => "DesertFox", "nationality" => "German"}) #WF
|
334
|
-
#Job.insert({"name" => "Patton", "alias" => "TheTank", "nationality" => "USA"}) #WF
|
335
|
-
#Job.insert({"name" => "Fredrik Paulo", "alias" => "Barbarosa", "nationality" => "German"}) #WF
|
336
|
-
|
337
|
-
#Job.select(:index => 5) #WF
|
338
|
-
#Job.select #WF
|
339
|
-
#Job.select(:limit => 6) #WF
|
340
|
-
#Job.select(:conditions => {"name" => "Patton"}) #WF
|
341
|
-
#Job.select(:conditions => {"nationality" => "German"}, :limit => 2) #WF
|
342
|
-
#Job.select(:conditions => {"nationality" => "German", "name" => "*o*", "alias" => "*t*"}) #WF
|
343
|
-
|
344
|
-
#Job.update(:set => {"name" => "WalterModel", "alias" => "BulgeBat"}, :conditions => {"name" => "Fermanshtine"}) #WF
|
345
|
-
#Job.update(:set => {"name" => "Fermanchtine", "alias" => "BerlinGuard", "nationality" => "German"}, :index => 2) #WF
|
346
|
-
|
347
|
-
#Job.delete(:index => 1) #WF
|
348
|
-
#Job.delete(:conditions => {"nationality" => "USA"}) #WF
|
349
|
-
#Job.delete(:conditions => "all") #WF
|
308
|
+
if self.is_table 'generals', 'history' #Checks if table exist in database
|
309
|
+
self.table_is 'generals'
|
310
|
+
else
|
311
|
+
self.create_table 'generals', 'name', 'alias', 'nationality' #Creating table. First argument is table name and rest fields for the table.
|
312
|
+
end
|
313
|
+
end
|
350
314
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yasha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Edwin Rozario
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-05-
|
18
|
+
date: 2012-05-29 00:00:00 +05:30
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|