findart 0.0.1
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/History.txt +3 -0
- data/Manifest.txt +33 -0
- data/README.rdoc +63 -0
- data/Rakefile +30 -0
- data/bin/findart +55 -0
- data/features/development.feature +13 -0
- data/features/findalbumarturls.feature +38 -0
- data/features/fixtures/search-albumartexchange-daft-punk-discovery.html +107 -0
- data/features/registerdscapers.feature +12 -0
- data/features/step_definitions/common_steps.rb +169 -0
- data/features/step_definitions/findalbumarturls_steps.rb +9 -0
- data/features/support/common.rb +29 -0
- data/features/support/env.rb +14 -0
- data/features/support/matchers.rb +11 -0
- data/lib/FindArt.rb +20 -0
- data/lib/FindArt/scraper.rb +76 -0
- data/lib/FindArt/scrapers/albumartexchange.rb +22 -0
- data/lib/FindArt/scrapers/amazon.rb.disabled +47 -0
- data/lib/FindArt/scrapers/discogs.rb +44 -0
- data/lib/FindArt/scrapers/junodownload.rb +31 -0
- data/lib/FindArt/scrapers/walmart.rb +38 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/albumartexchange_spec.rb +26 -0
- data/spec/amazon_spec.rb +34 -0
- data/spec/discogs_spec.rb +32 -0
- data/spec/junodownload_spec.rb +32 -0
- data/spec/scraper_spec.rb +121 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/walmart_spec.rb +26 -0
- data/tasks/rspec.rake +25 -0
- metadata +164 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.rdoc
|
4
|
+
Rakefile
|
5
|
+
bin/findart
|
6
|
+
features/development.feature
|
7
|
+
features/findalbumarturls.feature
|
8
|
+
features/fixtures/search-albumartexchange-daft-punk-discovery.html
|
9
|
+
features/registerdscapers.feature
|
10
|
+
features/step_definitions/common_steps.rb
|
11
|
+
features/step_definitions/findalbumarturls_steps.rb
|
12
|
+
features/support/common.rb
|
13
|
+
features/support/env.rb
|
14
|
+
features/support/matchers.rb
|
15
|
+
lib/FindArt.rb
|
16
|
+
lib/FindArt/scraper.rb
|
17
|
+
lib/FindArt/scrapers/albumartexchange.rb
|
18
|
+
lib/FindArt/scrapers/amazon.rb.disabled
|
19
|
+
lib/FindArt/scrapers/discogs.rb
|
20
|
+
lib/FindArt/scrapers/junodownload.rb
|
21
|
+
lib/FindArt/scrapers/walmart.rb
|
22
|
+
script/console
|
23
|
+
script/destroy
|
24
|
+
script/generate
|
25
|
+
spec/albumartexchange_spec.rb
|
26
|
+
spec/amazon_spec.rb
|
27
|
+
spec/discogs_spec.rb
|
28
|
+
spec/junodownload_spec.rb
|
29
|
+
spec/scraper_spec.rb
|
30
|
+
spec/spec.opts
|
31
|
+
spec/spec_helper.rb
|
32
|
+
spec/walmart_spec.rb
|
33
|
+
tasks/rspec.rake
|
data/README.rdoc
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
= FindArt
|
2
|
+
|
3
|
+
* http://github.com/michel/findart
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Findart is a handy console application that helps you find high quality album art.
|
8
|
+
It scrapes various sites and returns a list of urls that contain album art images.
|
9
|
+
|
10
|
+
Findart is very basic in its current form but still usable.
|
11
|
+
Stay tuned for new features in the near future.
|
12
|
+
|
13
|
+
|
14
|
+
== FEATURES/PROBLEMS:
|
15
|
+
Findart currently scrapes the following sites for artwork:
|
16
|
+
|
17
|
+
* albumartexchange
|
18
|
+
* junodownload
|
19
|
+
* walmart
|
20
|
+
* amazon (currently broken)
|
21
|
+
|
22
|
+
== SYNOPSIS:
|
23
|
+
|
24
|
+
findart find "Daft punk Discovery"
|
25
|
+
findart find --artist "Daft punk" --title "Discovery"
|
26
|
+
|
27
|
+
== REQUIREMENTS:
|
28
|
+
|
29
|
+
* mechanize >=0.9.3
|
30
|
+
* hpricot >=0.8.1
|
31
|
+
* fakeweb >=1.2.5
|
32
|
+
* cucumber >=0.3.97
|
33
|
+
* newgem" >=1.5.2
|
34
|
+
* visionmedia-commander >=3.2.9
|
35
|
+
|
36
|
+
== INSTALL:
|
37
|
+
|
38
|
+
sudo gem install findart
|
39
|
+
|
40
|
+
== LICENSE:
|
41
|
+
|
42
|
+
(The MIT License)
|
43
|
+
|
44
|
+
Copyright (c) 2009 Michel de Graaf (michel@re-invention.nl), http://re-invention.nl
|
45
|
+
|
46
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
47
|
+
a copy of this software and associated documentation files (the
|
48
|
+
'Software'), to deal in the Software without restriction, including
|
49
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
50
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
51
|
+
permit persons to whom the Software is furnished to do so, subject to
|
52
|
+
the following conditions:
|
53
|
+
|
54
|
+
The above copyright notice and this permission notice shall be
|
55
|
+
included in all copies or substantial portions of the Software.
|
56
|
+
|
57
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
58
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
59
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
60
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
61
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
62
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
63
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
require './lib/FindArt'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
8
|
+
# Hoe.plugin :website
|
9
|
+
Hoe.plugin :cucumberfeatures
|
10
|
+
|
11
|
+
# Generate all the Rake tasks
|
12
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
+
$hoe = Hoe.spec 'findart' do
|
14
|
+
self.developer 'Michel de Graaf', 'michel@re-invention.nl'
|
15
|
+
self.rubyforge_name = "findart"
|
16
|
+
self.extra_deps = [['mechanize','>=0.9.3'],
|
17
|
+
["hpricot",'>=0.8.1'],
|
18
|
+
["fakeweb",">=1.2.5"],
|
19
|
+
["cucumber",">=0.3.97"],
|
20
|
+
["newgem",">=1.5.2"],
|
21
|
+
["visionmedia-commander",">=3.2.9"]
|
22
|
+
]
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'newgem/tasks'
|
26
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
27
|
+
|
28
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
29
|
+
# remove_task :default
|
30
|
+
# task :default => [:spec, :features]
|
data/bin/findart
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
# sudo gem sources -a http://gems.github.com
|
5
|
+
# sudo gem install visionmedia-commander
|
6
|
+
require 'rubygems'
|
7
|
+
require 'commander'
|
8
|
+
|
9
|
+
|
10
|
+
require File.dirname(__FILE__) + '/../lib/FindArt.rb'
|
11
|
+
include FindArt
|
12
|
+
|
13
|
+
# :name is optional, otherwise uses the basename of this executable
|
14
|
+
program :name, 'findart - Album Art finder'
|
15
|
+
program :version, FindArt::VERSION
|
16
|
+
program :description, 'Searches for album art on several sites'
|
17
|
+
program :help, 'Copyright', '2009 Michel de Graaf'
|
18
|
+
global_option '--verbose'
|
19
|
+
|
20
|
+
command :find do |c|
|
21
|
+
c.syntax = 'find searchstring'
|
22
|
+
c.description = 'Searches for album art'
|
23
|
+
c.option '--artist "artistname"', String, 'Artist name.'
|
24
|
+
c.option '--title "title"', String, "Album title."
|
25
|
+
c.when_called do |args, options|
|
26
|
+
if options.artist.nil? && options.title.nil? && args.empty?
|
27
|
+
say "Please provide keywords e.g.\n findart find \"Daft punk Discovery\"\n findart find --artist \"Daft punk\" --title \"Discovery\""
|
28
|
+
else
|
29
|
+
artist = options.artist || ""
|
30
|
+
title = options.title || ""
|
31
|
+
artist = args if options.artist.nil? && options.title.nil?
|
32
|
+
@scraper = Scraper.new
|
33
|
+
results = @scraper.find_art(artist,title)
|
34
|
+
if results.empty?
|
35
|
+
query = "#{artist} #{title}".strip
|
36
|
+
say "No album art found for \"#{query}\""
|
37
|
+
else
|
38
|
+
say "Found #{results.size} results"
|
39
|
+
say results.join("\n")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
command :sites do |c|
|
47
|
+
c.syntax = 'sites'
|
48
|
+
c.description = 'Shows sites that are used for album art searching'
|
49
|
+
c.when_called do |args, options|
|
50
|
+
@scraper = Scraper.new
|
51
|
+
sites = @scraper.registerd_sites
|
52
|
+
say "Sites currently used to search for art:"
|
53
|
+
say sites.join("\n")
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: Development processes of newgem itself (rake tasks)
|
2
|
+
|
3
|
+
As a Newgem maintainer or contributor
|
4
|
+
I want rake tasks to maintain and release the gem
|
5
|
+
So that I can spend time on the tests and code, and not excessive time on maintenance processes
|
6
|
+
|
7
|
+
Scenario: Generate RubyGem
|
8
|
+
Given this project is active project folder
|
9
|
+
And "pkg" folder is deleted
|
10
|
+
When I invoke task "rake gem"
|
11
|
+
Then folder "pkg" is created
|
12
|
+
And file with name matching "pkg/*.gem" is created else you should run "rake manifest" to fix this
|
13
|
+
And gem spec key "rdoc_options" contains /--mainREADME.rdoc/
|
@@ -0,0 +1,38 @@
|
|
1
|
+
Feature: Find URLs of album art on the internet
|
2
|
+
|
3
|
+
As an avid music collector
|
4
|
+
I want all my mp3s to have album art
|
5
|
+
So that i can identify individual tracks and enjoy the colorful artwork
|
6
|
+
|
7
|
+
Scenario: Find URLs of album art for a given album
|
8
|
+
Given that i want to find artwork for the album "Daft punk Discovery"
|
9
|
+
When I run local executable "findart" with arguments "find 'Daft punk Discovery'"
|
10
|
+
Then I should see
|
11
|
+
"""
|
12
|
+
http://ecx.images-amazon.com/images/I/210AETN5YXL.jpg
|
13
|
+
"""
|
14
|
+
When I run local executable "findart" with arguments "find --artist 'Daft punk' --title 'Discovery'"
|
15
|
+
Then I should also see
|
16
|
+
"""
|
17
|
+
http://ecx.images-amazon.com/images/I/210AETN5YXL.jpg
|
18
|
+
"""
|
19
|
+
|
20
|
+
|
21
|
+
Scenario: There is no album art found
|
22
|
+
Given that i want to find artwork for the album "Irene Moors & De Smurfen Ga Je Mee Naar Smurfenland"
|
23
|
+
When I run local executable "findart" with arguments "find 'Irene Moors & De Smurfen Ga Je Mee Naar Smurfenland'"
|
24
|
+
Then I should see
|
25
|
+
"""
|
26
|
+
No album art found for "Irene Moors & De Smurfen Ga Je Mee Naar Smurfenland"
|
27
|
+
|
28
|
+
"""
|
29
|
+
Scenario: No arguments
|
30
|
+
When I run local executable "findart" with arguments "find"
|
31
|
+
Then I should see
|
32
|
+
"""
|
33
|
+
Please provide keywords e.g.
|
34
|
+
findart find "Daft punk Discovery"
|
35
|
+
findart find --artist "Daft punk" --title "Discovery"
|
36
|
+
"""
|
37
|
+
|
38
|
+
|
@@ -0,0 +1,107 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
5
|
+
<meta name="description" content="Album artwork, CD artwork, artwork scans">
|
6
|
+
<meta name="keywords" content="artwork, CD, album, scan, cover, art">
|
7
|
+
<link href="covers.css" rel="stylesheet" type="text/css">
|
8
|
+
<title>CD/Album Artwork</title>
|
9
|
+
<!--[if lt IE 7.]>
|
10
|
+
<script defer type="text/javascript" src="pngfix.js"></script>
|
11
|
+
<![endif]-->
|
12
|
+
<style type="text/css">
|
13
|
+
body {
|
14
|
+
margin: 8px auto 8px 8px;
|
15
|
+
width: 814px;
|
16
|
+
background-color: #000000;
|
17
|
+
}
|
18
|
+
|
19
|
+
.cbtext {
|
20
|
+
line-height: 20px;
|
21
|
+
vertical-align: top;
|
22
|
+
}
|
23
|
+
</style>
|
24
|
+
<script type="text/javascript" src="/gallery/gallery_ja2.js?20090307f"></script>
|
25
|
+
<script type="text/javascript" src="/amazon/jsxml/xmlparse.js?20090220a"></script>
|
26
|
+
<script type="text/javascript" src="/amazon/amazon_ajax.js?20090220a"></script>
|
27
|
+
<script type="text/javascript" src="covers.js"></script>
|
28
|
+
</head>
|
29
|
+
<body onLoad="init()">
|
30
|
+
<table border=0 cellspacing=0 cellpadding=0 width=800><tr>
|
31
|
+
<td width=200><img src="logo/aaxchg_logo_wont_200x040.png" width=200 height=40 border=0 alt="AlbumArtExchange.com"></td>
|
32
|
+
<td align=left style="font-size: 16px; font-weight: bold"> Gallery</td>
|
33
|
+
<td align=right>
|
34
|
+
<a href="?grid=2x5&q=Daft+punk+Discovery&page=1"><img src="/icon/2x5.png" border=0 width=18 height=21 alt="2x5"></a>
|
35
|
+
<a href="?grid=3x5&q=Daft+punk+Discovery&page=1"><img src="/icon/3x5.png" border=0 width=18 height=21 alt="3x5"></a>
|
36
|
+
<a href="?grid=4x5&q=Daft+punk+Discovery&page=1"><img src="/icon/4x5.png" border=0 width=18 height=21 alt="4x5"></a>
|
37
|
+
|
38
|
+
<a href="?bgc=000000&q=Daft+punk+Discovery&page=1"><img src="/icon/blak.png" border=0 width=18 height=21 alt=""></a>
|
39
|
+
<a href="?bgc=000033&q=Daft+punk+Discovery&page=1"><img src="/icon/dblu.png" border=0 width=18 height=21 alt=""></a>
|
40
|
+
<a href="?bgc=222222&q=Daft+punk+Discovery&page=1"><img src="/icon/dgry.png" border=0 width=18 height=21 alt=""></a>
|
41
|
+
<a href="?bgc=444444&q=Daft+punk+Discovery&page=1"><img src="/icon/mgry.png" border=0 width=18 height=21 alt=""></a>
|
42
|
+
<a href="?bgc=FFFFFF&q=Daft+punk+Discovery&page=1"><img src="/icon/whte.png" border=0 width=18 height=21 alt=""></a>
|
43
|
+
<a href="/"><img src="icon/home.png" width=16 height=16 border=0 alt="Home"> Home</a>
|
44
|
+
<a href="/forums/"><img src="icon/forums.png" width=16 height=16 border=0 alt="Home"> Forums</a>
|
45
|
+
<font color=gray><img src="icon/add_disabled.png" width=16 height=16 border=0 alt="Add"> Add images</a></font>
|
46
|
+
<a href="/forums/ucp.php?mode=login&redirect=..%2Fcovers.php"><img src="icon/login.png" width=16 height=16 border=0 alt="Log in"> Log in</a>
|
47
|
+
</td>
|
48
|
+
</tr></table>
|
49
|
+
<br><div align=center class=sort-bar style="background-color: #222222; padding: 2px 2px 2px 2px">
|
50
|
+
<form style="display: inline" name=sortFilter method=get action="/covers.php">
|
51
|
+
Sort by:
|
52
|
+
<select name="sort" size=1 onChange="return doSortSubmit()">
|
53
|
+
<option value=1>Artist</option>
|
54
|
+
<option value=2>Composer</option>
|
55
|
+
<option value=3>Title</option>
|
56
|
+
<option value=4>Date</option>
|
57
|
+
<option value=5>Poster</option>
|
58
|
+
<option value=6>Most Viewed</option>
|
59
|
+
<option selected value=7>Rating</option>
|
60
|
+
</select>
|
61
|
+
•
|
62
|
+
<input name=q type=text value="Daft punk Discovery" size=16>
|
63
|
+
<input type=submit value="Search">
|
64
|
+
<input type=submit value="← Clear" onClick="clearFilter()">
|
65
|
+
• Show:
|
66
|
+
<select name="fltr" size=1 onChange="return doSortSubmit()">
|
67
|
+
<option selected value=1>All Image Grades</option>
|
68
|
+
<option value=2>Ready-to-Go Images</option>
|
69
|
+
<option value=3>"Needs Work" Images</option>
|
70
|
+
</select>
|
71
|
+
<input name=bgc type=hidden value="">
|
72
|
+
<input name=page type=hidden value="">
|
73
|
+
</form>
|
74
|
+
</div>
|
75
|
+
<form name=edit method=post action="edit_albums.php">
|
76
|
+
<table border=0 cellpadding=0 cellspacing=10>
|
77
|
+
<tr>
|
78
|
+
<td colspan=5>
|
79
|
+
<table border=0 cellpadding=0 cellspacing=0 width=790>
|
80
|
+
<tr>
|
81
|
+
<td align=left>One image.</td>
|
82
|
+
<td align=right><span style="background-color: #D0D0E0; color: black; padding: 2px 1em 2px 1em">Click images to enlarge.</span></td>
|
83
|
+
</tr>
|
84
|
+
</table>
|
85
|
+
</td>
|
86
|
+
</tr>
|
87
|
+
<tr>
|
88
|
+
<td valign=top>
|
89
|
+
<table border=0 cellpadding=0 cellspacing=0 width=150>
|
90
|
+
<tr>
|
91
|
+
<td align=center valign=middle style="height: 150px;">
|
92
|
+
<a href="?id=10931&q=Daft+punk+Discovery"><img src="/phputil/scale_image.php?size=150&src=%2Fgallery%2Fimages%2Fpublic%2Fda%2Fdaftpu-discov_02.jpg" width=150 height=150 border=0 alt="Discovery; Daft Punk; JPEG; 650×650"></a>
|
93
|
+
</td>
|
94
|
+
</tr>
|
95
|
+
<tr><td align=left valign=top style="font-size: smaller"><a href="http://www.amazon.com/gp/search?ie=UTF8&keywords=Daft Punk%20Discovery&tag=abbum-20&search-alias=popular" target="_blank"><i>Discovery</i></a><br><a class="query-link" href="/covers.php?q=%22Daft+Punk%22">Daft Punk</a><br><img src="icon/stars_4_0_sml.png" width=35 height=8 border=0 alt="4.00" title="4.00"> · 650×650 · 204K<br>2008-12-27 22:04 PST<br>Posted by: <a class="query-link" href="/covers.php?q=%22Music+Hog%22">Music Hog</a></td></tr>
|
96
|
+
</table>
|
97
|
+
</td>
|
98
|
+
<td style="width: 150px; height: 150px;"> </td>
|
99
|
+
<td style="width: 150px; height: 150px;"> </td>
|
100
|
+
<td style="width: 150px; height: 150px;"> </td>
|
101
|
+
<td style="width: 150px; height: 150px;"> </td>
|
102
|
+
</tr>
|
103
|
+
</table>
|
104
|
+
<input id=id name=id type=hidden value="">
|
105
|
+
</form>
|
106
|
+
</body>
|
107
|
+
</html>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Feature: What sites are being used when searching for album art
|
2
|
+
|
3
|
+
As a user
|
4
|
+
I want to know what sites are being used to search for artwork
|
5
|
+
So that I can see where my artwork is coming from
|
6
|
+
|
7
|
+
Scenario: Several sites are being used to search for album art
|
8
|
+
When I run local executable "findart" with arguments "sites"
|
9
|
+
Then I should see
|
10
|
+
"""
|
11
|
+
Sites currently used to search for art:
|
12
|
+
"""
|
@@ -0,0 +1,169 @@
|
|
1
|
+
Given /^this project is active project folder/ do
|
2
|
+
@active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
|
3
|
+
end
|
4
|
+
|
5
|
+
Given /^env variable \$([\w_]+) set to "(.*)"/ do |env_var, value|
|
6
|
+
ENV[env_var] = value
|
7
|
+
end
|
8
|
+
|
9
|
+
Given /"(.*)" folder is deleted/ do |folder|
|
10
|
+
in_project_folder { FileUtils.rm_rf folder }
|
11
|
+
end
|
12
|
+
|
13
|
+
When /^I invoke "(.*)" generator with arguments "(.*)"$/ do |generator, arguments|
|
14
|
+
@stdout = StringIO.new
|
15
|
+
in_project_folder do
|
16
|
+
if Object.const_defined?("APP_ROOT")
|
17
|
+
APP_ROOT.replace(FileUtils.pwd)
|
18
|
+
else
|
19
|
+
APP_ROOT = FileUtils.pwd
|
20
|
+
end
|
21
|
+
run_generator(generator, arguments.split(' '), SOURCES, :stdout => @stdout)
|
22
|
+
end
|
23
|
+
File.open(File.join(@tmp_root, "generator.out"), "w") do |f|
|
24
|
+
@stdout.rewind
|
25
|
+
f << @stdout.read
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
When /^I run executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
31
|
+
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
32
|
+
in_project_folder do
|
33
|
+
system "#{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
When /^I run project executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
38
|
+
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
39
|
+
in_project_folder do
|
40
|
+
system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
When /^I run local executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
45
|
+
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
46
|
+
executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
|
47
|
+
in_project_folder do
|
48
|
+
system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
When /^I invoke task "rake (.*)"/ do |task|
|
53
|
+
@stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
|
54
|
+
in_project_folder do
|
55
|
+
system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
Then /^folder "(.*)" (is|is not) created/ do |folder, is|
|
60
|
+
in_project_folder do
|
61
|
+
File.exists?(folder).should(is == 'is' ? be_true : be_false)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
Then /^file "(.*)" (is|is not) created/ do |file, is|
|
66
|
+
in_project_folder do
|
67
|
+
File.exists?(file).should(is == 'is' ? be_true : be_false)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
Then /^file with name matching "(.*)" is created/ do |pattern|
|
72
|
+
in_project_folder do
|
73
|
+
Dir[pattern].should_not be_empty
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
Then /^file "(.*)" contents (does|does not) match \/(.*)\// do |file, does, regex|
|
78
|
+
in_project_folder do
|
79
|
+
actual_output = File.read(file)
|
80
|
+
(does == 'does') ?
|
81
|
+
actual_output.should(match(/#{regex}/)) :
|
82
|
+
actual_output.should_not(match(/#{regex}/))
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
Then /gem file "(.*)" and generated file "(.*)" should be the same/ do |gem_file, project_file|
|
87
|
+
File.exists?(gem_file).should be_true
|
88
|
+
File.exists?(project_file).should be_true
|
89
|
+
gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
|
90
|
+
project_file_contents = File.read(File.join(@active_project_folder, project_file))
|
91
|
+
project_file_contents.should == gem_file_contents
|
92
|
+
end
|
93
|
+
|
94
|
+
Then /^(does|does not) invoke generator "(.*)"$/ do |does_invoke, generator|
|
95
|
+
actual_output = File.read(@stdout)
|
96
|
+
does_invoke == "does" ?
|
97
|
+
actual_output.should(match(/dependency\s+#{generator}/)) :
|
98
|
+
actual_output.should_not(match(/dependency\s+#{generator}/))
|
99
|
+
end
|
100
|
+
|
101
|
+
Then /help options "(.*)" and "(.*)" are displayed/ do |opt1, opt2|
|
102
|
+
actual_output = File.read(@stdout)
|
103
|
+
actual_output.should match(/#{opt1}/)
|
104
|
+
actual_output.should match(/#{opt2}/)
|
105
|
+
end
|
106
|
+
|
107
|
+
Then /^I should see$/ do |text|
|
108
|
+
actual_output = File.read(@stdout)
|
109
|
+
actual_output.should contain(text)
|
110
|
+
end
|
111
|
+
|
112
|
+
Then /^I should also see$/ do |text|
|
113
|
+
actual_output = File.read(@stdout)
|
114
|
+
actual_output.should contain(text)
|
115
|
+
end
|
116
|
+
|
117
|
+
Then /^I should not see$/ do |text|
|
118
|
+
actual_output = File.read(@stdout)
|
119
|
+
actual_output.should_not contain(text)
|
120
|
+
end
|
121
|
+
|
122
|
+
Then /^I should see exactly$/ do |text|
|
123
|
+
actual_output = File.read(@stdout)
|
124
|
+
actual_output.should == text
|
125
|
+
end
|
126
|
+
|
127
|
+
Then /^I should see all (\d+) tests pass/ do |expected_test_count|
|
128
|
+
expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
|
129
|
+
actual_output = File.read(@stdout)
|
130
|
+
actual_output.should match(expected)
|
131
|
+
end
|
132
|
+
|
133
|
+
Then /^I should see all (\d+) examples pass/ do |expected_test_count|
|
134
|
+
expected = %r{^#{expected_test_count} examples?, 0 failures}
|
135
|
+
actual_output = File.read(@stdout)
|
136
|
+
actual_output.should match(expected)
|
137
|
+
end
|
138
|
+
|
139
|
+
Then /^yaml file "(.*)" contains (\{.*\})/ do |file, yaml|
|
140
|
+
in_project_folder do
|
141
|
+
yaml = eval yaml
|
142
|
+
YAML.load(File.read(file)).should == yaml
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
Then /^Rakefile can display tasks successfully/ do
|
147
|
+
@stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
|
148
|
+
in_project_folder do
|
149
|
+
system "rake -T > #{@stdout} 2> #{@stdout}"
|
150
|
+
end
|
151
|
+
actual_output = File.read(@stdout)
|
152
|
+
actual_output.should match(/^rake\s+\w+\s+#\s.*/)
|
153
|
+
end
|
154
|
+
|
155
|
+
Then /^task "rake (.*)" is executed successfully/ do |task|
|
156
|
+
@stdout.should_not be_nil
|
157
|
+
actual_output = File.read(@stdout)
|
158
|
+
actual_output.should_not match(/^Don't know how to build task '#{task}'/)
|
159
|
+
actual_output.should_not match(/Error/i)
|
160
|
+
end
|
161
|
+
|
162
|
+
Then /^gem spec key "(.*)" contains \/(.*)\// do |key, regex|
|
163
|
+
in_project_folder do
|
164
|
+
gem_file = Dir["pkg/*.gem"].first
|
165
|
+
gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
|
166
|
+
spec_value = gem_spec.send(key.to_sym)
|
167
|
+
spec_value.to_s.should match(/#{regex}/)
|
168
|
+
end
|
169
|
+
end
|