activate-admin 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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzFlMTY0ZTljYmU2NTZiMzY5NDg3Zjk5ODQ5ZDZhZmMzM2I2M2NmZg==
4
+ ZTkwNDU5OWQ0MGE5OGYwMjcxMmQ1NmZmNTk2OGY3NWUyMDg0ZTdmYw==
5
5
  data.tar.gz: !binary |-
6
- NmM4NGFhZjNlYTdmZmRlYjkzMzg0NDg3ZmRhZTcyNDk4NTk2NmI3Yw==
6
+ OTU4OTA4Mzc5ZDI2N2Y1NzdjYjMyYzY3M2QwNWY3ZDZhZWVhN2RiOQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MjhjZGJiNDkwN2YzOTZlMThiZDEzOWZhNjAyYTRmN2I4ODM4OTg5YjM2NDM2
10
- N2M1ODVhYzdiNWI4NjliNGE0MzdmNTZhYjE1ODU4ZWM4Y2IwYmJkMTJiOGU3
11
- NDM2ZjVkNzdiOTUxN2UxODc5MmIzMWY3OTgyZThjNjdiZTgwODE=
9
+ YTgwMWU0OWYwMTJmMDQ4NTEyOTY1YTA4N2NiMTUyNjYzNDBmZDVhMGJjYjJk
10
+ ODY5ZmEyOGFhMDQ2MzE1ZTRjYTc3MGY4MWNhYTE2MWQxYTNlYTQzZWIxZjg2
11
+ ZjBkODJiYjU3MDdjZmZlZWQyOWE1ODVhNjU4NmY1OTEzMmQwMmQ=
12
12
  data.tar.gz: !binary |-
13
- ZGQ2MWZkM2I3Zjg3ODI2MWUyMWQwYTZiZmI3NjFjMzAzNjY4NTU0NTk5YzBi
14
- YmQwMWU5ZGY3NmVlNmIwZmExYWMzZWVhNzRkNTM2MDVhZjE3MjJiN2MzZmVk
15
- YzAxOGI5MzhlYjliNTNhZDI0MjhlYjlhZmY4YWMyZTkyYjk0NzI=
13
+ OTdjMmFkYjg5NGI0YjA5OWI3Yzk0Nzg3NjA4NzQ1MmFkMDcyNjZhMmQ1Nzkz
14
+ NGI3Yzc1NmFiZWVhNWY2YjhjZDI5NDNiY2QzN2Y0NWRmZTZlMGRjMGJjYzRi
15
+ Nzk3N2UzMmMxYzVhNTgzZWFlYTQ1ZDYwNGRmN2Q0OWRkYzBlMmQ=
@@ -1,3 +1,3 @@
1
1
  module ActivateAdmin
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -1,32 +1,33 @@
1
- module ActivateAdmin::DatetimeHelpers
1
+ module ActivateAdmin
2
+ module DatetimeHelpers
2
3
 
3
- def datetime_select_tags(name, options)
4
- v = options[:value] || Time.zone.now
5
- c = options[:class]
6
- id = options[:id]
7
- s = []
8
- s << "<style>.datetime select { width: auto }</style>"
9
- s << "<span id=\"#{id if id}\" class=\"datetime #{c if c}\">"
10
- s << select_tag(:"#{name}[day]", :options => (1..31).to_a, :selected => v.day )
11
- s << select_tag(:"#{name}[month]", :options => Date::MONTHNAMES[1..-1].each_with_index.map { |x,i| [x,i+1] }, :selected => v.month)
12
- s << select_tag(:"#{name}[year]", :options => (2012..2020).to_a, :selected => v.year )
13
- s << '@'
14
- s << select_tag(:"#{name}[hour]", :options => (0..23).to_a.map { |x| [x < 10 ? "0#{x}" : x,x] }, :selected => v.hour )
15
- s << ':'
16
- s << select_tag(:"#{name}[min]", :options => (0..59).to_a.map { |x| [x < 10 ? "0#{x}" : x,x] }, :selected => v.min )
17
- s << '</span>'
18
- s.join(' ')
19
- end
20
-
21
- def compact_time_ago(t)
22
- d = Time.now - t
23
- if d < 1.day
24
- time_ago_in_words(t) + ' ago'
25
- elsif d < 3.days
26
- t.strftime('%A') + " at #{t.to_s(:time)}"
27
- else
28
- t
29
- end
30
- end
4
+ def datetime_select_tags(name, options)
5
+ v = options[:value] || Time.zone.now
6
+ c = options[:class]
7
+ id = options[:id]
8
+ s = []
9
+ s << "<style>.datetime select { width: auto }</style>"
10
+ s << "<span id=\"#{id if id}\" class=\"datetime #{c if c}\">"
11
+ s << select_tag(:"#{name}[day]", :options => (1..31).to_a, :selected => v.day )
12
+ s << select_tag(:"#{name}[month]", :options => Date::MONTHNAMES[1..-1].each_with_index.map { |x,i| [x,i+1] }, :selected => v.month)
13
+ s << select_tag(:"#{name}[year]", :options => (2012..2020).to_a, :selected => v.year )
14
+ s << '@'
15
+ s << select_tag(:"#{name}[hour]", :options => (0..23).to_a.map { |x| [x < 10 ? "0#{x}" : x,x] }, :selected => v.hour )
16
+ s << ':'
17
+ s << select_tag(:"#{name}[min]", :options => (0..59).to_a.map { |x| [x < 10 ? "0#{x}" : x,x] }, :selected => v.min )
18
+ s << '</span>'
19
+ s.join(' ')
20
+ end
31
21
 
22
+ def compact_time_ago(t)
23
+ d = Time.now - t
24
+ if d < 1.day
25
+ time_ago_in_words(t) + ' ago'
26
+ elsif d < 3.days
27
+ t.strftime('%A') + " at #{t.to_s(:time)}"
28
+ else
29
+ t
30
+ end
31
+ end
32
+ end
32
33
  end
data/lib/param_helpers.rb CHANGED
@@ -1,41 +1,43 @@
1
- module ActivateAdmin::ParamHelpers
1
+ module ActivateAdmin
2
+ module ParamHelpers
2
3
 
3
- def fix_params!
4
- datetime_hashes_to_datetimes!(params)
5
- file_hashes_to_files!(params)
6
- blanks_to_nils!(params)
7
- end
4
+ def fix_params!
5
+ datetime_hashes_to_datetimes!(params)
6
+ file_hashes_to_files!(params)
7
+ blanks_to_nils!(params)
8
+ end
8
9
 
9
- def datetime_hashes_to_datetimes!(hash)
10
- hash.each { |k,v|
11
- if v.is_a?(Hash) and [:year, :month, :day, :hour, :min].all? { |x| v.has_key?(x.to_s) }
12
- hash[k] = Time.zone.local(v[:year].to_i, v[:month].to_i, v[:day].to_i, v[:hour].to_i, v[:min].to_i)
13
- elsif v.is_a?(Hash)
14
- datetime_hashes_to_datetimes!(v)
15
- end
16
- }
17
- end
10
+ def datetime_hashes_to_datetimes!(hash)
11
+ hash.each { |k,v|
12
+ if v.is_a?(Hash) and [:year, :month, :day, :hour, :min].all? { |x| v.has_key?(x.to_s) }
13
+ hash[k] = Time.zone.local(v[:year].to_i, v[:month].to_i, v[:day].to_i, v[:hour].to_i, v[:min].to_i)
14
+ elsif v.is_a?(Hash)
15
+ datetime_hashes_to_datetimes!(v)
16
+ end
17
+ }
18
+ end
18
19
 
19
- def file_hashes_to_files!(hash)
20
- hash.each { |k, v|
21
- if v.is_a?(Hash) and v[:tempfile]
22
- hash[k] = v[:tempfile]
23
- elsif v.is_a?(Hash)
24
- file_hashes_to_files!(v)
25
- end
26
- }
27
- end
20
+ def file_hashes_to_files!(hash)
21
+ hash.each { |k, v|
22
+ if v.is_a?(Hash) and v[:tempfile]
23
+ hash[k] = v[:tempfile]
24
+ elsif v.is_a?(Hash)
25
+ file_hashes_to_files!(v)
26
+ end
27
+ }
28
+ end
28
29
 
29
- def blanks_to_nils!(hash)
30
- hash.each { |k,v|
31
- if v.blank?
32
- hash[k] = nil
33
- elsif v.is_a? Array
34
- v.each_with_index { |x,i| v[i] = nil if x.blank? }.compact!
35
- elsif v.is_a? Hash
36
- blanks_to_nils!(v)
37
- end
38
- }
39
- end
30
+ def blanks_to_nils!(hash)
31
+ hash.each { |k,v|
32
+ if v.blank?
33
+ hash[k] = nil
34
+ elsif v.is_a? Array
35
+ v.each_with_index { |x,i| v[i] = nil if x.blank? }.compact!
36
+ elsif v.is_a? Hash
37
+ blanks_to_nils!(v)
38
+ end
39
+ }
40
+ end
40
41
 
42
+ end
41
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activate-admin
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
  - Stephen Reid