Module: GollumRails::Core
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#assign_attributes(new_attributes) ⇒ Object
Allows you to set all the attributes by passing in a hash of attributes with keys matching the attribute name.
-
#canonicalized_filename ⇒ Object
Gets a canonicalized filename of the page.
-
#cname ⇒ Object
:nodoc:.
-
#compare_commits(sha1, sha2 = nil) ⇒ Object
Compare 2 Commits.
-
#current_version(long = false) ⇒ Object
Gets the version of current commit.
-
#file_name ⇒ Object
:nodoc:.
-
#full_path ⇒ Object
:nodoc:.
-
#history ⇒ Object
Gets the history of current gollum_page.
-
#html_data ⇒ Object
Gets formatted_data for current Gollum::Page.
-
#initialize(attrs = {}) {|_self| ... } ⇒ Object
Initializes a new Page.
-
#last_changed_by ⇒ Object
Gets the last modified by Gollum::Committer.
-
#path_name ⇒ Object
:nodoc:.
-
#preview(format = :markdown) ⇒ Object
Previews the page - Mostly used if you want to see what you do before saving.
-
#raw_data ⇒ Object
Gets raw_data for current Gollum::Page.
-
#sub_page? ⇒ Boolean
Checks if current page is a subpage.
-
#title ⇒ Object
Gets the title for current Gollum::Page.
-
#url ⇒ Object
Gets the url for current page from Gollum::Page.
-
#url_path ⇒ Object
:nodoc:.
Instance Method Details
#assign_attributes(new_attributes) ⇒ Object
Allows you to set all the attributes by passing in a hash of attributes with keys matching the attribute name
new_attributes - Hash - Hash of arguments
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/gollum_rails/core.rb', line 53 def assign_attributes(new_attributes) if !new_attributes.respond_to?(:stringify_keys) raise ArgumentError, "When assigning attributes, you must pass a hash as an argument." end return if new_attributes.blank? attributes = new_attributes.stringify_keys attributes.each do |k, v| _assign_attribute(k, v) end end |
#canonicalized_filename ⇒ Object
Gets a canonicalized filename of the page
90 91 92 |
# File 'lib/gollum_rails/core.rb', line 90 def canonicalized_filename Gollum::Page.canonicalize_filename(name) end |
#cname ⇒ Object
:nodoc:
85 86 87 |
# File 'lib/gollum_rails/core.rb', line 85 def cname #:nodoc: Gollum::Page.cname(self.name) end |
#compare_commits(sha1, sha2 = nil) ⇒ Object
Compare 2 Commits.
sha1 - SHA1 sha2 - SHA1
160 161 162 |
# File 'lib/gollum_rails/core.rb', line 160 def compare_commits(sha1,sha2=nil) Page.wiki.full_reverse_diff_for(@gollum_page,sha1,sha2) end |
#current_version(long = false) ⇒ Object
Gets the version of current commit
180 181 182 183 184 185 186 187 188 |
# File 'lib/gollum_rails/core.rb', line 180 def current_version(long=false) return nil unless persisted? unless long @gollum_page.version_short else @gollum_page.version.to_s end end |
#file_name ⇒ Object
:nodoc:
81 82 83 |
# File 'lib/gollum_rails/core.rb', line 81 def file_name #:nodoc: full_path.last end |
#full_path ⇒ Object
:nodoc:
77 78 79 |
# File 'lib/gollum_rails/core.rb', line 77 def full_path #:nodoc: File.split(name) end |
#history ⇒ Object
Gets the history of current gollum_page
Returns an Array
144 145 146 147 |
# File 'lib/gollum_rails/core.rb', line 144 def history return nil unless persisted? gollum_page.versions end |
#html_data ⇒ Object
Gets formatted_data for current Gollum::Page
Returns a String
131 132 133 |
# File 'lib/gollum_rails/core.rb', line 131 def html_data gollum_page.formatted_data end |
#initialize(attrs = {}) {|_self| ... } ⇒ Object
Initializes a new Page
attrs - Hash of attributes
commit must be given to perform any page action!
41 42 43 44 45 46 |
# File 'lib/gollum_rails/core.rb', line 41 def initialize(attrs = {}) assign_attributes(attrs) _update_page_attributes if attrs[:gollum_page] yield self if block_given? run_callbacks :initialize unless _initialize_callbacks.empty? end |
#last_changed_by ⇒ Object
Gets the last modified by Gollum::Committer
Returns a String
152 153 154 |
# File 'lib/gollum_rails/core.rb', line 152 def last_changed_by "%s <%s>" % [history.last..name, history.last..email] end |
#path_name ⇒ Object
:nodoc:
71 72 73 74 75 |
# File 'lib/gollum_rails/core.rb', line 71 def path_name #:nodoc: f = full_path.first return '/' if f == '.' f end |
#preview(format = :markdown) ⇒ Object
Previews the page - Mostly used if you want to see what you do before saving
This is an extremely fast method! 1 rendering attempt take depending on the content about 0.001 (simple markdown) upto 0.004 (1000 chars markdown) seconds, which is quite good
format - Specify the format you want to render with see GollumRails::Core.selfself.format_supported?
for formats
Returns a String
105 106 107 |
# File 'lib/gollum_rails/core.rb', line 105 def preview(format=:markdown) wiki.preview_page(name, content, format).formatted_data end |
#raw_data ⇒ Object
Gets raw_data for current Gollum::Page
Returns a String
137 138 139 |
# File 'lib/gollum_rails/core.rb', line 137 def raw_data gollum_page.raw_data end |
#sub_page? ⇒ Boolean
Checks if current page is a subpage
173 174 175 176 |
# File 'lib/gollum_rails/core.rb', line 173 def sub_page? return nil unless persisted? @gollum_page.sub_page end |
#title ⇒ Object
Gets the title for current Gollum::Page
Returns a String
123 124 125 |
# File 'lib/gollum_rails/core.rb', line 123 def title gollum_page.title end |
#url ⇒ Object
Gets the url for current page from Gollum::Page
Returns a String
114 115 116 117 118 |
# File 'lib/gollum_rails/core.rb', line 114 def url if gollum_page gollum_page.url_path end end |
#url_path ⇒ Object
:nodoc:
67 68 69 |
# File 'lib/gollum_rails/core.rb', line 67 def url_path #:nodoc: File.split(url) end |