mingle_cli 0.0.2 → 0.0.3

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: 0835611f502bca3efb706124401873324ca90c58
4
- data.tar.gz: e72c04e983738449c1b720e21710f2ad2f3d7cc5
3
+ metadata.gz: f825aa204a8f15f8e777f5f997613e582fb8a9c5
4
+ data.tar.gz: ba61176ea553e68e52f34fd5ce6fd4a83cc13140
5
5
  SHA512:
6
- metadata.gz: d7590bbf4af8cbe516882a00e03a8c1216b55bc4b66d4a57a01594d2f1a1c7d25a4a70c519e892e0931086190d0a22889fa87d59c2dc3a998a28b56163b2dc9a
7
- data.tar.gz: f521fe074dcc90ade956ae48f8c371393c58e278116fb18a565e492ef6604f66a39018b439eec727e34dc393c6cbce69d1c2f9b8b9cc92899604c1bd91c5b734
6
+ metadata.gz: 97b7f737b43bc6d6138339fea42061bc61a813af855be7c0bc639e1fcb11ef8d2824afe9972744273bac2b4545e264ecb84e0a8436332e0f8c9d3d0322cb8521
7
+ data.tar.gz: bdf533d6deb8b6216712f155247e71dba3ce6c4ec2b5e2c14e60ce290f50c085617a5251e39290a832ff7afd2d478735b960b406e201508db512edbcd9f257f0
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Dependency Status](https://gemnasium.com/ike18t/mingle_cli.png)](https://gemnasium.com/ike18t/mingle_cli)
6
6
 
7
7
  ## MingleCLI
8
- MingleCLI is a command line interface to the Mingle API. Currently the application is a read-only view of card(s) information.
8
+ MingleCLI is a command line interface to the Mingle API.
9
9
 
10
10
  #Configuring
11
11
  ```
@@ -23,6 +23,10 @@ mingle_cli.rb card [number] [format]
23
23
  mingle_cli.rb cards [filter] [format]
24
24
  ```
25
25
 
26
+ ```
27
+ mingle_cli.rb comment [number] [comment]
28
+ ```
29
+
26
30
  ```
27
31
  mingle_cli.rb comments [number]
28
32
  ```
@@ -30,6 +34,7 @@ mingle_cli.rb comments [number]
30
34
  ###Argument Definitions:###
31
35
  * __Number__: The card number.
32
36
  * __Format__: The format of the result of the command. Formats can contain property names nested in brackets which will then be replaced with the value of the property.
37
+ * __Comment__: The message to leave in the comment.
33
38
  * __Filter__: Mingle's MQL syntax.
34
39
 
35
40
 
@@ -58,6 +63,12 @@ mingle_cli.rb cards 'status is ["in development"]' 'Number: [number] Pair: [dev
58
63
  Number: 19480 Pair: Homer/Bart
59
64
  Number: 19495 Pair: Marge/Lisa
60
65
  ```
66
+ ####Adding a card comment:####
67
+
68
+ ```
69
+ mingle_cli.rb comment 19480 'Doh!'
70
+ ```
71
+
61
72
  ####Viewing card comments:####
62
73
 
63
74
  ```
@@ -65,5 +76,5 @@ mingle_cli.rb comments 19480
65
76
  ```
66
77
 
67
78
  ```
68
- 2014-01-30 12:57:46 -0500 Home Simpson: Doh!
69
- ```
79
+ 2014-01-30 12:57:46 -0500 Homer Simpson: Doh!
80
+ ```
data/lib/mingle_cli.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require 'active_resource'
2
2
  autoload :AppConfig, 'models/app_config'
3
- autoload :ConfigService, 'services/config_service'
4
- autoload :UrlGenerator, 'services/url_generator'
5
3
  autoload :MingleModel, 'models/mingle_model'
6
- autoload :Formattable, 'services/formattable'
7
- autoload :Comment, 'models/comment'
8
4
  autoload :Card, 'models/card'
5
+ autoload :Comment, 'models/comment'
6
+ autoload :ConfigService, 'services/config_service'
7
+ autoload :UrlGenerator, 'services/url_generator'
8
+ autoload :Formattable, 'modules/formattable'
9
+ autoload :MingleUnpagerizer, 'modules/mingle_unpagerizer'
data/lib/models/card.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  class Card < MingleModel
2
2
  include Formattable
3
+ extend MingleUnpagerizer
3
4
 
4
5
  has_many :comments
5
6
 
@@ -0,0 +1,12 @@
1
+ module Formattable
2
+ def format string
3
+ string.scan(/\[([^\]]*)\]/).flatten.inject(string) do |string, prop|
4
+ begin
5
+ value = self.send(prop).to_s
6
+ rescue NoMethodError
7
+ value = ''
8
+ end
9
+ string.gsub("[#{prop}]", value)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ module MingleUnpagerizer
2
+ MINGLE_ITEMS_PER_PAGE = 25
3
+
4
+ def find_every options
5
+ cards = []
6
+ the_end = false
7
+ page = 1
8
+ while not the_end do
9
+ before_size = cards.size
10
+ options[:params].merge!({ :page => page })
11
+ cards += super(options).to_a
12
+ cards.uniq!
13
+ nothing_added = cards.size == before_size
14
+ if cards.size < MINGLE_ITEMS_PER_PAGE or nothing_added then the_end = true end
15
+ page += 1
16
+ end
17
+ cards
18
+ end
19
+ end
20
+
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module MingleCLI
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/mingle_cli.gemspec CHANGED
@@ -1,5 +1,4 @@
1
1
  $LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
2
-
3
2
  require 'version'
4
3
 
5
4
  Gem::Specification.new do |spec|
@@ -17,7 +16,7 @@ Gem::Specification.new do |spec|
17
16
 
18
17
  spec.files = `git ls-files`.split($/)
19
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
- spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
20
  spec.extra_rdoc_files = ['LICENSE.txt', 'README.md']
22
21
  spec.require_paths = ['lib']
23
22
 
@@ -12,7 +12,7 @@ describe Formattable do
12
12
 
13
13
  it { @card.format('name is [name], status is [status]').should eq("name is #{@card.name}, status is #{@card.status}") }
14
14
 
15
- it { expect { @card.format('[not invalid] is invalid') }.to raise_error(NoMethodError) }
15
+ it { @card.format('[not invalid] is invalid').should eq(' is invalid') }
16
16
 
17
17
  it { @card.format('').should be_empty }
18
18
 
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe MingleUnpagerizer do
4
+ class MockMingleModel
5
+ attr_reader :call_count
6
+
7
+ def initialize
8
+ @call_count = 0
9
+ end
10
+
11
+ def find_every options
12
+ @call_count += 1
13
+ case options[:params][:page]
14
+ when 1
15
+ [:a, :b, :c]
16
+ when 2
17
+ [:d, :e, :f]
18
+ when 3..100
19
+ [:d, :e, :f]
20
+ end
21
+ end
22
+ end
23
+
24
+ context 'find_every' do
25
+ it 'should return unique data when hitting a duplicate page' do
26
+ stub_const 'MingleUnpagerizer::MINGLE_ITEMS_PER_PAGE', 3
27
+ m = MockMingleModel.new
28
+ m.extend MingleUnpagerizer
29
+ m.find_every({:params => {}}).should eq([:a, :b, :c, :d, :e, :f])
30
+ m.call_count.should eq(3)
31
+ end
32
+
33
+ it 'should not try for another page if count is less than the items per page' do
34
+ stub_const 'MingleUnpagerizer::MINGLE_ITEMS_PER_PAGE', 4
35
+ m = MockMingleModel.new
36
+ m.extend MingleUnpagerizer
37
+ m.find_every({:params => {}}).should eq([:a, :b, :c])
38
+ end
39
+ end
40
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mingle_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Isaac Datlof
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-03 00:00:00.000000000 Z
11
+ date: 2014-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
@@ -133,8 +133,9 @@ files:
133
133
  - lib/models/card.rb
134
134
  - lib/models/comment.rb
135
135
  - lib/models/mingle_model.rb
136
+ - lib/modules/formattable.rb
137
+ - lib/modules/mingle_unpagerizer.rb
136
138
  - lib/services/config_service.rb
137
- - lib/services/formattable.rb
138
139
  - lib/services/url_generator.rb
139
140
  - lib/version.rb
140
141
  - mingle_cli.gemspec
@@ -146,8 +147,9 @@ files:
146
147
  - spec/unit/models/card_spec.rb
147
148
  - spec/unit/models/comment_spec.rb
148
149
  - spec/unit/models/mingle_model_spec.rb
150
+ - spec/unit/modules/formattable_spec.rb
151
+ - spec/unit/modules/mingle_unpagerizer_spec.rb
149
152
  - spec/unit/services/config_service_spec.rb
150
- - spec/unit/services/formattable_spec.rb
151
153
  - spec/unit/services/url_generator_spec.rb
152
154
  homepage: http://github.com/ike18t/mingle_cli
153
155
  licenses:
@@ -182,6 +184,7 @@ test_files:
182
184
  - spec/unit/models/card_spec.rb
183
185
  - spec/unit/models/comment_spec.rb
184
186
  - spec/unit/models/mingle_model_spec.rb
187
+ - spec/unit/modules/formattable_spec.rb
188
+ - spec/unit/modules/mingle_unpagerizer_spec.rb
185
189
  - spec/unit/services/config_service_spec.rb
186
- - spec/unit/services/formattable_spec.rb
187
190
  - spec/unit/services/url_generator_spec.rb
@@ -1,7 +0,0 @@
1
- module Formattable
2
- def format string
3
- string.scan(/\[([^\]]*)\]/).flatten.inject(string) do |string, prop|
4
- string.gsub("[#{prop}]", self.send(prop).to_s)
5
- end
6
- end
7
- end