Fingertips-jewelry_portfolio 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/jewelry_portfolio/tasks.rb +36 -17
- data/test/tasks_test.rb +6 -7
- metadata +1 -1
data/VERSION.yml
CHANGED
@@ -10,12 +10,23 @@ end
|
|
10
10
|
|
11
11
|
class JewelryPortfolio
|
12
12
|
class Tasks
|
13
|
-
# The
|
14
|
-
|
15
|
-
attr_reader :repo
|
13
|
+
# The GitHub user account that this repo belongs to.
|
14
|
+
attr_accessor :account
|
16
15
|
|
17
|
-
#
|
18
|
-
|
16
|
+
# The name of the repo.
|
17
|
+
attr_accessor :name
|
18
|
+
|
19
|
+
# The version of the current version of the project.
|
20
|
+
attr_accessor :version
|
21
|
+
|
22
|
+
# The summary of the project.
|
23
|
+
attr_accessor :summary
|
24
|
+
|
25
|
+
# The description of the project.
|
26
|
+
attr_accessor :description
|
27
|
+
|
28
|
+
# Initialize the JewelryPortfolio rake tasks. The JewelryPortfolio::Tasks
|
29
|
+
# instance is yielded so additional configuration can be performed.
|
19
30
|
#
|
20
31
|
# If the repo you're working in does _not_ contain a +gemspec+ file, then
|
21
32
|
# you'll need to assign all values to the Repo yourself.
|
@@ -28,8 +39,8 @@ class JewelryPortfolio
|
|
28
39
|
# t.description = 'A longer description about the project.'
|
29
40
|
# end
|
30
41
|
def initialize
|
31
|
-
@
|
32
|
-
yield
|
42
|
+
@account = github_username
|
43
|
+
yield self if block_given?
|
33
44
|
define
|
34
45
|
end
|
35
46
|
|
@@ -51,24 +62,32 @@ class JewelryPortfolio
|
|
51
62
|
end
|
52
63
|
|
53
64
|
def portfolio
|
54
|
-
|
55
|
-
|
65
|
+
unless @account
|
66
|
+
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."
|
67
|
+
end
|
68
|
+
@portfolio ||= JewelryPortfolio.new(@account, (repo if repo.valid?))
|
69
|
+
end
|
70
|
+
|
71
|
+
def repo
|
72
|
+
unless @repo
|
73
|
+
@repo = Repo.new(account, gemspec)
|
74
|
+
%w{ account name version summary description }.each do |attr|
|
75
|
+
if value = send(attr)
|
76
|
+
@repo.send("#{attr}=", send(attr))
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
@repo
|
56
81
|
end
|
57
82
|
|
58
|
-
def
|
83
|
+
def gemspec
|
59
84
|
if spec_file = Dir.glob('*.gemspec').first
|
60
85
|
spec = eval(File.read(spec_file))
|
61
86
|
end
|
62
87
|
end
|
63
88
|
|
64
|
-
def
|
89
|
+
def github_username
|
65
90
|
Git.open('.').config['github.user']
|
66
91
|
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
|
73
92
|
end
|
74
93
|
end
|
data/test/tasks_test.rb
CHANGED
@@ -68,16 +68,15 @@ describe "JewelryPortfolio::Tasks, in general" do
|
|
68
68
|
@tasks_helper.stubs(:portfolio).returns(stub('JewelryPortfolio instance'))
|
69
69
|
end
|
70
70
|
|
71
|
-
it "should yield
|
72
|
-
|
73
|
-
|
71
|
+
it "should yield itself when initializing" do
|
72
|
+
yielded_instance = nil
|
73
|
+
returned_instance = JewelryPortfolio::Tasks.new { |t| yielded_instance = t }
|
74
74
|
|
75
|
-
|
76
|
-
@tasks_helper.repo.should.be repo
|
75
|
+
returned_instance.should.be yielded_instance
|
77
76
|
end
|
78
77
|
|
79
|
-
it "should
|
80
|
-
@tasks_helper.
|
78
|
+
it "should return the account to use from the local/global git config if the user didn't specify one" do
|
79
|
+
@tasks_helper.account.should == 'joe_the_plumber'
|
81
80
|
end
|
82
81
|
|
83
82
|
it "should raise an ArgumentError if no account could be resolved" do
|