gollum_rails 1.4.7 → 1.4.8

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: 57c07d301c92ee9ae439361a45e1a0317508396f
4
- data.tar.gz: 813634ee9e35af6a7392fa2fd1cef28e1b7eb308
3
+ metadata.gz: 3b460090ab3b9641ec3ea08931ccec91b44f47e6
4
+ data.tar.gz: 068b8e6ebdb52b6a9e84651c03de154f3712ccbf
5
5
  SHA512:
6
- metadata.gz: 6aa595beec356b66b0ac41a368623a5fcd1074aa308e15ffdda2e9a9100ee305c84d874310004ecea7eed0d9ea2ca7be947486c88fc10a0f2f52631c2bd56208
7
- data.tar.gz: d5115ae21d4c26bca9cd76b134c55e966528da4e4e2bdad675611bc18fe5504d413ae01b3a1d6fb44244e46f8294f0667c6f1250bbf1a89eba81b878858dd377
6
+ metadata.gz: 333ff674a490887f45dbe5097a50433219d1094481303e8df7d0f59d3a863b80729770a23aebe49f8e1a794b99bcc6189057e9f440ff00bf341dc1618295d8a2
7
+ data.tar.gz: 3895b9ef0bbacc2c98df81e01e2e214f8f98042c9f83a1643f76f33df27ddc438363bd7d7376aefa544a6bcf767f4322baf594252ff87b0895b91a81f6c61b94
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gollum_rails (1.4.7)
4
+ gollum_rails (1.4.8)
5
5
  activemodel (>= 3.2.11)
6
6
  activesupport (>= 3.2.11)
7
7
  gollum-lib (~> 1.0.9)
data/HISTORY.md CHANGED
@@ -1,3 +1,16 @@
1
+ # 1.4.8 13th January 2013
2
+ * Updated initializer
3
+ * Better errors
4
+ * no nil exception
5
+
6
+ # 1.4.7 22th December 2013
7
+ * rails3 and 4 support in a single release
8
+ * Major code refactoring
9
+ * Bugfixes
10
+ * Stability improvements
11
+ * Removed obsolete abstraction layer
12
+ * Decentralized code à la ActiveRecord
13
+
1
14
  # 1.4.6 9th December 2013
2
15
  * Updated the initializer to support paths now
3
16
  * Updated error messages
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 = '1.4.7'
7
+ s.version = '1.4.8'
8
8
 
9
9
  s.summary = 'Combines Gollum and Rails'
10
10
  s.description= 'include Gollum into Rails with ease'
@@ -46,11 +46,10 @@ Gem::Specification.new do |s|
46
46
  lib/gollum_rails.rb
47
47
  lib/gollum_rails/adapters/gollum.rb
48
48
  lib/gollum_rails/adapters/gollum/.gitkeep
49
- lib/gollum_rails/adapters/gollum/error.rb
50
49
  lib/gollum_rails/adapters/gollum/page.rb
51
- lib/gollum_rails/adapters/gollum/wiki.rb
52
50
  lib/gollum_rails/callbacks.rb
53
51
  lib/gollum_rails/core.rb
52
+ lib/gollum_rails/error.rb
54
53
  lib/gollum_rails/finders.rb
55
54
  lib/gollum_rails/orm.rb
56
55
  lib/gollum_rails/page.rb
@@ -58,12 +57,8 @@ Gem::Specification.new do |s|
58
57
  lib/gollum_rails/setup.rb
59
58
  lib/gollum_rails/store.rb
60
59
  lib/gollum_rails/validation.rb
61
- spec/gollum_rails/adapters/gollum/committer_spec.rb
62
60
  spec/gollum_rails/adapters/gollum/connector_spec.rb
63
61
  spec/gollum_rails/adapters/gollum/page_spec.rb
64
- spec/gollum_rails/adapters/gollum/wiki_spec_off.rb
65
- spec/gollum_rails/error_spec.rb
66
- spec/gollum_rails/orm_spec.rb
67
62
  spec/gollum_rails/page_spec.rb
68
63
  spec/gollum_rails/respository_spec.rb
69
64
  spec/gollum_rails/setup_spec.rb
data/lib/gollum_rails.rb CHANGED
@@ -34,6 +34,7 @@ module GollumRails
34
34
 
35
35
  autoload :Persistance
36
36
  autoload :Callbacks
37
+ autoload :Error
37
38
  autoload :Core
38
39
  autoload :Store
39
40
  autoload :Validation
@@ -43,33 +44,8 @@ module GollumRails
43
44
  autoload :Orm
44
45
 
45
46
  # GollumRails version string
46
- VERSION = '1.4.7'
47
+ VERSION = '1.4.8'
47
48
 
48
- # Simplified error
49
- class Error < StandardError; end
50
-
51
- # All Gollum internal exceptions will be redirected to this
52
- class GollumInternalError < Error
53
-
54
-
55
- attr_accessor :name
56
- attr_accessor :message
57
- attr_accessor :target
58
-
59
- # modifies content for throwing an exception
60
- def initialize(name, target = nil, message = nil)
61
- @name = name
62
- @target = target
63
- @message = message
64
-
65
- super(message || "An Error occured: #{name} on #{target}")
66
- end
67
-
68
- # Fancy inspects
69
- def inspect
70
- "#<GollumRails::GollumInternalError:#{object_id} {name: #{name.inspect}, message: #{message.inspect}, target: #{target.inspect}}>"
71
- end
72
- end
73
49
  end
74
50
 
75
- require File.expand_path '../gollum_rails/adapters/gollum', __FILE__
51
+ require 'gollum_rails/adapters/gollum'
@@ -7,7 +7,6 @@ module GollumRails
7
7
  module Gollum
8
8
  autoload :Wiki, 'gollum_rails/adapters/gollum/wiki'
9
9
  autoload :Page, 'gollum_rails/adapters/gollum/page'
10
- autoload :Error, 'gollum_rails/adapters/gollum/error'
11
10
 
12
11
  # connector version
13
12
  VERSION="2.0.0"
@@ -26,15 +25,6 @@ module GollumRails
26
25
  attr_writer :wiki_options
27
26
 
28
27
 
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
38
28
  # Gets the Globally used Page class or use a new one if not defined
39
29
  #
40
30
  #
@@ -24,11 +24,9 @@ module GollumRails
24
24
  # commit must be given to perform any page action!
25
25
  def initialize(attrs = {})
26
26
  run_callbacks :initialize do
27
- if Adapters::Gollum::Connector.enabled
27
+ if wiki
28
28
  attrs.each{|k,v| self.public_send("#{k}=",v)} if attrs
29
29
  update_attrs if attrs[:gollum_page]
30
- else
31
- raise GollumInternalError, 'gollum_rails is not enabled!'
32
30
  end
33
31
  end
34
32
  end
@@ -0,0 +1,6 @@
1
+ module GollumRails
2
+ class InitializationError < StandardError; end
3
+
4
+ module Error
5
+ end
6
+ end
@@ -75,6 +75,7 @@ module GollumRails
75
75
  include ActiveModel::Validations
76
76
  end
77
77
 
78
+ include Error
78
79
  include Core
79
80
  include Store
80
81
  include Validation
@@ -12,37 +12,21 @@ module GollumRails
12
12
  # config.startup
13
13
  # end
14
14
  #
15
- # TODO:
16
- # * more options
17
- #
18
- # FIXME:
19
- # currently nothing
20
15
  #
21
16
  class Setup
22
-
23
- # static baby
24
17
  class << self
25
18
 
19
+ attr_accessor :wiki_path
20
+
21
+ attr_accessor :wiki_options
26
22
 
27
- # Gets / Sets the repository
28
23
  attr_accessor :repository
29
-
24
+
25
+ attr_accessor :startup
26
+
30
27
  # Gets / Sets the init options
31
28
  attr_accessor :options
32
29
 
33
- # Startup action for building wiki components
34
- #
35
- # Returns true or throws an exception if the path is invalid
36
- def startup=(action)
37
- if action
38
- Adapters::Gollum::Connector.enabled = true
39
- if @repository == :application
40
- initialize_wiki Rails.application.config.wiki_repository
41
- else
42
- initialize_wiki @repository
43
- end
44
- end
45
- end
46
30
 
47
31
  # Wiki startup options
48
32
  def options=(options)
@@ -54,6 +38,16 @@ module GollumRails
54
38
  #
55
39
  def build(&block)
56
40
  block.call self
41
+ if @repository == :application
42
+ raise GollumRailsSetupError, "Rails configuration is not defined.
43
+ Are you in a Rails app?" if Rails.application.nil?
44
+
45
+ initialize_wiki Rails.application.config.wiki_repository
46
+ else
47
+ raise GollumRailsSetupError, "Git repository does not exist.
48
+ Was the specified pathname correct?" unless Pathname.new(@repository).exist?
49
+ initialize_wiki @repository
50
+ end
57
51
  end
58
52
 
59
53
  #######
@@ -75,15 +69,16 @@ module GollumRails
75
69
 
76
70
  def initialize_wiki(path)
77
71
  if path_valid? path
78
- repository = Grit::Repo.new path.to_s
79
- GollumRails::Adapters::Gollum::Wiki.new(repository, options || {})
72
+ @wiki_path = path.to_s
73
+ @wiki_options = options
80
74
  true
81
75
  else
82
- raise GollumInternalError, 'Repistory path empty or invalid!'
76
+ raise GollumRailsSetupError, 'Repistory path is empty or invalid!'
83
77
  end
84
78
 
85
79
  end
86
80
 
87
81
  end
88
82
  end
83
+ class GollumRailsSetupError < ArgumentError; end
89
84
  end
@@ -20,7 +20,8 @@ module GollumRails
20
20
  module ClassMethods
21
21
  # Gets the wiki instance
22
22
  def wiki
23
- @wiki ||= Gollum::Wiki.new(Adapters::Gollum::Connector.wiki_path, Adapters::Gollum::Connector.wiki_options)
23
+ raise InitializationError, "Wiki path was not initialized!" if Setup.wiki_path.nil?
24
+ @wiki ||= Gollum::Wiki.new(Setup.wiki_path, Setup.wiki_options)
24
25
  end
25
26
  end
26
27
  # Gets the pages format
@@ -3,64 +3,48 @@ require 'spec_helper'
3
3
  require 'rails'
4
4
  describe GollumRails::Setup do
5
5
  it "should setup the application" do
6
- GollumRails::Setup.build do |setup|
6
+ expect{
7
+ GollumRails::Setup.build do |setup|
7
8
 
8
- # => The repository path to the
9
- #
10
- #
11
- setup.repository = '.'
9
+ # => The repository path to the
10
+ #
11
+ #
12
+ setup.repository = '.'
12
13
 
13
- #setup.wiki.use = :default
14
- setup.startup=(true).should be_true
14
+ end
15
+ }.not_to raise_error
16
+
15
17
 
16
- setup.repository = nil
17
- expect{setup.startup=true}.to raise_error GollumRails::GollumInternalError
18
-
19
- end
20
18
 
19
+ end
20
+ it "should raise an error because no repo was supplied" do
21
+ expect{
22
+ GollumRails::Setup.build do |setup|
23
+ setup.repository = nil
21
24
 
25
+ end
26
+ }.to raise_error
22
27
  end
23
28
  class Bla < GollumRails::Page
24
29
  end
25
- it "should test the disable behavior" do
26
- GollumRails::Adapters::Gollum::Connector.enabled = false
27
30
 
28
- committer = {
29
- :name => "Flo",
30
- :message => "no",
31
- :email => "mosny@zyg.li"
32
- }
33
-
34
- expect{Bla.new :name => "Default page", :commit => committer, :content => "#title \n ##body", :format => :markdown}.to raise_error GollumRails::GollumInternalError
35
- end
36
- it "should test the applications config" do
37
- GollumRails::Setup.build do |config|
38
- config.repository = :application
31
+ it "could not start without a rails configuration" do
32
+
33
+ expect {
34
+ GollumRails::Setup.build do |config|
35
+ config.repository = :application
39
36
 
40
- expect{setup.startup=true}.to raise_error
41
- end
37
+ end
38
+ }.to raise_error GollumRails::GollumRailsSetupError
39
+
42
40
  end
43
41
  it "should throw an error if a pathname was supplied that does not exist" do
44
- GollumRails::Setup.build do |setup|
45
- setup.repository = Pathname.new('/nonexistingdirectoryshouldbenonexisting')
46
- expect{setup.startup=(true)}.to raise_error(GollumRails::GollumInternalError)
47
- end
42
+ expect{
43
+ GollumRails::Setup.build do |setup|
44
+ setup.repository = Pathname.new('/nonexistingdirectoryshouldbenonexisting')
45
+ end
46
+ }.to raise_error GollumRails::GollumRailsSetupError
48
47
  end
49
- it "should test the Rails configuration" do
50
- GollumRails::Setup.build do |setup|
51
48
 
52
- # => The repository path to the
53
- #
54
- #
55
- setup.repository = :application
56
-
57
- #setup.wiki.use = :default
58
- expect{setup.startup=(true)}.to raise_error(NoMethodError, "undefined method `config' for nil:NilClass")
59
-
60
- #setup.repository = nil
61
- #expect{setup.startup=true}.to raise_error GollumRails::GollumInternalError
62
-
63
- end
64
- end
65
49
 
66
50
  end
data/spec/spec_helper.rb CHANGED
@@ -11,9 +11,6 @@ require 'gollum_rails'
11
11
  RSpec.configure do |config|
12
12
  config.treat_symbols_as_metadata_keys_with_true_values = true
13
13
 
14
- config.before(:each) do
15
- GollumRails::Adapters::Gollum::Connector.enabled = true
16
- end
17
14
 
18
15
  config.mock_with :rr
19
16
 
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: 1.4.7
4
+ version: 1.4.8
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-12-22 00:00:00.000000000 Z
11
+ date: 2014-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -158,11 +158,10 @@ files:
158
158
  - lib/gollum_rails.rb
159
159
  - lib/gollum_rails/adapters/gollum.rb
160
160
  - lib/gollum_rails/adapters/gollum/.gitkeep
161
- - lib/gollum_rails/adapters/gollum/error.rb
162
161
  - lib/gollum_rails/adapters/gollum/page.rb
163
- - lib/gollum_rails/adapters/gollum/wiki.rb
164
162
  - lib/gollum_rails/callbacks.rb
165
163
  - lib/gollum_rails/core.rb
164
+ - lib/gollum_rails/error.rb
166
165
  - lib/gollum_rails/finders.rb
167
166
  - lib/gollum_rails/orm.rb
168
167
  - lib/gollum_rails/page.rb
@@ -170,12 +169,8 @@ files:
170
169
  - lib/gollum_rails/setup.rb
171
170
  - lib/gollum_rails/store.rb
172
171
  - lib/gollum_rails/validation.rb
173
- - spec/gollum_rails/adapters/gollum/committer_spec.rb
174
172
  - spec/gollum_rails/adapters/gollum/connector_spec.rb
175
173
  - spec/gollum_rails/adapters/gollum/page_spec.rb
176
- - spec/gollum_rails/adapters/gollum/wiki_spec_off.rb
177
- - spec/gollum_rails/error_spec.rb
178
- - spec/gollum_rails/orm_spec.rb
179
174
  - spec/gollum_rails/page_spec.rb
180
175
  - spec/gollum_rails/respository_spec.rb
181
176
  - spec/gollum_rails/setup_spec.rb
@@ -1,19 +0,0 @@
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,36 +0,0 @@
1
- require 'grit'
2
- module GollumRails
3
- module Adapters
4
- module Gollum
5
-
6
- # TODO: doc
7
- class Wiki
8
-
9
- # Initializes the class
10
- #
11
- # location - String or Grit::Repo
12
- def initialize(location, options={})
13
-
14
- Connector.wiki_options = options
15
-
16
- if location.is_a?(::String)
17
- con = location
18
- else
19
- con = location.path
20
- end
21
-
22
- Connector.wiki_path = con
23
-
24
- end
25
-
26
- # Static call from within any other class
27
- #
28
- # Returns a new instance of this class
29
- def self.wiki(location, options={})
30
- Wiki.new(location, options)
31
- end
32
-
33
- end
34
- end
35
- end
36
- end
File without changes
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
- require 'grit'
3
-
4
- describe GollumRails::Adapters::Gollum::Wiki do
5
- before(:each) do
6
- @location = "#{File.dirname(__FILE__)}/../../../utils/wiki.git"
7
- @repo = Grit::Repo.init_bare @location
8
- @wiki = GollumRails::Adapters::Gollum::Wiki.new @repo
9
- end
10
- it "should test initializer" do
11
- wiki = GollumRails::Adapters::Gollum::Wiki.new @location
12
- @wiki.git.should == @repo
13
- wiki.git.should be_instance_of(String)
14
- wiki.git.should == @location
15
- end
16
- it "should test the creation of a new wiki" do
17
- wiki = GollumRails::Adapters::Gollum::Wiki.wiki @repo
18
- wiki.git.should == @repo
19
- wiki = GollumRails::Adapters::Gollum::Wiki.wiki @location
20
- wiki.git.should == @location
21
- GollumRails::Adapters::Gollum::Connector.wiki_class.should be_instance_of(::Gollum::Wiki)
22
- end
23
- it "should test the error throwing and forwarding" do
24
- expect{GollumRails::Adapters::Gollum::Wiki.write_page}.to raise_error ArgumentError
25
- end
26
-
27
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
- describe GollumRails::GollumInternalError do
3
-
4
- it "should display a fancy inspect" do
5
- GollumRails::GollumInternalError.new("hihi").inspect.should include("{name: \"hihi\"")
6
- end
7
- it "should raise an error with custom message" do
8
- expect{raise GollumRails::GollumInternalError.new("myname", "is", "i am the message")}.to raise_error
9
- end
10
- end
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
-
3
-
4
- describe GollumRails::Orm do
5
- let(:commit){{
6
- name: "flo",
7
- message: "commit",
8
- email: "mosny@zyg.li"}}
9
- let(:pageattrs){{
10
- name: "Pagetester",
11
- content: "content data",
12
- commit: commit,
13
- format: :markdown}}
14
- class PTest < GollumRails::Page
15
- include GollumRails::Orm
16
- end
17
- # before(:each){@rr = PTest.create(pageattrs)}
18
- # after(:each){}
19
-
20
- it "should alias the all function" do
21
- @rr = PTest.new(pageattrs)
22
- #expect(PTest).to respond_to(:all_pages)
23
- #@rr.destroy(commit)
24
- end
25
- end