gollum_rails 1.4.0.rc2 → 1.4.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -6
  3. data/Gemfile.lock +7 -10
  4. data/HISTORY.md +91 -91
  5. data/LICENSE +661 -661
  6. data/README.md +74 -74
  7. data/Rakefile +170 -170
  8. data/gollum_rails.gemspec +6 -4
  9. data/lib/core_ext/string.rb +3 -7
  10. data/lib/generators/gollum_rails/install/install_generator.rb +27 -27
  11. data/lib/generators/gollum_rails/install/templates/gollum_initializer.rb +22 -22
  12. data/lib/generators/gollum_rails/language/language_generator.rb +81 -81
  13. data/lib/generators/gollum_rails/model/model_generator.rb +51 -51
  14. data/lib/generators/gollum_rails/model/templates/model_template.erb +13 -13
  15. data/lib/gollum_rails.rb +26 -6
  16. data/lib/gollum_rails/adapters/activemodel.rb +36 -36
  17. data/lib/gollum_rails/adapters/activemodel/boolean.rb +15 -15
  18. data/lib/gollum_rails/adapters/activemodel/error.rb +27 -27
  19. data/lib/gollum_rails/adapters/activemodel/naming.rb +42 -42
  20. data/lib/gollum_rails/adapters/gollum.rb +54 -54
  21. data/lib/gollum_rails/adapters/gollum/.gitkeep +0 -0
  22. data/lib/gollum_rails/adapters/gollum/error.rb +19 -19
  23. data/lib/gollum_rails/adapters/gollum/page.rb +177 -177
  24. data/lib/gollum_rails/adapters/gollum/wiki.rb +42 -42
  25. data/lib/gollum_rails/page.rb +266 -266
  26. data/lib/gollum_rails/setup.rb +81 -81
  27. data/lib/grit/git-ruby/internal/pack.rb +397 -397
  28. data/spec/gollum_rails/adapters/activemodel/error_spec.rb +11 -11
  29. data/spec/gollum_rails/adapters/activemodel/naming_spec.rb +27 -27
  30. data/spec/gollum_rails/adapters/activemodel/validation_unused.rb +102 -102
  31. data/spec/gollum_rails/adapters/gollum/committer_spec.rb +0 -0
  32. data/spec/gollum_rails/adapters/gollum/connector_spec.rb +15 -15
  33. data/spec/gollum_rails/adapters/gollum/error_spec.rb +7 -7
  34. data/spec/gollum_rails/adapters/gollum/page_spec.rb +89 -89
  35. data/spec/gollum_rails/adapters/gollum/wiki_spec.rb +27 -27
  36. data/spec/gollum_rails/error_spec.rb +10 -0
  37. data/spec/gollum_rails/page_spec.rb +207 -207
  38. data/spec/gollum_rails/respository_spec.rb +0 -0
  39. data/spec/gollum_rails/setup_spec.rb +44 -44
  40. data/spec/gollum_rails/wiki_spec.rb +0 -0
  41. data/spec/gollum_rails_spec.rb +9 -0
  42. data/spec/spec.opts +3 -3
  43. data/spec/spec_helper.rb +43 -43
  44. metadata +4 -5
  45. data/lib/gollum_rails/modules/hash.rb +0 -33
  46. data/lib/gollum_rails/modules/loader.rb +0 -5
  47. data/spec/gollum_rails/modules/hash_spec.rb +0 -31
@@ -1,11 +1,11 @@
1
- require 'spec_helper'
2
-
3
- describe GollumRails::Adapters::ActiveModel::Error do
4
- before(:each) do
5
- @error = GollumRails::Adapters::ActiveModel::Error
6
-
7
- end
8
- it "should throw a new error" do
9
-
10
- end
11
- end
1
+ require 'spec_helper'
2
+
3
+ describe GollumRails::Adapters::ActiveModel::Error do
4
+ before(:each) do
5
+ @error = GollumRails::Adapters::ActiveModel::Error
6
+
7
+ end
8
+ it "should throw a new error" do
9
+
10
+ end
11
+ end
@@ -1,27 +1,27 @@
1
- require 'spec_helper'
2
-
3
- describe GollumRails::Adapters::ActiveModel::Naming do
4
- include GollumRails::Adapters::ActiveModel::Naming
5
-
6
- before(:each) do
7
- @model = GollumRails::Adapters::ActiveModel::Naming
8
- end
9
-
10
- it "should use _scores" do
11
- class Blax < GollumRails::Adapters::ActiveModel::Naming::NameSpace
12
- include GollumRails::Adapters::ActiveModel::Naming
13
-
14
- def initialize
15
- class_name.should == self.class.name
16
- class_name.should == "Blax"
17
- plural_filename_for_class(Blax).should == "blaxes"
18
- singular_filename_for_class(Blax).should == "blax"
19
-
20
- end
21
-
22
- end
23
-
24
- bla = Blax.new
25
-
26
- end
27
- end
1
+ require 'spec_helper'
2
+
3
+ describe GollumRails::Adapters::ActiveModel::Naming do
4
+ include GollumRails::Adapters::ActiveModel::Naming
5
+
6
+ before(:each) do
7
+ @model = GollumRails::Adapters::ActiveModel::Naming
8
+ end
9
+
10
+ it "should use _scores" do
11
+ class Blax < GollumRails::Adapters::ActiveModel::Naming::NameSpace
12
+ include GollumRails::Adapters::ActiveModel::Naming
13
+
14
+ def initialize
15
+ class_name.should == self.class.name
16
+ class_name.should == "Blax"
17
+ plural_filename_for_class(Blax).should == "blaxes"
18
+ singular_filename_for_class(Blax).should == "blax"
19
+
20
+ end
21
+
22
+ end
23
+
24
+ bla = Blax.new
25
+
26
+ end
27
+ end
@@ -1,102 +1,102 @@
1
- require 'spec_helper'
2
- describe GollumRails::Adapters::ActiveModel::Validation do
3
- before(:each) do
4
- @model = GollumRails::Adapters::ActiveModel::Validation.new
5
-
6
- end
7
- it "should object types" do
8
- test = {}
9
- test[:boolean] = true
10
- test[:string] = "Stringity"
11
- test[:integer] = 1
12
- test[:hash] = {}
13
- test[:array] = []
14
- test[:object] = Object
15
- @model.validate do |sm|
16
- sm.test(test[:string], "type=String").should be_true
17
- sm.test(test[:array], "type=Integer").should be_false
18
- sm.test(test[:string], "type=Object").should be_true
19
- sm.test(test[:hash], "type=String").should be_false
20
- sm.test(test[:integer], "type=Integer").should be_true
21
- sm.test(test[:integer], "type=Object").should be_true
22
- sm.test(test[:boolean], "type=Object").should be_true
23
- sm.test(test[:boolean], "type=Boolean").should be_true
24
- sm.test(test[:boolean], "type=TrueClass").should be_true
25
- sm.test(test[:boolean], "type=FalseClass").should be_false
26
- sm.test(test[:object], "type=Object").should be_true
27
- sm.test(test[:array], "type=Array").should be_true
28
- sm.test(test[:array], "type=Boolean").should be_false
29
- sm.test(test, "type=Hash").should be_true
30
- end
31
- end
32
- it "should test module Boolean" do
33
- @model.test(true, "type=Boolean").should be_true
34
- @model.test(false, "type=Boolean").should be_true
35
- @model.test(true, "type=TrueClass").should be_true
36
- @model.test(false, "type=FalseClass").should be_true
37
- end
38
-
39
- it "should test the maxlen" do
40
- @model.validate do |sm|
41
- sm.test("stringvalue", "min=20").should be_false
42
- sm.test("stringvalue", "max=200").should be_true
43
- sm.test(1, "min=2").should be_false
44
- sm.test(2, "max=4").should be_true
45
- end
46
- end
47
- it "should test the presence validator" do
48
- @model.validate do |sm|
49
- sm.test([ ], "present=true").should be_false
50
- sm.test(nil, "presence=true").should be_false
51
- sm.test("test", "presence=true").should be_true
52
- end
53
- end
54
- it "tests chaining" do
55
- @model.validate do |sm|
56
- sm.test("google.de", "type=String,presence=true").should be_true
57
- sm.test("google.com", "type=Integer,presence=true").should be_false
58
- sm.test([ ], "type=Object,presence=true").should be_false
59
- sm.test("google.de", "type=String,min=1,max=20,presence=true").should be_true
60
- sm.test("google.de", "type=String,min=20,max=40").should be_false
61
- sm.test(1, "type=Integer,min=1,max=20").should be_true
62
- end
63
- end
64
- it "should test error message output" do
65
- preset = "google.de"
66
- @model.test(preset, "min=20")
67
- @model.error[:variable][0].should == "is too short (minimum is 20 characters)"
68
-
69
- @model.test preset, "type=Integer"
70
- @model.error[:type][0].should == "not a kind of given class Integer"
71
-
72
- @model.test preset, "max=2"
73
- #is too long (maximum is 2 characters)
74
- @model.error[:variable][0].should == "is too long (maximum is 2 characters)"
75
-
76
-
77
-
78
- end
79
-
80
- it "should test the performance" do
81
- @model.validate do |sm|
82
- 100.times do
83
- expect do
84
- sm.test("veryshortstring", "presence=true,max=2,min=1")
85
- end.to take_less_than(0.1).seconds
86
- end
87
- end
88
- end
89
-
90
- it "should test the blank param" do
91
- @model.validate do |sm|
92
- #sm.test("string")
93
- end
94
- end
95
- it "should test errors" do
96
- @model.validate do |sm|
97
- expect{sm.test("string", "presence!string")}.to raise_error GollumRails::Adapters::ActiveModel::Error
98
- sm.test("string", "nobla=tebla").should be_true
99
- sm.test("string", "type=123!").should be_false
100
- end
101
- end
102
- end
1
+ require 'spec_helper'
2
+ describe GollumRails::Adapters::ActiveModel::Validation do
3
+ before(:each) do
4
+ @model = GollumRails::Adapters::ActiveModel::Validation.new
5
+
6
+ end
7
+ it "should object types" do
8
+ test = {}
9
+ test[:boolean] = true
10
+ test[:string] = "Stringity"
11
+ test[:integer] = 1
12
+ test[:hash] = {}
13
+ test[:array] = []
14
+ test[:object] = Object
15
+ @model.validate do |sm|
16
+ sm.test(test[:string], "type=String").should be_true
17
+ sm.test(test[:array], "type=Integer").should be_false
18
+ sm.test(test[:string], "type=Object").should be_true
19
+ sm.test(test[:hash], "type=String").should be_false
20
+ sm.test(test[:integer], "type=Integer").should be_true
21
+ sm.test(test[:integer], "type=Object").should be_true
22
+ sm.test(test[:boolean], "type=Object").should be_true
23
+ sm.test(test[:boolean], "type=Boolean").should be_true
24
+ sm.test(test[:boolean], "type=TrueClass").should be_true
25
+ sm.test(test[:boolean], "type=FalseClass").should be_false
26
+ sm.test(test[:object], "type=Object").should be_true
27
+ sm.test(test[:array], "type=Array").should be_true
28
+ sm.test(test[:array], "type=Boolean").should be_false
29
+ sm.test(test, "type=Hash").should be_true
30
+ end
31
+ end
32
+ it "should test module Boolean" do
33
+ @model.test(true, "type=Boolean").should be_true
34
+ @model.test(false, "type=Boolean").should be_true
35
+ @model.test(true, "type=TrueClass").should be_true
36
+ @model.test(false, "type=FalseClass").should be_true
37
+ end
38
+
39
+ it "should test the maxlen" do
40
+ @model.validate do |sm|
41
+ sm.test("stringvalue", "min=20").should be_false
42
+ sm.test("stringvalue", "max=200").should be_true
43
+ sm.test(1, "min=2").should be_false
44
+ sm.test(2, "max=4").should be_true
45
+ end
46
+ end
47
+ it "should test the presence validator" do
48
+ @model.validate do |sm|
49
+ sm.test([ ], "present=true").should be_false
50
+ sm.test(nil, "presence=true").should be_false
51
+ sm.test("test", "presence=true").should be_true
52
+ end
53
+ end
54
+ it "tests chaining" do
55
+ @model.validate do |sm|
56
+ sm.test("google.de", "type=String,presence=true").should be_true
57
+ sm.test("google.com", "type=Integer,presence=true").should be_false
58
+ sm.test([ ], "type=Object,presence=true").should be_false
59
+ sm.test("google.de", "type=String,min=1,max=20,presence=true").should be_true
60
+ sm.test("google.de", "type=String,min=20,max=40").should be_false
61
+ sm.test(1, "type=Integer,min=1,max=20").should be_true
62
+ end
63
+ end
64
+ it "should test error message output" do
65
+ preset = "google.de"
66
+ @model.test(preset, "min=20")
67
+ @model.error[:variable][0].should == "is too short (minimum is 20 characters)"
68
+
69
+ @model.test preset, "type=Integer"
70
+ @model.error[:type][0].should == "not a kind of given class Integer"
71
+
72
+ @model.test preset, "max=2"
73
+ #is too long (maximum is 2 characters)
74
+ @model.error[:variable][0].should == "is too long (maximum is 2 characters)"
75
+
76
+
77
+
78
+ end
79
+
80
+ it "should test the performance" do
81
+ @model.validate do |sm|
82
+ 100.times do
83
+ expect do
84
+ sm.test("veryshortstring", "presence=true,max=2,min=1")
85
+ end.to take_less_than(0.1).seconds
86
+ end
87
+ end
88
+ end
89
+
90
+ it "should test the blank param" do
91
+ @model.validate do |sm|
92
+ #sm.test("string")
93
+ end
94
+ end
95
+ it "should test errors" do
96
+ @model.validate do |sm|
97
+ expect{sm.test("string", "presence!string")}.to raise_error GollumRails::Adapters::ActiveModel::Error
98
+ sm.test("string", "nobla=tebla").should be_true
99
+ sm.test("string", "type=123!").should be_false
100
+ end
101
+ end
102
+ end
File without changes
@@ -1,15 +1,15 @@
1
- require 'spec_helper'
2
-
3
- describe GollumRails::Adapters::Gollum::Connector do
4
- before(:each) do
5
- @class = GollumRails::Adapters::Gollum::Connector
6
- end
7
-
8
- it "should test the Wiki class connector" do
9
- @class.wiki_class.should == GollumRails::Adapters::Gollum::Wiki
10
- end
11
- it "should test the Page class connector" do
12
- @class.page_class.should == GollumRails::Adapters::Gollum::Page
13
- end
14
-
15
- end
1
+ require 'spec_helper'
2
+
3
+ describe GollumRails::Adapters::Gollum::Connector do
4
+ before(:each) do
5
+ @class = GollumRails::Adapters::Gollum::Connector
6
+ end
7
+
8
+ it "should test the Wiki class connector" do
9
+ @class.wiki_class.should == GollumRails::Adapters::Gollum::Wiki
10
+ end
11
+ it "should test the Page class connector" do
12
+ @class.page_class.should == GollumRails::Adapters::Gollum::Page
13
+ end
14
+
15
+ end
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
2
-
3
- describe GollumRails::Adapters::ActiveModel::Error do
4
- it "should test the error throwing" do
5
- expect{raise GollumRails::Adapters::ActiveModel::Error.new 'test', 'no'}.to raise_error GollumRails::Adapters::ActiveModel::Error
6
- end
7
- end
1
+ require 'spec_helper'
2
+
3
+ describe GollumRails::Adapters::ActiveModel::Error do
4
+ it "should test the error throwing" do
5
+ expect{raise GollumRails::Adapters::ActiveModel::Error.new 'test', 'no'}.to raise_error GollumRails::Adapters::ActiveModel::Error
6
+ end
7
+ end
@@ -1,89 +1,89 @@
1
- require 'spec_helper'
2
- describe GollumRails::Adapters::Gollum::Page do
3
- before(:each) do
4
- @commit = {
5
- :message => 'page action',
6
- :name => 'The Mosny',
7
- :email => 'mosny@zyg.li'
8
- }
9
-
10
- @location = "#{File.dirname(__FILE__)}/../../../utils/wiki.git"
11
- @repo = Grit::Repo.init_bare @location
12
- @wiki = GollumRails::Adapters::Gollum::Wiki.new @repo
13
- @page = GollumRails::Adapters::Gollum::Page.new
14
- end
15
- it "should initialize the correct wiki" do
16
- location = "#{File.dirname(__FILE__)}/../../../utils/wiki.git"
17
- repo = Grit::Repo.init_bare location
18
- wiki = GollumRails::Adapters::Gollum::Wiki.new repo
19
- page = GollumRails::Adapters::Gollum::Page.new
20
- page.wiki.should be_instance_of Gollum::Wiki
21
- end
22
- it "should create a new page" do
23
- location = "#{File.dirname(__FILE__)}/../../../utils/wiki.git"
24
- repo = Grit::Repo.init_bare location
25
- wiki = GollumRails::Adapters::Gollum::Wiki.new repo
26
- page = GollumRails::Adapters::Gollum::Page.new
27
- page.new_page("testpage", "content",:markdown, @commit ).should be_instance_of Gollum::Page
28
- page.delete_page(@commit)
29
- end
30
-
31
- it "should delete an existing page" do
32
- page = @page.new_page 'testpage', 'content', :markdown, @commit
33
- @page.delete_page(@commit,page).should be_instance_of String
34
-
35
- @page.new_page 'testpage', 'content', :markdown, @commit
36
- @page.delete_page(@commit).should be_instance_of String
37
- end
38
- it "should update an existing page" do
39
- @page.new_page 'testpage', 'content', :markdown, @commit
40
- page = {}
41
- page[:name] = 'test'
42
- page[:format] = :markdown
43
- page[:content] = "content"
44
- @page.update_page(page, @commit)
45
-
46
- page = []
47
- expect{@page.update_page(page, @commit)}.to raise_error GollumRails::Adapters::Gollum::Error
48
-
49
- page = {}
50
- page[:content] = "test"
51
- @page.update_page(page, @commit).raw_data.should == page[:content]
52
-
53
- page = {}
54
- page[:name] = "test"
55
- @page.update_page(page, @commit).name.should == page[:name]
56
-
57
- page = {}
58
- page[:format] = :wiki
59
- @page.update_page(page, @commit).format.should == :mediawiki
60
-
61
-
62
-
63
- @page.delete_page(@commit)
64
- end
65
- it "should find a page" do
66
- @page.new_page 'content_page', 'content', :markdown, @commit
67
-
68
- @page.find_page("content_page")
69
- @page.delete_page(@commit)
70
- end
71
- it "should test the commit methods" do
72
- @page.new_page 'content_page', 'content', :markdown, @commit
73
- @page.page_last_edited_date.should be_instance_of Time
74
- @page.page_created.should be_instance_of Time
75
- @page.page_last_commit.should be_instance_of Grit::Commit
76
- @page.page_commit(@page.page.versions.first.id).should be_instance_of Grit::Commit
77
- @page.page_commit_date(@page.page.versions.first.id).should be_instance_of Time
78
- @page.page_first_commit.should be_instance_of Grit::Commit
79
- @page.delete_page(@commit)
80
- end
81
- it "should test the error throwing" do
82
- expect{@page.page_last_commit}.to raise_error GollumRails::Adapters::Gollum::Error
83
- expect{@page.page_first_commit}.to raise_error GollumRails::Adapters::Gollum::Error
84
- expect{@page.page_last_edited_date}.to raise_error GollumRails::Adapters::Gollum::Error
85
- expect{@page.page_created}.to raise_error GollumRails::Adapters::Gollum::Error
86
- expect{@page.page_commit(1)}.to raise_error GollumRails::Adapters::Gollum::Error
87
- expect{@page.page_commit_date(1)}.to raise_error GollumRails::Adapters::Gollum::Error
88
- end
89
- end
1
+ require 'spec_helper'
2
+ describe GollumRails::Adapters::Gollum::Page do
3
+ before(:each) do
4
+ @commit = {
5
+ :message => 'page action',
6
+ :name => 'The Mosny',
7
+ :email => 'mosny@zyg.li'
8
+ }
9
+
10
+ @location = "#{File.dirname(__FILE__)}/../../../utils/wiki.git"
11
+ @repo = Grit::Repo.init_bare @location
12
+ @wiki = GollumRails::Adapters::Gollum::Wiki.new @repo
13
+ @page = GollumRails::Adapters::Gollum::Page.new
14
+ end
15
+ it "should initialize the correct wiki" do
16
+ location = "#{File.dirname(__FILE__)}/../../../utils/wiki.git"
17
+ repo = Grit::Repo.init_bare location
18
+ wiki = GollumRails::Adapters::Gollum::Wiki.new repo
19
+ page = GollumRails::Adapters::Gollum::Page.new
20
+ page.wiki.should be_instance_of Gollum::Wiki
21
+ end
22
+ it "should create a new page" do
23
+ location = "#{File.dirname(__FILE__)}/../../../utils/wiki.git"
24
+ repo = Grit::Repo.init_bare location
25
+ wiki = GollumRails::Adapters::Gollum::Wiki.new repo
26
+ page = GollumRails::Adapters::Gollum::Page.new
27
+ page.new_page("testpage", "content",:markdown, @commit ).should be_instance_of Gollum::Page
28
+ page.delete_page(@commit)
29
+ end
30
+
31
+ it "should delete an existing page" do
32
+ page = @page.new_page 'testpage', 'content', :markdown, @commit
33
+ @page.delete_page(@commit,page).should be_instance_of String
34
+
35
+ @page.new_page 'testpage', 'content', :markdown, @commit
36
+ @page.delete_page(@commit).should be_instance_of String
37
+ end
38
+ it "should update an existing page" do
39
+ @page.new_page 'testpage', 'content', :markdown, @commit
40
+ page = {}
41
+ page[:name] = 'test'
42
+ page[:format] = :markdown
43
+ page[:content] = "content"
44
+ @page.update_page(page, @commit)
45
+
46
+ page = []
47
+ expect{@page.update_page(page, @commit)}.to raise_error GollumRails::Adapters::Gollum::Error
48
+
49
+ page = {}
50
+ page[:content] = "test"
51
+ @page.update_page(page, @commit).raw_data.should == page[:content]
52
+
53
+ page = {}
54
+ page[:name] = "test"
55
+ @page.update_page(page, @commit).name.should == page[:name]
56
+
57
+ page = {}
58
+ page[:format] = :wiki
59
+ @page.update_page(page, @commit).format.should == :mediawiki
60
+
61
+
62
+
63
+ @page.delete_page(@commit)
64
+ end
65
+ it "should find a page" do
66
+ @page.new_page 'content_page', 'content', :markdown, @commit
67
+
68
+ @page.find_page("content_page")
69
+ @page.delete_page(@commit)
70
+ end
71
+ it "should test the commit methods" do
72
+ @page.new_page 'content_page', 'content', :markdown, @commit
73
+ @page.page_last_edited_date.should be_instance_of Time
74
+ @page.page_created.should be_instance_of Time
75
+ @page.page_last_commit.should be_instance_of Grit::Commit
76
+ @page.page_commit(@page.page.versions.first.id).should be_instance_of Grit::Commit
77
+ @page.page_commit_date(@page.page.versions.first.id).should be_instance_of Time
78
+ @page.page_first_commit.should be_instance_of Grit::Commit
79
+ @page.delete_page(@commit)
80
+ end
81
+ it "should test the error throwing" do
82
+ expect{@page.page_last_commit}.to raise_error GollumRails::Adapters::Gollum::Error
83
+ expect{@page.page_first_commit}.to raise_error GollumRails::Adapters::Gollum::Error
84
+ expect{@page.page_last_edited_date}.to raise_error GollumRails::Adapters::Gollum::Error
85
+ expect{@page.page_created}.to raise_error GollumRails::Adapters::Gollum::Error
86
+ expect{@page.page_commit(1)}.to raise_error GollumRails::Adapters::Gollum::Error
87
+ expect{@page.page_commit_date(1)}.to raise_error GollumRails::Adapters::Gollum::Error
88
+ end
89
+ end