content_directory 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +11 -0
- data/content_directory.gemspec +25 -0
- data/lib/content_directory/entry.rb +27 -0
- data/lib/content_directory/version.rb +3 -0
- data/lib/content_directory.rb +41 -0
- data/test/support/content/home/features/collaboration.md +5 -0
- data/test/support/content/home/features/manage.md +5 -0
- data/test/support/content/home/main.md +6 -0
- data/test/support/content/posts/a-new-blog.md +11 -0
- data/test/support/content/posts/sortable-stars.md +3 -0
- data/test/test_helper.rb +3 -0
- data/test/unit/content_directory_test.rb +26 -0
- data/test/unit/entry_test.rb +14 -0
- metadata +125 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
ZmViMTg4NTkxYTIyNWFlNDA1MDhmYTM1YjQ2MzgxNjFiNWNmODE1Zg==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
ZmZlMTk2YjE3M2IyZTY1MTVhNjQ2MTI5NDY1OTQyODVmNmNlMDcwOQ==
|
|
7
|
+
!binary "U0hBNTEy":
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
MTkyMjIyMzEwNTRkYzg0YjEzMWZlZGYzMWM5MzI3YmMwZmVmOTE2MzExMmFk
|
|
10
|
+
NTdmNmIyOTQyZWVmOTViYzRhZTNiOThhOTQ0ODM1ZTNiZjBkN2FhZTg4YzY1
|
|
11
|
+
ZjQzZTY5MmMxMGM5NTJjYTk5ZTY4NDMwMDg2N2FiMThhZTMyZTk=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
MjhjNDBmNDFmOWZhOTIzODc5ZGQ2YTZlZjBjMTg2NGM2YzViNTI1MmY1M2Ew
|
|
14
|
+
MzA5MDZiYmYxZjI5NDAxNWFhMDcxMjBkN2VjOTMxMzhiZjQwODZkMzNlYzhh
|
|
15
|
+
YjcwMDY4OGE0NThlODEyOWY5ZTM5YjczNTBhNzE0MTA0M2EwN2U=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013 Steve Randy Tantra
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# ContentDirectory
|
|
2
|
+
|
|
3
|
+
TODO: Write a gem description
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'content_directory'
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install content_directory
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
TODO: Write usage instructions here
|
|
22
|
+
|
|
23
|
+
## Contributing
|
|
24
|
+
|
|
25
|
+
1. Fork it
|
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'content_directory/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "content_directory"
|
|
8
|
+
spec.version = ContentDirectory::VERSION
|
|
9
|
+
spec.authors = ["Steve Randy Tantra"]
|
|
10
|
+
spec.email = ["steve.randy@gmail.com"]
|
|
11
|
+
spec.description = ""
|
|
12
|
+
spec.summary = ""
|
|
13
|
+
spec.homepage = ""
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files`.split($/)
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_dependency "redcarpet", ">= 2.0.0"
|
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
|
23
|
+
spec.add_development_dependency "rake"
|
|
24
|
+
spec.add_development_dependency "active_support"
|
|
25
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require "redcarpet"
|
|
2
|
+
require "yaml"
|
|
3
|
+
|
|
4
|
+
module ContentDirectory
|
|
5
|
+
class Entry
|
|
6
|
+
attr_reader :path, :text, :metadata
|
|
7
|
+
|
|
8
|
+
def initialize(path)
|
|
9
|
+
@path = path
|
|
10
|
+
@text = File.read "#{ContentDirectory.root}/#{@path}"
|
|
11
|
+
@metadata = @text.split("\n\n").first
|
|
12
|
+
|
|
13
|
+
begin
|
|
14
|
+
@metadata = YAML.load @metadata
|
|
15
|
+
@text = @text.split("\n\n", 2).last
|
|
16
|
+
rescue Exception => e
|
|
17
|
+
@metadata = nil
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def html
|
|
22
|
+
markdown = Redcarpet::Markdown.new Redcarpet::Render::HTML
|
|
23
|
+
html = markdown.render @text
|
|
24
|
+
Redcarpet::Render::SmartyPants.render html
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require "content_directory/version"
|
|
2
|
+
require "content_directory/entry"
|
|
3
|
+
|
|
4
|
+
module ContentDirectory
|
|
5
|
+
def self.root=(path)
|
|
6
|
+
@root = path
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.root
|
|
10
|
+
if @root
|
|
11
|
+
@root
|
|
12
|
+
elsif defined? Rails
|
|
13
|
+
"#{Rails.root}/content"
|
|
14
|
+
else
|
|
15
|
+
"content"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.find(path=nil)
|
|
20
|
+
result = {}
|
|
21
|
+
begin
|
|
22
|
+
entries = Dir.entries "#{root}/#{path}"
|
|
23
|
+
rescue Exception => e
|
|
24
|
+
return nil
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
entries.reject! do |entry|
|
|
28
|
+
entry[0] == "." || entry.include?(".") && !entry.include?(".md")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
entries.each do |entry|
|
|
32
|
+
if entry.include? "."
|
|
33
|
+
result[entry.split(".")[0]] = Entry.new "#{path}/#{entry}"
|
|
34
|
+
else
|
|
35
|
+
result[entry] = find("#{path}/#{entry}")
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
return result
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Title: A New Blog
|
|
2
|
+
|
|
3
|
+
I decided to blog on our blog about our new blog.
|
|
4
|
+
|
|
5
|
+
**Design**. The blog looks fresh no matter where you read it — be it on your desktop or on your phone.
|
|
6
|
+
|
|
7
|
+
**Search**. With our new emphasis on search, it made sense to add search to the blog, too.
|
|
8
|
+
|
|
9
|
+
**Atom feeds**. Only interested in posts about GitHub Enterprise? You can subscribe to Atom feeds of specific categories to get just the perfect mix of information.
|
|
10
|
+
|
|
11
|
+
Like always, there's more GitHub features and announcements to come — only now they'll be on our fresh new blog.
|
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class ContentDirectoryTest < ActiveSupport::TestCase
|
|
4
|
+
test "must be a Module" do
|
|
5
|
+
assert_kind_of Module, ContentDirectory
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
test "root" do
|
|
9
|
+
ContentDirectory.root = nil
|
|
10
|
+
assert_equal "content", ContentDirectory.root
|
|
11
|
+
ContentDirectory.root = "mycontent"
|
|
12
|
+
assert_equal "mycontent", ContentDirectory.root
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test "find" do
|
|
16
|
+
ContentDirectory.root = File.expand_path("../../support/content", __FILE__)
|
|
17
|
+
|
|
18
|
+
content = ContentDirectory.find
|
|
19
|
+
assert_equal 2, content.length
|
|
20
|
+
|
|
21
|
+
home = ContentDirectory.find "home"
|
|
22
|
+
assert_equal 2, home.length
|
|
23
|
+
assert_equal 2, home["features"].length
|
|
24
|
+
assert_kind_of ContentDirectory::Entry, home["main"]
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class EntryTest < ActiveSupport::TestCase
|
|
4
|
+
test "entry" do
|
|
5
|
+
ContentDirectory.root = File.expand_path("../../support/content", __FILE__)
|
|
6
|
+
home = ContentDirectory.find "home"
|
|
7
|
+
main = home["main"]
|
|
8
|
+
assert_kind_of ContentDirectory::Entry, main
|
|
9
|
+
assert_equal "Main", main.metadata["Title"]
|
|
10
|
+
assert_equal "2013/03/10", main.metadata["Last Modified"]
|
|
11
|
+
assert_equal "Build software better, together.\n\nPowerful collaboration, review, and code management for open source and private development projects.\n", main.text
|
|
12
|
+
assert_equal "<p>Build software better, together.</p>\n\n<p>Powerful collaboration, review, and code management for open source and private development projects.</p>\n", main.html
|
|
13
|
+
end
|
|
14
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: content_directory
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Steve Randy Tantra
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2013-03-10 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: redcarpet
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ! '>='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 2.0.0
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ! '>='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 2.0.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bundler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ~>
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.3'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ~>
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.3'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ! '>='
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ! '>='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: active_support
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ! '>='
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ! '>='
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
description: ''
|
|
70
|
+
email:
|
|
71
|
+
- steve.randy@gmail.com
|
|
72
|
+
executables: []
|
|
73
|
+
extensions: []
|
|
74
|
+
extra_rdoc_files: []
|
|
75
|
+
files:
|
|
76
|
+
- .gitignore
|
|
77
|
+
- Gemfile
|
|
78
|
+
- LICENSE.txt
|
|
79
|
+
- README.md
|
|
80
|
+
- Rakefile
|
|
81
|
+
- content_directory.gemspec
|
|
82
|
+
- lib/content_directory.rb
|
|
83
|
+
- lib/content_directory/entry.rb
|
|
84
|
+
- lib/content_directory/version.rb
|
|
85
|
+
- test/support/content/home/features/collaboration.md
|
|
86
|
+
- test/support/content/home/features/manage.md
|
|
87
|
+
- test/support/content/home/main.md
|
|
88
|
+
- test/support/content/posts/a-new-blog.md
|
|
89
|
+
- test/support/content/posts/sortable-stars.md
|
|
90
|
+
- test/test_helper.rb
|
|
91
|
+
- test/unit/content_directory_test.rb
|
|
92
|
+
- test/unit/entry_test.rb
|
|
93
|
+
homepage: ''
|
|
94
|
+
licenses:
|
|
95
|
+
- MIT
|
|
96
|
+
metadata: {}
|
|
97
|
+
post_install_message:
|
|
98
|
+
rdoc_options: []
|
|
99
|
+
require_paths:
|
|
100
|
+
- lib
|
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
|
+
requirements:
|
|
103
|
+
- - ! '>='
|
|
104
|
+
- !ruby/object:Gem::Version
|
|
105
|
+
version: '0'
|
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ! '>='
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
requirements: []
|
|
112
|
+
rubyforge_project:
|
|
113
|
+
rubygems_version: 2.0.2
|
|
114
|
+
signing_key:
|
|
115
|
+
specification_version: 4
|
|
116
|
+
summary: ''
|
|
117
|
+
test_files:
|
|
118
|
+
- test/support/content/home/features/collaboration.md
|
|
119
|
+
- test/support/content/home/features/manage.md
|
|
120
|
+
- test/support/content/home/main.md
|
|
121
|
+
- test/support/content/posts/a-new-blog.md
|
|
122
|
+
- test/support/content/posts/sortable-stars.md
|
|
123
|
+
- test/test_helper.rb
|
|
124
|
+
- test/unit/content_directory_test.rb
|
|
125
|
+
- test/unit/entry_test.rb
|