errbit_plugin 0.4.0 → 0.5.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: eccc791b162fd7dc93f1170175af0ff094838b95
4
- data.tar.gz: dc0f6986b2d73726ebe6bed09febfeac3bdb9057
3
+ metadata.gz: 379974aa8a736ab97c68e86d35a8a4abe74cf078
4
+ data.tar.gz: 68538a72756d7286cab6603f2fd5ff0eaf853a9e
5
5
  SHA512:
6
- metadata.gz: 4acc3fef4ec35e35b69e5d1cfb2dbc08516fc9bb80a0c36239fff9d11c56e27977278f8922f6e64a4e8e908992d358c38d2d55c8762d9e7078ce93ad4d130d8e
7
- data.tar.gz: 27d7f74a0d6ae77c3cf2d077030938ca11186c264b57c0703b12fcd95362a337ab5a22a36693cc6dfe7547ed12207f0388dadf4efc6e5875f76de5fc437ef203
6
+ metadata.gz: 0946dc453bf1c7a0eb1ec1091edd135287e7734684fb3291b2e29241739fbaa321adedde1ba71f14b2d29a60c72a90b9d010fbea810475937136616970f7b232
7
+ data.tar.gz: 8487cad20bfe5f99001a0a3974424b4de1fea6a100336ff344bbe6fc72aa263d8e98c2c6d2dea9448fb4579b31f3484dc9ad9e6d522e87a64fb0cdd473e00b1c
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ErrbitPlugin
1
+ # ErrbitPlugin [![Build Status](https://travis-ci.org/errbit/errbit_plugin.svg?branch=master)](https://travis-ci.org/errbit/errbit_plugin)
2
2
  ErrbitPlugin provides a set of base classes that you can extend to create
3
3
  Errbit plugins.
4
4
 
@@ -38,22 +38,38 @@ class MyIssueTracker < ErrbitPlugin::IssueTracker
38
38
  # later when we have an instance of this class.
39
39
  def self.fields
40
40
  {
41
- :field_one => {:label => 'Field One'},
42
- :field_two => {:label => 'Field Two'}
41
+ username: {
42
+ placeholder: "Some placeholder text"
43
+ },
44
+ password: {
45
+ placeholder: "Some more placeholder text"
46
+ }
47
+ }
48
+ end
49
+
50
+ # Icons to display during user interactions with this issue tracker. This
51
+ # method should return a hash of two-tuples, the key names being 'create',
52
+ # 'goto', and 'inactive'. The two-tuples should contain the icon media type
53
+ # and the binary icon data.
54
+ def self.icons
55
+ @icons ||= {
56
+ create: [ 'image/png', File.read('./path/to/create.png') ],
57
+ goto: [ 'image/png', File.read('./path/to/goto.png') ],
58
+ inactive: [ 'image/png', File.read('./path/to/inactive.png') ],
43
59
  }
44
60
  end
45
61
 
46
62
  # If this tracker can be in a configured or non-configured state, you can let
47
63
  # errbit know by returning a Boolean here
48
64
  def configured?
49
- # In this case, we'll say this issue tracker is configured when field_one
65
+ # In this case, we'll say this issue tracker is configured when username
50
66
  # is set
51
- !!params['field_one']
67
+ !!params['username']
52
68
  end
53
69
 
54
70
  # Called to validate user input. Just return a hash of errors if there are
55
71
  # any
56
- def check_params
72
+ def errors
57
73
  if @params['field_one']
58
74
  {}
59
75
  else
@@ -77,19 +93,10 @@ class MyIssueTracker < ErrbitPlugin::IssueTracker
77
93
  def url
78
94
  'http://some-remote-tracker.com'
79
95
  end
80
-
81
- # If you return false here, errbit will not show the built-in error comment
82
- # interface
83
- def comments_allowed?
84
- false
85
- end
86
96
  end
87
97
  ```
88
98
 
89
99
  ## Contributing
90
100
 
91
- 1. Fork it
92
- 2. Create your feature branch (`git checkout -b my-new-feature`)
93
- 3. Commit your changes (`git commit -am 'Add some feature'`)
94
- 4. Push to the branch (`git push origin my-new-feature`)
95
- 5. Create new Pull Request
101
+ Discuss any changes you'd like to make with the authors on the mailing list, or
102
+ by opening a github issue.
data/lib/errbit_plugin.rb CHANGED
@@ -3,4 +3,3 @@ require "errbit_plugin/registry"
3
3
  require "errbit_plugin/issue_tracker"
4
4
  require "errbit_plugin/validate_issue_tracker"
5
5
  require "errbit_plugin/issue_trackers/none"
6
- require "errbit_plugin/rails"
@@ -1,27 +1,10 @@
1
1
  module ErrbitPlugin
2
+ # abstract class for issue trackers
2
3
  class IssueTracker
3
- attr_reader :app, :params
4
+ attr_reader :options
4
5
 
5
- def initialize(app, params)
6
- @app = app
7
- @params = params
8
- end
9
-
10
- def pretty_hash(hash, nesting = 0)
11
- tab_size = 2
12
- nesting += 1
13
-
14
- pretty = "{"
15
- sorted_keys = hash.keys.sort
16
- sorted_keys.each do |key|
17
- val = hash[key].is_a?(Hash) ? pretty_hash(hash[key], nesting) : hash[key].inspect
18
- pretty += "\n#{' '*nesting*tab_size}"
19
- pretty += "#{key.inspect} => #{val}"
20
- pretty += "," unless key == sorted_keys.last
21
-
22
- end
23
- nesting -= 1
24
- pretty += "\n#{' '*nesting*tab_size}}"
6
+ def initialize(options)
7
+ @options = options
25
8
  end
26
9
  end
27
10
  end
@@ -6,14 +6,24 @@ module ErrbitPlugin
6
6
  'leave comments on errors.'
7
7
  end
8
8
  def self.fields; {}; end
9
+ def self.icons
10
+ @icons ||= {
11
+ create: ['image/png', read_static_file('none_create.png')],
12
+ goto: ['image/png', read_static_file('none_create.png')],
13
+ inactive: ['image/png', read_static_file('none_inactive.png')],
14
+ }
15
+ end
16
+ def self.read_static_file(file)
17
+ File.read(File.expand_path(File.join(
18
+ File.dirname(__FILE__), '..', '..', '..', 'static', file)))
19
+ end
9
20
  ##
10
21
  # The NoneIssueTracker is mark like configured? false because it not valid
11
22
  # like a real IssueTracker
12
23
  def configured?; false; end
13
24
  def errors; {}; end
14
- def create_issue; true; end
15
25
  def url; ''; end
16
- def comments_allowed?; true; end
26
+ def create_issue(*); true; end
17
27
  end
18
28
  end
19
29
 
@@ -7,9 +7,11 @@ module ErrbitPlugin
7
7
  attr_reader :errors
8
8
 
9
9
  def valid?
10
- good_inherit? &&
11
- implements_instance_methods? &&
12
- implements_class_methods?
10
+ valid_inherit = good_inherit?
11
+ valid_instance_methods = implements_instance_methods?
12
+ valid_class_methods = implements_class_methods?
13
+
14
+ valid_inherit && valid_instance_methods && valid_class_methods
13
15
  end
14
16
 
15
17
  private
@@ -24,7 +26,7 @@ module ErrbitPlugin
24
26
  end
25
27
 
26
28
  def implements_instance_methods?
27
- [:comments_allowed?, :configured?, :errors, :create_issue, :url].all? do |method|
29
+ impl = [:configured?, :errors, :create_issue, :url].map do |method|
28
30
  if instance.respond_to?(method)
29
31
  true
30
32
  else
@@ -32,10 +34,12 @@ module ErrbitPlugin
32
34
  false
33
35
  end
34
36
  end
37
+
38
+ impl.all? { |value| value == true }
35
39
  end
36
40
 
37
41
  def implements_class_methods?
38
- [:label, :fields, :note].all? do |method|
42
+ impl = [:label, :fields, :note, :icons].map do |method|
39
43
  if @klass.respond_to?(method)
40
44
  true
41
45
  else
@@ -43,10 +47,12 @@ module ErrbitPlugin
43
47
  false
44
48
  end
45
49
  end
50
+
51
+ impl.all? { |value| value == true }
46
52
  end
47
53
 
48
54
  def instance
49
- @instance ||= @klass.new(Object.new, {})
55
+ @instance ||= @klass.new({})
50
56
  end
51
57
 
52
58
  def add_errors(key, value=nil)
@@ -1,3 +1,3 @@
1
1
  module ErrbitPlugin
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -4,216 +4,216 @@ describe ErrbitPlugin::ValidateIssueTracker do
4
4
  describe "#valid?" do
5
5
 
6
6
  context "with a complete class" do
7
- class Foo < ErrbitPlugin::IssueTracker
7
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
8
8
  def self.label; 'foo'; end
9
9
  def self.note; 'foo'; end
10
10
  def self.fields; ['foo']; end
11
+ def self.icons; {}; end
11
12
  def configured?; true; end
12
13
  def errors; true; end
13
14
  def create_issue; 'http'; end
14
15
  def url; 'http'; end
15
- def comments_allowed?; false; end
16
16
  end
17
17
 
18
18
  it 'valid' do
19
- expect(ErrbitPlugin::ValidateIssueTracker.new(Foo).valid?).to be true
19
+ expect(ErrbitPlugin::ValidateIssueTracker.new(klass).valid?).to be true
20
20
  end
21
21
  end
22
22
 
23
23
  context "with class not inherit from ErrbitPlugin::IssueTracker" do
24
-
25
- class Bar
24
+ klass = Class.new do
26
25
  def self.label; 'foo'; end
27
26
  def self.note; 'foo'; end
28
27
  def self.fields; ['foo']; end
28
+ def self.icons; {}; end
29
+ def initialize(params); end
29
30
  def configured?; true; end
30
31
  def errors; true; end
31
32
  def create_issue; 'http'; end
32
33
  def url; 'http'; end
33
- def comments_allowed?; false; end
34
34
  end
35
35
 
36
36
  it 'not valid' do
37
- expect(ErrbitPlugin::ValidateIssueTracker.new(Bar).valid?).to be false
37
+ expect(ErrbitPlugin::ValidateIssueTracker.new(klass).valid?).to be false
38
38
  end
39
39
 
40
- it 'say not implement configured?' do
41
- is = ErrbitPlugin::ValidateIssueTracker.new(Bar)
40
+ it 'says :not_inherited' do
41
+ is = ErrbitPlugin::ValidateIssueTracker.new(klass)
42
42
  is.valid?
43
43
  expect(is.errors).to eql [[:not_inherited]]
44
44
  end
45
45
  end
46
46
 
47
47
  context "with no label method" do
48
- class Baz < ErrbitPlugin::IssueTracker
49
- def note; 'foo'; end
50
- def fields; ['foo']; end
48
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
49
+ def self.note; 'foo'; end
50
+ def self.fields; ['foo']; end
51
+ def self.icons; {}; end
51
52
  def configured?; true; end
52
53
  def errors; true; end
53
54
  def create_issue; 'http'; end
54
55
  def url; 'http'; end
55
- def comments_allowed?; false; end
56
56
  end
57
57
 
58
58
  it 'not valid' do
59
- expect(ErrbitPlugin::ValidateIssueTracker.new(Baz).valid?).to be false
59
+ expect(ErrbitPlugin::ValidateIssueTracker.new(klass).valid?).to be false
60
60
  end
61
61
 
62
62
  it 'say not implement configured?' do
63
- is = ErrbitPlugin::ValidateIssueTracker.new(Baz)
63
+ is = ErrbitPlugin::ValidateIssueTracker.new(klass)
64
64
  is.valid?
65
65
  expect(is.errors).to eql [[:class_method_missing, :label]]
66
66
  end
67
67
  end
68
68
 
69
+ context "with no icons method" do
70
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
71
+ def self.note; 'foo'; end
72
+ def self.fields; ['foo']; end
73
+ def self.label; 'alabel'; end
74
+ def configured?; true; end
75
+ def errors; true; end
76
+ def create_issue; 'http'; end
77
+ def url; 'http'; end
78
+ end
79
+
80
+ it 'not valid' do
81
+ expect(ErrbitPlugin::ValidateIssueTracker.new(klass).valid?).to be false
82
+ end
83
+
84
+ it 'say not implement configured?' do
85
+ is = ErrbitPlugin::ValidateIssueTracker.new(klass)
86
+ is.valid?
87
+ expect(is.errors).to eql [[:class_method_missing, :icons]]
88
+ end
89
+ end
90
+
69
91
  context "without fields method" do
70
- class BazFields < ErrbitPlugin::IssueTracker
92
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
71
93
  def self.label; 'foo'; end
72
- def note; 'foo'; end
94
+ def self.note; 'foo'; end
95
+ def self.icons; {}; end
73
96
  def configured?; true; end
74
97
  def errors; true; end
75
98
  def create_issue; 'http'; end
76
99
  def url; 'http'; end
77
- def comments_allowed?; false; end
78
100
  end
79
101
 
80
102
  it 'not valid' do
81
- expect(ErrbitPlugin::ValidateIssueTracker.new(BazFields).valid?).to be false
103
+ expect(ErrbitPlugin::ValidateIssueTracker.new(klass).valid?).to be false
82
104
  end
83
105
 
84
106
  it 'say not implement configured?' do
85
- is = ErrbitPlugin::ValidateIssueTracker.new(BazFields)
107
+ is = ErrbitPlugin::ValidateIssueTracker.new(klass)
86
108
  is.valid?
87
109
  expect(is.errors).to eql [[:class_method_missing, :fields]]
88
110
  end
89
111
  end
90
112
 
91
113
  context "without configured? method" do
92
- class BazConfigured < ErrbitPlugin::IssueTracker
93
- def label; 'foo'; end
94
- def note; 'foo'; end
95
- def fields; ['foo']; end
114
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
115
+ def self.label; 'foo'; end
116
+ def self.note; 'foo'; end
117
+ def self.fields; ['foo']; end
118
+ def self.icons; {}; end
96
119
  def errors; true; end
97
120
  def create_issue; 'http'; end
98
121
  def url; 'http'; end
99
- def comments_allowed?; false; end
100
122
  end
101
123
 
102
124
  it 'not valid' do
103
- expect(ErrbitPlugin::ValidateIssueTracker.new(BazConfigured).valid?).to be false
125
+ expect(ErrbitPlugin::ValidateIssueTracker.new(klass).valid?).to be false
104
126
  end
105
127
 
106
128
  it 'say not implement configured?' do
107
- is = ErrbitPlugin::ValidateIssueTracker.new(BazConfigured)
129
+ is = ErrbitPlugin::ValidateIssueTracker.new(klass)
108
130
  is.valid?
109
131
  expect(is.errors).to eql [[:instance_method_missing, :configured?]]
110
132
  end
111
133
  end
112
134
 
113
135
  context "without errors method" do
114
- class BazCheckParams < ErrbitPlugin::IssueTracker
115
- def label; 'foo'; end
116
- def note; 'foo'; end
117
- def fields; ['foo']; end
136
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
137
+ def self.label; 'foo'; end
138
+ def self.note; 'foo'; end
139
+ def self.fields; ['foo']; end
140
+ def self.icons; {}; end
118
141
  def configured?; true; end
119
142
  def create_issue; 'http'; end
120
143
  def url; 'http'; end
121
- def comments_allowed?; false; end
122
144
  end
123
145
 
124
146
  it 'not valid' do
125
- expect(ErrbitPlugin::ValidateIssueTracker.new(BazCheckParams).valid?).to be false
147
+ expect(ErrbitPlugin::ValidateIssueTracker.new(klass).valid?).to be false
126
148
  end
127
149
 
128
150
  it 'say not implement errors' do
129
- is = ErrbitPlugin::ValidateIssueTracker.new(BazCheckParams)
151
+ is = ErrbitPlugin::ValidateIssueTracker.new(klass)
130
152
  is.valid?
131
153
  expect(is.errors).to eql [[:instance_method_missing, :errors]]
132
154
  end
133
155
  end
134
156
 
135
157
  context "without create_issue method" do
136
- class BazCreateIssue < ErrbitPlugin::IssueTracker
137
- def label; 'foo'; end
138
- def note; 'foo'; end
139
- def fields; ['foo']; end
158
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
159
+ def self.label; 'foo'; end
160
+ def self.note; 'foo'; end
161
+ def self.fields; ['foo']; end
162
+ def self.icons; {}; end
140
163
  def configured?; true; end
141
164
  def errors; true; end
142
165
  def url; 'http'; end
143
- def comments_allowed?; false; end
144
166
  end
145
167
 
146
168
  it 'not valid' do
147
- expect(ErrbitPlugin::ValidateIssueTracker.new(BazCreateIssue).valid?).to be false
169
+ expect(ErrbitPlugin::ValidateIssueTracker.new(klass).valid?).to be false
148
170
  end
149
171
  it 'say not implement url' do
150
- is = ErrbitPlugin::ValidateIssueTracker.new(BazCreateIssue)
172
+ is = ErrbitPlugin::ValidateIssueTracker.new(klass)
151
173
  is.valid?
152
174
  expect(is.errors).to eql [[:instance_method_missing, :create_issue]]
153
175
  end
154
176
  end
155
177
 
156
178
  context "without url method" do
157
- class BazUrl < ErrbitPlugin::IssueTracker
158
- def label; 'foo'; end
159
- def note; 'foo'; end
160
- def fields; ['foo']; end
179
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
180
+ def self.label; 'foo'; end
181
+ def self.note; 'foo'; end
182
+ def self.fields; ['foo']; end
183
+ def self.icons; {}; end
161
184
  def configured?; true; end
162
185
  def errors; true; end
163
186
  def create_issue; 'http'; end
164
- def comments_allowed?; false; end
165
187
  end
166
188
 
167
189
  it 'not valid' do
168
- expect(ErrbitPlugin::ValidateIssueTracker.new(BazUrl).valid?).to be false
190
+ expect(ErrbitPlugin::ValidateIssueTracker.new(klass).valid?).to be false
169
191
  end
170
192
 
171
193
  it 'say not implement url' do
172
- is = ErrbitPlugin::ValidateIssueTracker.new(BazUrl)
194
+ is = ErrbitPlugin::ValidateIssueTracker.new(klass)
173
195
  is.valid?
174
196
  expect(is.errors).to eql [[:instance_method_missing, :url]]
175
197
  end
176
198
  end
177
199
 
178
- context "without comments_allowed? method" do
179
- class BazComment < ErrbitPlugin::IssueTracker
180
- def label; 'foo'; end
181
- def note; 'foo'; end
182
- def fields; ['foo']; end
183
- def configured?; true; end
184
- def errors; true; end
185
- def create_issue; 'http'; end
186
- def url; 'foo'; end
187
- end
188
-
189
- it 'not valid' do
190
- expect(ErrbitPlugin::ValidateIssueTracker.new(BazComment).valid?).to be false
191
- end
192
-
193
- it 'say not implement comments_allowed?' do
194
- is = ErrbitPlugin::ValidateIssueTracker.new(BazComment)
195
- is.valid?
196
- expect(is.errors).to eql [[:instance_method_missing, :comments_allowed?]]
197
- end
198
- end
199
-
200
200
  context "without note method" do
201
- class BazNote < ErrbitPlugin::IssueTracker
201
+ klass = Class.new(ErrbitPlugin::IssueTracker) do
202
202
  def self.label; 'foo'; end
203
203
  def self.fields; ['foo']; end
204
+ def self.icons; {}; end
204
205
  def configured?; true; end
205
206
  def errors; true; end
206
207
  def create_issue; 'http'; end
207
208
  def url; 'foo'; end
208
- def comments_allowed?; false; end
209
209
  end
210
210
 
211
211
  it 'not valid' do
212
- expect(ErrbitPlugin::ValidateIssueTracker.new(BazNote).valid?).to be false
212
+ expect(ErrbitPlugin::ValidateIssueTracker.new(klass).valid?).to be false
213
213
  end
214
214
 
215
- it 'say not implement comments_allowed?' do
216
- is = ErrbitPlugin::ValidateIssueTracker.new(BazNote)
215
+ it 'say not implement note method' do
216
+ is = ErrbitPlugin::ValidateIssueTracker.new(klass)
217
217
  is.valid?
218
218
  expect(is.errors).to eql [[:class_method_missing, :note]]
219
219
  end
File without changes
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: errbit_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Crosby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-06 00:00:00.000000000 Z
11
+ date: 2015-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -57,19 +57,17 @@ files:
57
57
  - errbit_plugin.gemspec
58
58
  - lib/errbit_plugin.rb
59
59
  - lib/errbit_plugin/issue_tracker.rb
60
- - lib/errbit_plugin/issue_trackers/fake.rb
61
60
  - lib/errbit_plugin/issue_trackers/none.rb
62
- - lib/errbit_plugin/rails.rb
63
61
  - lib/errbit_plugin/registry.rb
64
62
  - lib/errbit_plugin/validate_issue_tracker.rb
65
63
  - lib/errbit_plugin/version.rb
66
64
  - spec/errbit_plugin/registry_spec.rb
67
65
  - spec/errbit_plugin/validate_issue_tracker_spec.rb
68
66
  - spec/spec_helper.rb
69
- - vendor/assets/images/fake_create.png
70
- - vendor/assets/images/fake_inactive.png
71
- - vendor/assets/images/none_create.png
72
- - vendor/assets/images/none_inactive.png
67
+ - static/fake_create.png
68
+ - static/fake_inactive.png
69
+ - static/none_create.png
70
+ - static/none_inactive.png
73
71
  homepage: http://github.com/errbit/errbit
74
72
  licenses:
75
73
  - MIT
@@ -1,38 +0,0 @@
1
- module ErrbitPlugin
2
- class FakeIssueTracker < IssueTracker
3
- def self.label
4
- 'fake'
5
- end
6
-
7
- def self.note
8
- 'A fake issue tracker to help in testing purpose'
9
- end
10
-
11
- def self.fields
12
- {
13
- :foo => {:label => 'foo'},
14
- :bar => {:label => 'bar'}
15
- }
16
- end
17
-
18
- def configured?
19
- !errors.any?
20
- end
21
-
22
- def errors
23
- errors = {}
24
- errors[:foo] = 'foo is required' unless params[:foo]
25
- errors[:bar] = 'bar is required' unless params[:bar]
26
-
27
- errors
28
- end
29
-
30
- def create_issue(problem, reported_by=nil); true; end
31
-
32
- def url; ''; end
33
-
34
- def comments_allowed?; false; end
35
- end
36
- end
37
-
38
- ErrbitPlugin::Registry.add_issue_tracker(ErrbitPlugin::FakeIssueTracker)
@@ -1,8 +0,0 @@
1
- if defined?(Rails)
2
- module ErrbitPlugin
3
- module Rails
4
- class Engine < ::Rails::Engine
5
- end
6
- end
7
- end
8
- end