better_toolbar 0.0.1 → 0.1.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: 6d75afd49bb39c9b29f4e52ed42b8b27de23308d
4
- data.tar.gz: f54a6a0133fa3a03f8fabbbe691152ccf807baef
3
+ metadata.gz: 2086594670a6ce1c7eda06198a5256b2ee7e0df4
4
+ data.tar.gz: 7861f94bbd8479fcbd33b4c639d512ada9adedec
5
5
  SHA512:
6
- metadata.gz: 47c6b4774395d3721b71f374265e855ddf56152d02c7f35b6493fcd79038ef0421623cc5d5aaa04fa3623d8f3731304f9ba985d983adfbe29d3d2d09be500fc7
7
- data.tar.gz: f332fdaa7e9e7fd9cfc8c0809046bf5f2ea41bdc323948a55d591f1bdd6f9c52fac21ad09ade1c8895fe4a953b1dc6a0b95a39d990dc280e38eef6bd26fd53d1
6
+ metadata.gz: 683365b451401de4057705b3d0c556e23f6d009596891e670305161b7219d6516bc9f989b4103e3525b33f9c6685f122663389b20b512c0fba04ab126d4d5e04
7
+ data.tar.gz: c009f94a248737b6d170113b29de8a565f07f7c840b155aa89e9038507f33db36569b44c72d79af1608b4a9458737590134b697f3282ab158a8217409557ed27
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # better_toolbar
1
+ # BetterToolbar
2
2
 
3
- TODO: Write a gem description
3
+ No Ruby developer likes all those crazy constants thay Apple makes us try and remember, and creating a toolbar is full of that, plus extra crazy stuff that is basically just left over from the history of iOS. BetterToolbar helps you create toolbars and toolbar items in a more Ruby-esque way.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,12 +18,37 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ In version 0.0.1, you can create a `UIBarButtonItem` using a nicer factory style (yes, factories make you think of Java, but the fact is factories are useful).
22
+
23
+ ```ruby
24
+ toolbar = UIToolbar.new
25
+ item = BetterToolbar::Item.create(title: "Item 1", target: the_target, action: 'method_on_the_target:')
26
+ toolbar.setItems([item], animated: false)
27
+ ```
28
+
29
+ In later versions, the plan is to have a nicer factory for a whole toolbar, but this works well for now. A preview is it might look something like this though.
30
+
31
+ **NOT REAL CODE**
32
+
33
+ ```ruby
34
+ toolbar = BetterToolbar.create({
35
+ target: self,
36
+ items: [
37
+ { title: "Item 1", action: "item_one_pressed:" },
38
+ { image: "sun", action: "sun_pressed:" },
39
+ :flexible_space,
40
+ { title: "Item 3", target: different_target, action: "some_action:" }
41
+ ]
42
+ })
43
+ ```
44
+
45
+ That looks much nicer than what it would usually take to make a toolbar, and that's where it would be nice to get to.
22
46
 
23
47
  ## Contributing
24
48
 
25
49
  1. Fork it
26
50
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
51
+ 3. Make sure your tests pass
52
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
53
+ 5. Push to the branch (`git push origin my-new-feature`)
54
+ 6. Create new Pull Request
@@ -0,0 +1,14 @@
1
+ module BetterToolbar
2
+ def self.create(options = {})
3
+ toolbar = UIToolbar.new
4
+ items = options.fetch(:items, []).map { |i| item_options_to_item(options.merge(i)) }
5
+ toolbar.setItems(items, animated: false)
6
+ toolbar
7
+ end
8
+
9
+ private
10
+
11
+ def self.item_options_to_item(item_options)
12
+ Item.create(item_options)
13
+ end
14
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_toolbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Dean Watson-Hamblin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-03 00:00:00.000000000 Z
11
+ date: 2014-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -33,6 +33,7 @@ extra_rdoc_files: []
33
33
  files:
34
34
  - README.md
35
35
  - lib/better_toolbar.rb
36
+ - lib/better_toolbar/better_toolbar.rb
36
37
  - lib/better_toolbar/item.rb
37
38
  homepage: https://github.com/FluffyJack/better_toolbar
38
39
  licenses: