gitbc 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9cde4872d0db042174216009deb16045c9d9902
4
- data.tar.gz: 86307914e0ca9e847d0ac657f32d9eee1b336f0d
3
+ metadata.gz: 6adf83591c23faed7401a40dd2a608dfb5e2e173
4
+ data.tar.gz: 8b434cf71eaa42a7cb143386cee8b8e4858b44de
5
5
  SHA512:
6
- metadata.gz: 7ccdfe24751c1d79754852a8fe1d85c45e816fae33c625a1f23436a099f1048bcc8b6b5beaadedad5d7a63552f296530ce653bf5984295848475b05fb008f26c
7
- data.tar.gz: 452e3e4767ff406e589c907f01fe6b0df00437b9515c72c8603ca30af4f17d6825ffc6c56698b0ba334de47bd15e873dfb49478032e058bf1de165f05777411f
6
+ metadata.gz: cb69df4ab6c43414625bd51b9923121fbb327cde9154389d71503ba3cbcabd89691e54820f33ef1cbff388603aa66a55cb6e74dd65ca04ff3337121a7397ef65
7
+ data.tar.gz: 9d53b92fc602b07252f2bd32b12fd244ca463955a4bb53354a27bd2ab6607e0f89736bf3e64a5ff51f8346f7eec4722b843cd0d6aa112ad99001759fc4ff6d48
data/bin/gitbc CHANGED
@@ -154,11 +154,12 @@ if basecamp_todos.count > 0
154
154
  puts "end tag: #{options[:end_tag]}"
155
155
  puts "branch: #{options[:branch]}"
156
156
  puts "repository: #{options[:repository]}"
157
- puts "********************************************"
157
+ puts ''
158
158
  basecamp_todos.each do |pr, todos|
159
- puts "PR #{pr}"
160
- todos.each do |todo|
161
- puts " #{todo[:url]}" + (todo[:content] ? ": #{todo[:content]}" : '')
159
+ body = todos[:body].gsub("\r\n", '')
160
+ puts "* PR #{pr}" + (todos[:lines].length == 0 && body.length > 0 ? ", #{body}" : '')
161
+ todos[:lines].each do |line|
162
+ puts " --#{line[:url]}" + (line[:content] ? ", #{line[:content]}" : '')
162
163
  end
163
164
  end
164
165
  end
data/lib/gitbc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gitbc
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/lib/gitbc.rb CHANGED
@@ -10,6 +10,7 @@ require 'open3'
10
10
  class GitHubBasecampExtractor
11
11
  DEFAULT_CONFIG_FILE = File.expand_path('~/.gitbc')
12
12
  DEFAULT_END_TAG = 'HEAD'
13
+ MAX_PR_BODY_LENGTH = 235
13
14
 
14
15
  def initialize(params)
15
16
  @params = params
@@ -75,10 +76,11 @@ class GitHubBasecampExtractor
75
76
  basecamp_todos = pull_requests.inject({}) do |memo, pull_request_id|
76
77
  pr = @github_client.pull_request(@params[:repository], pull_request_id)
77
78
  basecamp_lines = pr.attrs[:body].split("\r\n").grep(/.*https\:\/\/basecamp\.com.*/)
79
+ memo[pull_request_id] = {body: pr.attrs[:body][0..MAX_PR_BODY_LENGTH].strip, lines: []}
78
80
  if basecamp_lines.count > 0
79
- memo[pull_request_id] = basecamp_lines.map { |line| {url: line[/.*(https\:\/\/basecamp\.com[^!?#:;,.\s]*)/, 1]} }.uniq
81
+ memo[pull_request_id][:lines] = basecamp_lines.map { |line| {url: line[/.*(https\:\/\/basecamp\.com[^!?#:;,.\s]*)/, 1]} }.uniq
80
82
  if @params[:basecamp_content]
81
- memo[pull_request_id].each do |line|
83
+ memo[pull_request_id][:lines].each do |line|
82
84
  line[:url].match /(https\:\/\/basecamp\.com\/\d+\/)(.*)/ do |match|
83
85
  begin
84
86
  ret = HTTParty.get "#{match[1]}api/v1/#{match[2]}.json", {basic_auth: {username: @params[:basecamp_user], password: @params[:basecamp_password]}, headers: {'Content-Type' => 'application/json', 'User-Agent' => "gitbc API (#{@params[:basecamp_user]})"}}
@@ -89,8 +91,7 @@ class GitHubBasecampExtractor
89
91
  end
90
92
  end
91
93
  end
92
- memo[pull_request_id] ||= []
93
- yield(pull_request_id, memo[pull_request_id])
94
+ yield(pull_request_id, memo[pull_request_id]) if block_given?
94
95
  memo
95
96
  end
96
97
  basecamp_todos
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitbc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Orest Kulik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-22 00:00:00.000000000 Z
11
+ date: 2016-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit