pivotal-github 1.1.1 → 1.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f59a52cc7afa00e5cb39764cc7ac45d6d82f787d
4
- data.tar.gz: a903b9d4f792f69492faf90b3240b126b01dc522
3
+ metadata.gz: 45a58bb6127bbee7345696b43a96afc44fde54ee
4
+ data.tar.gz: 937b78962142d01fa2d252c4d632818490573d2c
5
5
  SHA512:
6
- metadata.gz: 8b9d610a37af39dd35b60b573df29a2bf5f4f1dd7130c924e50edc018bb1d5016e5fcbf914c95023408d8b3f108c7cd0f733ba651bd4adb929330b8dcfed7cfb
7
- data.tar.gz: f6f252b091ba275cfe887326ed33bd232168af5c97c4cb21c187e056e8ab34253b2de0d3ee64e1e1b0f283ff68ff1c7315db9c33b27e10ad98a9996b0b6bb3ab
6
+ metadata.gz: ba3a6db85f4bdea3eef8aa16e0e38a7eb5ae2aead40dc2123b7b27e845fce40b9eb06260ae585303c5ca7b52b7761683e32a34a0ab65d9ece1011e4e63bb21d0
7
+ data.tar.gz: 2f90885f4c94c5c07ba0cb9ea186de358b2f65c5a2e57a6f3098dc74992cea03501406ae1dea3d272f3708c72dca30b48364cf87abb0c8dbb7dd822797b168af
@@ -58,28 +58,26 @@ class StoryAccept < Command
58
58
  Nokogiri::XML(response.body).at_css('current_state').content == "accepted"
59
59
  end
60
60
 
61
- def api_token
62
- api_filename = '.api_token'
63
- if File.exist?(api_filename)
64
- @api_token ||= File.read(api_filename).strip
61
+ def config_filename(filename, description)
62
+ if File.exist?(filename)
63
+ add_to_gitignore(filename)
64
+ varname = '@' + filename.sub('.', '')
65
+ value = File.read(filename).strip
66
+ instance_variable_set(varname, value)
65
67
  else
66
- puts "Please create a file called '#{api_filename}'"
67
- puts "containing your Pivotal Tracker API token."
68
- add_to_gitignore('.api_token')
68
+ puts "Please create a file called '#{filename}'"
69
+ puts "containing #{description}."
70
+ add_to_gitignore(filename)
69
71
  exit 1
70
72
  end
71
73
  end
72
74
 
75
+ def api_token
76
+ config_filename('.api_token', 'your Pivotal tracker API token')
77
+ end
78
+
73
79
  def project_id
74
- project_id_filename = '.project_id'
75
- if File.exist?(project_id_filename)
76
- @project_id ||= File.read(project_id_filename).strip
77
- else
78
- puts "Please create a file called '.project_id'"
79
- puts "containing the Pivotal Tracker project number."
80
- add_to_gitignore('.project_id')
81
- exit 1
82
- end
80
+ config_filename('.project_id', 'the Pivotal tracker project id')
83
81
  end
84
82
 
85
83
  # Adds a filename to the .gitignore file (if necessary).
@@ -90,7 +88,9 @@ class StoryAccept < Command
90
88
  if File.exist?(gitignore)
91
89
  contents = File.read(gitignore)
92
90
  unless contents =~ /#{filename}/
93
- File.open(gitignore, 'a') { |f| f.puts("\n" + filename) }
91
+ # Prepend a newline if the file doesn't end in a newline.
92
+ line = contents == contents.chomp ? "\n#{filename}" : filename
93
+ File.open(gitignore, 'a') { |f| f.puts(line) }
94
94
  puts "Added #{filename} to .gitignore"
95
95
  end
96
96
  end
@@ -1,5 +1,5 @@
1
1
  module Pivotal
2
2
  module Github
3
- VERSION = "1.1.1"
3
+ VERSION = "1.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pivotal-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hartl