gollum_rails 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c03ff854db8019836bed34d394b4164929c5658
4
- data.tar.gz: e56ab20032a7e1a6aaa869b0e20b8a9ab3c2f454
3
+ metadata.gz: e28f59903e3501a35a990311a3289ffb7fabf8de
4
+ data.tar.gz: 6554db1a2ad83743510b428e527a12980e6eaa23
5
5
  SHA512:
6
- metadata.gz: e6794926269a51b059d16236781149fce0b31c7d20dde9c1a50af4b49cd6f64d8b58e4a1ab28cebca26549b94003817d91488fd3db8b9c20457bb4552b651fd7
7
- data.tar.gz: d485279f1c32145f0c3a0be000d1cf7dd1d473aa1971a5447f3c7a05bd8106228234d8375baf55a018ebaa7cf0b1c349dc46346e779fff174d8d95b65864d86d
6
+ metadata.gz: 6b69256e1cec596b51086ee56dfc83df954d4a15563ad3b476ec155d325620ed081fb4963941cfe2f3833d6dc92bd53ddb24157d6a7cb30868ee7fc108423c2b
7
+ data.tar.gz: 90f3315569e2cfc5d070e6424de6b24ccc4dc780e4e8fed8e55a1227cde3bb5a5495af1419301e66a4f2986de3fe3ae82d30e244267b1eedd366c784e49ae817
data/Gemfile.lock CHANGED
@@ -10,7 +10,7 @@ GIT
10
10
  PATH
11
11
  remote: .
12
12
  specs:
13
- gollum_rails (0.0.6)
13
+ gollum_rails (0.0.7)
14
14
  activemodel (~> 3.2.13)
15
15
  builder (~> 3.0.0)
16
16
  gollum-lib (~> 0.0.1)
data/README.md CHANGED
@@ -23,6 +23,7 @@ with gollum_rails you can:
23
23
  - Unix like operating system (OS X, Ubuntu, Debian, and more)
24
24
  - Will not work on Windows (see [gollum](https://github.com/github/gollum/blob/master/README.md#system-requirements))
25
25
 
26
+ ## [RUBY >= 2.0 READ THIS](https://github.com/nirnanaaa/gollum_rails/wiki/Ruby#ruby-2.0)
26
27
  ## [Installation](https://github.com/nirnanaaa/gollum_rails/wiki/Installation)
27
28
 
28
29
  ## [Usage](https://github.com/nirnanaaa/gollum_rails/wiki/Usage)
data/gollum_rails.gemspec CHANGED
@@ -4,7 +4,7 @@ Gem::Specification.new do |s|
4
4
  s.name = 'gollum_rails'
5
5
  s.rubyforge_project = s.name
6
6
 
7
- s.version = '0.0.6'
7
+ s.version = '0.0.7'
8
8
 
9
9
  s.summary = 'Combines the benefits from Gollum and Rails'
10
10
  s.description= 'Use all the benefits from Rails and combine them with the awesome Gollum wiki'
@@ -1,11 +1,16 @@
1
1
  require 'rails/generators'
2
2
 
3
3
  module GollumRails
4
+
5
+ # Generators for GollumRails
4
6
  module Generators
7
+
8
+ # Installation generator
5
9
  class InstallGenerator < ::Rails::Generators::Base
6
10
  source_root File.expand_path("../templates", __FILE__)
7
11
  desc "This generator will install gollum_rails"
8
12
 
13
+ # Installs the necessary files
9
14
  def install_application
10
15
  if File.exist? 'config/initializers/gollum.rb'
11
16
  puts <<-EOM
@@ -29,6 +29,9 @@ module GollumRails
29
29
  Wiki.new(location)
30
30
  end
31
31
 
32
+ # Forwards unknown methods to Gollum::Wiki
33
+ #
34
+ # may throw an Argument error or method missing
32
35
  def self.method_missing(name, *args)
33
36
  Connector.wiki_class.send(name, *args)
34
37
  end
@@ -26,6 +26,15 @@ module GollumRails
26
26
  # Sets the committer
27
27
  attr_writer :committer_class
28
28
 
29
+ # Sets the applications status
30
+ attr_writer :enabled
31
+
32
+ # Gets the enabled status
33
+ #
34
+ # Returns a boolean value
35
+ def enabled
36
+ @enabled || false
37
+ end
29
38
  # Gets the Globally used Page class or use a new one if not defined
30
39
  #
31
40
  #
@@ -12,11 +12,21 @@ module GollumRails
12
12
  # * delete
13
13
  # * find_or_initialize_by_naname
14
14
  #
15
- class Page < Adapters::ActiveModel::Callback
15
+ class Page
16
+ extend ::ActiveModel::Callbacks
16
17
  include ::ActiveModel::Conversion
17
18
  extend ::ActiveModel::Naming
18
19
 
19
20
 
21
+ # Callback for save
22
+ define_model_callbacks :save
23
+
24
+ # Callback for update
25
+ define_model_callbacks :update
26
+
27
+ # Callback for delete
28
+ define_model_callbacks :delete
29
+
20
30
  # static
21
31
  class << self
22
32
  # Gets / Sets the gollum page
@@ -33,8 +43,12 @@ module GollumRails
33
43
  #
34
44
  # commit must be given to perform any page action!
35
45
  def initialize(attrs = {})
36
- attrs.each{|k,v| self.instance_variable_set("@#{k}", v)}
37
- attrs.each{|k,v| self.class.validator.instance_variable_set("@#{k}", v)}
46
+ if Adapters::Gollum::Connector.enabled
47
+ attrs.each{|k,v| self.instance_variable_set("@#{k}", v)}
48
+ attrs.each{|k,v| self.class.validator.instance_variable_set("@#{k}", v)}
49
+ else
50
+ raise GollumInternalError, 'gollum_rails is not enabled!'
51
+ end
38
52
  end
39
53
 
40
54
  #########
@@ -132,10 +146,12 @@ module GollumRails
132
146
  #
133
147
  # Returns an instance of Gollum::Page or false
134
148
  def save
135
- begin
136
- page.new_page(name,content,format,commit)
137
- rescue ::Gollum::DuplicatePageError => e
138
- page.instance_variable_set "@page",page.find_page(name)
149
+ run_callbacks :save do
150
+ begin
151
+ page.new_page(name,content,format,commit)
152
+ rescue ::Gollum::DuplicatePageError => e
153
+ page.instance_variable_set "@page",page.find_page(name)
154
+ end
139
155
  end
140
156
  return page.page
141
157
  end
@@ -182,7 +198,9 @@ module GollumRails
182
198
  #
183
199
  # Returns an instance of Gollum::Page
184
200
  def update_attributes(hash, commit=nil)
185
- page.update_page hash, get_right_commit(commit)
201
+ run_callbacks :update do
202
+ page.update_page hash, get_right_commit(commit)
203
+ end
186
204
  end
187
205
 
188
206
  # Deletes current page (also available static. See below)
@@ -192,7 +210,9 @@ module GollumRails
192
210
  #
193
211
  # Returns the commit id of the current action as String
194
212
  def delete(commit=nil)
195
- page.delete_page get_right_commit(commit)
213
+ run_callbacks :delete do
214
+ page.delete_page get_right_commit(commit)
215
+ end
196
216
  end
197
217
 
198
218
  # Previews the page - Mostly used if you want to see what you do before saving
@@ -32,6 +32,7 @@ module GollumRails
32
32
  # Returns true or throws an exception if the path is invalid
33
33
  def startup=(action)
34
34
  if action
35
+ Adapters::Gollum::Connector.enabled = true
35
36
  if @repository == :application
36
37
  initialize_wiki Rails.config.wiki_repository
37
38
  else
data/lib/gollum_rails.rb CHANGED
@@ -12,7 +12,7 @@ require 'gollum-lib'
12
12
  module GollumRails
13
13
 
14
14
  # GollumRails version string
15
- VERSION = '0.0.6'
15
+ VERSION = '0.0.7'
16
16
 
17
17
  # Simplified error
18
18
  class Error < StandardError; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gollum_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Kasper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-30 00:00:00.000000000 Z
11
+ date: 2013-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel