ciridiri 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,33 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'rake/testtask'
3
- require 'rake/gempackagetask'
4
3
 
5
4
  task :default => :test
6
5
 
7
- begin
8
- require 'jeweler'
9
- Jeweler::Tasks.new do |gemspec|
10
- gemspec.name = "ciridiri"
11
- gemspec.version = "0.8.1"
12
- gemspec.summary = gemspec.description = "Dead simple wiki engine"
13
- gemspec.email = "vasily@polovnyov.ru"
14
- gemspec.homepage = "http://vast.github.com/ciridiri.rb"
15
- gemspec.authors = ["Vasily Polovnyov"]
16
-
17
- gemspec.add_dependency 'sinatra', '>=0.9.1'
18
-
19
- gemspec.add_development_dependency 'rack-test', '>=0.3.0'
20
- gemspec.add_development_dependency 'contest', '>=0.1.0'
21
-
22
- gemspec.test_files = Dir.glob('test/*')
23
- gemspec.files = ["LICENSE", "README.md", "Rakefile", "config.ru"] + Dir.glob('lib/**/*') + gemspec.test_files +
24
- Dir.glob('public/**/*') + Dir.glob('views/*')
25
-
26
- end
27
- rescue LoadError
28
- puts "Jeweler not available. Install it with: sudo gem install jeweler"
29
- end
30
-
31
6
  Rake::TestTask.new do |t|
32
7
  t.libs << "test"
33
8
  t.test_files = FileList['test/*_test.rb']
data/lib/ciridiri/page.rb CHANGED
@@ -1,5 +1,6 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__)) unless $LOAD_PATH.include?(File.dirname(__FILE__))
2
- %w[fileutils finders paths extensions].each {|r| require r}
1
+ require 'fileutils'
2
+ dir = File.dirname(__FILE__)
3
+ %w[finders paths extensions].each {|r| require File.join(dir, r)}
3
4
 
4
5
  module Ciridiri
5
6
  class Page
@@ -9,7 +10,7 @@ module Ciridiri
9
10
  # A regular expression for markdown like headers (`#`, `##`, `###`, `=====`, `----`)
10
11
  MD_TITLE = Regexp.new("(^\#{1,3}\\s*?([^#].*?)#*$)|(^ {0,3}(\\S.*?)\\n(?:=|-)+(?=\\n+|\\Z))", Regexp::MULTILINE)
11
12
  # HTML headers (`<h1-3>`)
12
- HTML_TITLE = Regexp.new("^<h[1-3](.*)?>(.*)+</h[1-3]>")
13
+ HTML_TITLE = Regexp.new("^<h[1-3](.*)?>((.*)+)</h[1-3]>")
13
14
 
14
15
  # File extensions
15
16
  SOURCE_FILE_EXT = ".text".freeze
@@ -111,7 +112,12 @@ module Ciridiri
111
112
  # Tiny `attr_writer` for `@@content_dir` which creates the content directory if it doesn't exist
112
113
  def self.content_dir=(dir)
113
114
  @@content_dir = dir
114
- FileUtils.mkdir_p(@@content_dir) if !File.exists?(@@content_dir)
115
+ begin
116
+ FileUtils.mkdir_p(@@content_dir) if !File.exists?(@@content_dir)
117
+ rescue Errno::EACCES
118
+ # Can't create content dir, using current working dir
119
+ @@content_dir = "."
120
+ end
115
121
  end
116
122
 
117
123
  ###Protected methods
@@ -120,9 +126,9 @@ module Ciridiri
120
126
  # Find the title in contents (html or markdown variant).
121
127
  # Return `""` if nothing found.
122
128
  def self.find_title(contents="")
123
- if contents.detect {|s| s.match(MD_TITLE)}
129
+ if contents.match(MD_TITLE)
124
130
  $2.strip || $4.strip
125
- elsif contents.detect {|s| s.match(HTML_TITLE)}
131
+ elsif contents.match(HTML_TITLE)
126
132
  $2.strip
127
133
  else
128
134
  ""
@@ -75,7 +75,7 @@ class CiridiriTest < Test::Unit::TestCase
75
75
  protected
76
76
  def assert_redirect(uri)
77
77
  assert last_response.redirect?
78
- assert_equal last_response.headers['Location'], uri
78
+ assert last_response.headers['Location'] =~ Regexp.new(uri + '$')
79
79
  end
80
80
  end
81
81
  end
data/test/test_helper.rb CHANGED
@@ -1,7 +1,8 @@
1
+ gem 'minitest'
1
2
  require 'rubygems'
2
3
  require 'test/unit'
3
4
  require 'contest'
4
- require 'lib/ciridiri'
5
+ require './lib/ciridiri'
5
6
  begin; require 'turn'; rescue LoadError; end
6
7
 
7
8
  Ciridiri::Page.content_dir = File.join(File.dirname(__FILE__), 'pages')
metadata CHANGED
@@ -1,80 +1,56 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ciridiri
3
- version: !ruby/object:Gem::Version
4
- hash: 61
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 8
9
- - 1
10
- version: 0.8.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.2
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Vasily Polovnyov
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-10-01 00:00:00 +04:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-05-17 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: sinatra
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2157070940 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 57
30
- segments:
31
- - 0
32
- - 9
33
- - 1
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
34
21
  version: 0.9.1
35
22
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: rack-test
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2157070940
25
+ - !ruby/object:Gem::Dependency
26
+ name: rack-test
27
+ requirement: &2157070460 !ruby/object:Gem::Requirement
41
28
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 19
46
- segments:
47
- - 0
48
- - 3
49
- - 0
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
50
32
  version: 0.3.0
51
33
  type: :development
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: contest
55
34
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *2157070460
36
+ - !ruby/object:Gem::Dependency
37
+ name: contest
38
+ requirement: &2157069980 !ruby/object:Gem::Requirement
57
39
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 27
62
- segments:
63
- - 0
64
- - 1
65
- - 0
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
66
43
  version: 0.1.0
67
44
  type: :development
68
- version_requirements: *id003
45
+ prerelease: false
46
+ version_requirements: *2157069980
69
47
  description: Dead simple wiki engine
70
48
  email: vasily@polovnyov.ru
71
49
  executables: []
72
-
73
50
  extensions: []
74
-
75
- extra_rdoc_files:
51
+ extra_rdoc_files:
76
52
  - README.md
77
- files:
53
+ files:
78
54
  - README.md
79
55
  - Rakefile
80
56
  - config.ru
@@ -92,41 +68,32 @@ files:
92
68
  - views/edit.erb
93
69
  - views/layout.erb
94
70
  - views/show.erb
95
- has_rdoc: true
96
71
  homepage: http://vast.github.com/ciridiri.rb
97
72
  licenses: []
98
-
99
73
  post_install_message:
100
- rdoc_options:
74
+ rdoc_options:
101
75
  - --charset=UTF-8
102
- require_paths:
76
+ require_paths:
103
77
  - lib
104
- required_ruby_version: !ruby/object:Gem::Requirement
78
+ required_ruby_version: !ruby/object:Gem::Requirement
105
79
  none: false
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- hash: 3
110
- segments:
111
- - 0
112
- version: "0"
113
- required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
85
  none: false
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- hash: 3
119
- segments:
120
- - 0
121
- version: "0"
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
122
90
  requirements: []
123
-
124
91
  rubyforge_project:
125
- rubygems_version: 1.3.7
92
+ rubygems_version: 1.8.15
126
93
  signing_key:
127
94
  specification_version: 3
128
95
  summary: Dead simple wiki engine
129
- test_files:
96
+ test_files:
130
97
  - test/test_helper.rb
131
98
  - test/ciridiri_test.rb
132
99
  - test/page_test.rb