gollum_rails 1.5.2 → 1.5.3

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: 11fed99873df70a7a7d86d323bce04bc21bb71c6
4
- data.tar.gz: 3fa18480d1a55a289c488e2c731b8f7e8fd20b5c
3
+ metadata.gz: 7722875d793d56642ad1a05a5ebc360e297ca6b2
4
+ data.tar.gz: 0fb1d9f345e5b93afab6ae91e4687710cd7725cc
5
5
  SHA512:
6
- metadata.gz: 090c0e3d6986db52a453b2fa1516af14f4f2c335d5a9cc5d6beb02a97af7213d0297d8269657ac6ae585bf255e63ee450d86b00cba49451c157c6e4cdc471bd1
7
- data.tar.gz: 94a1f37f9965e2ed65db0663d815329272115cc44f6c51d506f5a15a5986dcf447b93c7648260d2862c6cdb771a346e4afe37ef0c3671fd62e8aff32e6c5234a
6
+ metadata.gz: 18f5e87b8172f330b77a418301f4805feea518ba72141c28a8ceeca98ee799d28e68ef69aed968ba17234b8ed88ed0f4407f628b981534d49f0bd3608cf4bb97
7
+ data.tar.gz: 8822651c8f55cbb3b49caeb9e2f2194989e46f738448bd3c118c4031ef0ffeb2a58fe9c326f1354faddc6071bf63f9e6f2c16f9505143682a89b7ca68fd928d1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gollum_rails (1.5.2)
4
+ gollum_rails (1.5.3)
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,11 @@
1
+ # 1.5.3 19th February 2014
2
+ * Documentation improvements
3
+ * Refactored find `find` method call to accept page resets and exact matches
4
+ * Bugfixing
5
+
6
+ # 1.5.2 18th February 2014
7
+ * Bugfixing
8
+
1
9
  # 1.5.1 28th January 2014
2
10
  * Updated `update_attributes` to work with hashes
3
11
  * Bugfixing
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.5.2'
7
+ s.version = '1.5.3'
8
8
 
9
9
  s.summary = 'Combines Gollum and Rails'
10
10
  s.description= 'include Gollum into Rails with ease'
data/lib/gollum_rails.rb CHANGED
@@ -45,7 +45,7 @@ module GollumRails
45
45
  autoload :Meta
46
46
 
47
47
  # GollumRails version string
48
- VERSION = '1.5.2'
48
+ VERSION = '1.5.3'
49
49
 
50
50
  end
51
51
 
@@ -1,6 +1,7 @@
1
1
  module GollumRails
2
2
  module Finders
3
3
  extend ActiveSupport::Concern
4
+
4
5
  module ClassMethods
5
6
  # Finds an existing page or creates it
6
7
  #
@@ -9,9 +10,9 @@ module GollumRails
9
10
  #
10
11
  # Returns self
11
12
  def find_or_initialize_by_name(name, commit={})
12
- result_for_find = find(name)
13
- unless result_for_find.nil?
14
- result_for_find
13
+ result = find(name)
14
+ if result
15
+ result
15
16
  else
16
17
  new(:format => :markdown, :name => name, :content => ".", :commit => commit)
17
18
  end
@@ -21,14 +22,26 @@ module GollumRails
21
22
  #
22
23
  # name - the name of the page
23
24
  # version - optional - The pages version
25
+ # reset_folder - optional - resets the folder to / before performing the search
26
+ # exact - optional - perform an exact match
24
27
  #
25
28
  # Return an instance of Gollum::Page
26
- def find(name, version=nil)
27
- page = Adapters::Gollum::Page.find_page(name, wiki, version)
28
-
29
- return new( :gollum_page => page ) unless page.nil?
30
- return nil
31
-
29
+ def find(name, version=nil, reset_folder=false, exact=true)
30
+ name = name[:name] if name.kind_of?(Hash) && name.has_key?(:name)
31
+ Setup.wiki_options.merge(:page_file_dir => nil) if reset_folder
32
+ wiki.clear_cache
33
+ path = File.split(name)
34
+ if path.first == '/' || path.first == '.'
35
+ folder = nil
36
+ else
37
+ folder = path.first
38
+ end
39
+ page = wiki.paged(path.last, folder, exact, version)
40
+ if page
41
+ new(gollum_page: page)
42
+ else
43
+ nil
44
+ end
32
45
  end
33
46
 
34
47
  # == Searches the wiki for files CONTENT!
@@ -41,26 +54,38 @@ module GollumRails
41
54
  end
42
55
 
43
56
  # Gets all pages in the wiki
57
+ #
58
+ # Returns an Array with GollumRails::Page s
44
59
  def all(options={})
45
60
  set_folder(options)
46
61
  pages = wiki.pages
47
- r = pages.map do |page|
62
+ pages.map do |page|
48
63
  self.new(gollum_page: page)
49
64
  end
50
65
  end
51
66
 
67
+ # Gets the last item from `all` method call
68
+ #
69
+ # options - optional - some options e.g. :folder
70
+ #
71
+ # Returns a single GollumRails::Page
52
72
  def first(options={})
53
73
  all(options).first
54
74
  end
55
75
 
76
+ # Gets the first item from `all` method call
77
+ #
78
+ # options - optional - some options e.g. :folder
79
+ #
80
+ # Returns a single GollumRails::Page
56
81
  def last(options={})
57
82
  all(options).last
58
83
  end
59
84
 
85
+ # Aliasing this for ActiveRecord behavior
60
86
  alias_method :find_all, :all
61
87
 
62
- # TODO: implement more of this (format, etc)
63
- #
88
+ # Catch-all method
64
89
  def method_missing(name, *args)
65
90
  if name =~ /^find_by_(name)$/
66
91
  self.find(args.first)
@@ -71,4 +96,4 @@ module GollumRails
71
96
 
72
97
  end
73
98
  end
74
- end
99
+ 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: 1.5.2
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Kasper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-18 00:00:00.000000000 Z
11
+ date: 2014-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel