swiss_db 0.6.6 → 0.6.7
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.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/motion-support/inflections.rb +2 -2
- data/lib/swiss_db/cursor.rb +30 -1
- data/lib/swiss_db/db.rb +2 -1
- data/lib/swiss_db/swiss_model.rb +7 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04dcca30855e79f7effe25280491f5ff88a60f05
|
4
|
+
data.tar.gz: 9d5aa72a3fb8b0b96acf70993143399a08d8313d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51423f441488fdfc031ce13f4523cc4d7f1b6f1e4607ea657b3d045f5fe170f54447227942f65c680957ae597cffd137e93d603a9bcca0a4d4b437617779d54d
|
7
|
+
data.tar.gz: 905a859a27dbfa725f6ceeb948c84744cf02e0a81e822b91754d33228290669da30525dced774963439bbb80a54c433fc679cae922866d30108c92a94c5db4b6
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ module MotionSupport
|
|
23
23
|
@__instance__ ||= new
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
attr_accessor :plurals, :singulars, :uncountables, :humans, :acronyms, :acronym_regex
|
27
27
|
|
28
28
|
def initialize
|
29
29
|
@plurals, @singulars, @uncountables, @humans, @acronyms, @acronym_regex = [], [], [], [], {}, /(?=a)b/
|
@@ -214,7 +214,7 @@ module MotionSupport
|
|
214
214
|
# MotionSupport::Inflector.inflections do |inflect|
|
215
215
|
# inflect.uncountable 'rails'
|
216
216
|
# end
|
217
|
-
def inflections
|
217
|
+
def inflections(&block)
|
218
218
|
if block_given?
|
219
219
|
yield Inflections.instance
|
220
220
|
else
|
data/lib/swiss_db/cursor.rb
CHANGED
@@ -3,7 +3,22 @@
|
|
3
3
|
# Convenience methods over the standard cursor
|
4
4
|
# Used by Swiss DataStore
|
5
5
|
|
6
|
-
class
|
6
|
+
class CursorModel
|
7
|
+
|
8
|
+
def initialize(h)
|
9
|
+
h.each do |k,v|
|
10
|
+
instance_variable_set("@#{k}", v)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def method_missing(methId, *args)
|
15
|
+
str = methId.id2name
|
16
|
+
instance_variable_get("@#{str}")
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
class Cursor # < Array
|
7
22
|
|
8
23
|
FIELD_TYPE_BLOB = 4
|
9
24
|
FIELD_TYPE_FLOAT = 2
|
@@ -31,6 +46,20 @@ class Cursor
|
|
31
46
|
cursor.moveToPosition(pos) ? self : nil
|
32
47
|
end
|
33
48
|
|
49
|
+
def to_a
|
50
|
+
arr = []
|
51
|
+
(0...count).each do |i|
|
52
|
+
# puts i
|
53
|
+
hash_obj = {}
|
54
|
+
cursor.moveToPosition(i)
|
55
|
+
$current_schema[model.class_name].each do |k, v|
|
56
|
+
hash_obj[k.to_sym] = self.send(k.to_sym)
|
57
|
+
end
|
58
|
+
arr << CursorModel.new(hash_obj)
|
59
|
+
end
|
60
|
+
arr
|
61
|
+
end
|
62
|
+
|
34
63
|
def count
|
35
64
|
cursor.getCount
|
36
65
|
end
|
data/lib/swiss_db/db.rb
CHANGED
@@ -35,7 +35,8 @@ class Object
|
|
35
35
|
@table_name = table_name
|
36
36
|
@current_schema[@table_name] = {}
|
37
37
|
block.call
|
38
|
-
|
38
|
+
$current_schema = @current_schema
|
39
|
+
DataStore.current_schema = @current_schema
|
39
40
|
end
|
40
41
|
|
41
42
|
def add_column(name, type)
|
data/lib/swiss_db/swiss_model.rb
CHANGED
@@ -6,10 +6,10 @@ class SwissModel
|
|
6
6
|
# meh? .. won't work for now in java... created classes become java packages
|
7
7
|
# name will become the namespace of the package...
|
8
8
|
# def self.inherited(subclass)
|
9
|
-
# puts "New subclass: #{subclass.class.name.
|
9
|
+
# puts "New subclass: #{subclass.class.name.split('.').last}"
|
10
10
|
# end
|
11
11
|
|
12
|
-
# attr_accessor :table_name
|
12
|
+
# attr_accessor :table_name, :class_name
|
13
13
|
|
14
14
|
def self.store
|
15
15
|
context = DataStore.context
|
@@ -17,7 +17,12 @@ class SwissModel
|
|
17
17
|
@store
|
18
18
|
end
|
19
19
|
|
20
|
+
def self.class_name
|
21
|
+
@class_name
|
22
|
+
end
|
23
|
+
|
20
24
|
def self.set_class_name(class_name) # hack, class.name not functioning in RM Android...
|
25
|
+
@class_name = class_name
|
21
26
|
set_table_name(class_name.tableize)
|
22
27
|
end
|
23
28
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swiss_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Silverman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|