kuler 0.1.0
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.tar.gz.sig +1 -0
- data/CHANGELOG.rdoc +7 -0
- data/LICENSE +24 -0
- data/Manifest.txt +12 -0
- data/README.rdoc +62 -0
- data/Rakefile +15 -0
- data/lib/kuler.rb +64 -0
- data/lib/kuler/swatch.rb +15 -0
- data/lib/kuler/theme.rb +48 -0
- data/test/fixtures/single_random_result.xml +102 -0
- data/test/test_kuler.rb +82 -0
- data/test/test_kuler_swatch.rb +24 -0
- data/test/test_kuler_theme.rb +46 -0
- metadata +138 -0
- metadata.gz.sig +0 -0
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
-���p��L�T2����:��1�p�cr�h*�%�IN��|�n���8u~��n�i�&x�!���<9�7�!OJ-�o���,�\h��[��7�{=%,�P�#4��$rp�U,�O�+�3+|�x�o}J���iR�b~�8G&@��.@�K�ج1��+��0�Aʍ.ȯ��PGd̥5f%ma�d9��Þӵ
|
data/CHANGELOG.rdoc
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
= KULER LICENSE
|
2
|
+
|
3
|
+
(the MIT license)
|
4
|
+
|
5
|
+
Copyright (c) 2010 Ben Bleything <ben@bleything.net>
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
8
|
+
a copy of this software and associated documentation files (the
|
9
|
+
"Software"), to deal in the Software without restriction, including
|
10
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
11
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
+
permit persons to whom the Software is furnished to do so, subject to
|
13
|
+
the following conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be included
|
16
|
+
in all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
19
|
+
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
20
|
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
= kuler
|
2
|
+
|
3
|
+
* http://github.com/bleything/kuler
|
4
|
+
* http://kuler.adobe.com
|
5
|
+
|
6
|
+
== DESCRIPTION
|
7
|
+
|
8
|
+
Kuler is a fun little webapp that allows you to discover, explore, and
|
9
|
+
share color themes. This is a Ruby library to access the Kuler service.
|
10
|
+
|
11
|
+
To use Kuler, you'll need an API key, which you can obtain from Adobe at
|
12
|
+
http://kuler.adobe.com/api
|
13
|
+
|
14
|
+
== FEATURES/PROBLEMS
|
15
|
+
|
16
|
+
* retrieve color themes from Kuler:
|
17
|
+
* most recent themes
|
18
|
+
* most popular
|
19
|
+
* highest rated
|
20
|
+
* random
|
21
|
+
|
22
|
+
== SYNOPSIS
|
23
|
+
|
24
|
+
Set up a new Kuler instance with your API key:
|
25
|
+
|
26
|
+
kuler = Kuler.new( 'your api key' )
|
27
|
+
|
28
|
+
# ... or ...
|
29
|
+
|
30
|
+
kuler = Kuler.new
|
31
|
+
kuler.api_key = 'your api key'
|
32
|
+
|
33
|
+
... then, grab a random color theme:
|
34
|
+
|
35
|
+
theme = kuler.fetch_random_theme
|
36
|
+
|
37
|
+
... and inspect the color theme:
|
38
|
+
|
39
|
+
theme.hex_codes
|
40
|
+
=> [ "#ff0000", "#00ff00", "#0000ff", "#ffff00", "#ff00ff" ]
|
41
|
+
|
42
|
+
For more, check out the rdoc.
|
43
|
+
|
44
|
+
== REQUIREMENTS
|
45
|
+
|
46
|
+
For users:
|
47
|
+
* nokogiri
|
48
|
+
|
49
|
+
For developers:
|
50
|
+
* hoe
|
51
|
+
* hoe-doofus
|
52
|
+
* hoe-git
|
53
|
+
* mocha
|
54
|
+
|
55
|
+
== INSTALL
|
56
|
+
|
57
|
+
* gem install kuler
|
58
|
+
|
59
|
+
== LICENSE
|
60
|
+
|
61
|
+
kuler is copyright (c) 2010 Ben Bleything, and distributed under the
|
62
|
+
terms of the MIT license. See the LICENSE file for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'hoe'
|
3
|
+
|
4
|
+
Hoe.plugin :doofus, :git
|
5
|
+
|
6
|
+
Hoe.spec 'kuler' do
|
7
|
+
developer 'Ben Bleything', 'ben@bleything.net'
|
8
|
+
|
9
|
+
self.extra_rdoc_files = Dir['*.rdoc'] + ['LICENSE']
|
10
|
+
self.history_file = 'CHANGELOG.rdoc'
|
11
|
+
self.readme_file = 'README.rdoc'
|
12
|
+
|
13
|
+
self.extra_deps << [ "nokogiri", "~> 1.4.1" ]
|
14
|
+
self.extra_dev_deps << [ "mocha", "~> 0.9.8" ]
|
15
|
+
end
|
data/lib/kuler.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
require 'kuler/swatch'
|
5
|
+
require 'kuler/theme'
|
6
|
+
|
7
|
+
class Kuler
|
8
|
+
VERSION = '0.1.0' # :nodoc:
|
9
|
+
BASE_URL = "http://kuler-api.adobe.com" # :nodoc:
|
10
|
+
|
11
|
+
### the key required to access the kuler API
|
12
|
+
attr_reader :api_key
|
13
|
+
|
14
|
+
### Create a new Kuler object. Accepts a single argument, the
|
15
|
+
### +api_key+.
|
16
|
+
def initialize( api_key )
|
17
|
+
@api_key = api_key
|
18
|
+
end
|
19
|
+
|
20
|
+
### Build the appropriate URL for a request to the Kuler API.
|
21
|
+
###
|
22
|
+
### Parameters:
|
23
|
+
### +type+:: the type of API call to make. Options are +recent+,
|
24
|
+
### +popular+, +rating+, or +random+.
|
25
|
+
### +limit+:: the number of themes to return. Valid range is
|
26
|
+
### 1 to 100.
|
27
|
+
def build_url( args = {} )
|
28
|
+
# default options
|
29
|
+
opts = {
|
30
|
+
:type => :recent,
|
31
|
+
:limit => 20
|
32
|
+
}.merge( args )
|
33
|
+
|
34
|
+
unless [ :recent, :popular, :rating, :random ].include? opts[:type]
|
35
|
+
raise ArgumentError, "unknown feed type '#{opts[:type]}'. Valid options are recent, popular, rating, or random"
|
36
|
+
end
|
37
|
+
|
38
|
+
unless (1..100).include? opts[:limit]
|
39
|
+
raise ArgumentError, "invalid limit: #{opts[:limit]}. Valid options are 1-100"
|
40
|
+
end
|
41
|
+
|
42
|
+
options = {
|
43
|
+
:key => self.api_key,
|
44
|
+
|
45
|
+
:itemsPerPage => opts[:limit],
|
46
|
+
:listType => opts[:type],
|
47
|
+
}
|
48
|
+
|
49
|
+
get_args = options.
|
50
|
+
sort_by {|k,v| k.to_s }.
|
51
|
+
map {|k,v| "#{k}=#{v}" }.
|
52
|
+
join( "&" )
|
53
|
+
|
54
|
+
return "#{BASE_URL}/rss/get.cfm?#{get_args}"
|
55
|
+
end
|
56
|
+
|
57
|
+
### fetch a single random color theme
|
58
|
+
def fetch_random_theme
|
59
|
+
url = build_url( :type => :random, :limit => 1 )
|
60
|
+
xml = Nokogiri::XML( open(url) ).at( "//kuler:themeItem" )
|
61
|
+
return Kuler::Theme.new( xml )
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
data/lib/kuler/swatch.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
class Kuler
|
2
|
+
class Swatch
|
3
|
+
|
4
|
+
### the hex code of the color swatch
|
5
|
+
attr_accessor :hex_code
|
6
|
+
|
7
|
+
### create a new Kuler::Swatch from a Nokogiri::XML::Element
|
8
|
+
def initialize( input )
|
9
|
+
hex = input.at( "./kuler:swatchHexColor" ).text
|
10
|
+
@hex_code = "##{hex.downcase}"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
end # class Kuler
|
data/lib/kuler/theme.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
class Kuler
|
2
|
+
class Theme
|
3
|
+
|
4
|
+
### the Kuler ID for the theme
|
5
|
+
attr_reader :theme_id
|
6
|
+
|
7
|
+
### the title of the theme
|
8
|
+
attr_reader :title
|
9
|
+
|
10
|
+
### array of tags attached to this theme
|
11
|
+
attr_reader :tags
|
12
|
+
|
13
|
+
### theme rating, 1-5
|
14
|
+
attr_reader :rating
|
15
|
+
|
16
|
+
### the display name of the theme's creator
|
17
|
+
attr_reader :author_name
|
18
|
+
|
19
|
+
### the Kuler ID for the theme's creator
|
20
|
+
attr_reader :author_id
|
21
|
+
|
22
|
+
### an array of Kuler::Swatch objects representing the colors in
|
23
|
+
### this theme
|
24
|
+
attr_reader :swatches
|
25
|
+
|
26
|
+
|
27
|
+
### create a new Kuler::Theme from a Nokogiri::XML::Element
|
28
|
+
def initialize( input )
|
29
|
+
@theme_id = input.at( "//kuler:themeID" ).text.to_i
|
30
|
+
@title = input.at( "//kuler:themeTitle" ).text
|
31
|
+
@tags = input.at( "//kuler:themeTags" ).text.gsub(/\s/, '').split(',')
|
32
|
+
@rating = input.at( "//kuler:themeRating" ).text.to_i
|
33
|
+
|
34
|
+
@author_name = input.at( "//kuler:themeAuthor/kuler:authorLabel" ).text
|
35
|
+
@author_id = input.at( "//kuler:themeAuthor/kuler:authorID" ).text.to_i
|
36
|
+
|
37
|
+
@swatches = input.search( "//kuler:swatch" ).map {|nodes| Kuler::Swatch.new nodes }
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
### returns an array of hex values of the swatches in this theme
|
42
|
+
def hex_codes
|
43
|
+
self.swatches.map {|s| s.hex_code }
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end # class Kuler
|
@@ -0,0 +1,102 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<rss xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:kuler="http://kuler.adobe.com/kuler/API/rss/" xmlns:rss="http://blogs.law.harvard.edu/tech/rss" version="2.0">
|
3
|
+
<channel>
|
4
|
+
<title>kuler popular themes</title>
|
5
|
+
<link>http://kuler.adobe.com/</link>
|
6
|
+
<description>most popular themes on kuler (1 to 1 of
|
7
|
+
328331)</description>
|
8
|
+
<language>en-us</language>
|
9
|
+
<pubDate>Sun, 28 Mar 2010 19:00:58 PST</pubDate>
|
10
|
+
<lastBuildDate>Sun, 28 Mar 2010 19:00:58 PST</lastBuildDate>
|
11
|
+
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
|
12
|
+
<generator>Kuler Services</generator>
|
13
|
+
<managingEditor>kulerfeedback@adobe.com</managingEditor>
|
14
|
+
<webMaster>kulerfeedback@adobe.com</webMaster>
|
15
|
+
<recordCount>328331</recordCount>
|
16
|
+
<startIndex>0</startIndex>
|
17
|
+
<itemsPerPage>1</itemsPerPage>
|
18
|
+
<item>
|
19
|
+
<title>Theme Title: sandy stone beach ocean diver</title>
|
20
|
+
<link>http://kuler.adobe.com/index.cfm#themeID/15325</link>
|
21
|
+
<guid>http://kuler.adobe.com/index.cfm#themeID/15325</guid>
|
22
|
+
<enclosure xmlns="http://www.solitude.dk/syndication/enclosures/">
|
23
|
+
|
24
|
+
<title>sandy stone beach ocean diver</title>
|
25
|
+
<link length="1" type="image/png">
|
26
|
+
<url>
|
27
|
+
http://kuler-api.adobe.com/kuler/themeImages/theme_15325.png</url>
|
28
|
+
</link>
|
29
|
+
</enclosure>
|
30
|
+
<description><img
|
31
|
+
src="http://kuler-api.adobe.com/kuler/themeImages/theme_15325.png"
|
32
|
+
/><br /> Artist: ps<br /> ThemeID: 15325<br
|
33
|
+
/> Posted: 01/18/2007<br /> Tags: beach, diver,
|
34
|
+
ocean, sandy, stone <br /> Hex: E6E2AF, A7A37E, EFECCA,
|
35
|
+
046380, 002F2F</description>
|
36
|
+
<kuler:themeItem>
|
37
|
+
<kuler:themeID>15325</kuler:themeID>
|
38
|
+
<kuler:themeTitle>sandy stone beach ocean diver</kuler:themeTitle>
|
39
|
+
<kuler:themeImage>
|
40
|
+
http://kuler-api.adobe.com/kuler/themeImages/theme_15325.png</kuler:themeImage>
|
41
|
+
<kuler:themeAuthor>
|
42
|
+
<kuler:authorID>17923</kuler:authorID>
|
43
|
+
<kuler:authorLabel>ps</kuler:authorLabel>
|
44
|
+
</kuler:themeAuthor>
|
45
|
+
<kuler:themeTags>beach, diver, ocean, sandy,
|
46
|
+
stone</kuler:themeTags>
|
47
|
+
<kuler:themeRating>4</kuler:themeRating>
|
48
|
+
<kuler:themeDownloadCount>20476</kuler:themeDownloadCount>
|
49
|
+
<kuler:themeCreatedAt>20070118</kuler:themeCreatedAt>
|
50
|
+
<kuler:themeEditedAt>20070118</kuler:themeEditedAt>
|
51
|
+
<kuler:themeSwatches>
|
52
|
+
<kuler:swatch>
|
53
|
+
<kuler:swatchHexColor>E6E2AF</kuler:swatchHexColor>
|
54
|
+
<kuler:swatchColorMode>rgb</kuler:swatchColorMode>
|
55
|
+
<kuler:swatchChannel1>0.901961</kuler:swatchChannel1>
|
56
|
+
<kuler:swatchChannel2>0.886275</kuler:swatchChannel2>
|
57
|
+
<kuler:swatchChannel3>0.686275</kuler:swatchChannel3>
|
58
|
+
<kuler:swatchChannel4>0.0</kuler:swatchChannel4>
|
59
|
+
<kuler:swatchIndex>0</kuler:swatchIndex>
|
60
|
+
</kuler:swatch>
|
61
|
+
<kuler:swatch>
|
62
|
+
<kuler:swatchHexColor>A7A37E</kuler:swatchHexColor>
|
63
|
+
<kuler:swatchColorMode>rgb</kuler:swatchColorMode>
|
64
|
+
<kuler:swatchChannel1>0.654902</kuler:swatchChannel1>
|
65
|
+
<kuler:swatchChannel2>0.639216</kuler:swatchChannel2>
|
66
|
+
<kuler:swatchChannel3>0.494118</kuler:swatchChannel3>
|
67
|
+
<kuler:swatchChannel4>0.0</kuler:swatchChannel4>
|
68
|
+
<kuler:swatchIndex>1</kuler:swatchIndex>
|
69
|
+
</kuler:swatch>
|
70
|
+
<kuler:swatch>
|
71
|
+
<kuler:swatchHexColor>EFECCA</kuler:swatchHexColor>
|
72
|
+
<kuler:swatchColorMode>rgb</kuler:swatchColorMode>
|
73
|
+
<kuler:swatchChannel1>0.937255</kuler:swatchChannel1>
|
74
|
+
<kuler:swatchChannel2>0.92549</kuler:swatchChannel2>
|
75
|
+
<kuler:swatchChannel3>0.792157</kuler:swatchChannel3>
|
76
|
+
<kuler:swatchChannel4>0.0</kuler:swatchChannel4>
|
77
|
+
<kuler:swatchIndex>2</kuler:swatchIndex>
|
78
|
+
</kuler:swatch>
|
79
|
+
<kuler:swatch>
|
80
|
+
<kuler:swatchHexColor>046380</kuler:swatchHexColor>
|
81
|
+
<kuler:swatchColorMode>rgb</kuler:swatchColorMode>
|
82
|
+
<kuler:swatchChannel1>0.0156863</kuler:swatchChannel1>
|
83
|
+
<kuler:swatchChannel2>0.388235</kuler:swatchChannel2>
|
84
|
+
<kuler:swatchChannel3>0.501961</kuler:swatchChannel3>
|
85
|
+
<kuler:swatchChannel4>0.0</kuler:swatchChannel4>
|
86
|
+
<kuler:swatchIndex>3</kuler:swatchIndex>
|
87
|
+
</kuler:swatch>
|
88
|
+
<kuler:swatch>
|
89
|
+
<kuler:swatchHexColor>002F2F</kuler:swatchHexColor>
|
90
|
+
<kuler:swatchColorMode>rgb</kuler:swatchColorMode>
|
91
|
+
<kuler:swatchChannel1>0.0</kuler:swatchChannel1>
|
92
|
+
<kuler:swatchChannel2>0.184314</kuler:swatchChannel2>
|
93
|
+
<kuler:swatchChannel3>0.184314</kuler:swatchChannel3>
|
94
|
+
<kuler:swatchChannel4>0.0</kuler:swatchChannel4>
|
95
|
+
<kuler:swatchIndex>4</kuler:swatchIndex>
|
96
|
+
</kuler:swatch>
|
97
|
+
</kuler:themeSwatches>
|
98
|
+
</kuler:themeItem>
|
99
|
+
<pubDate>Sun, 28 Mar 2010 19:00:58 PST</pubDate>
|
100
|
+
</item>
|
101
|
+
</channel>
|
102
|
+
</rss>
|
data/test/test_kuler.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require 'mocha'
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
require "kuler"
|
6
|
+
|
7
|
+
class TestKuler < Test::Unit::TestCase
|
8
|
+
API_KEY = "test_api_key"
|
9
|
+
FIXTURES = Pathname.new( File.dirname(__FILE__) ).expand_path + "fixtures"
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@kuler = Kuler.new( API_KEY )
|
13
|
+
end
|
14
|
+
|
15
|
+
########################################################################
|
16
|
+
### Basics
|
17
|
+
|
18
|
+
def test_creation
|
19
|
+
sample_key = '123456'
|
20
|
+
|
21
|
+
kuler = Kuler.new( sample_key )
|
22
|
+
assert_equal sample_key, kuler.api_key, "api key does not match"
|
23
|
+
end
|
24
|
+
|
25
|
+
########################################################################
|
26
|
+
### feed url generation
|
27
|
+
|
28
|
+
def test_url_builder
|
29
|
+
expected = "http://kuler-api.adobe.com/rss/get.cfm?itemsPerPage=20&key=#{API_KEY}&listType=recent"
|
30
|
+
actual = @kuler.build_url
|
31
|
+
|
32
|
+
assert_equal expected, actual, "feed url incorrectly generated"
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_url_builder_with_options
|
36
|
+
expected = "http://kuler-api.adobe.com/rss/get.cfm?itemsPerPage=100&key=#{API_KEY}&listType=random"
|
37
|
+
|
38
|
+
actual = @kuler.build_url( :type => :random, :limit => 100 )
|
39
|
+
assert_equal expected, actual
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_url_builder_argument_checking
|
43
|
+
# unknown feed type
|
44
|
+
assert_raise ArgumentError do
|
45
|
+
@kuler.build_url :type => :foo
|
46
|
+
end
|
47
|
+
|
48
|
+
assert_nothing_raised do
|
49
|
+
@kuler.build_url :type => :recent
|
50
|
+
end
|
51
|
+
|
52
|
+
# invalid counts
|
53
|
+
assert_raise ArgumentError do
|
54
|
+
@kuler.build_url :limit => 0
|
55
|
+
end
|
56
|
+
|
57
|
+
assert_raise ArgumentError do
|
58
|
+
@kuler.build_url :limit => 101
|
59
|
+
end
|
60
|
+
|
61
|
+
assert_nothing_raised do
|
62
|
+
@kuler.build_url :limit => 1
|
63
|
+
@kuler.build_url :limit => 50
|
64
|
+
@kuler.build_url :limit => 100
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
########################################################################
|
70
|
+
### feed url generation
|
71
|
+
|
72
|
+
def test_fetch_random_theme
|
73
|
+
url = @kuler.build_url( :type => :random, :limit => 1 )
|
74
|
+
xml = FIXTURES + "single_random_result.xml"
|
75
|
+
@kuler.expects( :open ).with( url ).returns( xml.read )
|
76
|
+
|
77
|
+
theme = @kuler.fetch_random_theme
|
78
|
+
assert_kind_of Kuler::Theme, theme
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require 'mocha'
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
require "kuler"
|
6
|
+
|
7
|
+
FIXTURES = Pathname.new( File.dirname(__FILE__) ).expand_path + "fixtures"
|
8
|
+
|
9
|
+
class TestKulerSwatch < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def setup
|
12
|
+
xml = FIXTURES + "single_random_result.xml"
|
13
|
+
nodes = Nokogiri::XML( xml.read ).at( "//kuler:swatch" )
|
14
|
+
@swatch = Kuler::Swatch.new( nodes )
|
15
|
+
end
|
16
|
+
|
17
|
+
########################################################################
|
18
|
+
### Basics
|
19
|
+
|
20
|
+
def test_create
|
21
|
+
assert_equal "#e6e2af", @swatch.hex_code
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
require "kuler"
|
5
|
+
|
6
|
+
class TestKulerTheme < Test::Unit::TestCase
|
7
|
+
FIXTURES = Pathname.new( File.dirname(__FILE__) ).expand_path + "fixtures"
|
8
|
+
|
9
|
+
def setup
|
10
|
+
xml = FIXTURES + "single_random_result.xml"
|
11
|
+
nodes = Nokogiri::XML( xml.read ).at( "//kuler:themeItem" )
|
12
|
+
@theme = Kuler::Theme.new( nodes )
|
13
|
+
end
|
14
|
+
|
15
|
+
########################################################################
|
16
|
+
### Basics
|
17
|
+
|
18
|
+
def test_create
|
19
|
+
assert_equal 15325, @theme.theme_id
|
20
|
+
assert_equal "sandy stone beach ocean diver", @theme.title
|
21
|
+
assert_equal %w( beach diver ocean sandy stone ), @theme.tags
|
22
|
+
assert_equal 4, @theme.rating
|
23
|
+
|
24
|
+
assert_equal "ps", @theme.author_name
|
25
|
+
assert_equal 17923, @theme.author_id
|
26
|
+
|
27
|
+
assert_equal 5, @theme.swatches.size
|
28
|
+
@theme.swatches.each do |swatch|
|
29
|
+
assert_kind_of Kuler::Swatch, swatch
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_hex_codes
|
34
|
+
expected = [
|
35
|
+
"#e6e2af",
|
36
|
+
"#a7a37e",
|
37
|
+
"#efecca",
|
38
|
+
"#046380",
|
39
|
+
"#002f2f"
|
40
|
+
]
|
41
|
+
|
42
|
+
assert_equal expected, @theme.hex_codes
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kuler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Bleything
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDMDCCAhigAwIBAgIBADANBgkqhkiG9w0BAQUFADA+MQwwCgYDVQQDDANiZW4x
|
14
|
+
GTAXBgoJkiaJk/IsZAEZFglibGV5dGhpbmcxEzARBgoJkiaJk/IsZAEZFgNuZXQw
|
15
|
+
HhcNMTAwMzMwMDAxNDA4WhcNMTEwMzMwMDAxNDA4WjA+MQwwCgYDVQQDDANiZW4x
|
16
|
+
GTAXBgoJkiaJk/IsZAEZFglibGV5dGhpbmcxEzARBgoJkiaJk/IsZAEZFgNuZXQw
|
17
|
+
ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC27Ag3uGxIjWFrTQ24YkZN
|
18
|
+
a1rPRKK6fM7lYjGCOH1hyhqSejZ3wtH9i9mM3scf6BzsweyU3GQ0t98fTJ+XF9+c
|
19
|
+
ciYaORr/VZpgs/JhjLZYer6Uvh2GA2qewtFOT88d7gW3v7LCu9nx7Xe6oiei4FDU
|
20
|
+
q6B5zUGSTqPlIiF7Ij17w2BkVAHu6oPShssfgwb+ZKhi7ABJ/KapCs8YK7Vx7Ndo
|
21
|
+
iZ1Nc31SfYUKWabxloy1qQCq2RZ24tukYTWcG0UXXTGbXsc3kbFJ1U+Zb+6ajwJW
|
22
|
+
fsaCIcjXP2OkwWAN3vJjYehaSoGVUgBcTlPVTvr0r2z2W1rlqY62qTxuHUSg5kSR
|
23
|
+
AgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBRHtCE+
|
24
|
+
brJGSZWqcCvS+ktcf7iNCzANBgkqhkiG9w0BAQUFAAOCAQEAJXV7CnRGhd8v2lp2
|
25
|
+
iphdVSgo1MFvtLyoDzdw1XQ8C6o4ELRH7eQxtqivRBQ3YB8AsRy9FtfUE46g8dLS
|
26
|
+
pwFRB+GIaHKMTNp3VgZ6VpwF5S9V73hA68nDP+R8nAjbxc/ePBXAAXY/EVJcCL+Y
|
27
|
+
dYmZU45WjTCAqZ4NRO4Izw2cqOQ7VWFLk6224fp7jaXxJkoHoVEm3d7vYYur1ff/
|
28
|
+
XfgKtX2YuzxNOCbRbtzLpeVmRWg0kf15/69/XUKD6Y6sQhi/0KBuyxgYtK9dkivK
|
29
|
+
zDDMEedi9o0PsLUMBalt+R1iDFZLm4WVDET0/qsW+Q7V7RjJRRs/+532JMdow+H5
|
30
|
+
2oorXg==
|
31
|
+
-----END CERTIFICATE-----
|
32
|
+
|
33
|
+
date: 2010-03-29 00:00:00 -07:00
|
34
|
+
default_executable:
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: nokogiri
|
38
|
+
type: :runtime
|
39
|
+
version_requirement:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 1.4.1
|
45
|
+
version:
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rubyforge
|
48
|
+
type: :development
|
49
|
+
version_requirement:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.0.3
|
55
|
+
version:
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: mocha
|
58
|
+
type: :development
|
59
|
+
version_requirement:
|
60
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ~>
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 0.9.8
|
65
|
+
version:
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: hoe
|
68
|
+
type: :development
|
69
|
+
version_requirement:
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 2.6.0
|
75
|
+
version:
|
76
|
+
description: |-
|
77
|
+
Kuler is a fun little webapp that allows you to discover, explore, and
|
78
|
+
share color themes. This is a Ruby library to access the Kuler service.
|
79
|
+
|
80
|
+
To use Kuler, you'll need an API key, which you can obtain from Adobe at
|
81
|
+
http://kuler.adobe.com/api
|
82
|
+
email:
|
83
|
+
- ben@bleything.net
|
84
|
+
executables: []
|
85
|
+
|
86
|
+
extensions: []
|
87
|
+
|
88
|
+
extra_rdoc_files:
|
89
|
+
- Manifest.txt
|
90
|
+
- CHANGELOG.rdoc
|
91
|
+
- README.rdoc
|
92
|
+
- LICENSE
|
93
|
+
files:
|
94
|
+
- CHANGELOG.rdoc
|
95
|
+
- LICENSE
|
96
|
+
- Manifest.txt
|
97
|
+
- README.rdoc
|
98
|
+
- Rakefile
|
99
|
+
- lib/kuler.rb
|
100
|
+
- lib/kuler/swatch.rb
|
101
|
+
- lib/kuler/theme.rb
|
102
|
+
- test/fixtures/single_random_result.xml
|
103
|
+
- test/test_kuler.rb
|
104
|
+
- test/test_kuler_swatch.rb
|
105
|
+
- test/test_kuler_theme.rb
|
106
|
+
has_rdoc: true
|
107
|
+
homepage: http://github.com/bleything/kuler
|
108
|
+
licenses: []
|
109
|
+
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options:
|
112
|
+
- --main
|
113
|
+
- README.rdoc
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: "0"
|
121
|
+
version:
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: "0"
|
127
|
+
version:
|
128
|
+
requirements: []
|
129
|
+
|
130
|
+
rubyforge_project: kuler
|
131
|
+
rubygems_version: 1.3.5
|
132
|
+
signing_key:
|
133
|
+
specification_version: 3
|
134
|
+
summary: Kuler is a fun little webapp that allows you to discover, explore, and share color themes
|
135
|
+
test_files:
|
136
|
+
- test/test_kuler.rb
|
137
|
+
- test/test_kuler_swatch.rb
|
138
|
+
- test/test_kuler_theme.rb
|
metadata.gz.sig
ADDED
Binary file
|