pivotal-github 1.1.7 → 1.2.0

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: 539f3b0c8e216974b9bff5ef66acbd97e17e64fe
4
- data.tar.gz: 40a1bfff6dc52af9f2408fccf0e33466cbf034ae
3
+ metadata.gz: 727659cf612b3572160046ca9f12608acf16698a
4
+ data.tar.gz: cc892a9b14ca4d3538d64b345d69c65825945fe8
5
5
  SHA512:
6
- metadata.gz: 0a27676c8844b14de42dae831605bc89fd4a7b465edaca72b6b51dfab1bcf64ba25f3f0967bef7510711e99573befc95663f438dc90540602e79631ccafeb3cc
7
- data.tar.gz: 9d4fa7934c92d112569eba79f0993e226abde76720d453be5b82af796ad50f94bc50eec501f6a673f4e192bd6647017b86e2e492bee0f0a60d0f104f63e50f17
6
+ metadata.gz: 0af10b8c3ef1fa9348d4aa4b06aee3bb552100258859a49af400ba809f79d286edf8b18f1a4066bc1322ece1a8ff686f0987d8724354ae5b5c07186a338306f2
7
+ data.tar.gz: 107f5d9c12867a47b3e548770cfe96fe1fc5ff5126859b70463101efc7599690a0d4ad46060491291b410fc0d2020895449acf0fdaa3c3069b462e0f7da4e3aa
data/README.md CHANGED
@@ -147,6 +147,13 @@ The `story-open` command (no `git`) opens the current story in the default brows
147
147
 
148
148
  $ story-open
149
149
 
150
+ ### project-open
151
+
152
+ The `project-open` command (no `git`) opens the current project in the default browser (OS X–only):
153
+
154
+ $ project-open
155
+
156
+ `project-open` requires the existence of file containing the project id with filename `.project_id` in the project's root directory. If it doesn't exist, the user is prompted to create it, and for safety it is automatically added to the `.gitignore` file.
150
157
 
151
158
  ## Configuration
152
159
 
data/bin/project-open ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+ require 'pivotal-github/project_open'
4
+
5
+ exit Command.run!(ProjectOpen, ARGV.dup)
@@ -6,3 +6,4 @@ require "pivotal-github/story_merge"
6
6
  require "pivotal-github/story_open"
7
7
  require "pivotal-github/story_pull_request"
8
8
  require "pivotal-github/story_accept"
9
+ require "pivotal-github/project_open"
@@ -0,0 +1,45 @@
1
+ module ConfigFiles
2
+
3
+ # Returns the Pivotal Tracker API token.
4
+ def api_token
5
+ config_filename('.api_token', 'your Pivotal tracker API token')
6
+ end
7
+
8
+ # Returns the Pivotal Tracker project id.
9
+ def project_id
10
+ config_filename('.project_id', 'the Pivotal tracker project id')
11
+ end
12
+
13
+ # Facilitate the creation of config variables based on files.
14
+ def config_filename(filename, description)
15
+ if File.exist?(filename)
16
+ add_to_gitignore(filename)
17
+ varname = '@' + filename.sub('.', '')
18
+ value = File.read(filename).strip
19
+ instance_variable_set(varname, value)
20
+ else
21
+ puts "Please create a file called '#{filename}'"
22
+ puts "containing #{description}."
23
+ add_to_gitignore(filename)
24
+ exit 1
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ # Adds a filename to the .gitignore file (if necessary).
31
+ # This is put in as a security precaution, especially to keep the
32
+ # Pivotal Tracker API key from leaking.
33
+ def add_to_gitignore(filename)
34
+ gitignore = '.gitignore'
35
+ if File.exist?(gitignore)
36
+ contents = File.read(gitignore)
37
+ unless contents =~ /#{filename}/
38
+ # Prepend a newline if the file doesn't end in a newline.
39
+ line = contents == contents.chomp ? "\n#{filename}" : filename
40
+ File.open(gitignore, 'a') { |f| f.puts(line) }
41
+ puts "Added #{filename} to .gitignore"
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,18 @@
1
+ require 'pivotal-github/command'
2
+ require 'pivotal-github/config_files'
3
+
4
+ class ProjectOpen < Command
5
+ include ConfigFiles
6
+
7
+ def project_url
8
+ "https://www.pivotaltracker.com/projects/#{project_id}"
9
+ end
10
+
11
+ def cmd
12
+ "open #{project_url}"
13
+ end
14
+
15
+ def run!
16
+ system cmd
17
+ end
18
+ end
@@ -1,11 +1,13 @@
1
1
  require 'pivotal-github/command'
2
2
  require 'pivotal-github/story'
3
+ require 'pivotal-github/config_files'
3
4
  require 'nokogiri'
4
5
  require 'net/http'
5
6
  require 'cgi'
6
7
 
7
8
  class StoryAccept < Command
8
9
  include Story
10
+ include ConfigFiles
9
11
 
10
12
  def parser
11
13
  OptionParser.new do |opts|
@@ -69,44 +71,6 @@ class StoryAccept < Command
69
71
  Nokogiri::XML(response.body).at_css('current_state').content == "accepted"
70
72
  end
71
73
 
72
- def config_filename(filename, description)
73
- if File.exist?(filename)
74
- add_to_gitignore(filename)
75
- varname = '@' + filename.sub('.', '')
76
- value = File.read(filename).strip
77
- instance_variable_set(varname, value)
78
- else
79
- puts "Please create a file called '#{filename}'"
80
- puts "containing #{description}."
81
- add_to_gitignore(filename)
82
- exit 1
83
- end
84
- end
85
-
86
- def api_token
87
- config_filename('.api_token', 'your Pivotal tracker API token')
88
- end
89
-
90
- def project_id
91
- config_filename('.project_id', 'the Pivotal tracker project id')
92
- end
93
-
94
- # Adds a filename to the .gitignore file (if necessary).
95
- # This is put in as a security precaution, especially to keep the
96
- # Pivotal Tracker API key from leaking.
97
- def add_to_gitignore(filename)
98
- gitignore = '.gitignore'
99
- if File.exist?(gitignore)
100
- contents = File.read(gitignore)
101
- unless contents =~ /#{filename}/
102
- # Prepend a newline if the file doesn't end in a newline.
103
- line = contents == contents.chomp ? "\n#{filename}" : filename
104
- File.open(gitignore, 'a') { |f| f.puts(line) }
105
- puts "Added #{filename} to .gitignore"
106
- end
107
- end
108
- end
109
-
110
74
  # Changes a story's state to **Accepted**.
111
75
  def accept!(story_id)
112
76
  accepted = "<story><current_state>accepted</current_state></story>"
@@ -1,5 +1,5 @@
1
1
  module Pivotal
2
2
  module Github
3
- VERSION = "1.1.7"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe ProjectOpen do
4
+
5
+ let(:command) { ProjectOpen.new }
6
+
7
+ it "should have a working project_url" do
8
+ expect { command.project_url }.not_to raise_error
9
+ end
10
+
11
+ context "with stubbed-out project_id" do
12
+ let(:project_id) { '6283185' }
13
+ before { command.stub(:project_id).and_return(project_id) }
14
+ let(:uri) { "https://www.pivotaltracker.com/projects/#{project_id}" }
15
+ subject { command }
16
+
17
+ its(:cmd) { should eq "open #{uri}" }
18
+ end
19
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pivotal-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hartl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-08 00:00:00.000000000 Z
11
+ date: 2013-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git-utils
@@ -46,6 +46,7 @@ executables:
46
46
  - git-story-commit
47
47
  - git-story-merge
48
48
  - git-story-pull-request
49
+ - project-open
49
50
  - story-open
50
51
  extensions: []
51
52
  extra_rdoc_files: []
@@ -63,11 +64,14 @@ files:
63
64
  - bin/git-story-commit
64
65
  - bin/git-story-merge
65
66
  - bin/git-story-pull-request
67
+ - bin/project-open
66
68
  - bin/story-open
67
69
  - lib/pivotal-github.rb
68
70
  - lib/pivotal-github/command.rb
71
+ - lib/pivotal-github/config_files.rb
69
72
  - lib/pivotal-github/finished_command.rb
70
73
  - lib/pivotal-github/options.rb
74
+ - lib/pivotal-github/project_open.rb
71
75
  - lib/pivotal-github/story.rb
72
76
  - lib/pivotal-github/story_accept.rb
73
77
  - lib/pivotal-github/story_commit.rb
@@ -77,6 +81,7 @@ files:
77
81
  - lib/pivotal-github/version.rb
78
82
  - pivotal-github.gemspec
79
83
  - spec/commands/command_spec.rb
84
+ - spec/commands/project_open_spec.rb
80
85
  - spec/commands/story_accept_spec.rb
81
86
  - spec/commands/story_commit_spec.rb
82
87
  - spec/commands/story_merge_spec.rb
@@ -110,6 +115,7 @@ specification_version: 4
110
115
  summary: See the README for full documentation
111
116
  test_files:
112
117
  - spec/commands/command_spec.rb
118
+ - spec/commands/project_open_spec.rb
113
119
  - spec/commands/story_accept_spec.rb
114
120
  - spec/commands/story_commit_spec.rb
115
121
  - spec/commands/story_merge_spec.rb