maneki 1.0.1 → 1.0.2

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 (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/maneki.rb +47 -47
  3. data/maneki.gemspec +4 -4
  4. metadata +9 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
data/lib/maneki.rb CHANGED
@@ -120,54 +120,54 @@ class Maneki
120
120
  # Create a new document
121
121
  def initialize (args = {})
122
122
  @filename = File.expand_path(args[:filename])
123
-
124
- @body = ''
125
- if File.exists? @filename
126
- @category = File.dirname(@filename).split('/').last unless @category
127
- @slug = @filename.gsub(File.expand_path(self.class.path) + '/', '').gsub(/\..+$/, '')
128
-
129
- body = File.open(@filename).readlines
130
- body.each do |line|
131
- line.gsub!("\r", '') # fix up any DOS EOLs
132
- end
123
+
124
+ @body = ''
125
+ if File.exists? @filename
126
+ @category = File.dirname(@filename).split('/').last unless @category
127
+ @slug = @filename.gsub(File.expand_path(self.class.path) + '/', '').gsub(/\..+$/, '')
128
+
129
+ body = File.open(@filename).readlines
130
+ body.each do |line|
131
+ line.gsub!("\r", '') # fix up any DOS EOLs
132
+ end
133
133
 
134
- title = body.find { |item| /^\#.+/.match item }
135
- body = body[2..body.length-1] if title # consume title
134
+ title = body.find { |item| /^\#.+/.match item }
135
+ body = body[2..body.length-1] if title # consume title
136
136
 
137
137
  # check for headers
138
138
  @headers = Hash.new
139
139
  if /^\s?\-.+/.match(body[0])
140
- headers_end = body.index("\n") || 1
141
- headers = body[0..headers_end-1] if headers_end # next blank line is end of headers
140
+ headers_end = body.index("\n") || 1
141
+ headers = body[0..headers_end-1] if headers_end # next blank line is end of headers
142
142
 
143
- body_start = 1
144
- body_start = body.index(headers.last) + 1 if headers
145
- body = body[body_start..body.length - 1] if title
143
+ body_start = 1
144
+ body_start = body.index(headers.last) + 1 if headers
145
+ body = body[body_start..body.length - 1] if title
146
146
 
147
- headers.each do |header|
148
- unless header.strip == '' or /^\#.+/.match header
149
- values = header.gsub(/^\s?\-/, '').strip.split(/:\s/)
150
- key = values.shift.downcase.gsub(/[^\w\_]+/, '_').to_sym
151
- value = values.join(': ').strip
152
- # check for special header values (true, false, lists, etc)
153
- if ['true', 't', 'yes', 'y'].include? value
154
- value = true
155
- elsif ['false', 'f', 'no', 'n'].include? value
156
- value = false
157
- elsif value.include? ','
158
- value = value.split(/\,\s?/)
159
- end
160
- @headers[key] = value
161
- end
162
- end if headers
163
- end
147
+ headers.each do |header|
148
+ unless header.strip == '' or /^\#.+/.match header
149
+ values = header.gsub(/^\s?\-/, '').strip.split(/:\s/)
150
+ key = values.shift.downcase.gsub(/[^\w\_]+/, '_').to_sym
151
+ value = values.join(': ').strip
152
+ # check for special header values (true, false, lists, etc)
153
+ if ['true', 't', 'yes', 'y'].include? value
154
+ value = true
155
+ elsif ['false', 'f', 'no', 'n'].include? value
156
+ value = false
157
+ elsif value.include? ','
158
+ value = value.split(/\,\s?/)
159
+ end
160
+ @headers[key] = value
161
+ end
162
+ end if headers
163
+ end
164
164
 
165
- # title
166
- @title = title.gsub(/^\#\s/, '').strip if title
165
+ # title
166
+ @title = title.gsub(/^\#\s/, '').strip if title
167
167
 
168
- # content
169
- @body = body.join("").strip
170
- end
168
+ # content
169
+ @body = body.join("").strip
170
+ end
171
171
  end
172
172
 
173
173
 
@@ -200,7 +200,7 @@ class Maneki
200
200
  # Grab the @path with a slash if needed
201
201
  def self.path_with_slash
202
202
  files_path = File.expand_path(@path)
203
- files_path += '/' unless files_path.end_with? '/'
203
+ files_path += '/' unless files_path.match /\/$/
204
204
  files_path
205
205
  end
206
206
 
@@ -223,9 +223,9 @@ class Maneki
223
223
  @documents = []
224
224
  @categorised = {}
225
225
 
226
- # find some documents
227
- Dir.glob(["#{files_path}*", "#{files_path}*/*"]).each do |filename|
228
- if filename.split('.').last == 'text'
226
+ # find some documents
227
+ Dir.glob(["#{files_path}*", "#{files_path}*/*"]).each do |filename|
228
+ if filename.split('.').last == 'text'
229
229
  document = new(:filename => filename)
230
230
  if document.valid?
231
231
  @documents << document
@@ -233,9 +233,9 @@ class Maneki
233
233
  @categorised[document.category] << document
234
234
  end
235
235
  end
236
- end
237
- @documents.sort!
238
- end
239
- @documents
236
+ end
237
+ @documents.sort!
238
+ end
239
+ @documents
240
240
  end
241
241
  end
data/maneki.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{maneki}
8
- s.version = "1.0.1"
8
+ s.version = "1.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nathan Hoad"]
12
- s.date = %q{2010-05-23}
12
+ s.date = %q{2010-05-30}
13
13
  s.description = %q{Maneki loads and parses any relevant text files in a given directory}
14
14
  s.email = %q{nathan@nathanhoad.net}
15
15
  s.extra_rdoc_files = [
@@ -36,7 +36,7 @@ Gem::Specification.new do |s|
36
36
  s.homepage = %q{http://github.com/nathanhoad/maneki}
37
37
  s.rdoc_options = ["--charset=UTF-8"]
38
38
  s.require_paths = ["lib"]
39
- s.rubygems_version = %q{1.3.6}
39
+ s.rubygems_version = %q{1.3.7}
40
40
  s.summary = %q{A simple file-based model for your Ruby projects}
41
41
  s.test_files = [
42
42
  "test/chapter.rb",
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
49
49
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
50
  s.specification_version = 3
51
51
 
52
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
52
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
53
  else
54
54
  end
55
55
  else
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maneki
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 0
8
- - 1
9
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Nathan Hoad
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-23 00:00:00 +10:00
18
+ date: 2010-05-30 00:00:00 +10:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
@@ -53,23 +54,27 @@ rdoc_options:
53
54
  require_paths:
54
55
  - lib
55
56
  required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
56
58
  requirements:
57
59
  - - ">="
58
60
  - !ruby/object:Gem::Version
61
+ hash: 3
59
62
  segments:
60
63
  - 0
61
64
  version: "0"
62
65
  required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
63
67
  requirements:
64
68
  - - ">="
65
69
  - !ruby/object:Gem::Version
70
+ hash: 3
66
71
  segments:
67
72
  - 0
68
73
  version: "0"
69
74
  requirements: []
70
75
 
71
76
  rubyforge_project:
72
- rubygems_version: 1.3.6
77
+ rubygems_version: 1.3.7
73
78
  signing_key:
74
79
  specification_version: 3
75
80
  summary: A simple file-based model for your Ruby projects