monster 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ Copyright [2011] [Ricardo Valeriano ricardo.valeriano@gmail.com | yo@ricardovaleriano.com]
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
File without changes
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ require 'monster/autorun'
4
+ rescue
5
+ $stderr.puts <<-OOPS
6
+ #{'*'*50}
7
+ Oh SHIT!
8
+ We are fucked.
9
+ OOPS
10
+ exit(1)
11
+ end
@@ -0,0 +1,5 @@
1
+ require 'core_ext/string_ext'
2
+
3
+ class String
4
+ include StringExt
5
+ end
@@ -0,0 +1,16 @@
1
+ module StringExt
2
+
3
+ def pagefy
4
+ normalize.gsub(/[ ]+/,"").downcase
5
+ end
6
+
7
+ def slugify
8
+ normalize.gsub(/[ ]+/," ").gsub(/ /,"-").downcase
9
+ end
10
+
11
+ private
12
+ def normalize
13
+ self.gsub(/[^a-zA-Z0-9 ]/,"")
14
+ end
15
+
16
+ end
@@ -0,0 +1,3 @@
1
+ require 'core_ext'
2
+ require 'monster/post'
3
+ require 'monster/author'
@@ -0,0 +1,18 @@
1
+ module Monster
2
+
3
+ class Author
4
+
5
+ def initialize(name)
6
+ @name = name
7
+ end
8
+
9
+ def name
10
+ @name
11
+ end
12
+
13
+ def page
14
+ @page ||= name.pagefy
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,101 @@
1
+ module Monster
2
+
3
+ class Post
4
+
5
+ def self.default_draft(title, generator)
6
+ post = Post.new(title)
7
+ post.date_generator = generator
8
+ post.author = Author.new("Ricardo Valeriano")
9
+ post.meta = {
10
+ :category => "Desenvolvimento",
11
+ :tags => [],
12
+ :type => "post",
13
+ :published => false,
14
+ :excerpt => title
15
+ }
16
+ post.create_draft
17
+ post
18
+ end
19
+
20
+ def initialize(title)
21
+ @title = title
22
+ end
23
+
24
+ def author=(author)
25
+ @author = author
26
+ end
27
+
28
+ def slug
29
+ @slug ||= @title.slugify
30
+ end
31
+
32
+ def date_generator=(generator)
33
+ @date_generator = generator
34
+ end
35
+
36
+ def date
37
+ @date_generator.call
38
+ end
39
+
40
+ def blog_root=(path)
41
+ @root = path
42
+ end
43
+
44
+ def category=(category)
45
+ @category = category
46
+ end
47
+
48
+ def create_draft
49
+ File.open(File.join(posts_dir, file_name), "w") do |file|
50
+ file << metadata_string
51
+ end
52
+ end
53
+
54
+ def meta=(metadata_hash)
55
+ metadata_hash.each { |key, value| self[key] = value }
56
+ end
57
+
58
+ def []=(metadata_key, value)
59
+ metadata_key = metadata_key.to_s unless metadata_key.class == String
60
+ metadata[metadata_key.downcase] = value
61
+ end
62
+
63
+ def [](metadata_key)
64
+ metadata_key = metadata_key.to_s unless metadata_key.class == String
65
+ metadata[metadata_key.downcase]
66
+ end
67
+
68
+ private
69
+ def metadata
70
+ @metadata ||= {}
71
+ end
72
+
73
+ def metadata_for(key)
74
+
75
+ end
76
+
77
+ def layout
78
+ "post"
79
+ end
80
+
81
+ def posts_dir
82
+ "_posts"
83
+ end
84
+
85
+ def file_name
86
+ "#{self.date}-#{self.slug}"
87
+ end
88
+
89
+ def metadata_string
90
+ {
91
+ "layout" => layout,
92
+ "title" => @title,
93
+ "author" => {
94
+ "name" => @author.name,
95
+ "page" => @author.page
96
+ }
97
+ }.merge(metadata).to_yaml << "---"
98
+ end
99
+
100
+ end
101
+ end
@@ -0,0 +1,3 @@
1
+ module Monster
2
+ VERSION="0.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: monster
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ricardo Valeriano
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: jekyll
16
+ requirement: &70317301521760 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70317301521760
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70317301521280 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70317301521280
36
+ description: OMG! Things generator for Jekyll blogs! :D
37
+ email:
38
+ - ricardovaleriano.com
39
+ executables:
40
+ - monster
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - bin/monster
45
+ - lib/core_ext/string_ext.rb
46
+ - lib/core_ext.rb
47
+ - lib/monster/author.rb
48
+ - lib/monster/post.rb
49
+ - lib/monster/version.rb
50
+ - lib/monster.rb
51
+ - LICENSE
52
+ - README.md
53
+ homepage: http://github.com/ricardovaleriano/monster
54
+ licenses: []
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: 1.3.6
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 1.8.10
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: Generators for Jekyll
77
+ test_files: []