motion-prime 0.9.7 → 0.9.8

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmEyMGMyMWQ4OTEwOGI2N2Y5YzZjYmI3MWRmY2Y4MzYzMGNiYjU2MQ==
4
+ OWYyOGRiMGJjNjc2MjdkM2JiOTBlMWZjMzk2YTFjZTgwNTUzMDA2YQ==
5
5
  data.tar.gz: !binary |-
6
- YzI4NzhiNWJiYjJmY2EyMmFiM2M0MjE4MzVmMWM5OWMxNzNjYTdlMQ==
6
+ MWU3OTRmN2RjZjRlZDc1M2Y2ZjAwZDI1MDRjYjI4MDk5ODU4N2E1Zg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OTlkZGM4MTg1YTI1NjVjOWU0M2U4MzYzNzQ5NzlhZWY5OWVkNjFjMTNkODY2
10
- NDAwZjNiMTRlZmJlZDFjMzExODZlOTVhM2YxZmFiMzgwNWVmY2JhOWI1MTI4
11
- ZGQ3MTYxOGI4NTAzNmVlMzQ0NDIyNTIxNDdiNmI0NWE4ZDMyMzM=
9
+ Y2U5NzJkZjkxMTMyMTNjMzk2NGJlYTRkYjZjNDljN2QwODI5NDg2OWYxNWI4
10
+ ZGU3ZTI3MWVlYWFiMGJjMjNhOGFmMzA2YWUyZmUwNzE0YjZmNTM4NzA0OWNl
11
+ ZDNmZDI4NjA5YWM5NWM4NWJlMDllZWEyN2ZkMGI0NjAzN2NjMTA=
12
12
  data.tar.gz: !binary |-
13
- MTNlNWRkMDhkNTJiZWU1NTQ2NDA2ODAzMzRhYmQzMzEwODEyYzQ1NjFmOGM5
14
- YWZjNWM0ZmY5ZTAyNTQyOGFjYTAzNjY0YzU2YjE1NjgzMWY2ZDhmZjdjMDY2
15
- YWYyNDViYTQ2NzJjNzFmMDI3ZGM3ZTBkMDA4MjczYmE4N2YzYjE=
13
+ Zjc5MDQ2MjJhYWY2MzU1YTIwYWJmZmE0NDhiOWVjNmY5Njg0ZmE5NTA3ZDg2
14
+ YmM2NmNhNWNmNmQ4NjQwYzQ3MTZkNDljNTFiY2EyMzljZDI0OGYzOTc2YjM3
15
+ YzU3ODg5MTNjNWJmNzMzZTNkMzVhNzE2YmRiOWRlM2FjZjE5ZGI=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.9.8
2
+ * Ability to fetch one record / all records from server using Model.fetch(id) or Model.fetch_all
3
+ * Bug fixes
4
+
1
5
  === 0.9.7
2
6
  * BREAKING CHANGE: screen#set_options renamed to screen#set_options_for.
3
7
  * BREAKING CHANGE: section#reload_section renamed to section#hard_reload_section. in common cases use section#reload.
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'motion-cocoapods', '~> 1.4.0'
3
+ gem 'motion-cocoapods', '~> 1.4.1'
4
4
  gemspec
data/Gemfile.lock CHANGED
@@ -1,17 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- motion-prime (0.9.7)
4
+ motion-prime (0.9.8)
5
5
  activesupport
6
6
  afmotion (~> 2.1.0)
7
- bubble-wrap (~> 1.5.0)
7
+ bubble-wrap (~> 1.6.0)
8
8
  cocoapods
9
9
  methadone
10
10
  motion-cocoapods
11
11
  motion-require
12
12
  motion-support (~> 0.2.6)
13
13
  rm-digest
14
- sugarcube (~> 1.5.2)
14
+ sugarcube (~> 1.6.0)
15
15
  thor
16
16
 
17
17
  GEM
@@ -20,61 +20,62 @@ GEM
20
20
  activesupport (3.2.17)
21
21
  i18n (~> 0.6, >= 0.6.4)
22
22
  multi_json (~> 1.0)
23
- afmotion (2.1.2)
23
+ afmotion (2.1.4)
24
24
  motion-cocoapods (~> 1.4.0)
25
25
  motion-require (>= 0.1)
26
- bubble-wrap (1.5.0)
27
- claide (0.4.0)
28
- cocoapods (0.29.0)
26
+ bubble-wrap (1.6.0)
27
+ bubble-wrap-http (= 1.6.0)
28
+ bubble-wrap-http (1.6.0)
29
+ claide (0.5.0)
30
+ cocoapods (0.32.1)
29
31
  activesupport (>= 3.2.15, < 4)
30
- claide (~> 0.4.0)
31
- cocoapods-core (= 0.29.0)
32
- cocoapods-downloader (~> 0.3.0)
33
- cocoapods-try-release-fix (~> 0.1.1)
32
+ claide (~> 0.5.0)
33
+ cocoapods-core (= 0.32.1)
34
+ cocoapods-downloader (~> 0.5.0)
35
+ cocoapods-try (~> 0.2.0)
34
36
  colored (~> 1.2)
35
37
  escape (~> 0.0.4)
36
38
  json_pure (~> 1.8)
37
- nap (~> 0.5)
39
+ nap (~> 0.7)
38
40
  open4 (~> 1.3)
39
- xcodeproj (~> 0.14.1)
40
- cocoapods-core (0.29.0)
41
+ xcodeproj (~> 0.16.1)
42
+ cocoapods-core (0.32.1)
41
43
  activesupport (>= 3.2.15, < 4)
42
44
  fuzzy_match (~> 2.0.4)
43
45
  json_pure (~> 1.8)
44
46
  nap (~> 0.5)
45
- cocoapods-downloader (0.3.0)
46
- cocoapods-try-release-fix (0.1.2)
47
+ cocoapods-downloader (0.5.0)
48
+ cocoapods-try (0.2.0)
47
49
  colored (1.2)
48
50
  escape (0.0.4)
49
51
  fuzzy_match (2.0.4)
50
52
  i18n (0.6.9)
51
53
  json_pure (1.8.1)
52
- methadone (1.3.2)
54
+ methadone (1.4.0)
53
55
  bundler
54
- motion-cocoapods (1.4.0)
55
- cocoapods (>= 0.26.2)
56
+ motion-cocoapods (1.4.1)
57
+ cocoapods (>= 0.32.1)
56
58
  motion-redgreen (0.1.0)
57
59
  motion-require (0.2.0)
58
- motion-stump (0.3.1)
60
+ motion-stump (0.3.2)
59
61
  motion-support (0.2.6)
60
62
  motion-require (>= 0.0.6)
61
- multi_json (1.9.0)
62
- nap (0.6.0)
63
+ multi_json (1.9.3)
64
+ nap (0.7.0)
63
65
  open4 (1.3.3)
64
- rake (10.1.1)
66
+ rake (10.3.1)
65
67
  rm-digest (0.0.2)
66
- sugarcube (1.5.5)
68
+ sugarcube (1.6.0)
67
69
  thor (0.19.1)
68
- xcodeproj (0.14.1)
70
+ xcodeproj (0.16.1)
69
71
  activesupport (~> 3.0)
70
72
  colored (~> 1.2)
71
- rake
72
73
 
73
74
  PLATFORMS
74
75
  ruby
75
76
 
76
77
  DEPENDENCIES
77
- motion-cocoapods (~> 1.4.0)
78
+ motion-cocoapods (~> 1.4.1)
78
79
  motion-prime!
79
80
  motion-redgreen
80
81
  motion-stump
data/files/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'motion-cocoapods', '~> 1.4.0'
4
- gem 'motion-prime', '0.9.7'
3
+ gem 'motion-cocoapods', '~> 1.4.1'
4
+ gem 'motion-prime', '0.9.8'
5
5
 
6
6
  # add reside menu for sidebar support
7
7
  # gem 'prime_reside_menu', '~> 0.1.4'
@@ -1,17 +1,19 @@
1
1
  Prime::Config.configure do |config|
2
2
  # Uncomments following if you don't want auto generating id for model on save
3
- #
3
+ #
4
4
  # config.model.auto_generate_id = false
5
5
 
6
6
  # After defining colors you will be able to use it via <uilabel>.text_color = :app_base.uicolor
7
7
  # config.colors do |colors|
8
+ # colors.navigation_base = 0x1b75bc
8
9
  # colors.base = 0x1b75bc
9
10
  # colors.dark = 0x333333
10
11
  # colors.error = 0xef471f
11
12
  # end
12
13
 
13
14
  # After defining fonts you will be able to use it via <uilabel>.font = :app_base.uifont
15
+ # Note: font should be copied to resources folder (e.g. resources/fonts/ubuntu.ttf) and added to Rakefile.
14
16
  # config.fonts do |fonts|
15
17
  # fonts.base = "Ubuntu"
16
18
  # end
17
- end
19
+ end
data/motion-prime.gemspec CHANGED
@@ -24,8 +24,8 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "motion-cocoapods"
25
25
  spec.add_dependency "motion-require"
26
26
  spec.add_dependency "motion-support", '~> 0.2.6'
27
- spec.add_dependency 'bubble-wrap', '~> 1.5.0'
28
- spec.add_dependency 'sugarcube', '~> 1.5.2'
27
+ spec.add_dependency 'bubble-wrap', '~> 1.6.0'
28
+ spec.add_dependency 'sugarcube', '~> 1.6.0'
29
29
  spec.add_dependency 'afmotion', '~> 2.1.0'
30
30
  spec.add_dependency "methadone"
31
31
  spec.add_dependency "rm-digest"
@@ -62,7 +62,7 @@ module MotionPrime
62
62
  paragrah_style.setLineSpacing(line_spacing)
63
63
  end
64
64
  if text_alignment
65
- text_alignment = text_alignment.uitextalignment if text_alignment.is_a?(Symbol)
65
+ text_alignment = text_alignment.nstextalignment if text_alignment.is_a?(Symbol)
66
66
  paragrah_style.setAlignment(text_alignment)
67
67
  end
68
68
  if line_break_mode
@@ -76,4 +76,4 @@ module MotionPrime
76
76
  [attributes, paragrah_style]
77
77
  end
78
78
  end
79
- end
79
+ end
@@ -12,7 +12,7 @@ module MotionPrime
12
12
  font = (options[:font] || :system).uifont
13
13
 
14
14
  text_alignment_name = options.fetch(:text_alignment, :left)
15
- text_alignment = text_alignment_name.uitextalignment
15
+ text_alignment = text_alignment_name.nstextalignment
16
16
  line_break_mode_name = options.fetch(:line_break_mode, :tail_truncation)
17
17
  line_break_mode = line_break_mode_name.uilinebreakmode
18
18
 
@@ -105,4 +105,4 @@ module MotionPrime
105
105
  end
106
106
  end
107
107
  end
108
- end
108
+ end
@@ -139,7 +139,7 @@ module MotionPrime
139
139
  end
140
140
 
141
141
  # Assign model attributes, using fetch. Differenct between assign_attributes and fetch_with_attributes is
142
- # ths you can create method named fetch_:attribute and it will be used to assign attribute only on fetch.
142
+ # that you can create method named fetch_:attribute and it will be used to assign attribute only on fetch.
143
143
  #
144
144
  # @example
145
145
  # class User < Prime::Model
@@ -339,7 +339,63 @@ module MotionPrime
339
339
  end
340
340
 
341
341
  module ClassMethods
342
- def fetch_all_with_attributes(data)
342
+ # Fetch model from server
343
+ #
344
+ # @param id [Integer] model id
345
+ # @param options [Hash] fetch options
346
+ # @option options [Symbol] :method Http method to calculate url, `:get` by default
347
+ # @option options [Boolean or Array] :associations Also fetch associations
348
+ # @option options [Boolean] :save Save model after fetch
349
+ # @param block [Proc] block to be executed after fetch
350
+ def fetch(id, options = {}, &block)
351
+ model = self.new(id: id)
352
+ model.fetch(options, &block)
353
+ end
354
+
355
+ # Fetch model from server and save on local
356
+ def fetch!(id, options = {}, &block)
357
+ fetch(id, options.merge(save: true), &block)
358
+ end
359
+
360
+ # Fetch collection from server
361
+ #
362
+ # @param options [Hash] fetch options
363
+ # @option options [Symbol] :method Http method to calculate url, `:get` by default
364
+ # @option options [Boolean] :save Save model after fetch
365
+ # @param block [Proc] block to be executed after fetch
366
+ def fetch_all(options = {}, &block)
367
+ use_callback = block_given?
368
+ url = self.new.sync_url(options[:method] || :get, options)
369
+
370
+ fetch_all_with_url url, options do |records, status_code, response|
371
+ records.each(&:save) if options[:save]
372
+ block.call(records, status_code, response) if use_callback
373
+ end if !url.blank?
374
+ end
375
+
376
+ # Fetch collection from server using url
377
+ #
378
+ # @param url [String] url to fetch
379
+ # @param block [Proc] block to be executed after fetch
380
+ def fetch_all_with_url(url, options = {}, &block)
381
+ use_callback = block_given?
382
+ App.delegate.api_client.get(url) do |response, status_code|
383
+ if response.present?
384
+ records = fetch_all_with_attributes(response, save_associations: options[:save], &block)
385
+ else
386
+ records = []
387
+ end
388
+ block.call(records, status_code, response) if use_callback
389
+ end
390
+ end
391
+
392
+ # Assign collection attributes, using fetch.
393
+ #
394
+ # @params attributes [Array<Hash>] attributes to be assigned
395
+ # @params options [Hash] options
396
+ # @option options [Boolean] :save_associations Save included to hash associations
397
+ # @return model [Prime::Model] the model
398
+ def fetch_all_with_attributes(data, options ={}, &block)
343
399
  data.map do |attrs|
344
400
  item = self.new
345
401
  item.fetch_with_attributes(attrs)
@@ -377,4 +433,4 @@ module MotionPrime
377
433
  end
378
434
  end
379
435
  end
380
- end
436
+ end
@@ -1,3 +1,5 @@
1
+ motion_require '../support/_key_value_store'
2
+ motion_require '../support/_padding_attribute'
1
3
  class MPButton < UIButton
2
4
  include MotionPrime::SupportKeyValueStore
3
5
  include MotionPrime::SupportPaddingAttribute
@@ -1,3 +1,5 @@
1
+ motion_require '../support/_key_value_store'
2
+ motion_require '../support/_padding_attribute'
1
3
  class MPLabel < UILabel
2
4
  include MotionPrime::SupportKeyValueStore
3
5
  include MotionPrime::SupportPaddingAttribute
@@ -1,6 +1,8 @@
1
1
  # This class have some modifications for UITextField:
2
2
  # * support padding, padding_left, padding_right options
3
3
  # * support placeholder_color, placeholder_font options
4
+ motion_require '../support/_key_value_store'
5
+ motion_require '../support/_padding_attribute'
4
6
  class MPTextField < UITextField
5
7
  include MotionPrime::SupportKeyValueStore
6
8
  include MotionPrime::SupportPaddingAttribute
@@ -32,7 +34,7 @@ class MPTextField < UITextField
32
34
 
33
35
  truncation = :tail_truncation.uilinebreakmode
34
36
  alignment = (placeholderAlignment || :left)
35
- alignment = alignment.uitextalignment if alignment.is_a?(Symbol)
37
+ alignment = alignment.nstextalignment if alignment.is_a?(Symbol)
36
38
  self.placeholder.drawInRect(rect, withFont: font, lineBreakMode: truncation, alignment: alignment)
37
39
  end
38
40
 
@@ -51,4 +53,4 @@ class MPTextField < UITextField
51
53
  bounds.origin.x + padding_left, bounds.origin.y + padding_top,
52
54
  bounds.size.width - (padding_left + padding_right), bounds.size.height - (padding_top + padding_bottom))
53
55
  end
54
- end
56
+ end
@@ -1,6 +1,8 @@
1
1
  # This class have some modifications for UITextView:
2
2
  # * support padding, padding_left, padding_right options
3
3
  # * support placeholder, placeholder_color, placeholder_font options
4
+ motion_require '../support/_key_value_store'
5
+ motion_require '../support/_padding_attribute'
4
6
  class MPTextView < UITextView
5
7
  include MotionPrime::SupportKeyValueStore
6
8
  include MotionPrime::SupportPaddingAttribute
@@ -1,3 +1,3 @@
1
1
  module MotionPrime
2
- VERSION = "0.9.7"
2
+ VERSION = "0.9.8"
3
3
  end
@@ -1,6 +1,10 @@
1
1
  # TODO: make it part of Sections
2
2
  motion_require '../support/mp_cell_with_section'
3
3
  motion_require '../support/mp_spinner'
4
+ motion_require '../support/mp_button'
5
+ motion_require '../support/mp_label'
6
+ motion_require '../support/mp_text_field'
7
+ motion_require '../support/mp_text_view'
4
8
  module MotionPrime
5
9
  module Layout
6
10
  def add_view(klass, options = {}, &block)
@@ -45,9 +49,9 @@ module MotionPrime
45
49
 
46
50
  def self.included base
47
51
  base.class_eval do
48
- [::UIActionSheet, ::UIActivityIndicatorView, ::UIButton, ::UIDatePicker, ::UIImageView, ::UILabel,
52
+ [::UIActionSheet, ::UIActivityIndicatorView, ::MPButton, ::UIDatePicker, ::UIImageView, ::MPLabel,
49
53
  ::UIPageControl, ::UIPickerView, ::UIProgressView, ::UIScrollView, ::UISearchBar, ::UISegmentedControl,
50
- ::UISlider, ::UIStepper, ::UISwitch, ::UITabBar, ::UITableView, ::UITableViewCell, ::UITextField, ::UITextView,
54
+ ::UISlider, ::UIStepper, ::UISwitch, ::UITabBar, ::UITableView, ::UITableViewCell, ::MPTextField, ::MPTextView,
51
55
  ::UIToolbar, ::UIWebView, ::UINavigationBar, ::MPCellWithSection, ::MBProgressHUD, ::MPSpinner].each do |klass|
52
56
 
53
57
  shorthand = "#{klass}"[2..-1].underscore.to_sym
@@ -151,7 +151,7 @@ module MotionPrime
151
151
  view.setValue "UIControlContentHorizontalAlignment#{value.camelize}".constantize, forKey: camelize_factory(key)
152
152
  true
153
153
  elsif key.end_with?('alignment') && value.is_a?(Symbol)
154
- view.setValue value.uitextalignment, forKey: camelize_factory(key)
154
+ view.setValue value.nstextalignment, forKey: camelize_factory(key)
155
155
  true
156
156
  elsif key.end_with?('line_break_mode') && value.is_a?(Symbol)
157
157
  view.setValue value.uilinebreakmode, forKey: camelize_factory(key)
@@ -278,4 +278,4 @@ module MotionPrime
278
278
  UIOffset => Proc.new {|v| NSValue.valueWithUIOffset(v) }
279
279
  }
280
280
  end
281
- end
281
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-prime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iskander Haziev
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-01 00:00:00.000000000 Z
12
+ date: 2014-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -115,28 +115,28 @@ dependencies:
115
115
  requirements:
116
116
  - - ~>
117
117
  - !ruby/object:Gem::Version
118
- version: 1.5.0
118
+ version: 1.6.0
119
119
  type: :runtime
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: 1.5.0
125
+ version: 1.6.0
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: sugarcube
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ~>
131
131
  - !ruby/object:Gem::Version
132
- version: 1.5.2
132
+ version: 1.6.0
133
133
  type: :runtime
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - ~>
138
138
  - !ruby/object:Gem::Version
139
- version: 1.5.2
139
+ version: 1.6.0
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: afmotion
142
142
  requirement: !ruby/object:Gem::Requirement