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 CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 2
4
- :patch: 0
4
+ :patch: 1
@@ -10,12 +10,23 @@ end
10
10
 
11
11
  class JewelryPortfolio
12
12
  class Tasks
13
- # The JewelryPortfolio::Repo instance. If a block is given to ::new, this
14
- # instance will be yielded.
15
- attr_reader :repo
13
+ # The GitHub user account that this repo belongs to.
14
+ attr_accessor :account
16
15
 
17
- # Initialize the JewelryPortfolio rake tasks. A JewelryPortfolio::Repo is
18
- # yielded so additional configuration can be performed.
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
- @repo = Repo.new(retrieve_github_username, retrieve_gemspec)
32
- yield @repo if block_given?
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
- validate_account!
55
- @portfolio ||= JewelryPortfolio.new(@repo.account, (@repo if @repo.valid?))
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 retrieve_gemspec
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 retrieve_github_username
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 a JewelryPortfolio::Repo when initializing" do
72
- repo = nil
73
- @tasks_helper = JewelryPortfolio::Tasks.new { |t| repo = t }
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
- repo.should.be.instance_of JewelryPortfolio::Repo
76
- @tasks_helper.repo.should.be repo
75
+ returned_instance.should.be yielded_instance
77
76
  end
78
77
 
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'
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
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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Duran