overcast 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ # YARD artifacts
20
+ .yardoc
21
+ _yardoc
22
+ doc/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in overcast.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jesper Christiansen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,49 @@
1
+ # Overcast
2
+
3
+ Manipulates colors. You can either lighten or darken a given hex-color
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'overcast'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install overcast
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ Overcast::Color.darken('#cccccc')
23
+ ```
24
+
25
+ The above returns #666666
26
+
27
+ You can specify the amount you want to darken it by, to make it more fine grained (default is amount 0.5)
28
+
29
+ ```ruby
30
+ Overcast::Color.darken('#cccccc', 0.1)
31
+ ````
32
+
33
+ That gives #141414
34
+
35
+ ```ruby
36
+ Overcast::Color.lighten('#ccccc')
37
+ ```
38
+
39
+ Gives #ffffff
40
+
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create new Pull Request
49
+ >>>>>>> Initial commit
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,31 @@
1
+ require "overcast/version"
2
+
3
+ module Overcast
4
+ # Your code goes here...
5
+ class Color
6
+ def self.darken(hex, amount=0.5)
7
+ hex = remove_pound(hex)
8
+ rgb = convert_to_rgb(hex).map{|element| element * amount }
9
+ convert_to_hex(rgb)
10
+ end
11
+
12
+ def self.lighten(hex, amount=0.5)
13
+ hex = remove_pound(hex)
14
+ rgb = convert_to_rgb(hex).map{ |element| [(element + 255 * amount).round, 255].min }
15
+ convert_to_hex(rgb)
16
+ end
17
+
18
+ private
19
+ def self.remove_pound(hex)
20
+ hex.gsub('#', '')
21
+ end
22
+
23
+ def self.convert_to_rgb(hex)
24
+ hex.scan(/../).map {|color| color.hex}
25
+ end
26
+
27
+ def self.convert_to_hex(rgb)
28
+ "#%02x%02x%02x" % rgb
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,3 @@
1
+ module Overcast
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+ require File.expand_path('../lib/overcast/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Jesper Christiansen"]
6
+ gem.email = ["me@jespr.com"]
7
+ gem.description = %q{Play with hex colors. Darken colors, lighten colors, find the right contrast based on a color.}
8
+ gem.summary = %q{Color manipulation}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "overcast"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Overcast::VERSION
17
+ gem.add_development_dependency "rspec"
18
+ gem.add_development_dependency "rake"
19
+ end
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ require "spec_helper"
4
+ require 'lib/overcast'
5
+
6
+ describe Overcast do
7
+ describe 'darken' do
8
+ it 'darkens the given hex-color by the amount' do
9
+ Overcast::Color.darken('#0f0f0f').should == '#070707'
10
+ end
11
+ end
12
+
13
+ describe "#lighten" do
14
+ it "lightens the given hex-color by the amount" do
15
+ Overcast::Color.lighten('#0f0f0f').should == '#8f8f8f'
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper.rb"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: overcast
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Jesper Christiansen
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2012-04-25 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ segments:
26
+ - 0
27
+ version: "0"
28
+ requirement: *id001
29
+ name: rspec
30
+ prerelease: false
31
+ type: :development
32
+ - !ruby/object:Gem::Dependency
33
+ version_requirements: &id002 !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ segments:
38
+ - 0
39
+ version: "0"
40
+ requirement: *id002
41
+ name: rake
42
+ prerelease: false
43
+ type: :development
44
+ description: Play with hex colors. Darken colors, lighten colors, find the right contrast based on a color.
45
+ email:
46
+ - me@jespr.com
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files: []
52
+
53
+ files:
54
+ - .gitignore
55
+ - .rspec
56
+ - Gemfile
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - lib/overcast.rb
61
+ - lib/overcast/version.rb
62
+ - overcast.gemspec
63
+ - spec/overcast_spec.rb
64
+ - spec/spec_helper.rb
65
+ has_rdoc: true
66
+ homepage: ""
67
+ licenses: []
68
+
69
+ post_install_message:
70
+ rdoc_options: []
71
+
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ requirements: []
89
+
90
+ rubyforge_project:
91
+ rubygems_version: 1.3.6
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: Color manipulation
95
+ test_files:
96
+ - spec/overcast_spec.rb
97
+ - spec/spec_helper.rb