ruby_slippers 0.2.0 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.3
data/lib/ext/ext.rb CHANGED
@@ -1,3 +1,78 @@
1
+ require 'iconv'
2
+
3
+ class Object
4
+ def meta_def name, &blk
5
+ (class << self; self; end).instance_eval do
6
+ define_method(name, &blk)
7
+ end
8
+ end
9
+ end
10
+
11
+ class String
12
+ def slugize(slug = '-')
13
+ slugged = Iconv.iconv('ascii//TRANSLIT//IGNORE', 'utf-8', self).to_s
14
+ slugged.gsub!(/&/, 'and')
15
+ slugged.gsub!(/[^\w_\-#{Regexp.escape(slug)}]+/i, slug)
16
+ slugged.gsub!(/#{slug}{2,}/i, slug)
17
+ slugged.gsub!(/^#{slug}|#{slug}$/i, '')
18
+ url_encode(slugged.downcase)
19
+ end
20
+
21
+ def url_encode(word)
22
+ URI.escape(word, /[^\w_+-]/i)
23
+ end
24
+
25
+ def humanize
26
+ self.capitalize.gsub(/[-_]+/, ' ')
27
+ end
28
+ end
29
+
30
+ class Fixnum
31
+ def ordinal
32
+ # 1 => 1st
33
+ # 2 => 2nd
34
+ # 3 => 3rd
35
+ # ...
36
+ case self % 100
37
+ when 11..13; "#{self}th"
38
+ else
39
+ case self % 10
40
+ when 1; "#{self}st"
41
+ when 2; "#{self}nd"
42
+ when 3; "#{self}rd"
43
+ else "#{self}th"
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ class Object
50
+ def blank?
51
+ self.nil? || self == ""
52
+ end
53
+ end
54
+
55
+ class Date
56
+ # This check is for people running RubySlippers::Enginewith ActiveSupport, avoid a collision
57
+ unless respond_to? :iso8601
58
+ # Return the date as a String formatted according to ISO 8601.
59
+ def iso8601
60
+ ::Time.utc(year, month, day, 0, 0, 0, 0).iso8601
61
+ end
62
+ end
63
+ end
64
+
65
+ module Kernel
66
+ def silence_stream(stream)
67
+ old_stream = stream.dup
68
+ stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
69
+ stream.sync = true
70
+ yield
71
+ ensure
72
+ stream.reopen(old_stream)
73
+ end
74
+ end
75
+
1
76
  require 'enumerator'
2
77
 
3
78
  class Array
@@ -98,67 +173,3 @@ class Array
98
173
  end
99
174
  end
100
175
  end
101
-
102
- class Object
103
- def meta_def name, &blk
104
- (class << self; self; end).instance_eval do
105
- define_method(name, &blk)
106
- end
107
- end
108
- end
109
-
110
- class String
111
- def slugize
112
- self.downcase.gsub(/&/, 'and').gsub(/\s+/, '-').gsub(/[^a-z0-9-]/, '')
113
- end
114
-
115
- def humanize
116
- self.capitalize.gsub(/[-_]+/, ' ')
117
- end
118
- end
119
-
120
- class Fixnum
121
- def ordinal
122
- # 1 => 1st
123
- # 2 => 2nd
124
- # 3 => 3rd
125
- # ...
126
- case self % 100
127
- when 11..13; "#{self}th"
128
- else
129
- case self % 10
130
- when 1; "#{self}st"
131
- when 2; "#{self}nd"
132
- when 3; "#{self}rd"
133
- else "#{self}th"
134
- end
135
- end
136
- end
137
- end
138
-
139
- class Object
140
- def blank?
141
- self.nil? || self == ""
142
- end
143
- end
144
-
145
- class Date
146
- # This check is for people running RubySlippers::Enginewith ActiveSupport, avoid a collision
147
- unless respond_to? :iso8601
148
- # Return the date as a String formatted according to ISO 8601.
149
- def iso8601
150
- ::Time.utc(year, month, day, 0, 0, 0, 0).iso8601
151
- end
152
- end
153
- end
154
-
155
- module Kernel
156
- def silence_stream(stream)
157
- old_stream = stream.dup
158
- stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
159
- stream.sync = true
160
- yield
161
- ensure
162
- stream.reopen(old_stream)
163
- end
164
- end
@@ -31,10 +31,6 @@ module RubySlippers::Engine
31
31
  self.load unless self.tainted?
32
32
  super
33
33
  end
34
-
35
- def thumb
36
- "/img/archives/#{article.slug}-full.png"
37
- end
38
34
 
39
35
  def slug
40
36
  self[:slug] || self[:title].slugize
@@ -10,7 +10,7 @@
10
10
  begin;
11
11
  "<div class='archived_article'>"+
12
12
  "<div class='title'>#{article.title}</div>"+
13
- "<a href='#{article.url}'><img src='#{article.thumb}' width='200'></img></a>"+
13
+ "<a href='#{article.url}'><img src='/img/archives/#{article.slug}-full.png' width='200'></img></a>"+
14
14
  "<div class='title'>#{article.date}</div>"+
15
15
  "</div>";
16
16
  rescue;end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ruby_slippers
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.2.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - dreamr