vibrant 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/examples/.gitignore +17 -0
- data/examples/Gemfile +18 -0
- data/examples/Gemfile.lock +135 -0
- data/examples/README.rdoc +28 -0
- data/examples/Rakefile +6 -0
- data/examples/app/assets/images/.keep +0 -0
- data/examples/app/assets/javascripts/application.coffee +1 -0
- data/examples/app/assets/javascripts/home.coffee +0 -0
- data/examples/app/assets/stylesheets/application.css +15 -0
- data/examples/app/assets/stylesheets/home.scss +3 -0
- data/examples/app/controllers/application_controller.rb +3 -0
- data/examples/app/controllers/concerns/.keep +0 -0
- data/examples/app/controllers/home_controller.rb +20 -0
- data/examples/app/helpers/application_helper.rb +2 -0
- data/examples/app/helpers/home_helper.rb +2 -0
- data/examples/app/mailers/.keep +0 -0
- data/examples/app/models/.keep +0 -0
- data/examples/app/models/concerns/.keep +0 -0
- data/examples/app/uploaders/photo_uploader.rb +51 -0
- data/examples/app/views/home/index.html.erb +26 -0
- data/examples/app/views/layouts/application.html.erb +14 -0
- data/examples/bin/bundle +3 -0
- data/examples/bin/rails +8 -0
- data/examples/bin/rake +8 -0
- data/examples/bin/setup +29 -0
- data/examples/bin/spring +15 -0
- data/examples/config.ru +4 -0
- data/examples/config/application.rb +29 -0
- data/examples/config/boot.rb +3 -0
- data/examples/config/database.yml +25 -0
- data/examples/config/environment.rb +5 -0
- data/examples/config/environments/development.rb +41 -0
- data/examples/config/environments/production.rb +79 -0
- data/examples/config/environments/test.rb +42 -0
- data/examples/config/initializers/assets.rb +11 -0
- data/examples/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/config/initializers/cookies_serializer.rb +3 -0
- data/examples/config/initializers/filter_parameter_logging.rb +4 -0
- data/examples/config/initializers/inflections.rb +16 -0
- data/examples/config/initializers/mime_types.rb +4 -0
- data/examples/config/initializers/session_store.rb +3 -0
- data/examples/config/initializers/wrap_parameters.rb +14 -0
- data/examples/config/locales/en.yml +23 -0
- data/examples/config/routes.rb +6 -0
- data/examples/config/secrets.yml +22 -0
- data/examples/db/seeds.rb +7 -0
- data/examples/lib/assets/.keep +0 -0
- data/examples/lib/tasks/.keep +0 -0
- data/examples/log/.keep +0 -0
- data/examples/public/1.jpg +0 -0
- data/examples/public/2.jpg +0 -0
- data/examples/public/3.jpg +0 -0
- data/examples/public/4.jpg +0 -0
- data/examples/public/404.html +67 -0
- data/examples/public/422.html +67 -0
- data/examples/public/500.html +66 -0
- data/examples/public/favicon.ico +0 -0
- data/examples/public/octocat.png +0 -0
- data/examples/public/robots.txt +5 -0
- data/examples/test/controllers/.keep +0 -0
- data/examples/test/controllers/home_controller_test.rb +9 -0
- data/examples/test/fixtures/.keep +0 -0
- data/examples/test/helpers/.keep +0 -0
- data/examples/test/integration/.keep +0 -0
- data/examples/test/mailers/.keep +0 -0
- data/examples/test/models/.keep +0 -0
- data/examples/test/test_helper.rb +10 -0
- data/examples/vendor/assets/javascripts/.keep +0 -0
- data/examples/vendor/assets/stylesheets/.keep +0 -0
- data/images/1.jpg +0 -0
- data/images/2.jpg +0 -0
- data/images/3.jpg +0 -0
- data/images/4.jpg +0 -0
- data/images/octocat.png +0 -0
- data/lib/vibrant.rb +15 -0
- data/lib/vibrant/swatch.rb +55 -0
- data/lib/vibrant/version.rb +4 -0
- data/lib/vibrant/vibrant.rb +177 -0
- data/vibrant-rb.gemspec +25 -0
- metadata +174 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
9
|
+
end
|
10
|
+
|
11
|
+
# To enable root element in JSON for ActiveRecord objects.
|
12
|
+
# ActiveSupport.on_load(:active_record) do
|
13
|
+
# self.include_root_in_json = true
|
14
|
+
# end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
+
# than English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t 'hello'
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t('hello') %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# To learn more, please read the Rails Internationalization guide
|
20
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
21
|
+
|
22
|
+
en:
|
23
|
+
hello: "Hello world"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rake secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure the secrets in this file are kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
|
13
|
+
development:
|
14
|
+
secret_key_base: e7f947cc6d465fb986b74cc221e9211ea7c59cfcc40d2356ece42332fce26f2f73b8751b515ed8e751bde107e779165ef565d350b8d52ecf9379411112f560f2
|
15
|
+
|
16
|
+
test:
|
17
|
+
secret_key_base: 65ca70f8c70a4023185a8db7be81b0abe03bc116c8d0e32d68d1a69cd05492e42b10f99319f996c14c14a63b6db9b7e30ac9fe807de693af325313cf8e6f6eec
|
18
|
+
|
19
|
+
# Do not keep production secrets in the repository,
|
20
|
+
# instead read values from the environment.
|
21
|
+
production:
|
22
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
7
|
+
# Mayor.create(name: 'Emanuel', city: cities.first)
|
File without changes
|
File without changes
|
data/examples/log/.keep
ADDED
File without changes
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/404.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/422.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
File without changes
|
Binary file
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
require File.expand_path('../../config/environment', __FILE__)
|
3
|
+
require 'rails/test_help'
|
4
|
+
|
5
|
+
class ActiveSupport::TestCase
|
6
|
+
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
7
|
+
fixtures :all
|
8
|
+
|
9
|
+
# Add more helper methods to be used by all tests here...
|
10
|
+
end
|
File without changes
|
File without changes
|
data/images/1.jpg
ADDED
Binary file
|
data/images/2.jpg
ADDED
Binary file
|
data/images/3.jpg
ADDED
Binary file
|
data/images/4.jpg
ADDED
Binary file
|
data/images/octocat.png
ADDED
Binary file
|
data/lib/vibrant.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'vibrant/version'
|
4
|
+
require 'rmagick'
|
5
|
+
|
6
|
+
require 'vibrant/swatch'
|
7
|
+
require 'vibrant/vibrant'
|
8
|
+
|
9
|
+
module Vibrant
|
10
|
+
|
11
|
+
def self.read(sourceImage, color_count: 64, quality: 5)
|
12
|
+
Vibrant.new(sourceImage, color_count: color_count, quality:quality).swatches
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Vibrant
|
3
|
+
|
4
|
+
class Swatches
|
5
|
+
|
6
|
+
attr_reader :vibrant, :muted, :dark_vibrant, :dark_muted, :light_vibrant,:light_muted
|
7
|
+
|
8
|
+
def initialize(vibrant: nil,
|
9
|
+
muted: nil,
|
10
|
+
dark_vibrant: nil,
|
11
|
+
dark_muted: nil,
|
12
|
+
light_vibrant: nil,
|
13
|
+
light_muted: nil)
|
14
|
+
|
15
|
+
@vibrant = vibrant
|
16
|
+
@muted = muted
|
17
|
+
@dark_vibrant = dark_vibrant
|
18
|
+
@dark_muted = dark_muted
|
19
|
+
@light_vibrant = light_vibrant
|
20
|
+
@light_muted = light_muted
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
class Swatch
|
27
|
+
|
28
|
+
attr_accessor :population, :hex, :hsla
|
29
|
+
|
30
|
+
def initialize(hex, hsla, population)
|
31
|
+
@population = population
|
32
|
+
@hex = hex
|
33
|
+
@hsla = hsla
|
34
|
+
@yiq = 0
|
35
|
+
end
|
36
|
+
|
37
|
+
# def title_text_color
|
38
|
+
# @ensure_text_colors
|
39
|
+
# @yiq<200 ? "#fff" : "#000"
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# def body_text_color
|
43
|
+
# @ensure_text_colors
|
44
|
+
# @yiq<150 ? "#fff" : "#000"
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
#protected
|
48
|
+
#
|
49
|
+
# def ensure_text_colors
|
50
|
+
# @yiq ||= (@rgb[0] * 299 + @rgb[1] * 587 + @rgb[2] * 114) / 1000
|
51
|
+
# end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|