redpotion 0.5.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33d59f9fe4ed03ce50987479a11a745dfcee3b29
4
- data.tar.gz: 68ce1bf746430e52535523f155b631553e88e358
3
+ metadata.gz: 62ecec116f423ede1149e470e67d497265969f96
4
+ data.tar.gz: c5c046f6ce6064129f0e34e4e1971090d87e49dc
5
5
  SHA512:
6
- metadata.gz: 8b8171dc7f119d605a1e2215cc1d2d7aa160f6cfff55cfff067ea2e17302ddbd40cb2639d0286865db2c2c63279cafa87e6143f46275b224287d17d60fde40ca
7
- data.tar.gz: a16471a01e726c6990177f49fd59d6d8fa48a1b99144ddfdbad90b12fe85b0438fe9b0103389a4e27d113276883bfb9808c59813308f8feed83e7855401ebf57
6
+ metadata.gz: 6e5e64bfd2696d11d25ad48c876916f64918c039a87d07a58103fb56124361e22df4330e360acca119388004a68d0883dff1f8cf2584fb4bc8f230451f70d09e
7
+ data.tar.gz: 7ea38189c9df9e7f22a3c7f689dbf0d09c862a8b8952d27fbde741045f929eb7c2e104445b3c046cab82b34aae7be37af6e48a664cc0ccbf0e85aed07e1cc0ee
data/README.md CHANGED
@@ -68,6 +68,11 @@ potion create lib foo
68
68
  potion create controller foo
69
69
  potion create collection_view_controller foos
70
70
  potion create table_view_controller bars
71
+
72
+ # RedPotion includes CDQ and afmotion by default, if you don't need these gems
73
+ # we have provided command line tasks to remove either of them
74
+ potion remove cdq
75
+ potion remove afmotion
71
76
  ```
72
77
 
73
78
  ## New features for RMQ
@@ -105,6 +110,9 @@ apply_style
105
110
  reapply_styles
106
111
  style
107
112
  color
113
+ image
114
+ stylesheet
115
+ stylesheet=
108
116
  ```
109
117
 
110
118
  ### Stylesheet in your screens
@@ -142,6 +150,14 @@ end
142
150
 
143
151
  ProMotion 2.2.0 added on_load and on_styled to match RedPotion
144
152
 
153
+ ## RedPotion specific features
154
+
155
+ UIColor has a `with` method. Allowing you to build a color from an existing color easily
156
+
157
+ ```ruby
158
+ # for example that time you want your existing color, but with a slight change
159
+ color.my_custom_color.with(a: 0.5)
160
+ ```
145
161
 
146
162
  ## Contributing
147
163
 
data/bin/potion CHANGED
@@ -13,6 +13,7 @@ class PotionCommandLine
13
13
  Some things you can do with the potion command:
14
14
 
15
15
  > potion create my_new_app
16
+ > potion create my_new_app --skip-cdq # Setup application without CDQ
16
17
 
17
18
  > potion create model foo
18
19
  > potion create screen foo
@@ -24,38 +25,60 @@ class PotionCommandLine
24
25
  You can still create controllers, but you should create screens instead
25
26
  > potion create controller foos
26
27
  > potion create collection_view_controller foos
27
- > potion create table_view_controller bars
28
+ > potion create table_view_controller bars
29
+
30
+ You can remove CDQ or afmotion if your project does not use it
31
+ > potion remove cdq
32
+ > potion remove afmotion
28
33
 
29
34
  > potion -h, --help
30
- > potion -v, --version
35
+ > potion -v, --version
31
36
 
32
37
  > rmq_docs
33
38
  > rmq_docs query
34
39
  > rmq_docs "background image" }
35
40
 
36
41
  class << self
42
+ SKIP_FLAGS = [ "--skip-cdq", "--skip-afmotion" ]
43
+
37
44
  VALID_CREATE_TYPES = [
38
45
  :screen, :table_screen,
39
- :model, :controller,
40
- :view,
41
- :shared,
42
- :lib,
43
- :collection_view_controller,
46
+ :model, :controller,
47
+ :view,
48
+ :shared,
49
+ :lib,
50
+ :collection_view_controller,
44
51
  :table_view_controller
45
52
  ]
46
53
 
47
- def create(template_or_app_name, name, options)
48
- @dry_run = true if options == 'dry_run'
49
54
 
50
- if name
51
- if VALID_CREATE_TYPES.include?(template_or_app_name.to_sym)
52
- insert_from_template(template_or_app_name, name)
53
- else
55
+ def create(template_or_app_name, *options)
56
+ # Dry Run option - TODO - change this to --dry_run to streamline
57
+ if options.first == 'dry_run'
58
+ @dry_run = true
59
+ options.slice!(0)
60
+ end
61
+
62
+ unless options.first.include?('--')
63
+ name = options.slice!(0)
64
+ unless VALID_CREATE_TYPES.include?(template_or_app_name.to_sym)
54
65
  puts "potion - Invalid command, do something like this: potion create controller my_controller\n"
66
+ return
55
67
  end
68
+ end
69
+
70
+ if name
71
+ insert_from_template(template_or_app_name, name)
56
72
  else
57
73
  #ensure_template_dir
58
74
  create_app(template_or_app_name)
75
+ options.each do |option|
76
+ if SKIP_FLAGS.include?(option)
77
+ Dir.chdir("./#{template_or_app_name}")
78
+ remove(option.split('-').last, true)
79
+ Dir.chdir('..')
80
+ end
81
+ end
59
82
  end
60
83
  end
61
84
 
@@ -142,13 +165,13 @@ class PotionCommandLine
142
165
  @in_app_path = File.dirname(template_file_path_and_name).gsub(@template_path, '')
143
166
  @ext = File.extname(template_file_path_and_name)
144
167
  @file_name = File.basename(template_file_path_and_name, @ext)
145
-
168
+
146
169
  @new_file_name = @file_name.gsub('name', @name)
147
170
  @new_file_path_name = "#{Dir.pwd}/#{@in_app_path}/#{@new_file_name}#{@ext}"
148
171
 
149
172
  if @dry_run
150
173
  puts "\n Instance vars:"
151
- self.instance_variables.each{|var| puts " #{var} = #{self.instance_variable_get(var)}"}
174
+ self.instance_variables.each{|var| puts " #{var} = #{self.instance_variable_get(var)}"}
152
175
  puts
153
176
  end
154
177
 
@@ -177,10 +200,35 @@ class PotionCommandLine
177
200
  erb = ERB.new(template_file)
178
201
  erb.result(binding)
179
202
  end
203
+
204
+ def remove(type, show_output=true)
205
+ case type
206
+ when 'cdq'
207
+ remove_lines('Gemfile', /gem ('|")cdq('|")/, show_output)
208
+ remove_lines('app/app_delegate.rb', /include CDQ|cdq.setup/, show_output)
209
+ remove_lines('Rakefile', /schema:build/, show_output)
210
+ File.delete('schemas/0001_initial.rb') if File.exists?('schemas/0001_initial.rb')
211
+ when 'afmotion'
212
+ remove_lines('Gemfile', /gem ('|")afmotion('|")/, show_output)
213
+ else
214
+ puts "potion - Invalid command option '#{type}', potion remove only works with cdq"
215
+ end
216
+ end
217
+
218
+ def remove_lines(file, match, show_output)
219
+ puts "Modifying #{file}" if show_output
220
+ data = IO.readlines(file)
221
+ File.open(file, 'w') do |f|
222
+ data.each do |line|
223
+ unless line =~ match
224
+ f.puts line
225
+ end
226
+ end
227
+ end
228
+ end
180
229
  end
181
230
  end
182
231
 
183
-
184
232
  # Process input, execute actions
185
233
  unless ARGV.length > 0
186
234
  puts "potion - Invalid command, do something like this: potion create my_new_app\n"
@@ -202,6 +250,8 @@ when 'rmq_docs'
202
250
  else
203
251
  `open http://rubymotionquery.com/documentation`
204
252
  end
253
+ when 'remove'
254
+ PotionCommandLine.remove(ARGV[1])
205
255
  when '--help', '-h'
206
256
  puts PotionCommandLine::HELP_TEXT
207
257
  when '-v', '--version'
@@ -210,4 +260,3 @@ else
210
260
  puts 'potion - Invalid action'
211
261
  puts PotionCommandLine::HELP_TEXT
212
262
  end
213
-
@@ -0,0 +1,13 @@
1
+ class Object
2
+ def app
3
+ rmq.app
4
+ end
5
+
6
+ def device
7
+ rmq.device
8
+ end
9
+
10
+ def find(*args) # Do not alias this, strange bugs happen where classes don't have methods
11
+ rmq(args)
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class UIColor
2
+ def with(options)
3
+ r, g, b, a = Pointer.new('d'), Pointer.new('d'), Pointer.new('d'), Pointer.new('d')
4
+ self.getRed(r, green: g, blue: b, alpha: a)
5
+
6
+ r = options[:r] || options[:red] || r.value
7
+ g = options[:g] || options[:green] || g.value
8
+ b = options[:b] || options[:blue] || b.value
9
+ a = options[:a] || options[:alpha] || a.value
10
+
11
+ UIColor.colorWithRed(r, green: g, blue: b, alpha: a)
12
+ end
13
+ end
@@ -0,0 +1,88 @@
1
+ class UIView
2
+ # You can use either rmq_build or on_load, not both. If you have both, on_load will be ignored,
3
+ # you can however call it from rmq_build. They are the same, on_load follows the ProMotion style
4
+ # and is recommended.
5
+ def rmq_build
6
+ on_load
7
+ end
8
+
9
+ def on_load
10
+ end
11
+
12
+ def on_styled
13
+ end
14
+
15
+ # You can user either rmq_style_applied or on_styled, not both. If you have both on_styled will be ignored,
16
+ # you can however call it from rmq_style_applied. They are the same, on_styled follows the Promotion style
17
+ # and is recommended.
18
+ def rmq_style_applied
19
+ on_styled
20
+ end
21
+
22
+ def append(view_or_constant, style=nil, opts = {})
23
+ rmq(self).append(view_or_constant, style, opts)
24
+ end
25
+ def append!(view_or_constant, style=nil, opts = {})
26
+ rmq(self).append!(view_or_constant, style, opts)
27
+ end
28
+
29
+ def prepend(view_or_constant, style=nil, opts = {})
30
+ rmq(self).prepend(view_or_constant, style, opts)
31
+ end
32
+ def prepend!(view_or_constant, style=nil, opts = {})
33
+ rmq(self).prepend!(view_or_constant, style, opts)
34
+ end
35
+
36
+ def create(view_or_constant, style=nil, opts = {})
37
+ rmq(self).create(view_or_constant, style, opts)
38
+ end
39
+ def create!(view_or_constant, style=nil, opts = {})
40
+ rmq(self).create!(view_or_constant, style, opts)
41
+ end
42
+
43
+ def build(view, style = nil, opts = {})
44
+ rmq(self).build(view, style, opts)
45
+ end
46
+ def build!(view, style = nil, opts = {})
47
+ rmq(self).build!(view, style, opts)
48
+ end
49
+
50
+ def on(event, args = {}, &block)
51
+ rmq(self).on(event, args, &block)
52
+ end
53
+
54
+ def off(*events)
55
+ rmq(self).off(*events)
56
+ end
57
+
58
+ def apply_style(style_name)
59
+ rmq(self).apply_style(style_name)
60
+ end
61
+
62
+ def reapply_styles
63
+ rmq(self).reapply_styles
64
+ end
65
+
66
+ def style(&block)
67
+ rmq(self).style(&block)
68
+ end
69
+
70
+ def color
71
+ rmq.color
72
+ end
73
+
74
+ def font
75
+ rmq.font
76
+ end
77
+
78
+ def image
79
+ rmq.image
80
+ end
81
+
82
+ def stylesheet
83
+ rmq.stylesheet
84
+ end
85
+ def stylesheet=(value)
86
+ rmq.stylesheet = value
87
+ end
88
+ end
@@ -1,97 +1,3 @@
1
- class Object
2
- def app
3
- rmq.app
4
- end
5
-
6
- def find(*args) # Do not alias this, strange bugs happen where classes don't have methods
7
- rmq(args)
8
- end
9
- end
10
-
11
- class UIView
12
- # You can use either rmq_build or on_load, not both. If you have both, on_load will be ignored,
13
- # you can however call it from rmq_build. They are the same, on_load follows the ProMotion style
14
- # and is recommended.
15
- def rmq_build
16
- on_load
17
- end
18
-
19
- def on_load
20
- end
21
-
22
- def on_styled
23
- end
24
-
25
- # You can user either rmq_style_applied or on_styled, not both. If you have both on_styled will be ignored,
26
- # you can however call it from rmq_style_applied. They are the same, on_styled follows the Promotion style
27
- # and is recommended.
28
- def rmq_style_applied
29
- on_styled
30
- end
31
-
32
- def append(view_or_constant, style=nil, opts = {})
33
- rmq(self).append(view_or_constant, style, opts)
34
- end
35
- def append!(view_or_constant, style=nil, opts = {})
36
- rmq(self).append!(view_or_constant, style, opts)
37
- end
38
-
39
- def prepend(view_or_constant, style=nil, opts = {})
40
- rmq(self).prepend(view_or_constant, style, opts)
41
- end
42
- def prepend!(view_or_constant, style=nil, opts = {})
43
- rmq(self).prepend!(view_or_constant, style, opts)
44
- end
45
-
46
- def create(view_or_constant, style=nil, opts = {})
47
- rmq(self).create(view_or_constant, style, opts)
48
- end
49
- def create!(view_or_constant, style=nil, opts = {})
50
- rmq(self).create!(view_or_constant, style, opts)
51
- end
52
-
53
- def build(view, style = nil, opts = {})
54
- rmq(self).build(view, style, opts)
55
- end
56
- def build!(view, style = nil, opts = {})
57
- rmq(self).build!(view, style, opts)
58
- end
59
-
60
- def on(event, args = {}, &block)
61
- rmq(self).on(event, args, &block)
62
- end
63
-
64
- def apply_style(style_name)
65
- rmq(self).apply_style(style_name)
66
- end
67
-
68
- def reapply_styles
69
- rmq(self).reapply_styles
70
- end
71
-
72
- def style(&block)
73
- rmq(self).style(&block)
74
- end
75
-
76
- def color
77
- rmq.color
78
- end
79
-
80
- def font
81
- rmq.font
82
- end
83
-
84
- def image
85
- rmq.image
86
- end
87
-
88
- def stylesheet
89
- rmq.stylesheet
90
- end
91
- def stylesheet=(value)
92
- rmq.stylesheet = value
93
- end
94
- end
95
1
  class UIViewController
96
2
  def append(view_or_constant, style=nil, opts = {})
97
3
  view.append(view_or_constant, style, opts)
@@ -165,7 +71,7 @@ class UIViewController
165
71
  end
166
72
 
167
73
  self.originalViewDidLoad
168
- unless pm_handles_did_load?
74
+ unless pm_handles_delegates?
169
75
  unless self.class.included_modules.include?(ProMotion::ScreenModule)
170
76
  self.view_did_load
171
77
  end
@@ -173,32 +79,36 @@ class UIViewController
173
79
  end
174
80
  end
175
81
 
176
- def pm_handles_did_load?
177
- self.is_a?(ProMotion::ViewController) || self.is_a?(ProMotion::TableScreen)
178
- end
179
-
180
82
  def view_will_appear(animated)
181
83
  end
182
84
  def viewWillAppear(animated)
183
- self.view_will_appear(animated)
85
+ unless pm_handles_delegates?
86
+ self.view_will_appear(animated)
87
+ end
184
88
  end
185
89
 
186
90
  def view_did_appear(animated)
187
91
  end
188
92
  def viewDidAppear(animated)
189
- self.view_did_appear(animated)
93
+ unless pm_handles_delegates?
94
+ self.view_did_appear(animated)
95
+ end
190
96
  end
191
97
 
192
98
  def view_will_disappear(animated)
193
99
  end
194
100
  def viewWillDisappear(animated)
195
- self.view_will_disappear(animated)
101
+ unless pm_handles_delegates?
102
+ self.view_will_disappear(animated)
103
+ end
196
104
  end
197
105
 
198
106
  def view_did_disappear(animated)
199
107
  end
200
108
  def viewDidDisappear(animated)
201
- self.view_did_disappear(animated)
109
+ unless pm_handles_delegates?
110
+ self.view_did_disappear(animated)
111
+ end
202
112
  end
203
113
 
204
114
  def should_rotate(orientation)
@@ -231,4 +141,10 @@ class UIViewController
231
141
  def willAnimateRotationToInterfaceOrientation(orientation, duration: duration)
232
142
  self.will_animate_rotate(orientation, duration)
233
143
  end
144
+
145
+ private
146
+
147
+ def pm_handles_delegates?
148
+ self.is_a?(ProMotion::ViewController) || self.is_a?(ProMotion::TableScreen)
149
+ end
234
150
  end
@@ -0,0 +1,66 @@
1
+ module ProMotion
2
+ #TODO ? - set_attributes is called twice - seems like this is in PM core
3
+ # this is because we call setup when we build the cell and setup when its
4
+ # about to display - this is because PM wants styling to fire in each case -
5
+ # and properties was where the styling is done in PM
6
+ #
7
+ # if we are going to wire an event when a value is set on a cell, this could
8
+ # be problematic, especially likely since cells are reused, etc
9
+ # see my new cell for example, where I have to remove and then add events
10
+ # because of the double call
11
+
12
+ class DataTableScreen < TableScreen
13
+ def self.cell(cell)
14
+ @cell = cell
15
+ end
16
+
17
+ def self.cell_properties
18
+ @cell
19
+ end
20
+
21
+ def table_data
22
+ [{
23
+ cells: cell_data
24
+ }]
25
+ end
26
+
27
+ def cell_properties
28
+ self.class.cell_properties
29
+ end
30
+
31
+ def cell_data
32
+ return [] if cell_properties.nil?
33
+ return [] if data_model.nil?
34
+
35
+ data_model.send(data_scope).collect do |c|
36
+ {
37
+ cell_class: cell_class,
38
+ properties: properties.inject({}) do |hash, element|
39
+ hash[element.first] = c.send(element.last)
40
+ hash
41
+ end
42
+ }
43
+ end
44
+ end
45
+
46
+ private
47
+
48
+ def properties
49
+ @properties ||= cell_properties[:template].reject do |k,v|
50
+ k == :cell_class
51
+ end
52
+ end
53
+
54
+ def cell_class
55
+ @cell_class ||= cell_properties[:template][:cell_class]
56
+ end
57
+
58
+ def data_model
59
+ @data_model ||= cell_properties[:model]
60
+ end
61
+
62
+ def data_scope
63
+ @data_scope ||= cell_properties[:scope] || :all
64
+ end
65
+ end
66
+ end
@@ -17,5 +17,4 @@ module ProMotion
17
17
  table_cell
18
18
  end
19
19
  end
20
-
21
20
  end
@@ -1,3 +1,3 @@
1
1
  module RedPotion
2
- VERSION = "0.5.0"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -24,6 +24,6 @@ class <%= @name_camel_case %>Screen < PM::<%= @screen_base %>
24
24
  # Then in will_animate_rotate
25
25
  # find(:reapply_style).reapply_styles#
26
26
  def will_animate_rotate(orientation, duration)
27
- find.all.reapply_styles
27
+ reapply_styles
28
28
  end
29
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redpotion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - InfiniteRed
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-18 00:00:00.000000000 Z
12
+ date: 2015-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby_motion_query
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.0'
20
+ version: '1.1'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '1.0'
27
+ version: '1.1'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: ProMotion
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -92,10 +92,13 @@ extra_rdoc_files: []
92
92
  files:
93
93
  - README.md
94
94
  - bin/potion
95
+ - lib/project/ext/object.rb
96
+ - lib/project/ext/ui_color.rb
97
+ - lib/project/ext/ui_view.rb
98
+ - lib/project/ext/ui_view_controller.rb
99
+ - lib/project/pro_motion/data_table_screen.rb
95
100
  - lib/project/pro_motion/table.rb
96
- - lib/project/redpotion.rb
97
101
  - lib/project/ruby_motion_query/app.rb
98
- - lib/project/ruby_motion_query/ext.rb
99
102
  - lib/project/ruby_motion_query/traverse.rb
100
103
  - lib/project/version.rb
101
104
  - lib/redpotion.rb
File without changes