motion-maml 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2013 Sebastian Burkhard
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,4 @@
1
+ motion-maml
2
+ ===========
3
+
4
+ Rubymotion helpers for building UI elements with support for pixate styleId and styleClass attributes
@@ -0,0 +1,3 @@
1
+ require 'motion-require'
2
+
3
+ Motion::Require.all(Dir.glob(File.expand_path('../motion-maml/**/*.rb', __FILE__)))
@@ -0,0 +1,100 @@
1
+ module Maml
2
+ # struct used by #parse
3
+ Tag = Struct.new(:element, :id, :class_name)
4
+
5
+ DEFAULT_TAG = 'view'.freeze
6
+
7
+ TAGS = {
8
+ # 'annotation-view' => ::MKAnnotationView,
9
+ # 'map-view' => ::MKMapView,
10
+ # 'volume-view' => ::MPVolumeView,
11
+ 'action-sheet' => ::UIActionSheet,
12
+ 'activity-indicator-view' => ::UIActivityIndicatorView,
13
+ 'bar-button-item' => ::UIBarButtonItem,
14
+ 'button' => ::UIButton,
15
+ 'collection-view' => ::UICollectionView,
16
+ 'collection-view-cell' => ::UICollectionViewCell,
17
+ 'date-picker' => ::UIDatePicker,
18
+ 'image-view' => ::UIImageView,
19
+ 'label' => ::UILabel,
20
+ 'navigation-bar' => ::UINavigationBar,
21
+ 'page-control' => ::UIPageControl,
22
+ 'picker-view' => ::UIPickerView,
23
+ 'refresh-control' => ::UIRefreshControl,
24
+ 'scroll-view' => ::UIScrollView,
25
+ 'search-bar' => ::UISearchBar,
26
+ 'segmented-control' => ::UISegmentedControl,
27
+ 'slider' => ::UISlider,
28
+ 'stepper' => ::UIStepper,
29
+ 'switch' => ::UISwitch,
30
+ 'tab-bar' => ::UITabBar,
31
+ 'tab-bar-item' => ::UITabBarItem,
32
+ 'progress-view' => ::UIProgressView,
33
+ 'table-view' => ::UITableView,
34
+ 'table-view-headerfooter-view' => ::UITableViewHeaderFooterView,
35
+ 'text-field' => ::UITextField,
36
+ 'text-view' => ::UITextView,
37
+ 'toolbar' => ::UIToolbar,
38
+ 'view' => ::UIView,
39
+ 'web-view' => ::UIWebView,
40
+ 'table-view-cell' => ::UITableViewCell
41
+ }.freeze
42
+
43
+
44
+ def alloc(selector)
45
+ build(selector)
46
+ end
47
+
48
+ def init(selector, options = nil)
49
+ element = alloc(selector).init
50
+ options && options.each do |key, value|
51
+ element.send("#{key}=", value)
52
+ end
53
+ element
54
+ end
55
+
56
+ def build(selector)
57
+ tag = parse(selector)
58
+
59
+ klass = klass_for(tag.element)
60
+ raise "#{tag.element.inspect} not a valid tag name" unless klass
61
+
62
+ element = klass.alloc
63
+ element.styleId = tag.id if tag.id
64
+ element.styleClass = tag.class_name if tag.class_name
65
+ element
66
+ end
67
+
68
+ def klass_for(name)
69
+ TAGS[name]
70
+ end
71
+
72
+ def parse(selector)
73
+ selector = selector.to_s.strip
74
+
75
+ rgx = /^([\w\-]+)?(#[\w\-]+)?(\.[\w\.\-]+)?/
76
+
77
+ captures = selector.match(rgx)
78
+
79
+ name = captures[1] || 'view'
80
+ name.gsub!('_', '-')
81
+
82
+ id = captures[2]
83
+ id.gsub!('#', '') if id
84
+
85
+ class_name = captures[3]
86
+ if class_name
87
+ class_name.gsub!('.', ' ')
88
+ class_name.strip!
89
+ end
90
+
91
+ Tag.new(name, id, class_name)
92
+ end
93
+
94
+ def [](selector)
95
+ init(selector, nil)
96
+ end
97
+
98
+ module_function :build, :parse, :alloc, :[], :init, :klass_for
99
+
100
+ end
@@ -0,0 +1,6 @@
1
+
2
+ def UI(selector, options = nil)
3
+ UI.init(selector, options)
4
+ end
5
+
6
+ UI = Maml
@@ -0,0 +1,3 @@
1
+ module Maml
2
+ VERSION = '0.1.1'
3
+ end
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/motion-maml/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["hasclass"]
6
+ gem.email = ["info@hasclass.com"]
7
+ gem.description = "Rubymotion helpers for building UI elements with support for pixate styleId and styleClass attributes"
8
+ gem.summary = "Rubymotion helpers for building UI elements with support for pixate styleId and styleClass attributes"
9
+ gem.homepage = "http://github.com/hasclass/motion-maml"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
+ gem.name = "motion-maml"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = Maml::VERSION
16
+
17
+ gem.add_dependency "motion-require"
18
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-maml
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - hasclass
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: motion-require
16
+ requirement: &70159909952360 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70159909952360
25
+ description: Rubymotion helpers for building UI elements with support for pixate styleId
26
+ and styleClass attributes
27
+ email:
28
+ - info@hasclass.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - LICENSE
36
+ - README.md
37
+ - lib/motion-maml.rb
38
+ - lib/motion-maml/maml.rb
39
+ - lib/motion-maml/ui.rb
40
+ - lib/motion-maml/version.rb
41
+ - motion-maml.gemspec
42
+ homepage: http://github.com/hasclass/motion-maml
43
+ licenses: []
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 1.8.11
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Rubymotion helpers for building UI elements with support for pixate styleId
66
+ and styleClass attributes
67
+ test_files: []
68
+ has_rdoc: