morale 0.1.2 → 0.1.3

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.
@@ -38,6 +38,21 @@ Feature: Running the tickets command
38
38
  No project specified.
39
39
  """
40
40
 
41
+ @interactive
42
+ Scenario: Deleting a ticket should return the ticket results
43
+ Given a file named "credentials" with:
44
+ """
45
+ spartan
46
+ 12345
47
+ 1
48
+ """
49
+ When I run `morale This should be deleted`
50
+ And I run `morale "d #10"` interactively
51
+ Then the output should contain:
52
+ """
53
+ This should be deleted
54
+ """
55
+
41
56
  @interactive
42
57
  Scenario: Running tickets should return a list of all active tickets
43
58
  Given a file named "credentials" with:
@@ -9,9 +9,9 @@ module Morale
9
9
  include Morale::CredentialsStore
10
10
  include Morale::Flow
11
11
 
12
- def subdomain
12
+ def subdomain(ask=true)
13
13
  if @subdomain.nil?
14
- get_credentials
14
+ get_credentials ask
15
15
  @subdomain = @credentials[0]
16
16
  end
17
17
  @subdomain
@@ -29,8 +29,8 @@ module Morale
29
29
  @credentials[1]
30
30
  end
31
31
 
32
- def project
33
- get_credentials
32
+ def project(ask=true)
33
+ get_credentials ask
34
34
  @credentials[2] if !@credentials.nil? && @credentials.length > 2
35
35
  end
36
36
 
@@ -46,10 +46,10 @@ module Morale
46
46
  @login_attempts < 3
47
47
  end
48
48
 
49
- def get_credentials
49
+ def get_credentials(ask=true)
50
50
  return if @credentials
51
51
  unless @credentials = read_credentials
52
- ask_for_and_save_credentials
52
+ ask_for_and_save_credentials if ask
53
53
  end
54
54
  @credentials
55
55
  end
@@ -57,7 +57,7 @@ module Morale
57
57
  end
58
58
 
59
59
  no_tasks do
60
- def self.handle_no_task_error(task, has_namespace = $thor_runner) #:nodoc:
60
+ def self.handle_no_task_error(task, has_namespace = $thor_runner)
61
61
  self.new.ticket ARGV.compact.join(" ")
62
62
  end
63
63
  end
@@ -16,7 +16,7 @@ module Morale::Commands
16
16
 
17
17
  if !accounts.nil?
18
18
  accounts.sort{|a,b| a['account']['group_name'] <=> b['account']['group_name']}.each_with_index do |record, i|
19
- say "#{i += 1}. #{record['account']['group_name']}"
19
+ say "#{i += 1}. #{record['account']['group_name']}#{' *' if Morale::Account.subdomain(false) == record['account']['site_address']}"
20
20
  end
21
21
 
22
22
  if change
@@ -12,7 +12,7 @@ module Morale::Commands
12
12
  projects = Morale::Command.client.projects
13
13
  if !projects.nil?
14
14
  projects.sort{|a,b| a['project']['name'] <=> b['project']['name']}.each_with_index do |record, i|
15
- puts "#{i += 1}. #{record['project']['name']}"
15
+ puts "#{i += 1}. #{record['project']['name']}#{' *' if Morale::Account.project(false) == record['project']['id'].to_s}"
16
16
  end
17
17
 
18
18
  if change
@@ -11,13 +11,29 @@ module Morale::Commands
11
11
  include Morale::Flow
12
12
 
13
13
  def command(command)
14
- ask_for_project
15
- print Morale::Command.client.ticket(Morale::Account.project, command) unless Morale::Account.project.nil?
14
+ begin
15
+ ask_for_project
16
+ print Morale::Command.client.ticket(Morale::Account.project, command) unless Morale::Account.project.nil?
17
+ rescue Morale::Client::Unauthorized
18
+ say "Authentication failure"
19
+ Morale::Commands::Authorization.login
20
+ retry if Morale::Authorization.retry_login?
21
+ rescue Morale::Client::NotFound
22
+ say "Communication failure"
23
+ end
16
24
  end
17
25
 
18
26
  def list
19
- ask_for_project
20
- print Morale::Command.client.tickets({ :project_id => Morale::Account.project }) unless Morale::Account.project.nil?
27
+ begin
28
+ ask_for_project
29
+ print Morale::Command.client.tickets({ :project_id => Morale::Account.project }) unless Morale::Account.project.nil?
30
+ rescue Morale::Client::Unauthorized
31
+ say "Authentication failure"
32
+ Morale::Commands::Authorization.login
33
+ retry if Morale::Authorization.retry_login?
34
+ rescue Morale::Client::NotFound
35
+ say "Communication failure"
36
+ end
21
37
  end
22
38
 
23
39
  private
data/lib/morale.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Morale
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
4
4
 
5
5
  require 'morale/command'
data/morale.gemspec CHANGED
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
5
5
  s.rubygems_version = '1.3.5'
6
6
 
7
7
  s.name = 'morale'
8
- s.version = '0.1.2'
9
- s.date = '2011-10-01'
8
+ s.version = '0.1.3'
9
+ s.date = '2011-10-02'
10
10
  s.rubyforge_project = 'morale'
11
11
 
12
12
  s.summary = "Command line interface to create & manage tickets on Morale."
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 2
9
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Brilliant Fantastic
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-10-01 00:00:00 -04:00
17
+ date: 2011-10-02 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency