css2cocoa 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{css2cocoa}
8
- s.version = "0.2.3"
8
+ s.version = "0.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Seivan Heidari"]
@@ -1,10 +1,10 @@
1
1
  #"color-stop(.9,#999999)"
2
+ #puts Gradient.parse_gradient("-webkit-gradient(linear, 0% 96%, 0% 100%, from(#38AFFF), to(#FFFFFF))")
2
3
  class Gradient
3
4
  def self.parse_gradient(css_gradient, engine=:webkit)
4
- css_gradient_array = css_gradient.split(", ")
5
-
6
- start_location = css_gradient.split(",")[1].split("%").last.to_i/100
7
- end_location = css_gradient.split(",")[2].split("%").last.to_i/100
5
+ css_gradient_array = css_gradient.split(", ")
6
+ start_location = css_gradient.split(",")[1].split("%").last.to_f/100.0
7
+ end_location = css_gradient.split(",")[2].split("%").last.to_f/100.0
8
8
 
9
9
  start_color, stop_color = css_gradient.split(",")[3..-1]
10
10
  colors_and_locations = {}
@@ -21,8 +21,8 @@ class Gradient
21
21
  puts "Generating two colour gradient!"
22
22
  end
23
23
 
24
- colors_and_locations[start_location.to_f] = start_color.gsub(/(\w+\d+)/).first
25
- colors_and_locations[end_location.to_f] = stop_color.gsub(/(\w+\d+)/).first
24
+ colors_and_locations[start_location.to_f] = start_color.scan(/(\.\d+|\w+)/).flatten.last
25
+ colors_and_locations[end_location.to_f] = stop_color.scan(/(\.\d+|\w+)/).flatten.last
26
26
  colors = []
27
27
  locations = []
28
28
  colors_and_locations.sort.each do |location, color|
@@ -69,3 +69,4 @@ class Gradient
69
69
  end
70
70
  end
71
71
 
72
+ #puts Gradient.parse_gradient("-webkit-gradient(linear, 0% 40%, 0% 100%, from(#EEF1F6), to(#E6154D), color-stop(.923,#999999),color-stop(.1,#999999),color-stop(.6,#999999))")
@@ -8,8 +8,8 @@ describe Gradient, "gradients" do
8
8
  let(:objc_multiple_colors_and_locations) do
9
9
  """
10
10
  #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
11
- gradient.locations = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0],[NSNumber numberWithFloat:0.1],[NSNumber numberWithFloat:0.6],[NSNumber numberWithFloat:0.923],[NSNumber numberWithFloat:1.0],nil];
12
- gradient.colors = [NSArray arrayWithObjects:(id)UIColorFromRGB(0xEEF1F6).CGColor,(id)UIColorFromRGB(0x999999).CGColor,(id)UIColorFromRGB(0x999999).CGColor,(id)UIColorFromRGB(0x999999).CGColor,(id)UIColorFromRGB(0xE6154).CGColor,nil];
11
+ gradient.locations = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.1],[NSNumber numberWithFloat:0.4],[NSNumber numberWithFloat:0.6],[NSNumber numberWithFloat:0.923],[NSNumber numberWithFloat:1.0],nil];
12
+ gradient.colors = [NSArray arrayWithObjects:(id)UIColorFromRGB(0x999999).CGColor,(id)UIColorFromRGB(0xEEF1F6).CGColor,(id)UIColorFromRGB(0x999999).CGColor,(id)UIColorFromRGB(0x999999).CGColor,(id)UIColorFromRGB(0xE6154D).CGColor,nil];
13
13
  """
14
14
  end
15
15
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 3
9
- version: 0.2.3
8
+ - 4
9
+ version: 0.2.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Seivan Heidari
@@ -117,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
117
  requirements:
118
118
  - - ">="
119
119
  - !ruby/object:Gem::Version
120
- hash: -2462370433945846191
120
+ hash: 4301940326048217632
121
121
  segments:
122
122
  - 0
123
123
  version: "0"