locabulary 0.6.2 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,27 +39,6 @@ REPOSITORY_PATH = ENV.fetch('REPOSITORY_PATH') { File.expand_path(File.join(File
39
39
  REMOTE = ENV.fetch('REMOTE', 'origin')
40
40
  FROM_BRANCH = ENV.fetch('FROM_BRANCH', 'master')
41
41
 
42
- issue_title_fetcher = lambda do
43
- begin
44
- remote_url = `cd #{REPOSITORY_PATH} && git config --get remote.#{REMOTE}.url`.strip
45
- match = remote_url.match(/(\w+)\/(\w+)(?:\.git)?\Z/)
46
- if match
47
- require 'open-uri'
48
- require 'json'
49
- owner, repository = match.captures
50
- document = open("https://api.github.com/repos/#{owner}/#{repository}/issues/#{ISSUE_NUMBER}.json").read
51
- json = JSON.parse(document)
52
- json.fetch('title').gsub(/\W+/, '-')
53
- else
54
- 'issue-on-github'
55
- end
56
- rescue
57
- 'issue-on-github'
58
- end
59
- end
60
-
61
- # TODO: Retrieve the dasherized issue from Github's API
62
- ISSUE_TITLE = ENV.fetch('ISSUE_TITLE', issue_title_fetcher)
63
42
  STARTED_ISSUES_FILE = ENV.fetch('STARTED_ISSUES_FILE', '.started-issues')
64
43
 
65
44
  #*******************************************************************************
@@ -77,7 +56,6 @@ if ARGV.grep(/-h/i).size == 1
77
56
  $stdout.puts "* Create a new branch for the given issue number"
78
57
  $stdout.puts "* Touch and append the issue number to a tracking file"
79
58
  $stdout.puts "* Write a rudimentary commit message"
80
- $stdout.puts "* Push that commit up to #{REMOTE}"
81
59
  $stdout.puts ""
82
60
  $stdout.puts "Note: There are steps to insure you have a clean working directory."
83
61
  $stdout.puts "Note: If you have spaces in your configuration all bets are off!"
@@ -103,17 +81,81 @@ end
103
81
 
104
82
  # Guard that I have an issue number
105
83
 
84
+ issue_source = nil
106
85
  ISSUE_NUMBER = ARGV.shift
107
86
 
108
- unless ISSUE_NUMBER =~ /^\d+$/
109
- $stderr.puts "Expected first parameter to be an issue number for REPOSITORY.\n\n"
87
+ if ISSUE_NUMBER =~ /^\w+-\d+$/
88
+ issue_source = :jira
89
+ elsif ISSUE_NUMBER =~ /^\d+$/
90
+ issue_source = :github
91
+ else
92
+ $stderr.puts "Expected first parameter to be a JIRA or GitHub issue number.\n\n"
110
93
  $stderr.puts "See help for details on specifying an issue number.\n\n"
111
94
  $stderr.puts "$ ./#{File.basename(__FILE__)} -h"
112
95
  exit!(1)
113
96
  end
114
97
 
98
+ unless system("which jira")
99
+ $stderr.puts "Expected to find `jira' in your path."
100
+ $stderr.puts "Run the following:"
101
+ $stderr.puts "\tbrew tap ndlib/dlt\n\tbrew install go-jira\n\n"
102
+ exit!(9)
103
+ end
104
+
105
+ unless File.exist?(File.join(ENV['HOME'], '.jira.d/config.yml'))
106
+ $stderr.puts "Expected ~/.jira.d/config.yml to exist"
107
+ $stderr.puts "Run the following:"
108
+ $stderr.puts "\tmkdir ~/.jira.d\n\techo 'endpoint: https://jira.library.nd.edu' > ~/.jira.d/config.yml"
109
+ exit!(10)
110
+ end
111
+
115
112
  # Capture the issue_title
116
- issue_title = ISSUE_TITLE.respond_to?(:call) ? ISSUE_TITLE.call : ISSUE_TITLE
113
+ ISSUE_TITLE = ENV.fetch('ISSUE_TITLE', nil)
114
+ if ISSUE_TITLE.nil?
115
+ case issue_source
116
+ when :github
117
+ issue_title = begin
118
+ remote_url = `cd #{REPOSITORY_PATH} && git config --get remote.#{REMOTE}.url`.strip
119
+ match = remote_url.match(/(\w+)\/(\w+)(?:\.git)?\Z/)
120
+ if match
121
+ require 'open-uri'
122
+ require 'json'
123
+ owner, repository = match.captures
124
+ document = open("https://api.github.com/repos/#{owner}/#{repository}/issues/#{ISSUE_NUMBER}.json").read
125
+ json = JSON.parse(document)
126
+ json.fetch('title').gsub(/\W+/, '-')
127
+ else
128
+ 'issue-on-github'
129
+ end
130
+ rescue
131
+ 'issue-on-github'
132
+ end
133
+ when :jira
134
+ issue_title = begin
135
+ require 'yaml'
136
+ # TODO(dbrower): sometimes this will block waiting for the user to
137
+ # enter a password. Is better way to handle the situation?
138
+ document = `jira view #{ISSUE_NUMBER}`
139
+ # sometimes there is garbage before the "issue:" line.
140
+ document.sub!(/\A[^i]*/, '')
141
+ issue = YAML.load(document)
142
+ title = issue["summary"]
143
+ if title == "<no value>"
144
+ $stdout.puts "Problem finding issue #{ISSUE_NUMBER}"
145
+ exit!(5)
146
+ end
147
+ title
148
+ rescue
149
+ $stdout.puts "Problem finding issue #{ISSUE_NUMBER}"
150
+ exit!(6)
151
+ end
152
+ end
153
+ else
154
+ issue_title = ISSUE_TITLE
155
+ end
156
+
157
+ # Ensure that we don't have ridiculously long branch names
158
+ issue_title = issue_title[0..30]
117
159
 
118
160
  # Guard that directories exist
119
161
  [:REPOSITORY_PATH].each do |key|
@@ -154,8 +196,10 @@ begin
154
196
  File.open(path_to_commit_message, 'w+') do |file|
155
197
  file.puts "Claiming issue #{ISSUE_NUMBER}"
156
198
  file.puts ""
157
- file.puts "relates to ##{ISSUE_NUMBER}"
158
- file.puts ""
199
+ if issue_source == :github
200
+ file.puts "relates to ##{ISSUE_NUMBER}"
201
+ file.puts ""
202
+ end
159
203
 
160
204
  message = "$ ./script/#{File.basename(__FILE__)} #{ISSUE_NUMBER}"
161
205
  CONFIG_KEYS.each_with_object(message) do |key, mem|
@@ -172,3 +216,11 @@ begin
172
216
  ensure
173
217
  File.unlink(path_to_commit_message) rescue true
174
218
  end
219
+
220
+ # If the commit was successful, assign the issue to us and move into "In Progress"
221
+ if issue_source == :jira
222
+ system("jira take #{ISSUE_NUMBER}")
223
+ exit!(5) unless $?.success?
224
+ system("jira --noedit transition \"In Progress\" #{ISSUE_NUMBER}")
225
+ exit!(5) unless $?.success?
226
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locabulary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Friesen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-31 00:00:00.000000000 Z
11
+ date: 2017-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -154,30 +154,30 @@ dependencies:
154
154
  name: rspec
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ">="
157
+ - - '='
158
158
  - !ruby/object:Gem::Version
159
- version: '0'
159
+ version: 3.5.0
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ">="
164
+ - - '='
165
165
  - !ruby/object:Gem::Version
166
- version: '0'
166
+ version: 3.5.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: rspec-its
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - ">="
171
+ - - '='
172
172
  - !ruby/object:Gem::Version
173
- version: '0'
173
+ version: 1.2.0
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - ">="
178
+ - - '='
179
179
  - !ruby/object:Gem::Version
180
- version: '0'
180
+ version: 1.2.0
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rake
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -196,100 +196,114 @@ dependencies:
196
196
  name: google_drive
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - ">="
199
+ - - '='
200
200
  - !ruby/object:Gem::Version
201
- version: '0'
201
+ version: 2.1.2
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
- - - ">="
206
+ - - '='
207
207
  - !ruby/object:Gem::Version
208
- version: '0'
208
+ version: 2.1.2
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: highline
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
- - - ">="
213
+ - - '='
214
214
  - !ruby/object:Gem::Version
215
- version: '0'
215
+ version: 1.7.8
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
- - - ">="
220
+ - - '='
221
221
  - !ruby/object:Gem::Version
222
- version: '0'
222
+ version: 1.7.8
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: rubocop
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
- - - ">="
227
+ - - "~>"
228
228
  - !ruby/object:Gem::Version
229
- version: '0'
229
+ version: 0.46.0
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
- - - ">="
234
+ - - "~>"
235
235
  - !ruby/object:Gem::Version
236
- version: '0'
236
+ version: 0.46.0
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: simplecov
239
239
  requirement: !ruby/object:Gem::Requirement
240
240
  requirements:
241
- - - ">="
241
+ - - '='
242
242
  - !ruby/object:Gem::Version
243
- version: '0'
243
+ version: 0.12.0
244
244
  type: :development
245
245
  prerelease: false
246
246
  version_requirements: !ruby/object:Gem::Requirement
247
247
  requirements:
248
- - - ">="
248
+ - - '='
249
249
  - !ruby/object:Gem::Version
250
- version: '0'
250
+ version: 0.12.0
251
251
  - !ruby/object:Gem::Dependency
252
252
  name: codeclimate-test-reporter
253
253
  requirement: !ruby/object:Gem::Requirement
254
254
  requirements:
255
- - - ">="
255
+ - - '='
256
256
  - !ruby/object:Gem::Version
257
- version: '0'
257
+ version: 1.0.3
258
258
  type: :development
259
259
  prerelease: false
260
260
  version_requirements: !ruby/object:Gem::Requirement
261
261
  requirements:
262
- - - ">="
262
+ - - '='
263
263
  - !ruby/object:Gem::Version
264
- version: '0'
264
+ version: 1.0.3
265
265
  - !ruby/object:Gem::Dependency
266
266
  name: fasterer
267
267
  requirement: !ruby/object:Gem::Requirement
268
268
  requirements:
269
- - - ">="
269
+ - - '='
270
270
  - !ruby/object:Gem::Version
271
- version: '0'
271
+ version: 0.3.2
272
272
  type: :development
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
- - - ">="
276
+ - - '='
277
277
  - !ruby/object:Gem::Version
278
- version: '0'
278
+ version: 0.3.2
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: shoulda-matchers
281
281
  requirement: !ruby/object:Gem::Requirement
282
282
  requirements:
283
- - - ">="
283
+ - - '='
284
284
  - !ruby/object:Gem::Version
285
- version: '0'
285
+ version: 3.1.1
286
286
  type: :development
287
287
  prerelease: false
288
288
  version_requirements: !ruby/object:Gem::Requirement
289
289
  requirements:
290
- - - ">="
290
+ - - '='
291
291
  - !ruby/object:Gem::Version
292
- version: '0'
292
+ version: 3.1.1
293
+ - !ruby/object:Gem::Dependency
294
+ name: nokogiri
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - "~>"
298
+ - !ruby/object:Gem::Version
299
+ version: 1.6.8.1
300
+ type: :development
301
+ prerelease: false
302
+ version_requirements: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - "~>"
305
+ - !ruby/object:Gem::Version
306
+ version: 1.6.8.1
293
307
  description: An extraction of limited localized vocabulary for Sipity and CurateND.
294
308
  email:
295
309
  - jeremy.n.friesen@gmail.com
@@ -340,6 +354,7 @@ files:
340
354
  - lib/locabulary/services.rb
341
355
  - lib/locabulary/services/active_hierarchical_roots_service.rb
342
356
  - lib/locabulary/services/active_items_for_service.rb
357
+ - lib/locabulary/services/all_items_for_service.rb
343
358
  - lib/locabulary/services/build_ordered_hierarchical_tree_service.rb
344
359
  - lib/locabulary/services/item_for_service.rb
345
360
  - lib/locabulary/utility.rb
@@ -347,6 +362,7 @@ files:
347
362
  - locabulary.gemspec
348
363
  - script/build-multi-commit-message
349
364
  - script/close-issue
365
+ - script/sort_json.rb
350
366
  - script/start-issue
351
367
  - script/update_data_files.sh
352
368
  homepage: https://github.com/ndlib/locabulary