motion_data_wrapper 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3da72e1eb1f458f7befcce0e620f963d2bbad3f1
4
+ data.tar.gz: 1ee074ffa517340dce15493f3afb9d740ab6b8e2
5
+ SHA512:
6
+ metadata.gz: a4afe689fd4c21370529084ffe24ba54b3ff94c470a15148ff39187ce5b5358885ccad3d0d67aa102d8f19f3e048d5e605b36356e3e9f84c82f385748bc235a3
7
+ data.tar.gz: 0696baa492af321233565b0cd70e2bf751e7a81d738f72a47f330d54dce49ffe5fa481e7085ea77500fbd49f3d7134b6df0a7d72c37702628f30f3a89cb88b9c
@@ -1,38 +1,38 @@
1
1
  module MotionDataWrapper
2
2
  class Model < NSManagedObject
3
3
  module FinderMethods
4
-
4
+
5
5
  def self.included(base)
6
6
  base.extend(ClassMethods)
7
7
  end
8
-
8
+
9
9
  module ClassMethods
10
-
10
+
11
11
  def all
12
12
  relation.to_a
13
13
  end
14
-
14
+
15
15
  def count
16
16
  relation.count
17
17
  end
18
-
18
+
19
19
  def destroy_all
20
20
  all.map &:destroy
21
21
  end
22
-
22
+
23
23
  def except(query_part)
24
24
  relation.except(query_part)
25
25
  end
26
-
26
+
27
27
  def find(object_id)
28
28
  raise MotionDataWrapper::RecordNotFound.new(self, object_id) unless entity = find_by_id(object_id)
29
29
  entity
30
30
  end
31
-
31
+
32
32
  def first
33
33
  relation.first
34
34
  end
35
-
35
+
36
36
  def first!
37
37
  first or raise MotionDataWrapper::RecordNotFound
38
38
  end
@@ -44,11 +44,11 @@ module MotionDataWrapper
44
44
  def last!
45
45
  last or raise MotionDataWrapper::RecordNotFound
46
46
  end
47
-
47
+
48
48
  def limit(l)
49
49
  relation.limit(l)
50
50
  end
51
-
51
+
52
52
  def method_missing(method, *args, &block)
53
53
  if method.start_with?("find_by_")
54
54
  attribute = method.gsub("find_by_", "")
@@ -60,7 +60,7 @@ module MotionDataWrapper
60
60
  super
61
61
  end
62
62
  end
63
-
63
+
64
64
  def offset(o)
65
65
  relation.offset(o)
66
66
  end
@@ -68,15 +68,15 @@ module MotionDataWrapper
68
68
  def order(*args)
69
69
  relation.order(*args)
70
70
  end
71
-
71
+
72
72
  def pluck(column)
73
73
  relation.pluck(column)
74
74
  end
75
-
75
+
76
76
  def reorder(*args)
77
77
  relation.except(:order).order(*args)
78
78
  end
79
-
79
+
80
80
  def respond_to?(method)
81
81
  if method.start_with?("find_by_") || method.start_with?("find_all_by_")
82
82
  true
@@ -84,7 +84,7 @@ module MotionDataWrapper
84
84
  super
85
85
  end
86
86
  end
87
-
87
+
88
88
  def uniq
89
89
  relation.uniq
90
90
  end
@@ -92,16 +92,20 @@ module MotionDataWrapper
92
92
  def where(*args)
93
93
  relation.where(*args)
94
94
  end
95
-
95
+
96
+ def with_context(ctx)
97
+ relation.with_context(ctx)
98
+ end
99
+
96
100
  private
97
-
101
+
98
102
  def relation
99
103
  Relation.alloc.initWithClass(self)
100
104
  end
101
-
102
- end
103
-
105
+
106
+ end
107
+
104
108
  end
105
-
109
+
106
110
  end
107
111
  end
@@ -1,21 +1,22 @@
1
1
  module MotionDataWrapper
2
2
  class Relation < NSFetchRequest
3
3
  module CoreData
4
-
4
+
5
5
  def inspect
6
6
  to_a
7
7
  end
8
-
8
+
9
9
  def to_a
10
10
  error_ptr = Pointer.new(:object)
11
11
  context.executeFetchRequest(self, error:error_ptr)
12
12
  end
13
-
13
+
14
+
14
15
  private
15
16
  def context
16
- App.delegate.managedObjectContext
17
+ @ctx || App.delegate.managedObjectContext
17
18
  end
18
-
19
+
19
20
  end
20
21
  end
21
22
  end
@@ -1,11 +1,11 @@
1
1
  module MotionDataWrapper
2
2
  class Relation < NSFetchRequest
3
3
  module FinderMethods
4
-
4
+
5
5
  def all
6
6
  to_a
7
7
  end
8
-
8
+
9
9
  def count
10
10
  return to_a.count if fetchOffset > 0
11
11
  old_result_type = self.resultType
@@ -14,11 +14,11 @@ module MotionDataWrapper
14
14
  self.resultType = old_result_type
15
15
  return count
16
16
  end
17
-
17
+
18
18
  def destroy_all
19
19
  all.map &:destroy
20
20
  end
21
-
21
+
22
22
  def except(query_part)
23
23
  case query_part.to_sym
24
24
  when :where
@@ -32,7 +32,7 @@ module MotionDataWrapper
32
32
  end
33
33
  self
34
34
  end
35
-
35
+
36
36
  def first
37
37
  self.fetchLimit = 1
38
38
  to_a[0]
@@ -43,28 +43,28 @@ module MotionDataWrapper
43
43
  self.fetchLimit = 1
44
44
  to_a[0]
45
45
  end
46
-
46
+
47
47
  def limit(l)
48
48
  l = l.to_i
49
49
  raise ArgumentError, "limit '#{l}' cannot be less than zero. Use zero for no limit." if l < 0
50
50
  self.fetchLimit = l
51
51
  self
52
52
  end
53
-
53
+
54
54
  def offset(o)
55
55
  o = o.to_i
56
56
  raise ArgumentError, "offset '#{o}' cannot be less than zero." if o < 0
57
57
  self.fetchOffset = o
58
58
  self
59
59
  end
60
-
60
+
61
61
  def order(column, opts={})
62
62
  descriptors = sortDescriptors.nil? ? [] : sortDescriptors.mutableCopy
63
63
  descriptors << NSSortDescriptor.sortDescriptorWithKey(column.to_s, ascending:opts.fetch(:ascending, true))
64
64
  self.sortDescriptors = descriptors
65
65
  self
66
66
  end
67
-
67
+
68
68
  def pluck(column)
69
69
  self.resultType = NSDictionaryResultType
70
70
 
@@ -74,12 +74,12 @@ module MotionDataWrapper
74
74
  self.propertiesToFetch = [attribute_description]
75
75
  to_a.collect { |r| r[column] }
76
76
  end
77
-
77
+
78
78
  def uniq
79
79
  self.returnsDistinctResults = true
80
80
  self
81
81
  end
82
-
82
+
83
83
  def where(format, *args)
84
84
  new_predicate = NSPredicate.predicateWithFormat(format.gsub("?", "%@"), argumentArray:args)
85
85
 
@@ -91,7 +91,12 @@ module MotionDataWrapper
91
91
 
92
92
  self
93
93
  end
94
-
94
+
95
+ def with_context(ctx)
96
+ @ctx = ctx
97
+ self
98
+ end
99
+
95
100
  end
96
101
  end
97
102
  end
@@ -1,3 +1,3 @@
1
1
  module MotionDataWrapper
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion_data_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Matt Brewer
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-23 00:00:00.000000000 Z
11
+ date: 2013-06-24 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bubble-wrap
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  description: Forked from the mattgreen/nitron gem, this provides an intuitive way
@@ -52,27 +49,25 @@ files:
52
49
  - lib/motion_data_wrapper/version.rb
53
50
  homepage: https://github.com/macfanatic/motion_data_wrapper
54
51
  licenses: []
52
+ metadata: {}
55
53
  post_install_message:
56
54
  rdoc_options: []
57
55
  require_paths:
58
56
  - lib
59
57
  required_ruby_version: !ruby/object:Gem::Requirement
60
- none: false
61
58
  requirements:
62
- - - ! '>='
59
+ - - '>='
63
60
  - !ruby/object:Gem::Version
64
61
  version: '0'
65
62
  required_rubygems_version: !ruby/object:Gem::Requirement
66
- none: false
67
63
  requirements:
68
- - - ! '>='
64
+ - - '>='
69
65
  - !ruby/object:Gem::Version
70
66
  version: '0'
71
67
  requirements: []
72
68
  rubyforge_project:
73
- rubygems_version: 1.8.24
69
+ rubygems_version: 2.0.3
74
70
  signing_key:
75
- specification_version: 3
71
+ specification_version: 4
76
72
  summary: Provides an easy ActiveRecord-like interface to CoreData
77
73
  test_files: []
78
- has_rdoc: