motion-prime 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDU3YTA1M2Q5YjkyMDM0OTcwNDlkNWUxNDIwM2MwY2I3NWY0NjY3Nw==
4
+ ZWVkMTljOTZkZDI3YThhODdjZGU3OWU4NWE1MzU2ZDY2ZmU1YTY2YQ==
5
5
  data.tar.gz: !binary |-
6
- NDdkNTIwOTc5ZDA0NmJmY2JiN2RlMmZiMWVjMzkxYmUwNTI0YTc3MQ==
6
+ ZjExNDBjZmEwZWQ4MWU3NmE5MGJhNmVkNDVmMWUyYmNkN2E3M2JmMg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MmQ2OGQ0Y2M0NzFkMDZlMmM4ODZmMTlkMGNiODczNWQwZGE5YmQxOTM2MjM0
10
- ZmM1MWNlNzVlZmQ5NzgwN2QxM2IyMDc2MTQzYjY5M2FiOTg4N2I2MDkyNzUx
11
- NTU5MmNmMTZhZGE4MWM1ZjY5MGUyZmQxM2Y1NjZiMmRiYWIwMjQ=
9
+ YWE1ZDk0YjZhZTZmYTA0ODg5NzIwYTBjZmU5NzA5OWM4YzVmMzZhOGQzODI1
10
+ ZDkwNGRhYmE0YjA3NmYyMjBiMzYzZThlMjQyYjVhZGQ4YzAwN2QzOTZiZmE3
11
+ MTJhMjIwYzBjMDYzOTRkNWIzYmE4YWRhNmI3ZTAwNWY2NmEzNWQ=
12
12
  data.tar.gz: !binary |-
13
- MWMxM2RiMjM5M2QyZWVjNWNmOWU4ZjI3MGM3ZmM4OWQ4YmIwZDFhMzU1MTQ0
14
- ZjgzYjg1NjY5ZGExNmQ0MTU4NDhmYzI4NzQ4MzlkNTk2ZDRmZTIwNTdjOGJi
15
- Y2MyNzg5ZDM4Nzg4MzUyNGU5YTBkMWY0YzNiZDViNWMzMDRhNWM=
13
+ ZTgzMDY0MjA4MGJjYmYxMTA4NDYzOGQ2NTI1MTgzOGNiZTNiMmFkMTA4NWQ5
14
+ MTkyYzQ1OTIwMGM2ODliZTkwZTYwMTNiZjJkYTE3NzliZDhiNzQwZTM2MjFk
15
+ NjQ4NTA0YTExMmVhYjNiNGNhNjY2MmM2OTllMGEwMWE1Y2QxNTQ=
data/.gitignore CHANGED
@@ -6,6 +6,7 @@ resources/*.nib
6
6
  resources/*.momd
7
7
  resources/*.storyboardc
8
8
  files/vendor/
9
+ files/.repl_history
9
10
  .DS_Store
10
11
  nbproject
11
12
  .redcar
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ === 0.5.1
2
+ * configurations and style definitions runs in correct order.
3
+
1
4
  === 0.5.0
2
5
  * renamed Prime::BaseModel to Prime::Model.
3
6
  * renamed Prime::BaseScreen to Prime::Screen.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- motion-prime (0.5.0)
4
+ motion-prime (0.5.1)
5
5
  bubble-wrap
6
6
  cocoapods
7
7
  methadone
data/README.md CHANGED
@@ -14,7 +14,12 @@ MotionPrime is yet another framework written on RubyMotion for creating really f
14
14
 
15
15
  $ prime new myapp
16
16
 
17
- ### 3. Run application
17
+ ### 3. Setup application
18
+
19
+ $ bundle install
20
+ $ rake pod:install
21
+
22
+ ### 4. Run application
18
23
 
19
24
  $ rake
20
25
 
data/ROADMAP.md CHANGED
@@ -1,10 +1,10 @@
1
1
  === 0.6.0
2
- * add configuration initializer.
3
2
  * add cleanup for section events
4
3
  * add computed_options.get(), this will allow to make sure that options is computed.
5
4
  * add dsl for push notifications
6
5
  * add some extensions/middleware system, at least for networking.
7
6
  * create "display_network_error" extension.
7
+ * add different templates. some templates should be more like final app.
8
8
 
9
9
  === 0.7.0
10
10
  * add testing framework
data/Rakefile CHANGED
@@ -21,12 +21,4 @@ require 'motion-redgreen'
21
21
 
22
22
  Motion::Project::App.setup do |app|
23
23
  app.name = 'Prime'
24
- app.pods do
25
- pod 'NanoStore', '~> 2.7.7'
26
- pod 'SDWebImage'
27
- pod 'SVPullToRefresh'
28
- pod 'MBAlertView'
29
- pod 'RESideMenu', git: 'https://github.com/feklistov/RESideMenu.git'
30
- pod 'MBProgressHUD', '~> 0.8'
31
- end
32
24
  end
data/files/Gemfile CHANGED
@@ -5,10 +5,10 @@ gem 'motion-support', '~> 0.2.4'
5
5
  gem 'sugarcube', '~> 1.3.7', require: 'sugarcube-classic'
6
6
  gem 'bubble-wrap', '~> 1.3.0'
7
7
 
8
- gem 'motion-prime', '~> 0.5.0.beta', path: '../'
8
+ gem 'motion-prime', '~> 0.5.0', path: '../'
9
9
 
10
10
  # add reside menu for sidebar support
11
- gem 'prime_reside_menu', '~> 0.1.0'
11
+ gem 'prime_reside_menu', '~> 0.1.3'
12
12
 
13
13
  # or add sliding menu for sidebar support
14
14
  # gem 'prime_sliding_menu', '~> 0.1.0'
data/files/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- motion-prime (0.5.0.beta)
4
+ motion-prime (0.5.0)
5
5
  bubble-wrap
6
6
  cocoapods
7
7
  methadone
@@ -50,7 +50,7 @@ GEM
50
50
  multi_json (1.8.2)
51
51
  nap (0.6.0)
52
52
  open4 (1.3.0)
53
- prime_reside_menu (0.1.0)
53
+ prime_reside_menu (0.1.3)
54
54
  cocoapods
55
55
  motion-cocoapods
56
56
  motion-require
@@ -67,7 +67,7 @@ PLATFORMS
67
67
  DEPENDENCIES
68
68
  bubble-wrap (~> 1.3.0)
69
69
  motion-cocoapods (~> 1.4.0)
70
- motion-prime (~> 0.5.0.beta)!
70
+ motion-prime (~> 0.5.0)!
71
71
  motion-support (~> 0.2.4)
72
- prime_reside_menu (~> 0.1.0)
72
+ prime_reside_menu (~> 0.1.3)
73
73
  sugarcube (~> 1.3.7)
data/files/Rakefile CHANGED
@@ -5,8 +5,6 @@ require "rubygems"
5
5
  require 'motion-cocoapods'
6
6
  require 'bundler'
7
7
  Bundler.require
8
- require 'sugarcube-common'
9
- require 'bubble-wrap/reactor'
10
8
  require 'motion-prime'
11
9
 
12
10
  Motion::Project::App.setup do |app|
@@ -6,7 +6,7 @@ class AppDelegate < Prime::BaseAppDelegate
6
6
 
7
7
  def setup_navigation_styles
8
8
  bar_appearance = UINavigationBar.appearance
9
- bar_appearance.barTintColor = Prime::Config.color.dark.uicolor
9
+ bar_appearance.barTintColor = :app_dark.uicolor
10
10
 
11
11
  settings = {
12
12
  UITextAttributeFont => Prime::Config.font.name.uifont(17),
@@ -1,15 +1,14 @@
1
- Prime::Config.color do |color|
2
- color.base = 0x3aa9b6
3
- color.dark = 0x41929c
4
- end
1
+ Prime::Config.configure do |config|
2
+ config.colors do |colors|
3
+ colors.base = 0x3aa9b6
4
+ colors.dark = 0x41929c
5
+ end
5
6
 
6
- Prime::Config.api do |api|
7
- api.base = "http://example.com"
8
- api.client_id = ""
9
- api.client_secret = ""
10
- end
7
+ config.font.name = "Ubuntu"
11
8
 
12
- Prime::Config.font.name = "Ubuntu"
13
-
14
- # setup model's store
15
- Prime::Store.connect
9
+ config.api do |api|
10
+ api.base = "http://example.com"
11
+ api.client_id = ""
12
+ api.client_secret = ""
13
+ end
14
+ end
@@ -1,10 +1,5 @@
1
1
  module MotionPrime
2
- def self.env
3
- ENV['PRIME_ENV'] || ENV['RUBYMOTION_ENV'] || 'development'
4
- end
5
-
6
2
  def self.root
7
3
  File.expand_path File.dirname(__FILE__) + '/../'
8
4
  end
9
- end
10
- ::Prime = MotionPrime unless defined?(::Prime)
5
+ end
Binary file
data/lib/motion-prime.rb CHANGED
@@ -1,4 +1,10 @@
1
1
  require 'motion-require'
2
+ require 'motion-support'
3
+ require 'sugarcube-common'
4
+ require 'bubble-wrap'
5
+ require 'bubble-wrap/reactor'
6
+ require File.expand_path('../../motion-prime/env.rb', __FILE__)
7
+ require File.expand_path('../../motion-prime/prime.rb', __FILE__)
2
8
 
3
9
  Motion::Require.all(Dir.glob(File.expand_path('../../motion-prime/**/*.rb', __FILE__)))
4
10
 
@@ -7,6 +7,9 @@ module MotionPrime
7
7
  attr_accessor :window
8
8
 
9
9
  def application(application, willFinishLaunchingWithOptions:opts)
10
+ MotionPrime::Config.configure!
11
+ MotionPrime::Styles.define!
12
+ Prime.logger.info "Loading Prime application with env: #{Prime.env}"
10
13
  application.setStatusBarStyle UIStatusBarStyleLightContent
11
14
  application.setStatusBarHidden false
12
15
  end
@@ -1,21 +1,18 @@
1
1
  motion_require './config.rb'
2
- MotionPrime::Config.model do |model|
3
- if RUBYMOTION_ENV == 'test'
4
- model.store_type = :memory
2
+ MotionPrime::Config.configure do |config|
3
+ if MotionPrime.env.test?
4
+ config.model.store_type = :memory
5
5
  else
6
- model.store_type = :file
6
+ config.model.store_type = :file
7
+ end
8
+ config.font.name = "Ubuntu"
9
+ config.colors do |colors|
10
+ colors.base = 0x424242
11
+ colors.error = 0xef471f
12
+ end
13
+ config.api do |api|
14
+ api.base = "http://example.com"
15
+ api.client_id = ""
16
+ api.client_secret = ""
7
17
  end
8
- end
9
- MotionPrime::Config.font.name = "Ubuntu"
10
- MotionPrime::Config.color do |color|
11
- color.base = 0x424242
12
- color.error = 0xef471f
13
- end
14
- MotionPrime::Config.sidebar do |sidebar|
15
- sidebar.background_image = "images/sidebar/background.png".uiimage
16
- end
17
- MotionPrime::Config.api do |api|
18
- api.base = "http://example.com"
19
- api.client_id = ""
20
- api.client_secret = ""
21
18
  end
@@ -22,6 +22,10 @@ module MotionPrime
22
22
  end
23
23
  alias :blank? :nil?
24
24
 
25
+ def present?
26
+ !blank?
27
+ end
28
+
25
29
  def has_key?(key)
26
30
  !self[key].is_a?(self.class)
27
31
  end
@@ -35,6 +39,39 @@ module MotionPrime
35
39
  @base_config ||= self.new()
36
40
  @base_config.send(name.to_sym, *args, &block)
37
41
  end
42
+
43
+ def configure(&block)
44
+ @configure_blocks ||= []
45
+ @configure_blocks << block
46
+ end
47
+
48
+ def configure!
49
+ @configure_blocks ||= []
50
+ @base_config ||= self.new()
51
+ @configure_blocks.each do |block|
52
+ block.call(@base_config)
53
+ end
54
+ setup_models
55
+ setup_colors
56
+ end
57
+
58
+ def setup_models
59
+ MotionPrime::Store.connect
60
+ end
61
+
62
+ def setup_colors
63
+ return unless @base_config
64
+ colors = @base_config.colors.to_hash.inject({}) do |res, (color, value)|
65
+ unless color == :prefix
66
+ unless @base_config.colors.prefix.nil?
67
+ res[:"#{@base_config.colors.prefix}_#{color}"] = value
68
+ end
69
+ res[:"app_#{color}"] = value
70
+ end
71
+ res
72
+ end
73
+ Symbol.css_colors.merge!(colors)
74
+ end
38
75
  end
39
76
 
40
77
  def method_missing(name, *args, &block)
@@ -42,10 +79,13 @@ module MotionPrime
42
79
  yield self[name]
43
80
  else
44
81
  name = name.to_s
45
- if /(.+)=$/.match(name)
46
- return store($1, args[0])
82
+ if /(.+)\=$/.match(name)
83
+ store($1, args[0])
84
+ elsif /(.+)\?$/.match(name)
85
+ value = self[$1]
86
+ value.present? && !!value
47
87
  else
48
- return self[name]
88
+ self[name]
49
89
  end
50
90
  end
51
91
  end
@@ -1,6 +1,6 @@
1
1
  class Kernel
2
2
  def pp(*attrs)
3
- NSLog([*attrs].map(&:inspect).join(' ') + ' ' + self.class.to_s)
3
+ NSLog([*attrs].map(&:inspect).join(' '))
4
4
  end
5
5
 
6
6
  def class_name_without_kvo
@@ -0,0 +1,25 @@
1
+ module MotionPrime
2
+ class Env
3
+ def env
4
+ ENV['PRIME_ENV'] || ENV['RUBYMOTION_ENV'] ||
5
+ (defined?(RUBYMOTION_ENV) && RUBYMOTION_ENV) ||
6
+ 'development'
7
+ end
8
+
9
+ def to_s
10
+ env
11
+ end
12
+
13
+ def inspect
14
+ env
15
+ end
16
+
17
+ def method_missing(name, *args, &block)
18
+ if /(.+)?$/.match(name.to_s)
19
+ env == name.to_s.gsub('?', '')
20
+ else
21
+ false
22
+ end
23
+ end
24
+ end
25
+ end
@@ -12,7 +12,11 @@ module MotionPrime
12
12
  end
13
13
 
14
14
  def self.env
15
- ENV['PRIME_ENV'] || ENV['RUBYMOTION_ENV'] || 'development'
15
+ @env ||= MotionPrime::Env.new
16
+ end
17
+
18
+ def self.logger
19
+ @logger ||= MotionPrime::Logger.new
16
20
  end
17
21
  end
18
22
  ::Prime = MotionPrime unless defined?(::Prime)
@@ -6,31 +6,33 @@ module MotionPrime
6
6
 
7
7
  class_attribute :level
8
8
 
9
- class << self
10
- def error(*args)
11
- pp(*args) if LOGGER_ERROR_LEVEL <= current_level
12
- end
9
+ def initialize
10
+ @default_level = Config.logger.level.nil? ? :info : Config.logger.level
11
+ end
13
12
 
14
- def info(*args)
15
- pp(*args) if LOGGER_INFO_LEVEL <= current_level
16
- end
13
+ def error(*args)
14
+ pp(*args) if LOGGER_ERROR_LEVEL <= current_level
15
+ end
17
16
 
18
- def debug(*args)
19
- pp(*args) if LOGGER_DEBUG_LEVEL <= current_level
20
- end
17
+ def info(*args)
18
+ pp(*args) if LOGGER_INFO_LEVEL <= current_level
19
+ end
20
+
21
+ def debug(*args)
22
+ pp(*args) if LOGGER_DEBUG_LEVEL <= current_level
23
+ end
21
24
 
22
- def current_level
23
- current_level = self.level || (Config.logger.level.nil? ? :info : Config.logger.level)
24
- case current_level.to_s
25
- when 'error'
26
- LOGGER_ERROR_LEVEL
27
- when 'info'
28
- LOGGER_INFO_LEVEL
29
- when 'debug'
30
- LOGGER_DEBUG_LEVE
31
- else
32
- 2
33
- end
25
+ def current_level
26
+ current_level = self.class.level || @default_level
27
+ case current_level.to_s
28
+ when 'error'
29
+ LOGGER_ERROR_LEVEL
30
+ when 'info'
31
+ LOGGER_INFO_LEVEL
32
+ when 'debug'
33
+ LOGGER_DEBUG_LEVE
34
+ else
35
+ 2
34
36
  end
35
37
  end
36
38
  end
@@ -41,7 +41,7 @@ MotionPrime::Styles.define :base_form do
41
41
  line_break_mode: :word_wrap,
42
42
  number_of_lines: 0,
43
43
  size_to_fit: true,
44
- text_color: proc { MotionPrime::Config.color.error },
44
+ text_color: :app_error,
45
45
  font: proc { MotionPrime::Config.font.name.uifont(12) }
46
46
 
47
47
  # available options for input:
@@ -105,9 +105,9 @@ MotionPrime::Styles.define :base_form do
105
105
 
106
106
  style :field_input_with_errors,
107
107
  layer: {
108
- border_color: proc { MotionPrime::Config.color.error }
108
+ border_color: :app_error
109
109
  },
110
- text_color: proc { MotionPrime::Config.color.error }
110
+ text_color: :app_error
111
111
 
112
112
  style :switch_field_input,
113
113
  top: 10,
@@ -1,13 +1,13 @@
1
1
  Prime::Styles.define :sidebar do
2
2
  style :screen,
3
- background_color: proc { Prime::Config.color.dark }
3
+ background_color: :app_dark
4
4
 
5
5
  style :table,
6
6
  top: 150,
7
7
  left: 0,
8
8
  width: 320,
9
9
  bottom: 0,
10
- background_color: proc { Prime::Config.color.dark },
10
+ background_color: :app_dark,
11
11
  separator_color: :clear
12
12
 
13
13
  style :table_cell,
@@ -20,4 +20,4 @@ Prime::Styles.define :sidebar do
20
20
  width: 320,
21
21
  font: proc { :system.uifont(20) },
22
22
  size_to_fit: true
23
- end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module MotionPrime
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -39,8 +39,21 @@ module MotionPrime
39
39
  include HasNormalizer
40
40
 
41
41
  def define(*namespaces, &block)
42
- Array.wrap(namespaces).each do |namespace|
43
- self.new(namespace).instance_eval(&block)
42
+ @definition_blocks ||= []
43
+ namespaces = Array.wrap(namespaces)
44
+ if namespaces.any?
45
+ namespaces.each do |namespace|
46
+ @definition_blocks << {namespace: namespace, block: block}
47
+ end
48
+ else
49
+ @definition_blocks << {namespace: false, block: block}
50
+ end
51
+ end
52
+
53
+ def define!
54
+ @definition_blocks.each do |definition|
55
+ block = definition[:block]
56
+ self.new(definition[:namespace]).instance_eval(&block)
44
57
  end
45
58
  end
46
59
 
@@ -35,6 +35,22 @@ describe MotionPrime::Config do
35
35
  end
36
36
  end
37
37
 
38
+ describe ":key_name?" do
39
+ it "returns true if there is value and it's not false" do
40
+ @config.foo = true
41
+ @config.foo?.should == true
42
+ end
43
+
44
+ it "returns false if there is value and it's false" do
45
+ @config.foo = false
46
+ @config.foo?.should == false
47
+ end
48
+
49
+ it "returns false if there is no value" do
50
+ @config.foo?.should == false
51
+ end
52
+ end
53
+
38
54
  describe "class methods" do
39
55
  it "should allow to set value for class" do
40
56
  MotionPrime::Config.foo.nil?.should == true
@@ -0,0 +1,2 @@
1
+ MotionPrime::Config.configure!
2
+ MotionPrime::Styles.define!
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.5.0
4
+ version: 0.5.1
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-01-08 00:00:00.000000000 Z
12
+ date: 2014-01-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -204,7 +204,6 @@ files:
204
204
  - files/app/sections/sidebar/action.rb
205
205
  - files/app/sections/sidebar/table.rb
206
206
  - files/app/styles/home.rb
207
- - files/app/styles/sidebar.rb
208
207
  - files/resources/Default-568h@2x.png
209
208
  - files/resources/Default.png
210
209
  - files/resources/Default@2x.png
@@ -240,6 +239,7 @@ files:
240
239
  - motion-prime/elements/text_field.rb
241
240
  - motion-prime/elements/text_view.rb
242
241
  - motion-prime/elements/view_with_section.rb
242
+ - motion-prime/env.rb
243
243
  - motion-prime/helpers/has_authorization.rb
244
244
  - motion-prime/helpers/has_class_factory.rb
245
245
  - motion-prime/helpers/has_normalizer.rb
@@ -290,6 +290,7 @@ files:
290
290
  - motion-prime/styles/_mixins.rb
291
291
  - motion-prime/styles/base.rb
292
292
  - motion-prime/styles/form.rb
293
+ - motion-prime/styles/sidebar.rb
293
294
  - motion-prime/support/_key_value_store.rb
294
295
  - motion-prime/support/_padding_attribute.rb
295
296
  - motion-prime/support/mp_button.rb
@@ -313,6 +314,7 @@ files:
313
314
  - spec/config/store_spec.rb
314
315
  - spec/delegate/delegate_spec.rb
315
316
  - spec/helpers/delegates.rb
317
+ - spec/helpers/init.rb
316
318
  - spec/helpers/models.rb
317
319
  - spec/helpers/screens.rb
318
320
  - spec/models/associations_spec.rb
@@ -353,6 +355,7 @@ test_files:
353
355
  - spec/config/store_spec.rb
354
356
  - spec/delegate/delegate_spec.rb
355
357
  - spec/helpers/delegates.rb
358
+ - spec/helpers/init.rb
356
359
  - spec/helpers/models.rb
357
360
  - spec/helpers/screens.rb
358
361
  - spec/models/associations_spec.rb