Fingertips-jewelry_portfolio 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +15 -4
- data/VERSION.yml +2 -2
- data/lib/jewelry_portfolio.rb +12 -9
- data/lib/jewelry_portfolio/repo.rb +46 -11
- data/lib/jewelry_portfolio/repos_index.rb +15 -21
- data/lib/jewelry_portfolio/tasks.rb +34 -27
- data/lib/jewelry_portfolio/template.rb +10 -3
- data/test/fixtures/alloy.github.com.tgz +0 -0
- data/test/fixtures/dr-nic-magic-awesome.gemspec_ +2 -1
- data/test/fixtures/dr-nic-magic-awesome.html +1 -1
- data/test/fixtures/repo.html.erb +2 -2
- data/test/fixtures/repos.yml +10 -104
- data/test/fixtures/template.html +1 -1
- data/test/jewelry_portfolio_test.rb +21 -8
- data/test/repo_test.rb +92 -25
- data/test/repos_index_test.rb +20 -27
- data/test/tasks_test.rb +108 -0
- data/test/template_test.rb +8 -14
- metadata +3 -2
data/README.rdoc
CHANGED
@@ -16,18 +16,29 @@ Jeweler[http://github.com/technicalpickles/jeweler/tree/master] does.
|
|
16
16
|
First things first; create a GitHub pages repository if you haven't done so
|
17
17
|
already. See http://github.com/guides/pages for more info.
|
18
18
|
|
19
|
-
Then create the following files, and content, in the
|
19
|
+
Then create the following files, and content, in the master branch of your
|
20
20
|
pages repository (<em>for a more elaborate example see:
|
21
|
-
http://github.com/alloy/alloy.github.com/tree/
|
21
|
+
http://github.com/alloy/alloy.github.com/tree/master</em>):
|
22
22
|
|
23
23
|
* <b>Rakefile:</b>
|
24
24
|
|
25
25
|
require 'jewelry_portfolio/tasks'
|
26
26
|
JewelryPortfolio::Tasks.new do |t|
|
27
|
-
|
28
|
-
t.
|
27
|
+
t.account = 'Fingertips'
|
28
|
+
t.name = 'passengerpane'
|
29
|
+
t.version = '1.2.0'
|
30
|
+
t.summary = 'A short summary about the project.'
|
31
|
+
t.description = 'A longer description about the project.'
|
29
32
|
end
|
30
33
|
|
34
|
+
The +account+ is only necessary when you haven't configured github.user in
|
35
|
+
the local or global git config. (For more info see:
|
36
|
+
http://github.com/guides/local-github-config.) Or if you want to override the
|
37
|
+
+account+ that was retrieved from the git config.
|
38
|
+
|
39
|
+
The other attributes are only necessary when there's no gemspec file in the
|
40
|
+
work directory.
|
41
|
+
|
31
42
|
* <b>template.html.erb:</b>
|
32
43
|
|
33
44
|
This is the main template file which will be used to generate the index.html
|
data/VERSION.yml
CHANGED
data/lib/jewelry_portfolio.rb
CHANGED
@@ -5,21 +5,24 @@ require 'jewelry_portfolio/template'
|
|
5
5
|
class JewelryPortfolio
|
6
6
|
class FileMissingError < StandardError; end
|
7
7
|
|
8
|
-
attr_reader :account, :
|
8
|
+
attr_reader :account, :repo, :index, :template
|
9
9
|
|
10
10
|
# Initializes a JewelryPortfolio instance for the specified +account+.
|
11
11
|
#
|
12
|
-
# If an optional +
|
13
|
-
# index. If no +
|
12
|
+
# If an optional +repo+ is provided it will be added to, or updated in, the
|
13
|
+
# index. If no +repo+ is provided it is assumed you are working in a clone of
|
14
14
|
# your GitHub pages repo. In this case no fetching and merging will be
|
15
15
|
# performed.
|
16
|
-
def initialize(account,
|
16
|
+
def initialize(account, repo = nil)
|
17
|
+
raise ArgumentError, "No `account' given." unless account
|
18
|
+
raise ArgumentError, "No valid `repo' given." if repo && !repo.valid?
|
19
|
+
|
17
20
|
@account = account
|
18
|
-
@
|
19
|
-
@index = ReposIndex.new(@account, (Dir.pwd unless @
|
21
|
+
@repo = repo
|
22
|
+
@index = ReposIndex.new(@account, (Dir.pwd unless @repo))
|
20
23
|
@template = Template.new(File.join(@index.path, 'template'), @index.repos)
|
21
24
|
|
22
|
-
@index.add(@
|
25
|
+
@index.add(@repo) if @repo
|
23
26
|
end
|
24
27
|
|
25
28
|
# Renders the index.html file.
|
@@ -38,8 +41,8 @@ class JewelryPortfolio
|
|
38
41
|
private
|
39
42
|
|
40
43
|
def commit_message
|
41
|
-
if @
|
42
|
-
"Updated github pages for: #{@
|
44
|
+
if @repo
|
45
|
+
"Updated github pages for: #{@repo.name}-#{@repo.version}"
|
43
46
|
else
|
44
47
|
"Re-generated github pages"
|
45
48
|
end
|
@@ -1,14 +1,42 @@
|
|
1
1
|
class JewelryPortfolio
|
2
2
|
class Repo
|
3
|
-
|
3
|
+
class InvalidError < StandardError; end
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
# The GitHub user account that this repo belongs to.
|
6
|
+
attr_accessor :account
|
7
|
+
|
8
|
+
# The name of the repo.
|
9
|
+
#
|
10
|
+
# Not needed when initialized with a Gem::Specification.
|
11
|
+
attr_accessor :name
|
12
|
+
|
13
|
+
# The version of the current version of the project.
|
14
|
+
#
|
15
|
+
# Not needed when initialized with a Gem::Specification.
|
16
|
+
attr_accessor :version
|
17
|
+
|
18
|
+
# The summary of the project.
|
19
|
+
#
|
20
|
+
# Not needed when initialized with a Gem::Specification.
|
21
|
+
attr_accessor :summary
|
22
|
+
|
23
|
+
# The description of the project.
|
24
|
+
#
|
25
|
+
# Not needed when initialized with a Gem::Specification.
|
26
|
+
attr_accessor :description
|
27
|
+
|
28
|
+
def initialize(account = nil, spec = nil)
|
29
|
+
@account = account
|
30
|
+
@gem = !spec.nil?
|
31
|
+
|
32
|
+
%w{ name version summary description }.each do |attr|
|
33
|
+
send("#{attr}=", spec.send(attr).to_s)
|
34
|
+
end if spec
|
7
35
|
end
|
8
36
|
|
9
|
-
# Returns
|
10
|
-
def
|
11
|
-
@
|
37
|
+
# Returns whether or not there's a Ruby gem for this repo.
|
38
|
+
def gem?
|
39
|
+
@gem
|
12
40
|
end
|
13
41
|
|
14
42
|
# Returns the URL to the project page on GitHub.
|
@@ -24,7 +52,7 @@ class JewelryPortfolio
|
|
24
52
|
# Returns the name of the gem file from GitHub, which is made up of the
|
25
53
|
# account name and the gem name.
|
26
54
|
def gem_name
|
27
|
-
"#{@account}-#{name}"
|
55
|
+
"#{@account}-#{@name}"
|
28
56
|
end
|
29
57
|
|
30
58
|
# Returns the command to install the gem. This is a helper for your views.
|
@@ -32,12 +60,19 @@ class JewelryPortfolio
|
|
32
60
|
"sudo gem install #{gem_name} -s http://gems.github.com"
|
33
61
|
end
|
34
62
|
|
35
|
-
|
36
|
-
|
63
|
+
# Raises a JewelryPortfolio::Repo::InvalidError if any of: account, name,
|
64
|
+
# version, summary, or description is +nil+.
|
65
|
+
def valid?
|
66
|
+
@account && @name && @version && @summary && @description
|
67
|
+
end
|
68
|
+
|
69
|
+
def hash
|
70
|
+
@name.hash
|
37
71
|
end
|
38
72
|
|
39
|
-
def
|
40
|
-
|
73
|
+
def ==(other)
|
74
|
+
other.is_a?(Repo) && hash == other.hash
|
41
75
|
end
|
76
|
+
alias_method :eql?, :==
|
42
77
|
end
|
43
78
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'git'
|
2
2
|
require 'rubygems/specification'
|
3
|
+
require 'set'
|
3
4
|
require 'tempfile'
|
4
5
|
require 'yaml'
|
5
6
|
|
@@ -32,24 +33,17 @@ class JewelryPortfolio
|
|
32
33
|
File.join(path, 'repos.yml')
|
33
34
|
end
|
34
35
|
|
35
|
-
def
|
36
|
-
unless @
|
36
|
+
def repos
|
37
|
+
unless @repos
|
37
38
|
load_pages_repo!
|
38
|
-
|
39
|
+
data = File.read(repos_file) if File.exist?(repos_file)
|
40
|
+
@repos = data.nil? || data.empty? ? Set.new : YAML.load(data).to_set
|
39
41
|
end
|
40
|
-
@
|
42
|
+
@repos
|
41
43
|
end
|
42
44
|
|
43
|
-
def
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
def add(spec)
|
48
|
-
if old_spec = specs.find { |s| s.name == spec.name }
|
49
|
-
specs[specs.index(old_spec)] = spec
|
50
|
-
else
|
51
|
-
specs << spec
|
52
|
-
end
|
45
|
+
def add(repo)
|
46
|
+
@repos = Set.new([repo]).merge(@repos)
|
53
47
|
update_repos_file!
|
54
48
|
end
|
55
49
|
|
@@ -59,12 +53,12 @@ class JewelryPortfolio
|
|
59
53
|
end
|
60
54
|
|
61
55
|
def push!
|
62
|
-
puts "Pushing branch `
|
63
|
-
reraise_with_path { pages_repo.push('origin', '
|
56
|
+
puts "Pushing branch `master' to remote `#{url}'"
|
57
|
+
reraise_with_path { pages_repo.push('origin', 'master') }
|
64
58
|
end
|
65
59
|
|
66
60
|
def to_yaml
|
67
|
-
|
61
|
+
repos.to_a.to_yaml
|
68
62
|
end
|
69
63
|
|
70
64
|
private
|
@@ -90,9 +84,9 @@ class JewelryPortfolio
|
|
90
84
|
@pages_repo = Git.open(path)
|
91
85
|
unless @custom_work_directory
|
92
86
|
puts "Pulling `#{url}'"
|
93
|
-
@pages_repo.checkout('
|
87
|
+
@pages_repo.checkout('master')
|
94
88
|
@pages_repo.fetch('origin')
|
95
|
-
@pages_repo.merge('origin/
|
89
|
+
@pages_repo.merge('origin/master')
|
96
90
|
end
|
97
91
|
end
|
98
92
|
end
|
@@ -101,8 +95,8 @@ class JewelryPortfolio
|
|
101
95
|
reraise_with_path do
|
102
96
|
puts "Cloning `#{url}'"
|
103
97
|
@pages_repo = Git.clone(url, repo_name, :path => File.dirname(path))
|
104
|
-
@pages_repo.checkout('origin/
|
105
|
-
branch = @pages_repo.branch('
|
98
|
+
@pages_repo.checkout('origin/master')
|
99
|
+
branch = @pages_repo.branch('master')
|
106
100
|
branch.create
|
107
101
|
branch.checkout
|
108
102
|
end
|
@@ -1,35 +1,35 @@
|
|
1
1
|
require 'jewelry_portfolio'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
Rake::Task['portfolio:release'].invoke
|
9
|
-
end
|
3
|
+
# Add the JewelryPortfolio `portfolio:release' Rake task so it's ran after the
|
4
|
+
# original `release' Rake task if it exists.
|
5
|
+
if defined?(Rake) && Rake::Task.task_defined?('release')
|
6
|
+
task :release do
|
7
|
+
Rake::Task['portfolio:release'].invoke
|
10
8
|
end
|
11
9
|
end
|
12
10
|
|
13
11
|
class JewelryPortfolio
|
14
12
|
class Tasks
|
15
|
-
#
|
16
|
-
#
|
17
|
-
|
13
|
+
# The JewelryPortfolio::Repo instance. If a block is given to ::new, this
|
14
|
+
# instance will be yielded.
|
15
|
+
attr_reader :repo
|
18
16
|
|
19
|
-
# Initialize the JewelryPortfolio rake tasks.
|
20
|
-
# additional configuration can be performed.
|
17
|
+
# Initialize the JewelryPortfolio rake tasks. A JewelryPortfolio::Repo is
|
18
|
+
# yielded so additional configuration can be performed.
|
19
|
+
#
|
20
|
+
# If the repo you're working in does _not_ contain a +gemspec+ file, then
|
21
|
+
# you'll need to assign all values to the Repo yourself.
|
21
22
|
#
|
22
23
|
# JewelryPortfolio::Tasks.new do |t|
|
23
|
-
# t.account
|
24
|
+
# t.account = 'Fingertips'
|
25
|
+
# t.name = 'passengerpane'
|
26
|
+
# t.version = '1.2.0'
|
27
|
+
# t.summary = 'A short summary about the project.'
|
28
|
+
# t.description = 'A longer description about the project.'
|
24
29
|
# end
|
25
30
|
def initialize
|
26
|
-
|
27
|
-
|
28
|
-
@account ||= github_username
|
29
|
-
unless @account
|
30
|
-
raise ArgumentError, "Unable to determine `account'. Add a github user entry to your global, or local, git config. Or explicitely set the `account' on the JewelryPortfolio::Tasks instance."
|
31
|
-
end
|
32
|
-
|
31
|
+
@repo = Repo.new(retrieve_github_username, retrieve_gemspec)
|
32
|
+
yield @repo if block_given?
|
33
33
|
define
|
34
34
|
end
|
35
35
|
|
@@ -51,17 +51,24 @@ class JewelryPortfolio
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def portfolio
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
validate_account!
|
55
|
+
@portfolio ||= JewelryPortfolio.new(@repo.account, (@repo if @repo.valid?))
|
56
|
+
end
|
57
|
+
|
58
|
+
def retrieve_gemspec
|
59
|
+
if spec_file = Dir.glob('*.gemspec').first
|
60
|
+
spec = eval(File.read(spec_file))
|
59
61
|
end
|
60
|
-
@portfolio
|
61
62
|
end
|
62
63
|
|
63
|
-
def
|
64
|
+
def retrieve_github_username
|
64
65
|
Git.open('.').config['github.user']
|
65
66
|
end
|
67
|
+
|
68
|
+
def validate_account!
|
69
|
+
unless @repo.account
|
70
|
+
raise ArgumentError, "Unable to determine `account'. Add a github user entry to your global, or local, git config. Or explicitely set the `account' on the JewelryPortfolio::Tasks instance."
|
71
|
+
end
|
72
|
+
end
|
66
73
|
end
|
67
74
|
end
|
@@ -3,7 +3,14 @@ require 'erb'
|
|
3
3
|
class JewelryPortfolio
|
4
4
|
# This class is responsible for rendering a template.
|
5
5
|
class Template
|
6
|
-
|
6
|
+
# The full path to the template file.
|
7
|
+
attr_reader :template
|
8
|
+
|
9
|
+
# The directory in which the template resides.
|
10
|
+
attr_reader :view_path
|
11
|
+
|
12
|
+
# The array of JewelryPortfolio::Repo instances.
|
13
|
+
attr_reader :repos
|
7
14
|
|
8
15
|
# Initialize with the path to the +template+, minus the extensions, and an
|
9
16
|
# array of JewelryPortfolio::Repo instances as +repos+.
|
@@ -11,7 +18,7 @@ class JewelryPortfolio
|
|
11
18
|
template = File.expand_path(template)
|
12
19
|
@view_path = File.dirname(template)
|
13
20
|
@template = html_template_file(File.basename(template))
|
14
|
-
@repos = repos
|
21
|
+
@repos = repos.to_a
|
15
22
|
end
|
16
23
|
|
17
24
|
# Renders the template and returns the output.
|
@@ -44,7 +51,7 @@ class JewelryPortfolio
|
|
44
51
|
#
|
45
52
|
# See partial for more info.
|
46
53
|
def repo_partial(repo, local_variables = {})
|
47
|
-
partial 'repo', local_variables.merge(:repo => repo
|
54
|
+
partial 'repo', local_variables.merge(:repo => repo)
|
48
55
|
end
|
49
56
|
|
50
57
|
private
|
Binary file
|
@@ -5,7 +5,8 @@ Gem::Specification.new do |spec|
|
|
5
5
|
spec.author = 'John Barnette'
|
6
6
|
spec.email = 'jbarnette@example.com'
|
7
7
|
|
8
|
-
spec.
|
8
|
+
spec.summary = %{ Magically fix your projects overnight! }
|
9
|
+
spec.description = %{ A gem which summons Dr. Nic to fix all your projects while you are cuddled underneath your blankie. }
|
9
10
|
|
10
11
|
spec.files = Dir['lib/**/*.rb', 'bin/*', '[A-Z]*', 'test/**/*']
|
11
12
|
|
@@ -1,2 +1,2 @@
|
|
1
1
|
<h1>dr-nic-magic-awesome</h1>
|
2
|
-
<p>
|
2
|
+
<p>A gem which summons Dr. Nic to fix all your projects while you are cuddled underneath your blankie.</p>
|
data/test/fixtures/repo.html.erb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
<h1><%=
|
2
|
-
<p><%= repo.
|
1
|
+
<h1><%= repo.name %></h1>
|
2
|
+
<p><%= repo.description %></p>
|
data/test/fixtures/repos.yml
CHANGED
@@ -1,109 +1,15 @@
|
|
1
1
|
---
|
2
|
-
- !ruby/object:
|
2
|
+
- !ruby/object:JewelryPortfolio::Repo
|
3
|
+
account: alloy
|
4
|
+
description: A gem which summons Dr. Nic to fix all your projects while you are cuddled underneath your blankie.
|
5
|
+
gem: true
|
3
6
|
name: dr-nic-magic-awesome
|
4
|
-
version: !ruby/object:Gem::Version
|
5
|
-
version: 1.0.0
|
6
|
-
platform: ruby
|
7
|
-
authors:
|
8
|
-
- John Barnette
|
9
|
-
autorequire:
|
10
|
-
bindir: bin
|
11
|
-
cert_chain: []
|
12
|
-
|
13
|
-
date: &id001 2009-02-27 00:00:00 +01:00
|
14
|
-
default_executable:
|
15
|
-
dependencies: []
|
16
|
-
|
17
|
-
description: Magically fix your projects overnight!
|
18
|
-
email: jbarnette@example.com
|
19
|
-
executables: []
|
20
|
-
|
21
|
-
extensions: []
|
22
|
-
|
23
|
-
extra_rdoc_files:
|
24
|
-
- README.rdoc
|
25
|
-
- LICENSE
|
26
|
-
- TODO
|
27
|
-
files: []
|
28
|
-
|
29
|
-
has_rdoc: true
|
30
|
-
homepage:
|
31
|
-
post_install_message:
|
32
|
-
rdoc_options:
|
33
|
-
- --charset=utf-8
|
34
|
-
- --main
|
35
|
-
- README.rdoc
|
36
|
-
require_paths:
|
37
|
-
- lib
|
38
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
-
requirements: &id002
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: "0"
|
43
|
-
version:
|
44
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
-
requirements: &id003
|
46
|
-
- - ">="
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: "0"
|
49
|
-
version:
|
50
|
-
requirements: []
|
51
|
-
|
52
|
-
rubyforge_project:
|
53
|
-
rubygems_version: 1.3.1
|
54
|
-
signing_key:
|
55
|
-
specification_version: 2
|
56
7
|
summary: Magically fix your projects overnight!
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
name: microgem
|
61
|
-
version: !ruby/object:Gem::Version
|
62
|
-
version: 0.2.0
|
63
|
-
platform: ruby
|
64
|
-
authors:
|
65
|
-
- Eloy Duran
|
66
|
-
autorequire:
|
67
|
-
bindir: bin
|
68
|
-
cert_chain: []
|
69
|
-
|
70
|
-
date: *id001
|
71
|
-
default_executable:
|
72
|
-
dependencies: []
|
73
|
-
|
8
|
+
version: 1.0.0
|
9
|
+
- !ruby/object:JewelryPortfolio::Repo
|
10
|
+
account: alloy
|
74
11
|
description: MicroGem provides a simple naive replacement for the `gem install' command in the form of the `mgem' commandline utility.
|
75
|
-
|
76
|
-
|
77
|
-
- ugem
|
78
|
-
extensions: []
|
79
|
-
|
80
|
-
extra_rdoc_files:
|
81
|
-
- README.rdoc
|
82
|
-
- LICENSE
|
83
|
-
- TODO
|
84
|
-
files: []
|
85
|
-
|
86
|
-
has_rdoc: true
|
87
|
-
homepage:
|
88
|
-
post_install_message:
|
89
|
-
rdoc_options:
|
90
|
-
- --charset=utf-8
|
91
|
-
- --main
|
92
|
-
- README.rdoc
|
93
|
-
require_paths:
|
94
|
-
- lib
|
95
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
-
requirements: *id002
|
97
|
-
version:
|
98
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
-
requirements: *id003
|
100
|
-
version:
|
101
|
-
requirements: []
|
102
|
-
|
103
|
-
rubyforge_project:
|
104
|
-
rubygems_version: 1.3.1
|
105
|
-
signing_key:
|
106
|
-
specification_version: 2
|
12
|
+
gem: true
|
13
|
+
name: microgem
|
107
14
|
summary: MicroGem provides a simple naive replacement for the `gem install' command in the form of the `mgem' commandline utility.
|
108
|
-
|
109
|
-
|
15
|
+
version: 0.2.0
|
data/test/fixtures/template.html
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
<html>
|
2
2
|
<body>
|
3
3
|
<h1>dr-nic-magic-awesome</h1>
|
4
|
-
<p>
|
4
|
+
<p>A gem which summons Dr. Nic to fix all your projects while you are cuddled underneath your blankie.</p>
|
5
5
|
<h1>microgem</h1>
|
6
6
|
<p>MicroGem provides a simple naive replacement for the `gem install' command in the form of the `mgem' commandline utility.</p>
|
7
7
|
</body>
|
@@ -7,15 +7,28 @@ describe "JewelryPortfolio" do
|
|
7
7
|
JewelryPortfolio::ReposIndex.any_instance.stubs(:puts)
|
8
8
|
FileUtils.rm_rf(TMP_PAGES_REPO)
|
9
9
|
|
10
|
-
@
|
11
|
-
@portfolio = JewelryPortfolio.new('alloy', @
|
10
|
+
@repo = JewelryPortfolio::Repo.new('alloy', eval(fixture_read('dr-nic-magic-awesome.gemspec_')))
|
11
|
+
@portfolio = JewelryPortfolio.new('alloy', @repo)
|
12
12
|
|
13
13
|
@portfolio.stubs(:puts)
|
14
14
|
end
|
15
15
|
|
16
|
+
it "should raise an ArgumentError if no account is given" do
|
17
|
+
lambda {
|
18
|
+
JewelryPortfolio.new(nil, @repo)
|
19
|
+
}.should.raise ArgumentError
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should raise a JewelryPortfolio::Repo::InvalidError if the given repo isn't valid" do
|
23
|
+
@repo.version = nil
|
24
|
+
lambda {
|
25
|
+
JewelryPortfolio.new('alloy', @repo)
|
26
|
+
}.should.raise ArgumentError
|
27
|
+
end
|
28
|
+
|
16
29
|
it "should add the spec to the index" do
|
17
|
-
JewelryPortfolio::ReposIndex.any_instance.expects(:add).with(@
|
18
|
-
JewelryPortfolio.new('alloy', @
|
30
|
+
JewelryPortfolio::ReposIndex.any_instance.expects(:add).with(@repo)
|
31
|
+
JewelryPortfolio.new('alloy', @repo)
|
19
32
|
end
|
20
33
|
|
21
34
|
it "should also initialize without gemspec" do
|
@@ -26,14 +39,14 @@ describe "JewelryPortfolio" do
|
|
26
39
|
it "should return the local pages repos index" do
|
27
40
|
index = @portfolio.index
|
28
41
|
index.should.be.instance_of JewelryPortfolio::ReposIndex
|
29
|
-
index.repos.map { |r| r.
|
42
|
+
index.repos.map { |r| r.name }.should == %w{ dr-nic-magic-awesome microgem }
|
30
43
|
end
|
31
44
|
|
32
45
|
it "should return the template" do
|
33
46
|
template = @portfolio.template
|
34
47
|
template.should.be.instance_of JewelryPortfolio::Template
|
35
48
|
template.template.should == File.join(@portfolio.index.path, 'template.html.erb')
|
36
|
-
template.repos.should == @portfolio.index.repos
|
49
|
+
template.repos.should == @portfolio.index.repos.to_a
|
37
50
|
end
|
38
51
|
|
39
52
|
it "should write out the template" do
|
@@ -41,7 +54,7 @@ describe "JewelryPortfolio" do
|
|
41
54
|
File.read(File.join(@portfolio.index.path, 'index.html')).should == File.read(fixture('template.html'))
|
42
55
|
end
|
43
56
|
|
44
|
-
it "should render, commit, and push the
|
57
|
+
it "should render, commit, and push the master branch" do
|
45
58
|
@portfolio.expects(:render!)
|
46
59
|
@portfolio.index.expects(:commit!).with("Updated github pages for: dr-nic-magic-awesome-1.0.0")
|
47
60
|
@portfolio.index.expects(:push!)
|
@@ -61,7 +74,7 @@ describe "JewelryPortfolio, with a custom work_directory" do
|
|
61
74
|
@portfolio.index.instance_variable_get("@custom_work_directory").should == Dir.pwd
|
62
75
|
end
|
63
76
|
|
64
|
-
it "should render, commit, and push the
|
77
|
+
it "should render, commit, and push the master branch" do
|
65
78
|
@portfolio.expects(:render!)
|
66
79
|
@portfolio.index.expects(:commit!).with("Re-generated github pages")
|
67
80
|
@portfolio.index.expects(:push!)
|
data/test/repo_test.rb
CHANGED
@@ -1,25 +1,104 @@
|
|
1
1
|
require File.expand_path('../test_helper', __FILE__)
|
2
2
|
|
3
|
-
|
3
|
+
module SharedRepoSpecs
|
4
|
+
def self.included(klass)
|
5
|
+
klass.class_eval do
|
6
|
+
it "should return the name of the repo it represents" do
|
7
|
+
@repo.name.should == 'dr-nic-magic-awesome'
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return the version of the project" do
|
11
|
+
@repo.version.should == '1.0.0'
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return the summary of the project" do
|
15
|
+
@repo.summary.should == 'Magically fix your projects overnight!'
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return the description of the project" do
|
19
|
+
@repo.description.should == 'A gem which summons Dr. Nic to fix all your projects while you are cuddled underneath your blankie.'
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return the url to the github project page" do
|
23
|
+
@repo.url.should == 'http://github.com/alloy/dr-nic-magic-awesome/tree/master'
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return the public clone url" do
|
27
|
+
@repo.clone_url.should == 'git://github.com/alloy/dr-nic-magic-awesome.git'
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return a custom #hash" do
|
31
|
+
@repo.hash.should == 'dr-nic-magic-awesome'.hash
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should be equal if the name is equal" do
|
35
|
+
other = JewelryPortfolio::Repo.new('alloy')
|
36
|
+
other.name = @repo.name
|
37
|
+
|
38
|
+
@repo.should == other
|
39
|
+
@repo.should.eql other
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should not be equal if the name doesn't match" do
|
43
|
+
other = JewelryPortfolio::Repo.new('alloy')
|
44
|
+
other.name = 'other-gem'
|
45
|
+
|
46
|
+
@repo.should.not == other
|
47
|
+
@repo.should.not.eql other
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should return itself serialized as YAML" do
|
51
|
+
loaded_repo = YAML.load(@repo.to_yaml)
|
52
|
+
|
53
|
+
loaded_repo.name.should == @repo.name
|
54
|
+
loaded_repo.version.should == @repo.version
|
55
|
+
loaded_repo.summary.should == @repo.summary
|
56
|
+
loaded_repo.description.should == @repo.description
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should be valid with all necessary attributes set" do
|
60
|
+
@repo.should.be.valid
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should not be valid with any of its attributes missing" do
|
64
|
+
%w{ account name version summary description }.each do |attr|
|
65
|
+
repo = @repo.dup
|
66
|
+
repo.send("#{attr}=", nil)
|
67
|
+
|
68
|
+
repo.should.not.be.valid
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "JewelryPortfolio::Repo, when initialized without a gemspec" do
|
4
76
|
before do
|
5
|
-
@
|
6
|
-
@repo =
|
77
|
+
@repo = JewelryPortfolio::Repo.new
|
78
|
+
@repo.account = 'alloy'
|
79
|
+
@repo.name = 'dr-nic-magic-awesome'
|
80
|
+
@repo.version = '1.0.0'
|
81
|
+
@repo.summary = 'Magically fix your projects overnight!'
|
82
|
+
@repo.description = 'A gem which summons Dr. Nic to fix all your projects while you are cuddled underneath your blankie.'
|
7
83
|
end
|
8
84
|
|
9
|
-
|
10
|
-
@repo.spec.should == @spec
|
11
|
-
end
|
85
|
+
include SharedRepoSpecs
|
12
86
|
|
13
|
-
it "should return
|
14
|
-
@repo.
|
87
|
+
it "should return that there's _no_ a gem for the repo" do
|
88
|
+
@repo.gem?.should.be false
|
15
89
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "JewelryPortfolio::Repo, when initialized with a gemspec" do
|
93
|
+
before do
|
94
|
+
@spec = fixture_eval('dr-nic-magic-awesome.gemspec_')
|
95
|
+
@repo = JewelryPortfolio::Repo.new('alloy', @spec)
|
19
96
|
end
|
20
97
|
|
21
|
-
|
22
|
-
|
98
|
+
include SharedRepoSpecs
|
99
|
+
|
100
|
+
it "should return that there's a gem for the repo" do
|
101
|
+
@repo.gem?.should.be true
|
23
102
|
end
|
24
103
|
|
25
104
|
it "should return the gem name" do
|
@@ -29,16 +108,4 @@ describe "JewelryPortfolio::Repo" do
|
|
29
108
|
it "should return the gem install command" do
|
30
109
|
@repo.gem_install_command.should == "sudo gem install #{@repo.gem_name} -s http://gems.github.com"
|
31
110
|
end
|
32
|
-
|
33
|
-
xit "should return itself serialized as YAML" do
|
34
|
-
@repo.to_yaml.should == fixture_read('dr-nic-magic-awesome_repo.yml')
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should be equal if the name matches" do
|
38
|
-
JewelryPortfolio::Repo.new(fixture_eval('dr-nic-magic-awesome.gemspec_'), 'alloy').should ==
|
39
|
-
JewelryPortfolio::Repo.new(fixture_eval('dr-nic-magic-awesome.gemspec_'), 'alloy')
|
40
|
-
|
41
|
-
JewelryPortfolio::Repo.new(fixture_eval('dr-nic-magic-awesome.gemspec_'), 'alloy').should.not ==
|
42
|
-
JewelryPortfolio::Repo.new(fixture_eval('microgem.gemspec_'), 'alloy')
|
43
|
-
end
|
44
111
|
end
|
data/test/repos_index_test.rb
CHANGED
@@ -72,22 +72,20 @@ describe "JewelryPortfolio::ReposIndex, when working with a pages repo" do
|
|
72
72
|
File.should.exist File.join(TMP_PAGES_REPO, 'repos.yml')
|
73
73
|
end
|
74
74
|
|
75
|
-
it "should not create a new checkout if it already exists, but
|
75
|
+
it "should not create a new checkout if it already exists, but fetch and merge" do
|
76
76
|
@index.pages_repo # make sure it exists
|
77
77
|
@index.instance_variable_set("@pages_repo", nil)
|
78
78
|
|
79
79
|
Git.expects(:clone).never
|
80
|
-
Git::Base.any_instance.expects(:checkout).with('
|
80
|
+
Git::Base.any_instance.expects(:checkout).with('master')
|
81
81
|
Git::Base.any_instance.expects(:fetch).with('origin')
|
82
|
-
Git::Base.any_instance.expects(:merge).with('origin/
|
82
|
+
Git::Base.any_instance.expects(:merge).with('origin/master')
|
83
83
|
@index.pages_repo
|
84
84
|
end
|
85
85
|
|
86
|
-
it "should create and checkout the `
|
86
|
+
it "should create and checkout the `master' branch" do
|
87
87
|
FileUtils.rm_rf(TMP_PAGES_REPO)
|
88
|
-
@index.pages_repo.branch('
|
89
|
-
@index.pages_repo.config('branch.gh-pages.remote').should == 'origin'
|
90
|
-
@index.pages_repo.config('branch.gh-pages.merge').should == 'refs/heads/gh-pages'
|
88
|
+
@index.pages_repo.branch('master').should.be.current
|
91
89
|
end
|
92
90
|
|
93
91
|
it "should return the pages repo" do
|
@@ -95,33 +93,33 @@ describe "JewelryPortfolio::ReposIndex, when working with a pages repo" do
|
|
95
93
|
repo.should.be.instance_of Git::Base
|
96
94
|
end
|
97
95
|
|
98
|
-
|
96
|
+
xit "should return an array of specs" do
|
99
97
|
FileUtils.rm_rf(TMP_PAGES_REPO)
|
100
98
|
|
101
99
|
@index.specs.each { |s| s.should.be.instance_of Gem::Specification }
|
102
100
|
@index.specs.map { |s| s.name }.should == %w{ dr-nic-magic-awesome microgem }
|
103
101
|
end
|
104
102
|
|
105
|
-
it "should return an empty
|
103
|
+
it "should return an empty set if the repos.yml file does not exist yet" do
|
106
104
|
FileUtils.rm(@index.repos_file)
|
107
|
-
@index.
|
105
|
+
@index.repos.should == Set.new
|
108
106
|
end
|
109
107
|
|
110
|
-
it "should return
|
108
|
+
it "should return a set of repos with their gemspecs" do
|
111
109
|
FileUtils.rm_rf(TMP_PAGES_REPO)
|
112
110
|
|
113
111
|
@index.repos.should == [
|
114
|
-
JewelryPortfolio::Repo.new(fixture_eval('dr-nic-magic-awesome.gemspec_')
|
115
|
-
JewelryPortfolio::Repo.new(fixture_eval('microgem.gemspec_')
|
116
|
-
]
|
112
|
+
JewelryPortfolio::Repo.new('alloy', fixture_eval('dr-nic-magic-awesome.gemspec_')),
|
113
|
+
JewelryPortfolio::Repo.new('alloy', fixture_eval('microgem.gemspec_'))
|
114
|
+
].to_set
|
117
115
|
end
|
118
116
|
|
119
117
|
xit "should serialize the array of repos as YAML" do
|
120
118
|
@index.to_yaml.should == fixture_read('repos.yml')
|
121
119
|
end
|
122
120
|
|
123
|
-
it "should push the
|
124
|
-
@index.pages_repo.expects(:push).with('origin', '
|
121
|
+
it "should push the to origin/master" do
|
122
|
+
@index.pages_repo.expects(:push).with('origin', 'master')
|
125
123
|
@index.push!
|
126
124
|
end
|
127
125
|
|
@@ -139,20 +137,15 @@ describe "JewelryPortfolio::ReposIndex, when working with a pages repo" do
|
|
139
137
|
end
|
140
138
|
end
|
141
139
|
|
142
|
-
it "should
|
143
|
-
@index.pages_repo.expects(:push).with('origin', 'gh-pages')
|
144
|
-
@index.push!
|
145
|
-
end
|
146
|
-
|
147
|
-
it "should add a new spec to the repos.yml" do
|
140
|
+
it "should add a new repo to the repos.yml" do
|
148
141
|
FileUtils.rm_rf(TMP_PAGES_REPO)
|
149
142
|
@index.repos # make sure its loaded
|
150
143
|
|
151
|
-
|
152
|
-
|
144
|
+
repo = JewelryPortfolio::Repo.new('alloy', eval(fixture_read('dr-nic-magic-awesome.gemspec_').
|
145
|
+
gsub('dr-nic-magic-awesome', 'dr-nic-magic-awesome-v2')))
|
153
146
|
|
154
147
|
assert_difference('repos_from_file.length', +1) do
|
155
|
-
@index.add(
|
148
|
+
@index.add(repo)
|
156
149
|
end
|
157
150
|
|
158
151
|
repos_from_file.last.name.should == 'dr-nic-magic-awesome-v2'
|
@@ -162,10 +155,10 @@ describe "JewelryPortfolio::ReposIndex, when working with a pages repo" do
|
|
162
155
|
FileUtils.rm_rf(TMP_PAGES_REPO)
|
163
156
|
@index.repos # make sure its loaded
|
164
157
|
|
165
|
-
|
158
|
+
repo = JewelryPortfolio::Repo.new('alloy', eval(fixture_read('dr-nic-magic-awesome.gemspec_').gsub('1.0.0', '1.1.1')))
|
166
159
|
|
167
160
|
assert_no_difference('repos_from_file.length') do
|
168
|
-
@index.add(
|
161
|
+
@index.add(repo)
|
169
162
|
end
|
170
163
|
|
171
164
|
repos_from_file.first.version.to_s.should == '1.1.1'
|
data/test/tasks_test.rb
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'jewelry_portfolio/tasks'
|
3
|
+
|
4
|
+
module RakeTaskTestHelper
|
5
|
+
class Namespace
|
6
|
+
attr_reader :tasks
|
7
|
+
|
8
|
+
def initialize(tasks_helper)
|
9
|
+
@tasks = {}
|
10
|
+
@tasks_helper = tasks_helper
|
11
|
+
end
|
12
|
+
|
13
|
+
def task(name, &block)
|
14
|
+
@tasks[name] = block
|
15
|
+
end
|
16
|
+
|
17
|
+
def desc(title)
|
18
|
+
# nothing
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_missing(method, *args, &block)
|
22
|
+
@tasks_helper.send(method, *args, &block)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def namespace(name, &block)
|
27
|
+
@namespaces ||= {}
|
28
|
+
(@namespaces[name] = Namespace.new(self)).instance_eval(&block)
|
29
|
+
end
|
30
|
+
|
31
|
+
def namespaces
|
32
|
+
@namespaces
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
JewelryPortfolio::Tasks.send(:include, RakeTaskTestHelper)
|
37
|
+
|
38
|
+
describe "JewelryPortfolio::Tasks" do
|
39
|
+
before do
|
40
|
+
@tasks_helper = JewelryPortfolio::Tasks.new
|
41
|
+
@tasks_helper.stubs(:portfolio).returns(stub('JewelryPortfolio instance'))
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should define a portfolio namespace" do
|
45
|
+
@tasks_helper.namespaces.should.has_key :portfolio
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should define a portfolio:generate task which calls render! on the portfolio instance and opens the index.html file" do
|
49
|
+
@tasks_helper.portfolio.stubs(:index).returns(stub('JewelryPortfolio::ReposIndex', :path => '/path/to/repo'))
|
50
|
+
|
51
|
+
@tasks_helper.portfolio.expects(:render!)
|
52
|
+
@tasks_helper.expects(:sh).with("open '/path/to/repo/index.html'")
|
53
|
+
|
54
|
+
@tasks_helper.namespaces[:portfolio].tasks[:generate].call
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should define a portfolio:release task which calls release! on the portfolio instance" do
|
58
|
+
@tasks_helper.portfolio.expects(:release!)
|
59
|
+
@tasks_helper.namespaces[:portfolio].tasks[:release].call
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "JewelryPortfolio::Tasks, in general" do
|
64
|
+
before do
|
65
|
+
Git.stubs(:open).with('.').returns(stub('Git config', :config => { 'github.user' => 'joe_the_plumber' }))
|
66
|
+
|
67
|
+
@tasks_helper = JewelryPortfolio::Tasks.new
|
68
|
+
@tasks_helper.stubs(:portfolio).returns(stub('JewelryPortfolio instance'))
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should yield a JewelryPortfolio::Repo when initializing" do
|
72
|
+
repo = nil
|
73
|
+
@tasks_helper = JewelryPortfolio::Tasks.new { |t| repo = t }
|
74
|
+
|
75
|
+
repo.should.be.instance_of JewelryPortfolio::Repo
|
76
|
+
@tasks_helper.repo.should.be repo
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should assign the account to use on the repo, from the local/global git config if the user didn't specify one" do
|
80
|
+
@tasks_helper.repo.account.should == 'joe_the_plumber'
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should raise an ArgumentError if no account could be resolved" do
|
84
|
+
Git.stubs(:open).with('.').returns(stub('Git config', :config => {}))
|
85
|
+
@tasks_helper = JewelryPortfolio::Tasks.new
|
86
|
+
|
87
|
+
lambda { @tasks_helper.send(:portfolio) }.should.raise ArgumentError
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should try to find a gemspec file in the current work directory and return a JewelryPortfolio instance with that spec" do
|
91
|
+
Dir.expects(:glob).with('*.gemspec').returns([fixture('dr-nic-magic-awesome.gemspec_')])
|
92
|
+
@tasks_helper = JewelryPortfolio::Tasks.new
|
93
|
+
|
94
|
+
JewelryPortfolio.expects(:new).with('joe_the_plumber',
|
95
|
+
JewelryPortfolio::Repo.new('joe_the_plumber', fixture_eval('dr-nic-magic-awesome.gemspec_'))).
|
96
|
+
returns('JewelryPortfolio')
|
97
|
+
|
98
|
+
@tasks_helper.send(:portfolio).should == 'JewelryPortfolio'
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should not pass the Repo instance if it's not valid" do
|
102
|
+
Dir.stubs(:glob).with('*.gemspec').returns([])
|
103
|
+
@tasks_helper = JewelryPortfolio::Tasks.new
|
104
|
+
|
105
|
+
JewelryPortfolio.expects(:new).with('joe_the_plumber', nil).returns('JewelryPortfolio')
|
106
|
+
@tasks_helper.send(:portfolio).should == 'JewelryPortfolio'
|
107
|
+
end
|
108
|
+
end
|
data/test/template_test.rb
CHANGED
@@ -1,21 +1,15 @@
|
|
1
1
|
require File.expand_path('../test_helper', __FILE__)
|
2
2
|
|
3
|
-
class GemSpecMock
|
4
|
-
attr_accessor :name, :description
|
5
|
-
|
6
|
-
def initialize(name, description)
|
7
|
-
@name, @description = name, description
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
3
|
describe "JewelryPortfolio::Template" do
|
12
4
|
before do
|
13
|
-
@repos =
|
14
|
-
JewelryPortfolio::Repo.new(
|
15
|
-
JewelryPortfolio::Repo.new(GemSpecMock.new('microgem', "MicroGem provides a simple naive replacement for the `gem install' command in the form of the `mgem' commandline utility."), 'alloy')
|
16
|
-
]
|
5
|
+
@repos = %w{ dr-nic-magic-awesome.gemspec_ microgem.gemspec_ }.
|
6
|
+
map { |spec| JewelryPortfolio::Repo.new('alloy', fixture_eval(spec)) }
|
17
7
|
|
18
|
-
@page = JewelryPortfolio::Template.new(fixture('template'), @repos)
|
8
|
+
@page = JewelryPortfolio::Template.new(fixture('template'), @repos.to_set)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should turn the repos set into an array" do
|
12
|
+
@page.repos.should.be.instance_of Array
|
19
13
|
end
|
20
14
|
|
21
15
|
it "should raise a JewelryPortfolio::FileMissingError if the specified template does not exist" do
|
@@ -47,7 +41,7 @@ describe "JewelryPortfolio::Template" do
|
|
47
41
|
end
|
48
42
|
|
49
43
|
it "should render an ERB partial with the specified local variables" do
|
50
|
-
@page.partial('repo', :repo => @repos.first
|
44
|
+
@page.partial('repo', :repo => @repos.first).should ==
|
51
45
|
File.read(fixture('dr-nic-magic-awesome.html'))
|
52
46
|
end
|
53
47
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Fingertips-jewelry_portfolio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eloy Duran
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-03 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- test/jewelry_portfolio_test.rb
|
49
49
|
- test/repo_test.rb
|
50
50
|
- test/repos_index_test.rb
|
51
|
+
- test/tasks_test.rb
|
51
52
|
- test/template_test.rb
|
52
53
|
- test/test_helper.rb
|
53
54
|
- test/tmp
|