motion-awesome 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,9 @@ Motion::Project::App.setup do |app|
7
7
  Dir.glob(File.join( LIB_DIR, %w(motion-awesome ** *.rb))).each do |file|
8
8
  app.files.unshift(file)
9
9
  end
10
- FileUtils.cp( File.join( LIB_DIR, %w(assets fontawesome-webfont.ttf) ), './resources/' )
11
- FileUtils.cp( File.join( LIB_DIR, %w(assets fontawesome.plist) ), './resources/' )
12
- app.fonts << "fontawesome-webfont.ttf"
13
- end
10
+ FileUtils.cp( File.join( LIB_DIR, %w(assets fontawesome-webfont.ttf) ),
11
+ './resources/' )
12
+ FileUtils.cp( File.join( LIB_DIR, %w(assets fontawesome.plist) ),
13
+ './resources/' )
14
+ app.fonts << "fontawesome-webfont.ttf"
15
+ end
@@ -1,30 +1,30 @@
1
1
  module MotionAwesome
2
- module_function
3
-
2
+ module_function
3
+
4
4
  class InvalidAwesomeIconError < RuntimeError; end
5
-
5
+
6
6
  def button( icon, options={}, &block )
7
7
  opts = parse_options( icon, options )
8
- comp = UIButton.buttonWithType( map_types( opts.type? ? opts.type : nil ) )
8
+ comp = UIButton.buttonWithType( map_types( opts.type? ? opts.type : nil ) )
9
9
  comp.setAttributedTitle( attributed_text(opts), forState: UIControlStateNormal )
10
10
  yield comp if block_given?
11
11
  comp
12
12
  end
13
-
13
+
14
14
  def label( icon, options={}, &block )
15
15
  opts = parse_options( icon, options )
16
16
  comp = UILabel.alloc.initWithFrame( [[0,0],[opts[:size],opts[:size]]] )
17
17
  comp.setAttributedText( attributed_text(opts) )
18
18
  comp.awesome_color = opts.color if opts.color?
19
19
  yield comp if block_given?
20
- comp
20
+ comp
21
21
  end
22
-
22
+
23
23
  def font( size )
24
24
  UIFont.fontWithName( 'FontAwesome', size:size )
25
25
  end
26
-
27
- def parse_options( icon, opts )
26
+
27
+ def parse_options( icon, opts )
28
28
  options = MotionMap::Map[opts.merge( icon: xform_icon(icon) )]
29
29
  options[:size] = UIFont.systemFontSize unless options[:size]
30
30
  options
@@ -37,7 +37,7 @@ module MotionAwesome
37
37
  def attributed_text( opts )
38
38
  awesome_attrs = MotionMap::Map[NSFontAttributeName, font(opts[:size])]
39
39
  awesome_attrs[NSForegroundColorAttributeName] = opts.color if opts.color?
40
- text = hex_for_icon( opts.icon )
40
+ text = hex_for_icon( opts.icon )
41
41
  text += " " + opts.text if opts.text?
42
42
  range = opts.text? ? (0..1) : (0..0)
43
43
  NSMutableAttributedString.alloc.initWithString( text, attributes: nil ).tap do |attrs|
@@ -46,7 +46,7 @@ module MotionAwesome
46
46
  end
47
47
 
48
48
  def hex_for_icon( icon )
49
- index = plist["icon-#{icon}"]
49
+ index = plist["fa-#{icon}"]
50
50
  raise InvalidAwesomeIconError, "Unable to find icon representation for `#{icon.inspect}" unless index
51
51
  index.hex.chr(Encoding::UTF_8)
52
52
  end
@@ -66,5 +66,5 @@ module MotionAwesome
66
66
  def button_types
67
67
  @button_types ||=
68
68
  MotionMap::Map[custom: UIButtonTypeCustom, rounded: UIButtonTypeRoundedRect]
69
- end
70
- end
69
+ end
70
+ end
@@ -1,3 +1,3 @@
1
1
  module MotionAwesome
2
- VERSION = '0.0.5'
3
- end
2
+ VERSION = '0.0.6'
3
+ end
@@ -3,24 +3,27 @@ include CssParser
3
3
  require 'plist'
4
4
 
5
5
  module MotionAwesome
6
- class Generator
7
- def self.plist; File.join( File.dirname( __FILE__), %w(.. .. resources fontawesome.plist) ) end
8
-
6
+ class Generator
7
+ def self.plist
8
+ File.join( File.dirname( __FILE__),
9
+ %w(.. .. resources fontawesome.plist) )
10
+ end
11
+
9
12
  def self.gen_plist( css )
10
13
  parser = CssParser::Parser.new
11
14
  parser.load_file!( css )
12
15
  fonts = {}
13
16
  parser.each_selector do |selector, declarations, _|
14
- next if selector !~ /\A.icon/
17
+ next if selector !~ /\A.fa\-/
15
18
  name = selector[/\.(.*)\:before/,1]
16
19
  next unless name and name != 'icon-large'
17
20
  fonts[name] = "0x#{declarations[/(f.*)"/, 1]}"
18
21
  end
19
22
  write( fonts )
20
23
  end
21
-
24
+
22
25
  def self.write( fonts )
23
26
  File.open( plist, 'w' ) { |f| f << fonts.to_plist }
24
27
  end
25
28
  end
26
- end
29
+ end
@@ -7,15 +7,15 @@ Gem::Specification.new do |gem|
7
7
  gem.authors = ['Fernand Galiana']
8
8
  gem.email = ['fernand.galiana@gmail.com']
9
9
  gem.summary = %{Port of the most excellent FontAwesome lib to IOS}
10
- gem.description = %{Blah Blah attributions}
10
+ gem.description = %{FontAwesomess for IOS apps}
11
11
  gem.homepage = 'http://derailed.github.io/motion-awesome'
12
12
  gem.files = `git ls-files`.split($\)
13
13
  gem.test_files = gem.files.grep(%r{^spec/})
14
14
  gem.require_paths = ['lib']
15
-
15
+
16
16
  gem.add_development_dependency 'rspec'
17
17
  gem.add_development_dependency 'plist'
18
- gem.add_development_dependency 'css_parser'
19
-
18
+ gem.add_development_dependency 'css_parser'
19
+
20
20
  gem.add_dependency 'motion-map'
21
- end
21
+ end
metadata CHANGED
@@ -1,72 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-awesome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernand Galiana
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-23 00:00:00.000000000 Z
11
+ date: 2013-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- prerelease: false
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ! '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
14
  name: rspec
21
15
  requirement: !ruby/object:Gem::Requirement
22
16
  requirements:
23
- - - ! '>='
17
+ - - '>='
24
18
  - !ruby/object:Gem::Version
25
19
  version: '0'
26
20
  type: :development
27
- - !ruby/object:Gem::Dependency
28
21
  prerelease: false
29
22
  version_requirements: !ruby/object:Gem::Requirement
30
23
  requirements:
31
- - - ! '>='
24
+ - - '>='
32
25
  - !ruby/object:Gem::Version
33
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
34
28
  name: plist
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
- - - ! '>='
31
+ - - '>='
38
32
  - !ruby/object:Gem::Version
39
33
  version: '0'
40
34
  type: :development
41
- - !ruby/object:Gem::Dependency
42
35
  prerelease: false
43
36
  version_requirements: !ruby/object:Gem::Requirement
44
37
  requirements:
45
- - - ! '>='
38
+ - - '>='
46
39
  - !ruby/object:Gem::Version
47
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
48
42
  name: css_parser
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
- - !ruby/object:Gem::Dependency
56
49
  prerelease: false
57
50
  version_requirements: !ruby/object:Gem::Requirement
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
62
56
  name: motion-map
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
- - - ! '>='
59
+ - - '>='
66
60
  - !ruby/object:Gem::Version
67
61
  version: '0'
68
62
  type: :runtime
69
- description: Blah Blah attributions
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: FontAwesomess for IOS apps
70
70
  email:
71
71
  - fernand.galiana@gmail.com
72
72
  executables: []
@@ -86,7 +86,9 @@ files:
86
86
  - app/controllers/e.rb
87
87
  - app/controllers/z.rb
88
88
  - lib/assets/fontawesome-webfont.ttf
89
+ - lib/assets/fontawesome-webfont.ttf.old
89
90
  - lib/assets/fontawesome.plist
91
+ - lib/assets/fontawesome.plist.old
90
92
  - lib/motion-awesome.rb
91
93
  - lib/motion-awesome/awesome.rb
92
94
  - lib/motion-awesome/core_ext/ui_label.rb
@@ -106,12 +108,12 @@ require_paths:
106
108
  - lib
107
109
  required_ruby_version: !ruby/object:Gem::Requirement
108
110
  requirements:
109
- - - ! '>='
111
+ - - '>='
110
112
  - !ruby/object:Gem::Version
111
113
  version: '0'
112
114
  required_rubygems_version: !ruby/object:Gem::Requirement
113
115
  requirements:
114
- - - ! '>='
116
+ - - '>='
115
117
  - !ruby/object:Gem::Version
116
118
  version: '0'
117
119
  requirements: []