Class: Helm::Session
- Inherits:
-
Object
- Object
- Helm::Session
- Defined in:
- lib/helm/session.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#[](name) ⇒ Object
Access positional parameters sent to the active command based on the order specified in configure_params.
-
#configure_params(*names) ⇒ Object
Configure the set of params to be used by the active command.
-
#initialize ⇒ Session
constructor
A new instance of Session.
- #milestone(id = nil) ⇒ Object
- #new_ticket ⇒ Object
- #password ⇒ Object
- #project ⇒ Object
- #ticket(id = nil) ⇒ Object
- #ticket_path(id = nil) ⇒ Object
- #tickets(filter = nil) ⇒ Object
- #uri ⇒ Object
- #url ⇒ Object
- #user(id = nil) ⇒ Object
- #username ⇒ Object
Constructor Details
#initialize ⇒ Session
Returns a new instance of Session.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/helm/session.rb', line 8 def initialize Choice. do option :url do long '--url' desc 'The project URL' end option :token do long '--token' desc 'The token to authenticate against the server' end option :username do long '--username' desc 'The username to authenticate against the server' end option :password do long '--password' desc 'The username to authenticate against the server' end option :project do long '--project' short '-p' desc 'The project title' end end = Choice.choices configure end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/helm/session.rb', line 6 def end |
Instance Method Details
#[](name) ⇒ Object
Access positional parameters sent to the active command based on the order specified in configure_params.
52 53 54 |
# File 'lib/helm/session.rb', line 52 def [](name) arguments[@params[name].succ] end |
#configure_params(*names) ⇒ Object
Configure the set of params to be used by the active command.
43 44 45 46 47 48 |
# File 'lib/helm/session.rb', line 43 def configure_params(*names) @params = {} names.each_with_index do |name, index| @params[name] = index end end |
#milestone(id = nil) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/helm/session.rb', line 72 def milestone(id = nil) if id Lighthouse::Milestone.find(id) else @milestone ||= Lighthouse::Milestone.find(:all, :params => {:project_id => project.id}).detect {|m| m.title == self[:milestone] } end end |
#new_ticket ⇒ Object
60 61 62 |
# File 'lib/helm/session.rb', line 60 def new_ticket Lighthouse::Ticket.new(:project_id => project.id) end |
#password ⇒ Object
100 101 102 |
# File 'lib/helm/session.rb', line 100 def password .password end |
#project ⇒ Object
56 57 58 |
# File 'lib/helm/session.rb', line 56 def project @project ||= Lighthouse::Project.find(:all).detect {|p| p.name == .project } end |
#ticket(id = nil) ⇒ Object
64 65 66 |
# File 'lib/helm/session.rb', line 64 def ticket(id = nil) Lighthouse::Ticket.find(id || self[:ticket], :params => {:project_id => project.id}) end |
#ticket_path(id = nil) ⇒ Object
104 105 106 |
# File 'lib/helm/session.rb', line 104 def ticket_path(id = nil) Lighthouse::Ticket.element_path(id || self[:ticket], {:project_id => project.id}).sub(/\.xml$/, '') end |
#tickets(filter = nil) ⇒ Object
68 69 70 |
# File 'lib/helm/session.rb', line 68 def tickets(filter = nil) project.tickets(:q => filter) end |
#uri ⇒ Object
88 89 90 |
# File 'lib/helm/session.rb', line 88 def uri @uri ||= URI.parse(url) end |
#url ⇒ Object
92 93 94 |
# File 'lib/helm/session.rb', line 92 def url .url end |
#user(id = nil) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/helm/session.rb', line 80 def user(id = nil) if id Lighthouse::User.find(id) else @user ||= Lighthouse::User.find(Lighthouse::Token.find(token).user_id) end end |
#username ⇒ Object
96 97 98 |
# File 'lib/helm/session.rb', line 96 def username .username end |