bonanza 1.7.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.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +2 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/CHANGELOG.md +188 -0
  7. data/Gemfile +5 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +95 -0
  10. data/Rakefile +9 -0
  11. data/VERSION +1 -0
  12. data/bonanza.gemspec +27 -0
  13. data/config/locales/de.yml +7 -0
  14. data/config/locales/en.yml +7 -0
  15. data/lib/bonanza.rb +5 -0
  16. data/lib/bonanza/call_link_helpers.rb +24 -0
  17. data/lib/bonanza/engine.rb +15 -0
  18. data/lib/bonanza/link_helpers.rb +65 -0
  19. data/lib/bonanza/link_strategies.rb +14 -0
  20. data/lib/bonanza/link_strategies/base.rb +45 -0
  21. data/lib/bonanza/link_strategies/billing.rb +24 -0
  22. data/lib/bonanza/link_strategies/kuba.rb +11 -0
  23. data/lib/bonanza/link_strategies/mojito.rb +11 -0
  24. data/lib/bonanza/link_strategies/ninevirt.rb +11 -0
  25. data/lib/bonanza/link_strategies/openshift.rb +29 -0
  26. data/lib/bonanza/link_strategies/otrs.rb +25 -0
  27. data/lib/bonanza/link_strategies/redmine.rb +11 -0
  28. data/lib/bonanza/link_strategies/stats.rb +17 -0
  29. data/lib/bonanza/link_strategies/wiki.rb +15 -0
  30. data/lib/bonanza/link_strategies/yimin.rb +15 -0
  31. data/lib/bonanza/urn_link_helpers.rb +40 -0
  32. data/lib/bonanza/validators.rb +3 -0
  33. data/lib/bonanza/validators/domain_name_validator.rb +16 -0
  34. data/lib/bonanza/validators/otrs_number_validator.rb +13 -0
  35. data/lib/bonanza/validators/urn_validator.rb +14 -0
  36. data/spec/bonanza/call_link_helpers_spec.rb +50 -0
  37. data/spec/bonanza/link_helpers_spec.rb +126 -0
  38. data/spec/bonanza/link_strategies/base_spec.rb +50 -0
  39. data/spec/bonanza/link_strategies/billing_spec.rb +35 -0
  40. data/spec/bonanza/link_strategies/openshift_spec.rb +26 -0
  41. data/spec/bonanza/urn_link_helpers_spec.rb +80 -0
  42. data/spec/bonanza/validators/domain_name_validator_spec.rb +59 -0
  43. data/spec/bonanza/validators/otrs_number_validator_spec.rb +53 -0
  44. data/spec/bonanza/validators/urn_validator_spec.rb +64 -0
  45. data/spec/spec_helper.rb +90 -0
  46. metadata +182 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 436af178366a5323774912ace2390102ab59cd81
4
+ data.tar.gz: 96a267f97213b9f87722c27106487bf06842bd13
5
+ SHA512:
6
+ metadata.gz: 8cbdc23883a56341cb9dbf9ec412698ea07ca64c6f8df1e44aac3474e9008ac2594c72f90dfcbdb4ee2bc61d5e006a4064748b8c4f0b15a2185d6586b788f138
7
+ data.tar.gz: 06aed64f50827b5ba933fd9f88caa2b7807e0000427f12daea86a9be2ba915d457993de74858c56b9b9be05ea5e384eb79bfdcb2152526011cb3c0fb051eafe8
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1 @@
1
+ bonanza
@@ -0,0 +1 @@
1
+ 2.3.1
@@ -0,0 +1,188 @@
1
+
2
+ # 1.7.0
3
+
4
+ # Feature
5
+ * Feature [#37739](https://redmine.nine.ch/issues/37739) URN Support for OpenShift Projects
6
+
7
+
8
+
9
+
10
+ # 1.6.0
11
+
12
+
13
+
14
+
15
+
16
+ # 1.5.0
17
+
18
+
19
+
20
+
21
+
22
+ # 1.4.4
23
+
24
+
25
+
26
+
27
+
28
+ # 1.4.3
29
+
30
+
31
+
32
+
33
+
34
+ # 1.4.2
35
+
36
+
37
+
38
+
39
+
40
+ # 1.4.1
41
+
42
+
43
+
44
+
45
+
46
+ # 1.4.0
47
+
48
+ # Bug
49
+ * Bug [#30847](https://redmine.nine.ch/issues/30847) Bonanza should render helpful error messages when using invalid urns
50
+
51
+
52
+
53
+
54
+ # 1.3.0
55
+
56
+
57
+
58
+
59
+
60
+ # 1.2.3
61
+
62
+
63
+
64
+
65
+
66
+ # 1.2.2
67
+
68
+
69
+
70
+
71
+
72
+ # 1.2.1
73
+
74
+ # Feature
75
+ * Feature [#20228](https://redmine.nine.ch/issues/20228) URN Link Helper um IPv6 Subnetz erweitern
76
+
77
+
78
+
79
+
80
+ # 1.2.0
81
+
82
+
83
+
84
+
85
+
86
+ # 1.1.6
87
+
88
+
89
+
90
+
91
+
92
+ # 1.1.5
93
+
94
+
95
+
96
+
97
+
98
+ # 1.1.4
99
+
100
+
101
+
102
+
103
+
104
+ # 1.1.3
105
+
106
+ # Bug
107
+ * Bug [#16830](https://redmine.nine.ch/issues/16830) Link zu OTRS wird falsch codiert
108
+
109
+
110
+
111
+
112
+ # 1.1.2
113
+
114
+ # Feature
115
+ * Feature [#16437](https://redmine.nine.ch/issues/16437) Feature Request / Link zu Doku in Kuba einbinden
116
+
117
+
118
+
119
+
120
+ # 1.1.1
121
+
122
+ # Bug
123
+ * Bug [#16263](https://redmine.nine.ch/issues/16263) Kuba Staging redmine(und andere)-links sollen ins redmine-staging zeigen
124
+
125
+
126
+
127
+
128
+ # 1.1.0
129
+
130
+
131
+
132
+
133
+
134
+ # 1.0.7
135
+
136
+
137
+
138
+
139
+
140
+ # 1.1.0
141
+
142
+ * Added OTRS Number Validator for Rails models.
143
+
144
+
145
+
146
+
147
+ # 1.0.6
148
+
149
+
150
+
151
+
152
+
153
+ # 1.0.5
154
+
155
+
156
+
157
+
158
+
159
+ # 1.0.4
160
+
161
+
162
+
163
+
164
+
165
+ # 1.0.3
166
+
167
+ # Bug
168
+ * Bug [#14278](https://redmine.nine.ch/issues/14278) Link zu Billing im Kuba anpassen
169
+
170
+
171
+
172
+
173
+ # 1.0.2
174
+
175
+
176
+
177
+
178
+
179
+ # 1.0.1
180
+
181
+
182
+
183
+
184
+
185
+ # 1.0.0
186
+
187
+
188
+
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.nine.ch/private'
2
+ source 'https://rubygems.nine.ch'
3
+
4
+ # Specify your gem's dependencies in bonanza.gemspec
5
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Philippe Hässig
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,95 @@
1
+ # Bonanza
2
+
3
+ Bonanza provides some nice helpers and enhancements for nine.ch Rails apps.
4
+
5
+ For real cowboys only!
6
+
7
+ ![Bonanza](http://www.tv-cowboys.com/images/Cartwrightfamily.jpg)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'bonanza'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ ## Link Helpers
22
+
23
+ There is a basic little helper to get an application's url. To use the urn
24
+ specific link helpers, the infrastructure-client dependency is required.
25
+
26
+ ```ruby
27
+ nine_app_url(:redmine, :issue, '123')
28
+ => "https://redmine.nine.ch/issues/123"
29
+ ```
30
+
31
+ There are two link helpers for the nine ticket systems. One for customer profiles
32
+ and one for tickets.
33
+
34
+ Link to a customer profile:
35
+
36
+ ```erb
37
+ <%= link_to_otrs_customer 'OTRS Customer Profile', 5247, class: 'blue' %>
38
+ ```
39
+
40
+ Link to an otrs ticket:
41
+
42
+ ```erb
43
+ <%= link_to_otrs_ticket 'OTRS Ticket', '2014110610000325' %>
44
+ ```
45
+
46
+ Link to customer data in Billing:
47
+
48
+ ```erb
49
+ <%= link_to_billing 'Billing', 5247, class: 'blue' %>
50
+ ```
51
+
52
+ Link to customer data in the Mighty Stats:
53
+
54
+ ```erb
55
+ <%= link_to_stats 'Stats', 5247, class: 'black' %>
56
+ ```
57
+
58
+ Link to a redmine issue:
59
+
60
+ ```erb
61
+ <%= link_to_redmine 'Redmine', 123 %>
62
+ ```
63
+
64
+ Link to a migration item:
65
+
66
+ ```erb
67
+ <%= link_to_migration_item 'Migration', 123 %>
68
+ ```
69
+
70
+ Link to a resource represented by a URN:
71
+
72
+ ```erb
73
+ <%= link_to_urn 'VServer', 'urn:nine:vserver:1279' %>
74
+ ```
75
+
76
+ ## Validators
77
+
78
+ Bonanza can validate OTRS Ticket numbers. But don't fear! It just checks for a 16-character number.
79
+
80
+ ```ruby
81
+ class Order < ActiveRecord::Base
82
+ include Bonanza::Validators
83
+ validates :otrs_ticket, otrs_number: true
84
+ end
85
+ ```
86
+
87
+ Bonanza can validate nine urns, like 'urn:nine:vserver:1234'. To use this
88
+ validator, the infrastructure-client dependency is required.
89
+
90
+ ```ruby
91
+ class Order < ActiveRecord::Base
92
+ include Bonanza::Validators
93
+ validates :urn, urn: true
94
+ end
95
+ ```
@@ -0,0 +1,9 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task default: :spec
7
+ rescue LoadError
8
+ end
9
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.7.0
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'bonanza'
7
+ spec.version = File.read(File.expand_path('../VERSION', __FILE__)).strip
8
+ spec.authors = ['Philippe Hassig']
9
+ spec.email = ['phil@nine.ch']
10
+ spec.summary = 'Rails enhancements for nine.ch'
11
+ spec.description = 'Some nice Rails enhancements for nine.ch apps. A real bonanza!'
12
+ spec.homepage = 'http://www.nine.ch'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_runtime_dependency 'rails'
21
+ spec.add_runtime_dependency 'simpleidn'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.7'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'infrastructure-client', '>= 2.2.0'
27
+ end
@@ -0,0 +1,7 @@
1
+ ---
2
+ de:
3
+ errors:
4
+ messages:
5
+ not_an_otrs_ticket: keine OTRS Nummer
6
+ not_a_valid_domain_name: keine gültige Domain
7
+ invalid_urn: ungültige URN
@@ -0,0 +1,7 @@
1
+ ---
2
+ en:
3
+ errors:
4
+ messages:
5
+ not_an_otrs_ticket: not an OTRS number
6
+ not_a_valid_domain_name: not a valid domain name
7
+ invalid_urn: invalid URN
@@ -0,0 +1,5 @@
1
+ require 'active_support'
2
+ require 'bonanza/engine' if defined?(Rails)
3
+
4
+ module Bonanza
5
+ end
@@ -0,0 +1,24 @@
1
+ require 'active_support/core_ext'
2
+ require 'action_view/helpers'
3
+
4
+ module Bonanza
5
+ module CallLinkHelpers
6
+ include ActionView::Helpers::UrlHelper
7
+
8
+ ASTERISK_URL_PATTERN = 'http://pbx.nine.ch/call.php?ext=%{phone_number}'.freeze
9
+
10
+ def call_to(number)
11
+ link_to_if number.present?, number, call_to_url(number)
12
+ end
13
+
14
+ private
15
+
16
+ def call_to_url(phone_number)
17
+ ASTERISK_URL_PATTERN % { phone_number: format_phone_number_url(phone_number) }
18
+ end
19
+
20
+ def format_phone_number_url(phone_number)
21
+ (phone_number || '').delete(' ').gsub('+', '00')
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,15 @@
1
+ require 'bonanza/link_helpers'
2
+ require 'bonanza/call_link_helpers'
3
+ require 'bonanza/urn_link_helpers'
4
+ require 'bonanza/validators'
5
+ require 'bonanza/link_strategies'
6
+
7
+ module Bonanza
8
+ class Engine < ::Rails::Engine
9
+ initializer 'bonanza.link_helpers' do
10
+ ActionView::Base.send :include, LinkHelpers
11
+ ActionView::Base.send :include, UrnLinkHelpers
12
+ ActionView::Base.send :include, CallLinkHelpers
13
+ end
14
+ end
15
+ end