sugar 0.0.23 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/Rakefile +3 -0
  2. data/VERSION +1 -1
  3. data/lib/sugar/actionview.rb +33 -12
  4. data/sugar.gemspec +1 -1
  5. metadata +1 -1
data/Rakefile CHANGED
@@ -47,3 +47,6 @@ rescue LoadError
47
47
  abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
48
48
  end
49
49
  end
50
+
51
+ desc "Bump patch version and release to github and gemcutter"
52
+ task :bump => %w(version:bump:patch release gemcutter:release)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.23
1
+ 0.0.25
@@ -11,16 +11,17 @@ module Sugar
11
11
  end
12
12
 
13
13
  def default_page_title
14
- case action_name
15
- when 'index'
16
- controller_name.camelize
17
- when 'new', 'create'
18
- t("#{t('new', :default => 'New')} #{controller_name.classify.constantize.human_name}")
19
- when 'edit', 'update'
20
- t("#{t('editing', :default => 'Editing')} #{controller_name.classify.constantize.human_name}")
21
- else
22
- t("#{controller_name}.#{view_name}.title")
23
- end
14
+ text = case action_name
15
+ when 'index'
16
+ controller_name.camelize
17
+ when 'new', 'create'
18
+ t("#{t('new', :default => 'New')} #{controller_name.classify.constantize.human_name}")
19
+ when 'edit', 'update'
20
+ t("#{t('editing', :default => 'Editing')} #{controller_name.classify.constantize.human_name}")
21
+ else
22
+ t("#{controller_name}.#{view_name}.title")
23
+ end
24
+ %(<span class="trasnlation_missing">#{text}</span>)
24
25
  end
25
26
 
26
27
  # Return page title for use in layout
@@ -32,6 +33,11 @@ module Sugar
32
33
  end
33
34
  end
34
35
 
36
+ def html_page_title(default = false, separator = ' | ')
37
+ default ||= t('application.title')
38
+ [page_title, default].compat.join(separator)
39
+ end
40
+
35
41
  # Put submit with proper text
36
42
  def submit(form, title = nil)
37
43
  title ||= t("#{controller.controller_name}.#{view_name}.submit",
@@ -94,7 +100,7 @@ module Sugar
94
100
 
95
101
  def button_to_delete(something, title = nil)
96
102
  title ||= t('.delete',
97
- :default => "Delete #{(something.is_a?(Array) ? something.last : something).class.human_name}")
103
+ :default => %(Delete #{(something.is_a?(Array) ? something.last : something).class.human_name}))
98
104
  button_to(title,
99
105
  polymorphic_path(something),
100
106
  :class => 'delete action',
@@ -146,7 +152,22 @@ module Sugar
146
152
  end
147
153
  end
148
154
 
149
- end
155
+ def human(*args)
156
+ if args.size == 2
157
+ args.first.human_attribute_name(args.second.to_s)
158
+ else
159
+ args.first.human_name
160
+ end
161
+ end
162
+
163
+ def zebra
164
+ {:class => cycle('even', 'odd')}
165
+ end
150
166
 
167
+ def translatable(text, key = nil)
168
+ key ||= ".#{text.gsub(/[\s\.,-]+/, '_').downcase}"
169
+ translate(key, :default => text)
170
+ end
171
+ end
151
172
  end
152
173
 
data/sugar.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sugar}
8
- s.version = "0.0.23"
8
+ s.version = "0.0.25"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alexander Semyonov"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sugar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Semyonov