Standupguy 0.0.8 → 0.0.9

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: ba4bd2e4edfbcee6241461bb5008fe793faf4b65
4
- data.tar.gz: 1238127b7bb2644348b6318a2e2cc156d79cd549
3
+ metadata.gz: d89d88926c7b160d56688692aace3e91aad9185b
4
+ data.tar.gz: 7e357661c32ebb99e0556c0769e95dd4e09e98d3
5
5
  SHA512:
6
- metadata.gz: 8017d3360110eeb5df50d4036bc3d1b53589f265087cd51ad060f5b8acbaf3931470b25806bfe62c4ec7dda768a74b5e829998549d8ad4b1cbe94e256f25eda5
7
- data.tar.gz: c734bd54c9da9f8b2d4680c96d5810107158c661015b6e0a37d348e2f477f5bbbfc884b0618bb05a319da1b87f1e800167ed577ba0d2d4ed18221b46f4d7bfde
6
+ metadata.gz: dc19f6bb20eae4f7cb5a6e9e6e6e9318346fffcd8432b871d82acad48c58c4f9e7634d240ec51565241b9efb8aab8de6339c58f6787adabfceae53a29f8516fc
7
+ data.tar.gz: ccfce4d5eed8e03a15fc577d8225d53821f0a3f63c7091f261c969072e970b64b6b1c07b9c6409a41aaa27c2ca1d2b88f4e3b25dc3364ce7d798fa8969199d8a
@@ -0,0 +1,4 @@
1
+ Metrics/LineLength:
2
+ Enabled: false
3
+ Rails/Output:
4
+ Enabled: false
data/.semver CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 0
4
- :patch: 8
4
+ :patch: 9
5
5
  :special: ''
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency "byebug"
24
24
  spec.add_development_dependency "rspec"
25
- spec.add_development_dependency "rspec-nc"
26
25
  spec.add_development_dependency "guard"
27
26
  spec.add_development_dependency "guard-rspec"
28
27
  spec.add_development_dependency "semver"
@@ -176,25 +176,47 @@ module Standupguy
176
176
  attr_accessor :data
177
177
 
178
178
  def method_missing(method, *args)
179
- return unless [:description=, :name=, :date=].include?(method)
179
+ method_list = [:description=, :name=, :date=, :ticket_id=]
180
+ return unless method_list.include?(method)
180
181
  method = method.to_s.chop.to_sym
181
182
  @data[method] = args.first
182
183
  end
183
184
 
185
+ def continue?
186
+ puts <<-EOS
187
+ This ticket has already been added. Do you want to continue adding it? (y/N)
188
+ EOS
189
+ STDIN.gets.downcase.chomp[0] == "y"
190
+ end
191
+
184
192
  def save
185
193
  current_standup = load_data
186
194
  current_standup ||= { date_key => [] }
187
195
  data_exists = current_standup.keys.include?(date_key)
188
- current_standup[date_key] = [] unless data_exists
196
+ begin
197
+ if data_exists && !!@data[:ticket_id]
198
+ ticket_list = current_standup[date_key]
199
+ ticket_list.map! { |item| item["ticket_id"] }
200
+ unless ticket_list.empty?
201
+ already_added = ticket_list.include?(@data[:ticket_id])
202
+ raise "Already added" if already_added
203
+ end
204
+ end
205
+ rescue RuntimeError
206
+ return unless continue?
207
+ end
208
+
209
+ current_standup[date_key] ||= []
189
210
  current_standup[date_key] << @data
190
211
  write_data(current_standup)
191
212
  end
192
213
 
193
214
  def add_to_today(item)
194
- @data ||= { description: "", name: "", date: "" }
215
+ @data ||= { description: "", date: "", ticket_id: false }
195
216
  ticket = TicketUrl.new(item)
196
217
  if ticket.valid?
197
218
  zendesk_ticket = client(ticket.subdomain).tickets.find(id: ticket.id)
219
+ self.ticket_id = item
198
220
  self.description = "#{item} => (#{zendesk_ticket.subject})"
199
221
  else
200
222
  self.description = item
@@ -1,3 +1,3 @@
1
1
  module Standupguy
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -2,43 +2,83 @@ require "spec_helper"
2
2
  require_relative "../lib/Standupguy"
3
3
 
4
4
  describe Standupguy::Item do
5
+ before { @datafile = create_test_file! }
5
6
  describe "#add_to_today" do
6
- subject(:item) { Standupguy::Item.new }
7
-
8
- context "for zendesk tickets" do
7
+ describe "for zendesk tickets" do
9
8
  before do
9
+ @item = Standupguy::Item.new
10
10
  expect_zendesk("foo", "api/v2/tickets/1").
11
11
  to_return(headers: {"Content-Type" => "application/json"}, body: JSON.dump("ticket" => {"subject" => "test ticket"}))
12
- item.add_to_today("https://foo.zendesk.com/tickets/1")
12
+ @item.add_to_today("https://foo.zendesk.com/tickets/1")
13
13
  end
14
14
 
15
15
  it "includes the ticket subject in the description" do
16
- expect(item.data[:description]).to match(/test ticket/)
16
+ expect(@item.data[:description]).to match(/test ticket/)
17
17
  end
18
18
 
19
19
  it "includes the original url" do
20
- expect(item.data[:description]).to match(/foo.zendesk.com\/tickets\/1/)
20
+ expect(@item.data[:description]).to match(/foo.zendesk.com\/tickets\/1/)
21
+ end
22
+
23
+ it "includes the ticket_id" do
24
+ expect(@item.data[:ticket_id]).to eq("https://foo.zendesk.com/tickets/1")
25
+ end
26
+
27
+ describe "adding the same ticket again" do
28
+ subject { Standupguy::Item.new }
29
+
30
+ before do
31
+ @item.save
32
+ expect_zendesk("foo", "api/v2/tickets/1").
33
+ to_return(headers: {"Content-Type" => "application/json"}, body: JSON.dump("ticket" => {"subject" => "test ticket"}))
34
+ end
35
+
36
+ describe "choosing to continue" do
37
+ it "adds the item" do
38
+ Standupguy::Item.any_instance.expects(:continue?).returns(true)
39
+ subject.add_to_today("https://foo.zendesk.com/tickets/1")
40
+ subject.save
41
+ expect(JSON.load(@datafile.read)[key].size).to eq(2)
42
+ end
43
+
44
+ describe "#continue?" do
45
+ it "outputs" do
46
+ STDIN.expects(:gets).returns("y")
47
+ expect do
48
+ subject.add_to_today("https://foo.zendesk.com/tickets/1")
49
+ subject.save
50
+ end.to output.to_stdout
51
+ end
52
+ end
53
+ end
54
+
55
+ describe "choosing not to continue" do
56
+ it "does not add the item" do
57
+ Standupguy::Item.any_instance.expects(:continue?).returns(false)
58
+ subject.add_to_today("https://foo.zendesk.com/tickets/1")
59
+ subject.save
60
+ expect(JSON.load(@datafile.read)[key].size).to eq(1)
61
+ end
62
+ end
21
63
  end
22
64
  end
23
65
 
24
- context "for non-zendesk tickets" do
66
+ describe "for non-zendesk tickets" do
67
+ subject{ Standupguy::Item.new }
68
+
25
69
  it "takes an item" do
26
- item.add_to_today("foob")
27
- expect(item.data[:description]).to match(/foob/)
28
- expect(item.data[:name]).to match(`whoami`.chop)
29
- expect(item.data[:date]).to match(key)
70
+ subject.add_to_today("foob")
71
+ expect(subject.data[:description]).to match(/foob/)
72
+ expect(subject.data[:name]).to match(`whoami`.chop)
73
+ expect(subject.data[:date]).to match(key)
30
74
  end
31
75
  end
32
76
  end
33
77
 
34
78
  describe "#save" do
35
- before do
36
- @datafile = create_test_file!
37
- end
38
-
39
79
  subject(:item) do
40
80
  test_item = Standupguy::Item.new
41
- test_item.add_to_today("foo")
81
+ test_item.add_to_today("foo bazzyle")
42
82
  test_item
43
83
  end
44
84
 
@@ -46,10 +86,10 @@ describe Standupguy::Item do
46
86
  item.save
47
87
  expect_datafile(@datafile, %r{foo})
48
88
  end
89
+ end
49
90
 
50
- after do
51
- @datafile.close
52
- @datafile.unlink
53
- end
91
+ after do
92
+ @datafile.close
93
+ @datafile.unlink
54
94
  end
55
95
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Standupguy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Panzer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-30 00:00:00.000000000 Z
11
+ date: 2015-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rspec-nc
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: guard
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -217,6 +203,7 @@ files:
217
203
  - ".coveralls.yml"
218
204
  - ".gitignore"
219
205
  - ".hound.yml"
206
+ - ".rubocop.yml"
220
207
  - ".semver"
221
208
  - ".travis.yml"
222
209
  - Gemfile