context_help 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -173,8 +173,8 @@ module ContextHelp
173
173
  true
174
174
  end
175
175
  def self.get_title(options)
176
- title = options[:title] || I18n.t(options[:calculated_path]+'.title', :default => {})
177
- if (title.nil? or title.is_a?(Hash))
176
+ title = options[:title] || get_doc_string(options[:calculated_path]+'.title')
177
+ if title.nil?
178
178
  title = nil
179
179
  if options[:path][:model]
180
180
  begin
@@ -190,18 +190,12 @@ module ContextHelp
190
190
  else
191
191
  title = I18n.t(options[:calculated_path]+'.title') if Rails.env.development? and ContextHelp::Base.config[:show_missing]
192
192
  end
193
- else
194
- if title.start_with?('t.')
195
- title = I18n.t title[2, title.length]
196
- elsif title.start_with?('I18n.')
197
- title = I18n.t title[5, title.length]
198
- end
199
193
  end
200
194
  title
201
195
  end
202
196
  def self.get_text(options,missing=true)
203
- text = options[:text] || I18n.t(options[:calculated_path]+'.text', :default => {})
204
- if (text.nil? or text.is_a?(Hash))
197
+ text = options[:text] || get_doc_string(options[:calculated_path]+'.text')
198
+ if text.nil?
205
199
  if missing and Rails.env.development? and ContextHelp::Base.config[:show_missing]
206
200
  I18n.t(options[:calculated_path]+'.text')
207
201
  else
@@ -211,6 +205,30 @@ module ContextHelp
211
205
  text
212
206
  end
213
207
  end
208
+ def self.get_doc_string(path)
209
+ plugin_prefixes = ['']
210
+ plugin_prefixes += Rails.plugins.select{|p| p.is_a?(Engines::Plugin) }.map{ |p| "#{p.name}." }
211
+
212
+ text = ''
213
+ found = false
214
+
215
+ plugin_prefixes.each do |prefix|
216
+ begin
217
+ Rails.logger.info "CHH: " + prefix + path
218
+ item = I18n.translate prefix + path, :raise => true
219
+ if item.start_with?('t.')
220
+ item = I18n.t item[2, item.length]
221
+ elsif item.start_with?('I18n.')
222
+ item = I18n.t item[5, item.length]
223
+ end
224
+
225
+ text = text + ' ' + item
226
+ found = true
227
+ rescue
228
+ end
229
+ end
230
+ found ? text : nil
231
+ end
214
232
  def self.model_name(model)
215
233
  model = model.to_s.underscore
216
234
  if model =~ /^[a-z][a-z0-9_]*\[[a-z][a-z0-9_]*_attributes\]/
@@ -1,3 +1,3 @@
1
1
  module ContextHelp
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: context_help
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-30 00:00:00.000000000 -03:00
12
+ date: 2011-09-15 00:00:00.000000000 -03:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
  description: ContextHelp is a gem that allows you to show inline or aside help about