gollum_rails 1.4.0.rc1 → 1.4.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -6
  3. data/Gemfile.lock +2 -1
  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 +1 -1
  9. data/lib/core_ext/string.rb +7 -10
  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 +1 -1
  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/modules/hash.rb +33 -33
  26. data/lib/gollum_rails/modules/loader.rb +5 -5
  27. data/lib/gollum_rails/page.rb +266 -266
  28. data/lib/gollum_rails/setup.rb +81 -81
  29. data/lib/grit/git-ruby/internal/pack.rb +397 -397
  30. data/spec/gollum_rails/adapters/activemodel/error_spec.rb +11 -11
  31. data/spec/gollum_rails/adapters/activemodel/naming_spec.rb +27 -27
  32. data/spec/gollum_rails/adapters/activemodel/validation_unused.rb +102 -102
  33. data/spec/gollum_rails/adapters/gollum/committer_spec.rb +0 -0
  34. data/spec/gollum_rails/adapters/gollum/connector_spec.rb +15 -15
  35. data/spec/gollum_rails/adapters/gollum/error_spec.rb +7 -7
  36. data/spec/gollum_rails/adapters/gollum/page_spec.rb +89 -89
  37. data/spec/gollum_rails/adapters/gollum/wiki_spec.rb +27 -27
  38. data/spec/gollum_rails/modules/hash_spec.rb +31 -31
  39. data/spec/gollum_rails/page_spec.rb +207 -207
  40. data/spec/gollum_rails/respository_spec.rb +0 -0
  41. data/spec/gollum_rails/setup_spec.rb +44 -44
  42. data/spec/gollum_rails/wiki_spec.rb +0 -0
  43. data/spec/spec.opts +3 -3
  44. data/spec/spec_helper.rb +43 -43
  45. metadata +2 -2
@@ -1,15 +1,15 @@
1
- module GollumRails
2
- module Adapters
3
- module ActiveModel
4
-
5
- # Own implemented Boolean method for validating
6
- module Boolean; end
7
-
8
- # inherit
9
- class ::TrueClass; include Boolean; end
10
-
11
- # inherit
12
- class ::FalseClass; include Boolean; end
13
- end
14
- end
15
- end
1
+ module GollumRails
2
+ module Adapters
3
+ module ActiveModel
4
+
5
+ # Own implemented Boolean method for validating
6
+ module Boolean; end
7
+
8
+ # inherit
9
+ class ::TrueClass; include Boolean; end
10
+
11
+ # inherit
12
+ class ::FalseClass; include Boolean; end
13
+ end
14
+ end
15
+ end
@@ -1,27 +1,27 @@
1
- module GollumRails
2
- module Adapters
3
- module ActiveModel
4
-
5
- # Error handling class, with several exception types and debug / info messages
6
- class Error < ::GollumRails::GollumInternalError
7
- extend ::ActiveModel::Naming
8
-
9
- ######
10
- public
11
- ######
12
-
13
- # Gets/Sets the Error
14
- attr_reader :errors
15
-
16
- # Initializes a new Exception
17
- #
18
- def initialize(name, message = nil, priority = :crit)
19
- super("Error thrown: #{name},\n\n #{(message)}")
20
- end
21
-
22
-
23
- end
24
-
25
- end
26
- end
27
- end
1
+ module GollumRails
2
+ module Adapters
3
+ module ActiveModel
4
+
5
+ # Error handling class, with several exception types and debug / info messages
6
+ class Error < ::GollumRails::GollumInternalError
7
+ extend ::ActiveModel::Naming
8
+
9
+ ######
10
+ public
11
+ ######
12
+
13
+ # Gets/Sets the Error
14
+ attr_reader :errors
15
+
16
+ # Initializes a new Exception
17
+ #
18
+ def initialize(name, message = nil, priority = :crit)
19
+ super("Error thrown: #{name},\n\n #{(message)}")
20
+ end
21
+
22
+
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -1,42 +1,42 @@
1
-
2
- module GollumRails
3
- module Adapters
4
- module ActiveModel
5
-
6
- # Naming class for all Classes, extending the AdtiveModel::Naming module
7
- #
8
- # provides base functionality like filenames, classnames, variable-, instancenames
9
- module Naming
10
-
11
- # Outputs the currents class name
12
- #
13
- # Returns a String
14
- def class_name
15
- self.class.name
16
- end
17
-
18
- # Gets the pluralized filename for an object
19
- #
20
- # Returns a String
21
- def plural_filename_for_class(name)
22
- return ::ActiveModel::Naming.plural name if name.model_name
23
- return nil
24
- end
25
-
26
- # Gets the singularized filename for an object
27
- #
28
- # Returns a String
29
- def singular_filename_for_class(name)
30
- return ::ActiveModel::Naming.singular name if name.model_name
31
- return nil
32
- end
33
-
34
- # dummy namespace class
35
- class NameSpace
36
- extend ::ActiveModel::Naming
37
- end
38
- end
39
-
40
- end
41
- end
42
- end
1
+
2
+ module GollumRails
3
+ module Adapters
4
+ module ActiveModel
5
+
6
+ # Naming class for all Classes, extending the AdtiveModel::Naming module
7
+ #
8
+ # provides base functionality like filenames, classnames, variable-, instancenames
9
+ module Naming
10
+
11
+ # Outputs the currents class name
12
+ #
13
+ # Returns a String
14
+ def class_name
15
+ self.class.name
16
+ end
17
+
18
+ # Gets the pluralized filename for an object
19
+ #
20
+ # Returns a String
21
+ def plural_filename_for_class(name)
22
+ return ::ActiveModel::Naming.plural name if name.model_name
23
+ return nil
24
+ end
25
+
26
+ # Gets the singularized filename for an object
27
+ #
28
+ # Returns a String
29
+ def singular_filename_for_class(name)
30
+ return ::ActiveModel::Naming.singular name if name.model_name
31
+ return nil
32
+ end
33
+
34
+ # dummy namespace class
35
+ class NameSpace
36
+ extend ::ActiveModel::Naming
37
+ end
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -1,54 +1,54 @@
1
- # ~*~ encoding: utf-8 ~*~
2
- module GollumRails
3
- module Adapters
4
- # Gollum Wiki connector classes
5
- #
6
- #
7
- module Gollum
8
- autoload :Wiki, 'gollum_rails/adapters/gollum/wiki'
9
- autoload :Page, 'gollum_rails/adapters/gollum/page'
10
- autoload :Error, 'gollum_rails/adapters/gollum/error'
11
-
12
- # connector version
13
- VERSION="2.0.0"
14
-
15
- # Gollum connector class, keeping defaults!
16
- #
17
- class Connector
18
- class << self
19
- # Sets the page class used by all instances
20
- attr_writer :page_class
21
-
22
- # Sets the wiki class used by all instances
23
- attr_writer :wiki_class
24
-
25
- # Sets the applications status
26
- attr_writer :enabled
27
-
28
- # Gets the enabled status
29
- #
30
- # Returns a boolean value
31
- def enabled
32
- @enabled || false
33
- end
34
- # Gets the Globally used Page class or use a new one if not defined
35
- #
36
- #
37
- # Returns the internal page class or a fresh ::Gollum::Page
38
- def page_class
39
- @page_class || Page
40
- end
41
-
42
- # Gets the Globally used Page class or use a new one if not defined
43
- #
44
- #
45
- # Returns the internal page class or a fresh ::Gollum::Page
46
- def wiki_class
47
- @wiki_class || Wiki
48
- end
49
-
50
- end
51
- end
52
- end
53
- end
54
- end
1
+ # ~*~ encoding: utf-8 ~*~
2
+ module GollumRails
3
+ module Adapters
4
+ # Gollum Wiki connector classes
5
+ #
6
+ #
7
+ module Gollum
8
+ autoload :Wiki, 'gollum_rails/adapters/gollum/wiki'
9
+ autoload :Page, 'gollum_rails/adapters/gollum/page'
10
+ autoload :Error, 'gollum_rails/adapters/gollum/error'
11
+
12
+ # connector version
13
+ VERSION="2.0.0"
14
+
15
+ # Gollum connector class, keeping defaults!
16
+ #
17
+ class Connector
18
+ class << self
19
+ # Sets the page class used by all instances
20
+ attr_writer :page_class
21
+
22
+ # Sets the wiki class used by all instances
23
+ attr_writer :wiki_class
24
+
25
+ # Sets the applications status
26
+ attr_writer :enabled
27
+
28
+ # Gets the enabled status
29
+ #
30
+ # Returns a boolean value
31
+ def enabled
32
+ @enabled || false
33
+ end
34
+ # Gets the Globally used Page class or use a new one if not defined
35
+ #
36
+ #
37
+ # Returns the internal page class or a fresh ::Gollum::Page
38
+ def page_class
39
+ @page_class || Page
40
+ end
41
+
42
+ # Gets the Globally used Page class or use a new one if not defined
43
+ #
44
+ #
45
+ # Returns the internal page class or a fresh ::Gollum::Page
46
+ def wiki_class
47
+ @wiki_class || Wiki
48
+ end
49
+
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
File without changes
@@ -1,19 +1,19 @@
1
- module GollumRails
2
- module Adapters
3
- module Gollum
4
-
5
- # Gollum adapter Error handling class
6
- #
7
- # provides better errors
8
- class Error < ::StandardError
9
-
10
- # does the formatting of the Error message
11
- #
12
- #
13
- def initialize(error_message, urgence)
14
- super "#{urgence.upcase} :: #{error_message}"
15
- end
16
- end
17
- end
18
- end
19
- end
1
+ module GollumRails
2
+ module Adapters
3
+ module Gollum
4
+
5
+ # Gollum adapter Error handling class
6
+ #
7
+ # provides better errors
8
+ class Error < ::StandardError
9
+
10
+ # does the formatting of the Error message
11
+ #
12
+ #
13
+ def initialize(error_message, urgence)
14
+ super "#{urgence.upcase} :: #{error_message}"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,177 +1,177 @@
1
- module GollumRails
2
- module Adapters
3
- module Gollum
4
-
5
- # Main page class for the Gollum connector.
6
- #
7
- # It provides some awesome features for connecting gollum to gollum_rails such as:
8
- # * new_page
9
- # * find_page
10
- # * delete_page
11
- # * rename_page
12
- # * move_page
13
- # * first_page_commit
14
- # * page_creation time
15
- # * ...
16
- #
17
- class Page
18
-
19
- Connector.page_class = self
20
-
21
- # Gets / Sets current page
22
- attr_accessor :page
23
-
24
- # Gets / Sets the wiki
25
- attr_accessor :wiki
26
-
27
- # Initializer
28
- def initialize
29
- @wiki = Connector.wiki_class
30
- end
31
-
32
-
33
- # creates a new Page
34
- #
35
- # name - String
36
- # type - Symbol
37
- # content - Text
38
- # commit - Hash or instance of Committer
39
- #
40
- # Returns the commit id
41
- def new_page( name, content,type=:markdown, commit={} )
42
- @wiki.write_page name.to_s, type, content, commit if name
43
- @page = @wiki.page name
44
- @page
45
- end
46
-
47
- # updates an existing page
48
- #
49
- # new - Hash with changed data
50
- # commit - Hash or instance of Committer
51
- # old - also an instance of self
52
- #
53
- # Returns the commit id
54
- def update_page( new, commit={}, old=nil)
55
- if new.is_a?(Hash)
56
- commit_id = @wiki.update_page (old||@page),
57
- new[:name]||@page.name,
58
- new[:format]||@page.format,
59
- new[:content]||@page.raw_data,
60
- commit
61
- else
62
- raise Error.new "commit must be a Hash. #{new.class} given", :crit
63
- end
64
-
65
- # this is very ugly. Shouldn't gollum return the new page?
66
- @page = @page.find(new[:name]||@page.name, commit_id)
67
- @page
68
- end
69
-
70
- # deletes an existing page
71
- #
72
- # page - instance of self
73
- # commit - Hash or instance of Committer
74
- #
75
- # Returns the commit id
76
- def delete_page( commit={}, page = nil )
77
- @wiki.delete_page (page||@page), commit
78
- end
79
-
80
- # renames an existing page
81
- #
82
- # page - instance of myself
83
- # newname - new pagename
84
- # commit - Hash or instance of Committer
85
- #
86
- # Returns the commit id
87
- def rename_page( page, newname, commit={} )
88
-
89
- end
90
-
91
- # finds all versions of a page
92
- #
93
- # name - the pagename to search
94
- #
95
- # Returns the Gollum::Page class
96
- def find_page(name)
97
- @wiki.page ::Gollum::Page.cname(name)
98
- end
99
-
100
- # moves an existing page
101
- #
102
- # TODO:
103
- # * implement
104
- def move_page()
105
- end
106
-
107
- # gets page last edit date
108
- #
109
- # Returns an instance of Time
110
- def page_last_edited_date
111
- if @page
112
- return @page.versions.first.authored_date
113
- else
114
- raise Error.new "page cannot be empty for #{__method__}", :high
115
- end
116
- end
117
-
118
- # gets the latest commit
119
- #
120
- # Returns an instance of Grit::Commit
121
- def page_last_commit
122
- if @page
123
- return @page.versions.first
124
- else
125
- raise Error.new "page cannot be empty for #{__method__}", :high
126
- end
127
- end
128
-
129
- # gets the creation date of the page
130
- #
131
- # Returns an instance of Time
132
- def page_created
133
- if @page
134
- return @page.versions.last.authored_date
135
- else
136
- raise Error.new "page cannot be empty for #{__method__}", :high
137
- end
138
-
139
- end
140
-
141
- # gets the first page commit
142
- #
143
- # Returns an instance of Grit::Commit
144
- def page_first_commit
145
- if @page
146
- return @page.versions.last
147
- else
148
- raise Error.new "page cannot be empty for #{__method__}", :high
149
- end
150
- end
151
-
152
- # gets a specific commit version
153
- #
154
- # Returns an instance of Grit::Commit
155
- def page_commit(id)
156
- if @page
157
- return @page.versions.each{|v| return v if v.id == id}
158
- else
159
- raise Error.new "page cannot be empty for #{__method__}", :high
160
- end
161
- end
162
-
163
- # gets a specific commit time
164
- #
165
- # Returns an instance of Time
166
- def page_commit_date(id)
167
- if @page
168
- return @page.versions.each{|v| return v.authored_date if v.id == id}
169
- else
170
- raise Error.new "page cannot be empty for #{__method__}", :high
171
- end
172
- end
173
-
174
- end
175
- end
176
- end
177
- end
1
+ module GollumRails
2
+ module Adapters
3
+ module Gollum
4
+
5
+ # Main page class for the Gollum connector.
6
+ #
7
+ # It provides some awesome features for connecting gollum to gollum_rails such as:
8
+ # * new_page
9
+ # * find_page
10
+ # * delete_page
11
+ # * rename_page
12
+ # * move_page
13
+ # * first_page_commit
14
+ # * page_creation time
15
+ # * ...
16
+ #
17
+ class Page
18
+
19
+ Connector.page_class = self
20
+
21
+ # Gets / Sets current page
22
+ attr_accessor :page
23
+
24
+ # Gets / Sets the wiki
25
+ attr_accessor :wiki
26
+
27
+ # Initializer
28
+ def initialize
29
+ @wiki = Connector.wiki_class
30
+ end
31
+
32
+
33
+ # creates a new Page
34
+ #
35
+ # name - String
36
+ # type - Symbol
37
+ # content - Text
38
+ # commit - Hash or instance of Committer
39
+ #
40
+ # Returns the commit id
41
+ def new_page( name, content,type=:markdown, commit={} )
42
+ @wiki.write_page name.to_s, type, content, commit if name
43
+ @page = @wiki.page name
44
+ @page
45
+ end
46
+
47
+ # updates an existing page
48
+ #
49
+ # new - Hash with changed data
50
+ # commit - Hash or instance of Committer
51
+ # old - also an instance of self
52
+ #
53
+ # Returns the commit id
54
+ def update_page( new, commit={}, old=nil)
55
+ if new.is_a?(Hash)
56
+ commit_id = @wiki.update_page (old||@page),
57
+ new[:name]||@page.name,
58
+ new[:format]||@page.format,
59
+ new[:content]||@page.raw_data,
60
+ commit
61
+ else
62
+ raise Error.new "commit must be a Hash. #{new.class} given", :crit
63
+ end
64
+
65
+ # this is very ugly. Shouldn't gollum return the new page?
66
+ @page = @page.find(new[:name]||@page.name, commit_id)
67
+ @page
68
+ end
69
+
70
+ # deletes an existing page
71
+ #
72
+ # page - instance of self
73
+ # commit - Hash or instance of Committer
74
+ #
75
+ # Returns the commit id
76
+ def delete_page( commit={}, page = nil )
77
+ @wiki.delete_page (page||@page), commit
78
+ end
79
+
80
+ # renames an existing page
81
+ #
82
+ # page - instance of myself
83
+ # newname - new pagename
84
+ # commit - Hash or instance of Committer
85
+ #
86
+ # Returns the commit id
87
+ def rename_page( page, newname, commit={} )
88
+
89
+ end
90
+
91
+ # finds all versions of a page
92
+ #
93
+ # name - the pagename to search
94
+ #
95
+ # Returns the Gollum::Page class
96
+ def find_page(name)
97
+ @wiki.page ::Gollum::Page.cname(name)
98
+ end
99
+
100
+ # moves an existing page
101
+ #
102
+ # TODO:
103
+ # * implement
104
+ def move_page()
105
+ end
106
+
107
+ # gets page last edit date
108
+ #
109
+ # Returns an instance of Time
110
+ def page_last_edited_date
111
+ if @page
112
+ return @page.versions.first.authored_date
113
+ else
114
+ raise Error.new "page cannot be empty for #{__method__}", :high
115
+ end
116
+ end
117
+
118
+ # gets the latest commit
119
+ #
120
+ # Returns an instance of Grit::Commit
121
+ def page_last_commit
122
+ if @page
123
+ return @page.versions.first
124
+ else
125
+ raise Error.new "page cannot be empty for #{__method__}", :high
126
+ end
127
+ end
128
+
129
+ # gets the creation date of the page
130
+ #
131
+ # Returns an instance of Time
132
+ def page_created
133
+ if @page
134
+ return @page.versions.last.authored_date
135
+ else
136
+ raise Error.new "page cannot be empty for #{__method__}", :high
137
+ end
138
+
139
+ end
140
+
141
+ # gets the first page commit
142
+ #
143
+ # Returns an instance of Grit::Commit
144
+ def page_first_commit
145
+ if @page
146
+ return @page.versions.last
147
+ else
148
+ raise Error.new "page cannot be empty for #{__method__}", :high
149
+ end
150
+ end
151
+
152
+ # gets a specific commit version
153
+ #
154
+ # Returns an instance of Grit::Commit
155
+ def page_commit(id)
156
+ if @page
157
+ return @page.versions.each{|v| return v if v.id == id}
158
+ else
159
+ raise Error.new "page cannot be empty for #{__method__}", :high
160
+ end
161
+ end
162
+
163
+ # gets a specific commit time
164
+ #
165
+ # Returns an instance of Time
166
+ def page_commit_date(id)
167
+ if @page
168
+ return @page.versions.each{|v| return v.authored_date if v.id == id}
169
+ else
170
+ raise Error.new "page cannot be empty for #{__method__}", :high
171
+ end
172
+ end
173
+
174
+ end
175
+ end
176
+ end
177
+ end