motion-prime 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +6 -6
- data/README.md +1 -10
- data/Rakefile +0 -1
- data/app/app_delegate.rb +1 -1
- data/bin/prime +1 -1
- data/files/Gemfile +1 -1
- data/motion-prime/api_client.rb +87 -31
- data/motion-prime/config/base.rb +20 -11
- data/motion-prime/config/config.rb +9 -3
- data/motion-prime/core_ext/kernel.rb +2 -1
- data/motion-prime/core_ext/nil_class.rb +5 -0
- data/motion-prime/delegate/app_delegate.rb +5 -0
- data/motion-prime/elements/base_element.rb +21 -2
- data/motion-prime/elements/draw.rb +6 -16
- data/motion-prime/helpers/has_authorization.rb +1 -1
- data/motion-prime/models/_base_mixin.rb +1 -1
- data/motion-prime/prime.rb +4 -0
- data/motion-prime/screens/extensions/_indicators_mixin.rb +16 -10
- data/motion-prime/screens/screen.rb +1 -1
- data/motion-prime/sections/_async_table_mixin.rb +1 -2
- data/motion-prime/sections/_draw_section_mixin.rb +3 -1
- data/motion-prime/sections/base_section.rb +37 -26
- data/motion-prime/sections/form.rb +23 -8
- data/motion-prime/sections/form/base_field_section.rb +1 -15
- data/motion-prime/sections/form/date_field_section.rb +1 -1
- data/motion-prime/sections/form/password_field_section.rb +1 -1
- data/motion-prime/sections/form/select_field_section.rb +1 -1
- data/motion-prime/sections/form/string_field_section.rb +1 -1
- data/motion-prime/sections/form/submit_field_section.rb +1 -1
- data/motion-prime/sections/form/text_field_section.rb +1 -1
- data/motion-prime/sections/table.rb +58 -27
- data/motion-prime/sections/table/refresh_mixin.rb +1 -1
- data/motion-prime/services/logger.rb +60 -21
- data/motion-prime/support/consts.rb +11 -0
- data/motion-prime/version.rb +1 -1
- data/motion-prime/views/layout.rb +5 -4
- data/motion-prime/views/view_styler.rb +3 -0
- data/spec/{helpers → factories}/delegates.rb +0 -3
- data/spec/{helpers → factories}/init.rb +0 -0
- data/spec/{helpers → factories}/models.rb +0 -0
- data/spec/factories/scaffold/models/task.rb +4 -0
- data/spec/factories/scaffold/screens/tasks.rb +45 -0
- data/spec/factories/scaffold/sections/tasks/form.rb +31 -0
- data/spec/factories/scaffold/sections/tasks/index_cell.rb +4 -0
- data/spec/factories/scaffold/sections/tasks/index_table.rb +12 -0
- data/spec/factories/scaffold/sections/tasks/show.rb +3 -0
- data/spec/factories/scaffold/styles/tasks.rb +18 -0
- data/spec/{helpers → factories}/screens.rb +0 -0
- data/spec/factories/sections.rb +9 -0
- data/spec/features/scaffold/index.rb +14 -0
- data/spec/features/screens/open_screen.rb +14 -2
- data/spec/helpers/has_content.rb +25 -0
- data/spec/unit/models/dirty_spec.rb +0 -1
- data/spec/unit/models/model_spec.rb +2 -0
- data/spec/unit/prime/logger.rb +49 -0
- data/spec/unit/sections/section_spec.rb +59 -0
- data/travis.sh +1 -1
- metadata +36 -41
- data/doc/FAQ.md +0 -2
- data/doc/SECTION.md +0 -7
- data/doc/STYLE.md +0 -39
- data/doc/code/getting_started.rb +0 -106
- data/doc/code/models.rb +0 -36
- data/doc/code/screens.rb +0 -93
- data/doc/code/sections.rb +0 -65
- data/doc/code/tables.rb +0 -54
- data/doc/docs/docco.css +0 -337
- data/doc/docs/getting_started.html +0 -195
- data/doc/docs/index.html +0 -205
- data/doc/docs/models.html +0 -115
- data/doc/docs/public/fonts/aller-bold.eot +0 -0
- data/doc/docs/public/fonts/aller-bold.ttf +0 -0
- data/doc/docs/public/fonts/aller-bold.woff +0 -0
- data/doc/docs/public/fonts/aller-light.eot +0 -0
- data/doc/docs/public/fonts/aller-light.ttf +0 -0
- data/doc/docs/public/fonts/aller-light.woff +0 -0
- data/doc/docs/public/fonts/fleurons.eot +0 -0
- data/doc/docs/public/fonts/fleurons.ttf +0 -0
- data/doc/docs/public/fonts/fleurons.woff +0 -0
- data/doc/docs/public/fonts/novecento-bold.eot +0 -0
- data/doc/docs/public/fonts/novecento-bold.ttf +0 -0
- data/doc/docs/public/fonts/novecento-bold.woff +0 -0
- data/doc/docs/public/images/gray.png +0 -0
- data/doc/docs/public/stylesheets/normalize.css +0 -375
- data/doc/docs/screens.html +0 -187
- data/doc/docs/sections.html +0 -138
- data/doc/docs/tables.html +0 -128
- data/spec/helpers/sections.rb +0 -3
@@ -0,0 +1,31 @@
|
|
1
|
+
class TasksFormSection < Prime::FormSection
|
2
|
+
field :title,
|
3
|
+
label: { text: 'Title' },
|
4
|
+
input: {
|
5
|
+
text: proc { model.title },
|
6
|
+
placeholder: "Enter title here"
|
7
|
+
}
|
8
|
+
|
9
|
+
field :delete, type: :submit,
|
10
|
+
button: {
|
11
|
+
title: "Delete",
|
12
|
+
background_color: :red
|
13
|
+
},
|
14
|
+
action: :on_delete,
|
15
|
+
if: proc { model.persisted? }
|
16
|
+
|
17
|
+
field :submit, type: :submit,
|
18
|
+
button: { title: "Save" },
|
19
|
+
action: :on_submit
|
20
|
+
|
21
|
+
def on_delete
|
22
|
+
model.delete
|
23
|
+
screen.close_screen(to_root: true)
|
24
|
+
end
|
25
|
+
|
26
|
+
def on_submit
|
27
|
+
model.assign_attributes(field_values)
|
28
|
+
model.save
|
29
|
+
screen.close_screen
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class TasksIndexTableSection < Prime::TableSection
|
2
|
+
def table_data
|
3
|
+
Task.all.map do |model|
|
4
|
+
TasksIndexCellSection.new(model: model)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def on_click(table, index)
|
9
|
+
section = data[index.row]
|
10
|
+
screen.open_screen 'tasks#show', params: { model: section.model }
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Prime::Styles.define :tasks do
|
2
|
+
style :index do
|
3
|
+
style :cell_title,
|
4
|
+
text_color: :app_base,
|
5
|
+
left: 20,
|
6
|
+
top: 10,
|
7
|
+
width: 280,
|
8
|
+
font: :app_base.uifont(16),
|
9
|
+
height: 20
|
10
|
+
end
|
11
|
+
style :show do
|
12
|
+
style :title,
|
13
|
+
top: 120,
|
14
|
+
left: 0,
|
15
|
+
right: 0,
|
16
|
+
text_alignment: :center
|
17
|
+
end
|
18
|
+
end
|
File without changes
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class SampleViewSection < Prime::Section
|
2
|
+
element :description, text: "Lorem Ipsum", as: :view
|
3
|
+
end
|
4
|
+
class SampleDrawSection < Prime::Section
|
5
|
+
element :description, text: "Lorem Ipsum", as: :draw
|
6
|
+
end
|
7
|
+
class SampleSection < Prime::Section
|
8
|
+
element :description, text: "Lorem Ipsum"
|
9
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
describe "scaffold index" do
|
2
|
+
before do
|
3
|
+
5.times do |index|
|
4
|
+
Task.create(title: "Task #{index}")
|
5
|
+
end
|
6
|
+
App.delegate.open_screen 'tasks#index'
|
7
|
+
@controller = App.delegate.content_controller.childViewControllers.last
|
8
|
+
end
|
9
|
+
it "should render tasks list" do
|
10
|
+
wait 0.3 do
|
11
|
+
@controller.has_content?("Task 2").should.be.true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -2,7 +2,7 @@ describe "open screen" do
|
|
2
2
|
describe "from app delegate with default options" do
|
3
3
|
before do
|
4
4
|
App.delegate.open_screen :sample
|
5
|
-
@controller = App.delegate.
|
5
|
+
@controller = App.delegate.content_controller
|
6
6
|
end
|
7
7
|
it "should open with navigation by default" do
|
8
8
|
@controller.is_a?(UINavigationController).should.be.true
|
@@ -25,6 +25,18 @@ describe "open screen" do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
describe "from app delegate with action" do
|
29
|
+
before do
|
30
|
+
App.delegate.open_screen 'tasks#new'
|
31
|
+
@controller = App.delegate.content_controller.childViewControllers.last
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should open screen with action" do
|
35
|
+
@controller.is_a?(TasksScreen).should.be.true
|
36
|
+
@controller.title.should == 'New Task'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
28
40
|
describe "from another screen with navigation: true" do
|
29
41
|
before do
|
30
42
|
@parent_screen = SampleScreen.new(navigation: true)
|
@@ -32,7 +44,7 @@ describe "open screen" do
|
|
32
44
|
|
33
45
|
App.delegate.open_screen @parent_screen
|
34
46
|
@parent_screen.open_screen @child_screen
|
35
|
-
@controller = App.delegate.
|
47
|
+
@controller = App.delegate.content_controller
|
36
48
|
|
37
49
|
# we should call it because will_appear will happen async
|
38
50
|
@child_screen.will_appear
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class MotionPrime::BaseElement
|
2
|
+
def has_content?(content)
|
3
|
+
text = computed_options[:text] || computed_options[:title] || ''
|
4
|
+
!!text.match(content)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
class MotionPrime::Section
|
8
|
+
def has_content?(content)
|
9
|
+
self.elements.values.any? do |element|
|
10
|
+
element.has_content?(content)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
class MotionPrime::TableSection
|
15
|
+
def has_content?(content)
|
16
|
+
data.any? do |section|
|
17
|
+
section.has_content?(content)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
class MotionPrime::Screen
|
22
|
+
def has_content?(content)
|
23
|
+
main_section.has_content?(content)
|
24
|
+
end
|
25
|
+
end
|
@@ -50,6 +50,7 @@ describe MotionPrime::Model do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it "creates model when invalid parameter and validate_attribute_presence=false" do
|
53
|
+
Prime.logger.disabled = true
|
53
54
|
user = User.new({
|
54
55
|
name: "Eddie",
|
55
56
|
age: 12,
|
@@ -57,6 +58,7 @@ describe MotionPrime::Model do
|
|
57
58
|
gender: "m",
|
58
59
|
})
|
59
60
|
user.name.should == "Eddie"
|
61
|
+
Prime.logger.disabled = false
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
describe "Prime.env" do
|
2
|
+
|
3
|
+
before do
|
4
|
+
@logger = Prime::Logger.new
|
5
|
+
@logger.stub!(:output) do |message|
|
6
|
+
message
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should work' do
|
11
|
+
@logger.log("Hello world").should == 'Hello world'
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "error level" do
|
15
|
+
before { Prime::Logger.level = :error }
|
16
|
+
|
17
|
+
it 'should log errors' do
|
18
|
+
@logger.error("message").should == ["message"]
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should not log info' do
|
22
|
+
@logger.info("message").should == nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "info level" do
|
27
|
+
before { Prime::Logger.level = :info }
|
28
|
+
|
29
|
+
it 'should log info' do
|
30
|
+
@logger.info("message").should == ["message"]
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should not log debug' do
|
34
|
+
@logger.debug("message").should == nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "debug level" do
|
39
|
+
before { Prime::Logger.level = :debug }
|
40
|
+
|
41
|
+
it 'should log debug' do
|
42
|
+
@logger.debug("message").should == ["message"]
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should not log dealloc' do
|
46
|
+
@logger.dealloc_message("message", Prime::Section.new).should == nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
describe MotionPrime::Section do
|
2
|
+
|
3
|
+
describe "general" do
|
4
|
+
before do
|
5
|
+
@section = SampleSection.new(screen: @screen)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#name" do
|
9
|
+
it "should use class name by default" do
|
10
|
+
@section.name.should == 'sample'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should use given name" do
|
14
|
+
section = SampleSection.new(name: 'my_section')
|
15
|
+
section.name.should == 'my_section'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "base section" do
|
21
|
+
before do
|
22
|
+
@screen = BaseScreen.new
|
23
|
+
@section = SampleViewSection.new(screen: @screen)
|
24
|
+
@section.render
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#element" do
|
28
|
+
it "should return element by name" do
|
29
|
+
@section.element(:description).is_a?(MotionPrime::BaseElement).should.be.true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#view" do
|
34
|
+
it "should return view by element name" do
|
35
|
+
@section.view(:description).is_a?(MPLabel).should.be.true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "draw section" do
|
41
|
+
before do
|
42
|
+
@screen = BaseScreen.new
|
43
|
+
@section = SampleDrawSection.new(screen: @screen)
|
44
|
+
@section.render
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#element" do
|
48
|
+
it "should return element by name" do
|
49
|
+
@section.element(:description).is_a?(MotionPrime::DrawElement).should.be.true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#view" do
|
54
|
+
it "should return container view by element name" do
|
55
|
+
@section.view(:description).is_a?(MPViewWithSection).should.be.true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/travis.sh
CHANGED
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.
|
4
|
+
version: 0.9.7
|
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-
|
12
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -226,35 +226,6 @@ files:
|
|
226
226
|
- Rakefile
|
227
227
|
- app/app_delegate.rb
|
228
228
|
- bin/prime
|
229
|
-
- doc/FAQ.md
|
230
|
-
- doc/SECTION.md
|
231
|
-
- doc/STYLE.md
|
232
|
-
- doc/code/getting_started.rb
|
233
|
-
- doc/code/models.rb
|
234
|
-
- doc/code/screens.rb
|
235
|
-
- doc/code/sections.rb
|
236
|
-
- doc/code/tables.rb
|
237
|
-
- doc/docs/docco.css
|
238
|
-
- doc/docs/getting_started.html
|
239
|
-
- doc/docs/index.html
|
240
|
-
- doc/docs/models.html
|
241
|
-
- doc/docs/public/fonts/aller-bold.eot
|
242
|
-
- doc/docs/public/fonts/aller-bold.ttf
|
243
|
-
- doc/docs/public/fonts/aller-bold.woff
|
244
|
-
- doc/docs/public/fonts/aller-light.eot
|
245
|
-
- doc/docs/public/fonts/aller-light.ttf
|
246
|
-
- doc/docs/public/fonts/aller-light.woff
|
247
|
-
- doc/docs/public/fonts/fleurons.eot
|
248
|
-
- doc/docs/public/fonts/fleurons.ttf
|
249
|
-
- doc/docs/public/fonts/fleurons.woff
|
250
|
-
- doc/docs/public/fonts/novecento-bold.eot
|
251
|
-
- doc/docs/public/fonts/novecento-bold.ttf
|
252
|
-
- doc/docs/public/fonts/novecento-bold.woff
|
253
|
-
- doc/docs/public/images/gray.png
|
254
|
-
- doc/docs/public/stylesheets/normalize.css
|
255
|
-
- doc/docs/screens.html
|
256
|
-
- doc/docs/sections.html
|
257
|
-
- doc/docs/tables.html
|
258
229
|
- files/Gemfile
|
259
230
|
- files/Rakefile
|
260
231
|
- files/app/app_delegate.rb
|
@@ -290,6 +261,7 @@ files:
|
|
290
261
|
- motion-prime/config/base.rb
|
291
262
|
- motion-prime/config/config.rb
|
292
263
|
- motion-prime/core_ext/kernel.rb
|
264
|
+
- motion-prime/core_ext/nil_class.rb
|
293
265
|
- motion-prime/core_ext/time.rb
|
294
266
|
- motion-prime/delegate/_base_mixin.rb
|
295
267
|
- motion-prime/delegate/_navigation_mixin.rb
|
@@ -382,6 +354,7 @@ files:
|
|
382
354
|
- motion-prime/styles/form.rb
|
383
355
|
- motion-prime/support/_key_value_store.rb
|
384
356
|
- motion-prime/support/_padding_attribute.rb
|
357
|
+
- motion-prime/support/consts.rb
|
385
358
|
- motion-prime/support/mp_button.rb
|
386
359
|
- motion-prime/support/mp_cell_content_view.rb
|
387
360
|
- motion-prime/support/mp_cell_with_section.rb
|
@@ -404,12 +377,21 @@ files:
|
|
404
377
|
- motion-prime/views/view_styler.rb
|
405
378
|
- resources/Default-568h@2x.png
|
406
379
|
- resources/Icon.png
|
380
|
+
- spec/factories/delegates.rb
|
381
|
+
- spec/factories/init.rb
|
382
|
+
- spec/factories/models.rb
|
383
|
+
- spec/factories/scaffold/models/task.rb
|
384
|
+
- spec/factories/scaffold/screens/tasks.rb
|
385
|
+
- spec/factories/scaffold/sections/tasks/form.rb
|
386
|
+
- spec/factories/scaffold/sections/tasks/index_cell.rb
|
387
|
+
- spec/factories/scaffold/sections/tasks/index_table.rb
|
388
|
+
- spec/factories/scaffold/sections/tasks/show.rb
|
389
|
+
- spec/factories/scaffold/styles/tasks.rb
|
390
|
+
- spec/factories/screens.rb
|
391
|
+
- spec/factories/sections.rb
|
392
|
+
- spec/features/scaffold/index.rb
|
407
393
|
- spec/features/screens/open_screen.rb
|
408
|
-
- spec/helpers/
|
409
|
-
- spec/helpers/init.rb
|
410
|
-
- spec/helpers/models.rb
|
411
|
-
- spec/helpers/screens.rb
|
412
|
-
- spec/helpers/sections.rb
|
394
|
+
- spec/helpers/has_content.rb
|
413
395
|
- spec/unit/config/store_spec.rb
|
414
396
|
- spec/unit/delegate/delegate_spec.rb
|
415
397
|
- spec/unit/models/association_collection_spec.rb
|
@@ -423,7 +405,9 @@ files:
|
|
423
405
|
- spec/unit/models/store_extension_spec.rb
|
424
406
|
- spec/unit/models/store_spec.rb
|
425
407
|
- spec/unit/prime/env.rb
|
408
|
+
- spec/unit/prime/logger.rb
|
426
409
|
- spec/unit/screens/screen_spec.rb
|
410
|
+
- spec/unit/sections/section_spec.rb
|
427
411
|
- travis.sh
|
428
412
|
homepage: ''
|
429
413
|
licenses:
|
@@ -450,12 +434,21 @@ signing_key:
|
|
450
434
|
specification_version: 4
|
451
435
|
summary: RubyMotion apps development framework
|
452
436
|
test_files:
|
437
|
+
- spec/factories/delegates.rb
|
438
|
+
- spec/factories/init.rb
|
439
|
+
- spec/factories/models.rb
|
440
|
+
- spec/factories/scaffold/models/task.rb
|
441
|
+
- spec/factories/scaffold/screens/tasks.rb
|
442
|
+
- spec/factories/scaffold/sections/tasks/form.rb
|
443
|
+
- spec/factories/scaffold/sections/tasks/index_cell.rb
|
444
|
+
- spec/factories/scaffold/sections/tasks/index_table.rb
|
445
|
+
- spec/factories/scaffold/sections/tasks/show.rb
|
446
|
+
- spec/factories/scaffold/styles/tasks.rb
|
447
|
+
- spec/factories/screens.rb
|
448
|
+
- spec/factories/sections.rb
|
449
|
+
- spec/features/scaffold/index.rb
|
453
450
|
- spec/features/screens/open_screen.rb
|
454
|
-
- spec/helpers/
|
455
|
-
- spec/helpers/init.rb
|
456
|
-
- spec/helpers/models.rb
|
457
|
-
- spec/helpers/screens.rb
|
458
|
-
- spec/helpers/sections.rb
|
451
|
+
- spec/helpers/has_content.rb
|
459
452
|
- spec/unit/config/store_spec.rb
|
460
453
|
- spec/unit/delegate/delegate_spec.rb
|
461
454
|
- spec/unit/models/association_collection_spec.rb
|
@@ -469,4 +462,6 @@ test_files:
|
|
469
462
|
- spec/unit/models/store_extension_spec.rb
|
470
463
|
- spec/unit/models/store_spec.rb
|
471
464
|
- spec/unit/prime/env.rb
|
465
|
+
- spec/unit/prime/logger.rb
|
472
466
|
- spec/unit/screens/screen_spec.rb
|
467
|
+
- spec/unit/sections/section_spec.rb
|