pig-media-server 100 → 200
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pig-media-server/model/data_use_rdb.rb +27 -25
- data/lib/pig-media-server/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e768e9c0ca509bbfe0436b914d3a9d701e3f011
|
4
|
+
data.tar.gz: 4029590cdbeab4e540acf47505c52468d2720a64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b5c47f8cd29bfaa8e9a29e2e0da7826ad3228fbc627edb01ca55590b7ab745ebbac8b4ba15eca4f5215e65d0584ad6658f71cfaebe3a1e898e73e9a4f794224
|
7
|
+
data.tar.gz: f17ba70242e1bb0f55afc98d4c9b8d4f071076a8cb12c44125354e375ea2d921ac076f6a57e9f745f39f925e98b3a1c686351aa1307312904f307358f5d2b930
|
@@ -10,8 +10,8 @@ ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
10
10
|
|
11
11
|
tables = ActiveRecord::Base.connection.tables
|
12
12
|
|
13
|
-
unless tables.index('
|
14
|
-
ActiveRecord::Migration.create_table :
|
13
|
+
unless tables.index('app_data')
|
14
|
+
ActiveRecord::Migration.create_table :app_data do |t|
|
15
15
|
t.string :key
|
16
16
|
t.string :original_key
|
17
17
|
t.text :value
|
@@ -35,29 +35,7 @@ unless tables.index('recents')
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
class
|
39
|
-
def self.find key
|
40
|
-
key = Digest::MD5.hexdigest(key)
|
41
|
-
a = self.where(key: key).first
|
42
|
-
if a
|
43
|
-
a.parse
|
44
|
-
else
|
45
|
-
nil
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.set key, value
|
50
|
-
a_key = Digest::MD5.hexdigest(key)
|
51
|
-
a = self.find_or_create_by(key: a_key)
|
52
|
-
a.value = value.to_json
|
53
|
-
a.original_key = key
|
54
|
-
a.save!
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.all
|
58
|
-
super.map{|x| {key: x.original_key, value: x.parse}}
|
59
|
-
end
|
60
|
-
|
38
|
+
class AppDatum < ActiveRecord::Base
|
61
39
|
def parse
|
62
40
|
val = self.value
|
63
41
|
case val
|
@@ -78,6 +56,30 @@ class AppData < ActiveRecord::Base
|
|
78
56
|
end
|
79
57
|
end
|
80
58
|
|
59
|
+
class AppData
|
60
|
+
def self.find key
|
61
|
+
key = Digest::MD5.hexdigest(key)
|
62
|
+
a = AppDatum.where(key: key).first
|
63
|
+
if a
|
64
|
+
a.parse
|
65
|
+
else
|
66
|
+
nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.set key, value
|
71
|
+
a_key = Digest::MD5.hexdigest(key)
|
72
|
+
a = AppDatum.find_or_create_by(key: a_key)
|
73
|
+
a.value = value.to_json
|
74
|
+
a.original_key = key
|
75
|
+
a.save!
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.all
|
79
|
+
AppDatum.all.map{|x| {key: x.original_key, value: x.parse}}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
81
83
|
class Star < ActiveRecord::Base
|
82
84
|
end
|
83
85
|
|