RuGPost 0.1.0.1.beta → 0.1.1
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.
- data/Gemfile +6 -6
- data/Gemfile.lock +34 -5
- data/README.rdoc +43 -3
- data/Rakefile +13 -39
- data/RuGPost.gemspec +54 -12
- data/VERSION +1 -1
- data/bin/rugpost +9 -0
- data/lib/RuGPost.rb +26 -0
- data/lib/rugpost/commands.rb +15 -0
- data/lib/rugpost/commands/post_commands.rb +20 -0
- data/lib/rugpost/commands/project_commands.rb +23 -0
- data/lib/rugpost/on_error.rb +6 -0
- data/lib/rugpost/post.rb +96 -0
- data/lib/rugpost/prepost.rb +10 -0
- data/lib/rugpost/project.rb +34 -0
- data/lib/rugpost/site.rb +6 -0
- data/lib/rugpost/utilis.rb +27 -0
- data/rdoc/classes/RuGPost.html +200 -0
- data/rdoc/classes/RuGPost/Post.html +462 -0
- data/rdoc/classes/RuGPost/Project.html +210 -0
- data/rdoc/classes/RuGPost/Site.html +111 -0
- data/rdoc/classes/RuGPost/Utilis.html +196 -0
- data/rdoc/created.rid +1 -0
- data/rdoc/files/README_rdoc.html +204 -0
- data/rdoc/files/lib/RuGPost_rb.html +113 -0
- data/rdoc/files/lib/rugpost/commands/post_commands_rb.html +101 -0
- data/rdoc/files/lib/rugpost/commands/project_commands_rb.html +101 -0
- data/rdoc/files/lib/rugpost/commands_rb.html +108 -0
- data/rdoc/files/lib/rugpost/on_error_rb.html +101 -0
- data/rdoc/files/lib/rugpost/post_rb.html +101 -0
- data/rdoc/files/lib/rugpost/prepost_rb.html +101 -0
- data/rdoc/files/lib/rugpost/project_rb.html +101 -0
- data/rdoc/files/lib/rugpost/site_rb.html +101 -0
- data/rdoc/files/lib/rugpost/utilis_rb.html +101 -0
- data/rdoc/fr_class_index.html +31 -0
- data/rdoc/fr_file_index.html +37 -0
- data/rdoc/fr_method_index.html +43 -0
- data/rdoc/index.html +26 -0
- data/rdoc/rdoc-style.css +208 -0
- data/spec/post_spec.rb +76 -0
- data/spec/project_spec.rb +40 -0
- data/spec/spec_helper.rb +24 -0
- metadata +100 -33
@@ -0,0 +1,34 @@
|
|
1
|
+
module RuGPost
|
2
|
+
|
3
|
+
class Project
|
4
|
+
def Project.init(args=[],ops={})
|
5
|
+
puts "Initializing RuGPost project under current directory..."
|
6
|
+
File.open( CONFIG, 'w' ) { |f| f.write("---\n:gmail: notset") }
|
7
|
+
File.open( TEMPLATE, 'w' ) {|f| f.write(template_meta + "---\n" + template_body)}
|
8
|
+
end
|
9
|
+
|
10
|
+
def Project.add_repo(args=[],ops={})
|
11
|
+
raise "Must supply repo name" unless args.size == 1
|
12
|
+
raise "Site repo already exists" if File.exist?(args[0])
|
13
|
+
# create repository structure
|
14
|
+
puts "Adding new site repository: #{args[0]}..."
|
15
|
+
repo = args[0]
|
16
|
+
Dir.mkdir(repo)
|
17
|
+
Dir.mkdir(repo/'drafts')
|
18
|
+
Dir.mkdir(repo/'published')
|
19
|
+
Dir.mkdir(repo/'published/source')
|
20
|
+
Dir.mkdir(repo/'published/output')
|
21
|
+
end
|
22
|
+
|
23
|
+
def Project.config(args=[],ops={})
|
24
|
+
# load configuration as hash
|
25
|
+
config = YAML.load_file( CONFIG )
|
26
|
+
# set key
|
27
|
+
config.merge!(ops)
|
28
|
+
# hash to config
|
29
|
+
File.open( CONFIG,'w' ) {|f| f.write( config.to_yaml )}
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/lib/rugpost/site.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module RuGPost
|
2
|
+
|
3
|
+
module Utilis
|
4
|
+
|
5
|
+
def template_meta
|
6
|
+
metahash = {
|
7
|
+
:title => "Hello World",
|
8
|
+
:tags => ["Hello World", VERSION]
|
9
|
+
}
|
10
|
+
metahash.to_yaml
|
11
|
+
end
|
12
|
+
|
13
|
+
def template_body
|
14
|
+
"Hello from new *RuGPost* (#{VERSION}) user!"
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_gmail
|
18
|
+
puts "Please insert your gmail user name:"
|
19
|
+
STDOUT.flush
|
20
|
+
gmail=gets.chomp
|
21
|
+
puts gmail
|
22
|
+
return gmail
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,200 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Module: RuGPost</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">RuGPost</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/lib/RuGPost_rb.html">
|
59
|
+
lib/RuGPost.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
<a href="../files/lib/rugpost/project_rb.html">
|
63
|
+
lib/rugpost/project.rb
|
64
|
+
</a>
|
65
|
+
<br />
|
66
|
+
<a href="../files/lib/rugpost/site_rb.html">
|
67
|
+
lib/rugpost/site.rb
|
68
|
+
</a>
|
69
|
+
<br />
|
70
|
+
<a href="../files/lib/rugpost/post_rb.html">
|
71
|
+
lib/rugpost/post.rb
|
72
|
+
</a>
|
73
|
+
<br />
|
74
|
+
<a href="../files/lib/rugpost/utilis_rb.html">
|
75
|
+
lib/rugpost/utilis.rb
|
76
|
+
</a>
|
77
|
+
<br />
|
78
|
+
</td>
|
79
|
+
</tr>
|
80
|
+
|
81
|
+
</table>
|
82
|
+
</div>
|
83
|
+
<!-- banner header -->
|
84
|
+
|
85
|
+
<div id="bodyContent">
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
<div id="contextContent">
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
</div>
|
94
|
+
|
95
|
+
|
96
|
+
</div>
|
97
|
+
|
98
|
+
|
99
|
+
<!-- if includes -->
|
100
|
+
<div id="includes">
|
101
|
+
<h3 class="section-bar">Included Modules</h3>
|
102
|
+
|
103
|
+
<div id="includes-list">
|
104
|
+
<span class="include-name"><a href="RuGPost/Utilis.html">RuGPost::Utilis</a></span>
|
105
|
+
</div>
|
106
|
+
</div>
|
107
|
+
|
108
|
+
<div id="section">
|
109
|
+
|
110
|
+
<div id="class-list">
|
111
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
112
|
+
|
113
|
+
Module <a href="RuGPost/Utilis.html" class="link">RuGPost::Utilis</a><br />
|
114
|
+
Class <a href="RuGPost/Post.html" class="link">RuGPost::Post</a><br />
|
115
|
+
Class <a href="RuGPost/Project.html" class="link">RuGPost::Project</a><br />
|
116
|
+
Class <a href="RuGPost/Site.html" class="link">RuGPost::Site</a><br />
|
117
|
+
|
118
|
+
</div>
|
119
|
+
|
120
|
+
<div id="constants-list">
|
121
|
+
<h3 class="section-bar">Constants</h3>
|
122
|
+
|
123
|
+
<div class="name-list">
|
124
|
+
<table summary="Constants">
|
125
|
+
<tr class="top-aligned-row context-row">
|
126
|
+
<td class="context-item-name">LIB</td>
|
127
|
+
<td>=</td>
|
128
|
+
<td class="context-item-value">Pathname(__FILE__).dirname.expand_path/'rugpost'</td>
|
129
|
+
<td width="3em"> </td>
|
130
|
+
<td class="context-item-desc">
|
131
|
+
directory containing <a href="RuGPost.html">RuGPost</a> library files
|
132
|
+
|
133
|
+
</td>
|
134
|
+
</tr>
|
135
|
+
<tr class="top-aligned-row context-row">
|
136
|
+
<td class="context-item-name">CONFIG</td>
|
137
|
+
<td>=</td>
|
138
|
+
<td class="context-item-value">'config.yaml'</td>
|
139
|
+
<td width="3em"> </td>
|
140
|
+
<td class="context-item-desc">
|
141
|
+
project configuration file
|
142
|
+
|
143
|
+
</td>
|
144
|
+
</tr>
|
145
|
+
<tr class="top-aligned-row context-row">
|
146
|
+
<td class="context-item-name">TEMPLATE</td>
|
147
|
+
<td>=</td>
|
148
|
+
<td class="context-item-value">'template'</td>
|
149
|
+
</tr>
|
150
|
+
<tr class="top-aligned-row context-row">
|
151
|
+
<td class="context-item-name">VERSION</td>
|
152
|
+
<td>=</td>
|
153
|
+
<td class="context-item-value">'0.1.1'</td>
|
154
|
+
</tr>
|
155
|
+
<tr class="top-aligned-row context-row">
|
156
|
+
<td class="context-item-name">META</td>
|
157
|
+
<td>=</td>
|
158
|
+
<td class="context-item-value">/--- \n.*\n---\n/m</td>
|
159
|
+
</tr>
|
160
|
+
<tr class="top-aligned-row context-row">
|
161
|
+
<td class="context-item-name">DRAFTS</td>
|
162
|
+
<td>=</td>
|
163
|
+
<td class="context-item-value">'drafts'</td>
|
164
|
+
</tr>
|
165
|
+
<tr class="top-aligned-row context-row">
|
166
|
+
<td class="context-item-name">PUBLISHED</td>
|
167
|
+
<td>=</td>
|
168
|
+
<td class="context-item-value">'published'</td>
|
169
|
+
</tr>
|
170
|
+
<tr class="top-aligned-row context-row">
|
171
|
+
<td class="context-item-name">SOURCE</td>
|
172
|
+
<td>=</td>
|
173
|
+
<td class="context-item-value">PUBLISHED/'source'</td>
|
174
|
+
</tr>
|
175
|
+
<tr class="top-aligned-row context-row">
|
176
|
+
<td class="context-item-name">OUTPUT</td>
|
177
|
+
<td>=</td>
|
178
|
+
<td class="context-item-value">PUBLISHED/'output'</td>
|
179
|
+
</tr>
|
180
|
+
</table>
|
181
|
+
</div>
|
182
|
+
</div>
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
<!-- if method_list -->
|
190
|
+
|
191
|
+
|
192
|
+
</div>
|
193
|
+
|
194
|
+
|
195
|
+
<div id="validator-badges">
|
196
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
197
|
+
</div>
|
198
|
+
|
199
|
+
</body>
|
200
|
+
</html>
|
@@ -0,0 +1,462 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: RuGPost::Post</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">RuGPost::Post</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/rugpost/post_rb.html">
|
59
|
+
lib/rugpost/post.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000012">draft</a>
|
90
|
+
<a href="#M000014">get_site</a>
|
91
|
+
<a href="#M000010">move_html</a>
|
92
|
+
<a href="#M000009">move_source</a>
|
93
|
+
<a href="#M000004">new</a>
|
94
|
+
<a href="#M000013">publish</a>
|
95
|
+
<a href="#M000011">remove</a>
|
96
|
+
<a href="#M000007">set_body</a>
|
97
|
+
<a href="#M000008">set_html</a>
|
98
|
+
<a href="#M000005">set_meta</a>
|
99
|
+
<a href="#M000006">set_subj</a>
|
100
|
+
</div>
|
101
|
+
</div>
|
102
|
+
|
103
|
+
</div>
|
104
|
+
|
105
|
+
|
106
|
+
<!-- if includes -->
|
107
|
+
|
108
|
+
<div id="section">
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
<div id="attribute-list">
|
115
|
+
<h3 class="section-bar">Attributes</h3>
|
116
|
+
|
117
|
+
<div class="name-list">
|
118
|
+
<table>
|
119
|
+
<tr class="top-aligned-row context-row">
|
120
|
+
<td class="context-item-name">draft</td>
|
121
|
+
<td class="context-item-value"> [RW] </td>
|
122
|
+
<td class="context-item-desc"></td>
|
123
|
+
</tr>
|
124
|
+
<tr class="top-aligned-row context-row">
|
125
|
+
<td class="context-item-name">html_o</td>
|
126
|
+
<td class="context-item-value"> [RW] </td>
|
127
|
+
<td class="context-item-desc"></td>
|
128
|
+
</tr>
|
129
|
+
<tr class="top-aligned-row context-row">
|
130
|
+
<td class="context-item-name">metaops</td>
|
131
|
+
<td class="context-item-value"> [RW] </td>
|
132
|
+
<td class="context-item-desc"></td>
|
133
|
+
</tr>
|
134
|
+
<tr class="top-aligned-row context-row">
|
135
|
+
<td class="context-item-name">pwd</td>
|
136
|
+
<td class="context-item-value"> [RW] </td>
|
137
|
+
<td class="context-item-desc"></td>
|
138
|
+
</tr>
|
139
|
+
<tr class="top-aligned-row context-row">
|
140
|
+
<td class="context-item-name">src_body</td>
|
141
|
+
<td class="context-item-value"> [RW] </td>
|
142
|
+
<td class="context-item-desc"></td>
|
143
|
+
</tr>
|
144
|
+
<tr class="top-aligned-row context-row">
|
145
|
+
<td class="context-item-name">subject</td>
|
146
|
+
<td class="context-item-value"> [RW] </td>
|
147
|
+
<td class="context-item-desc"></td>
|
148
|
+
</tr>
|
149
|
+
</table>
|
150
|
+
</div>
|
151
|
+
</div>
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
<!-- if method_list -->
|
156
|
+
<div id="methods">
|
157
|
+
<h3 class="section-bar">Public Class methods</h3>
|
158
|
+
|
159
|
+
<div id="method-M000012" class="method-detail">
|
160
|
+
<a name="M000012"></a>
|
161
|
+
|
162
|
+
<div class="method-heading">
|
163
|
+
<a href="#M000012" class="method-signature">
|
164
|
+
<span class="method-name">draft</span><span class="method-args">(args,ops)</span>
|
165
|
+
</a>
|
166
|
+
</div>
|
167
|
+
|
168
|
+
<div class="method-description">
|
169
|
+
<p><a class="source-toggle" href="#"
|
170
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
171
|
+
<div class="method-source-code" id="M000012-source">
|
172
|
+
<pre>
|
173
|
+
<span class="ruby-comment cmt"># File lib/rugpost/post.rb, line 62</span>
|
174
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">Post</span>.<span class="ruby-identifier">draft</span>(<span class="ruby-identifier">args</span>,<span class="ruby-identifier">ops</span>)
|
175
|
+
<span class="ruby-identifier">ops</span>[<span class="ruby-identifier">:site</span>]=<span class="ruby-constant">Post</span>.<span class="ruby-identifier">get_site</span>(<span class="ruby-identifier">ops</span>)
|
176
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"Please provide draft name!"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]
|
177
|
+
<span class="ruby-identifier">target_file</span> = <span class="ruby-identifier">ops</span>[<span class="ruby-identifier">:site</span>]<span class="ruby-operator">/</span><span class="ruby-value str">'drafts'</span><span class="ruby-operator">/</span><span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">+</span><span class="ruby-value str">'.textile'</span>
|
178
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Adding draft '#{args[0]}' to site repo '#{ops[:site]}'..."</span>
|
179
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"File already exists!\n\t#{target_file}\n\tPlease indicate a different draft name."</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">target_file</span>)
|
180
|
+
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">copy_file</span>(<span class="ruby-constant">TEMPLATE</span>, <span class="ruby-identifier">target_file</span>)
|
181
|
+
<span class="ruby-keyword kw">end</span>
|
182
|
+
</pre>
|
183
|
+
</div>
|
184
|
+
</div>
|
185
|
+
</div>
|
186
|
+
|
187
|
+
<div id="method-M000014" class="method-detail">
|
188
|
+
<a name="M000014"></a>
|
189
|
+
|
190
|
+
<div class="method-heading">
|
191
|
+
<a href="#M000014" class="method-signature">
|
192
|
+
<span class="method-name">get_site</span><span class="method-args">(ops)</span>
|
193
|
+
</a>
|
194
|
+
</div>
|
195
|
+
|
196
|
+
<div class="method-description">
|
197
|
+
<p><a class="source-toggle" href="#"
|
198
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
199
|
+
<div class="method-source-code" id="M000014-source">
|
200
|
+
<pre>
|
201
|
+
<span class="ruby-comment cmt"># File lib/rugpost/post.rb, line 86</span>
|
202
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">Post</span>.<span class="ruby-identifier">get_site</span>(<span class="ruby-identifier">ops</span>)
|
203
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">ops</span>[<span class="ruby-identifier">:site</span>]<span class="ruby-operator">==</span><span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">then</span>
|
204
|
+
<span class="ruby-identifier">ops</span>[<span class="ruby-identifier">:site</span>]=<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-value str">'*'</span>).<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span> <span class="ruby-identifier">d</span>}[<span class="ruby-value">0</span>]
|
205
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"No site name option provided, switching to default...'#{ops[:site]}'"</span>
|
206
|
+
<span class="ruby-keyword kw">end</span>
|
207
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">ops</span>[<span class="ruby-identifier">:site</span>]
|
208
|
+
<span class="ruby-keyword kw">end</span>
|
209
|
+
</pre>
|
210
|
+
</div>
|
211
|
+
</div>
|
212
|
+
</div>
|
213
|
+
|
214
|
+
<div id="method-M000004" class="method-detail">
|
215
|
+
<a name="M000004"></a>
|
216
|
+
|
217
|
+
<div class="method-heading">
|
218
|
+
<a href="#M000004" class="method-signature">
|
219
|
+
<span class="method-name">new</span><span class="method-args">(args,ops)</span>
|
220
|
+
</a>
|
221
|
+
</div>
|
222
|
+
|
223
|
+
<div class="method-description">
|
224
|
+
<p><a class="source-toggle" href="#"
|
225
|
+
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
226
|
+
<div class="method-source-code" id="M000004-source">
|
227
|
+
<pre>
|
228
|
+
<span class="ruby-comment cmt"># File lib/rugpost/post.rb, line 14</span>
|
229
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">args</span>,<span class="ruby-identifier">ops</span>)
|
230
|
+
<span class="ruby-identifier">ops</span>[<span class="ruby-identifier">:site</span>]=<span class="ruby-constant">Post</span>.<span class="ruby-identifier">get_site</span>(<span class="ruby-identifier">ops</span>)
|
231
|
+
<span class="ruby-ivar">@draftid</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]
|
232
|
+
<span class="ruby-ivar">@pwd</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">1</span>]
|
233
|
+
<span class="ruby-ivar">@draft</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-identifier">ops</span>[<span class="ruby-identifier">:site</span>]<span class="ruby-operator">/</span><span class="ruby-constant">DRAFTS</span><span class="ruby-operator">/</span><span class="ruby-ivar">@draftid</span><span class="ruby-operator">+</span><span class="ruby-value str">".*"</span>)
|
234
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"Draft not found! Searched for '#{args[0]}' in '#{ops[:site]}/drafts'"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@draft</span>
|
235
|
+
<span class="ruby-ivar">@draft</span> = <span class="ruby-ivar">@draft</span>[<span class="ruby-value">0</span>]
|
236
|
+
<span class="ruby-identifier">set_body</span>
|
237
|
+
<span class="ruby-identifier">set_html</span>
|
238
|
+
<span class="ruby-identifier">set_meta</span> <span class="ruby-identifier">ops</span>
|
239
|
+
<span class="ruby-identifier">set_subj</span>
|
240
|
+
<span class="ruby-keyword kw">end</span>
|
241
|
+
</pre>
|
242
|
+
</div>
|
243
|
+
</div>
|
244
|
+
</div>
|
245
|
+
|
246
|
+
<div id="method-M000013" class="method-detail">
|
247
|
+
<a name="M000013"></a>
|
248
|
+
|
249
|
+
<div class="method-heading">
|
250
|
+
<a href="#M000013" class="method-signature">
|
251
|
+
<span class="method-name">publish</span><span class="method-args">(post)</span>
|
252
|
+
</a>
|
253
|
+
</div>
|
254
|
+
|
255
|
+
<div class="method-description">
|
256
|
+
<p><a class="source-toggle" href="#"
|
257
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
258
|
+
<div class="method-source-code" id="M000013-source">
|
259
|
+
<pre>
|
260
|
+
<span class="ruby-comment cmt"># File lib/rugpost/post.rb, line 71</span>
|
261
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">Post</span>.<span class="ruby-identifier">publish</span>(<span class="ruby-identifier">post</span>)
|
262
|
+
<span class="ruby-identifier">account</span> = <span class="ruby-node">"#{post.metaops[:gmail]}@gmail.com"</span>
|
263
|
+
<span class="ruby-identifier">gmail</span> = <span class="ruby-constant">Gmail</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">account</span>,<span class="ruby-identifier">post</span>.<span class="ruby-identifier">pwd</span>)
|
264
|
+
<span class="ruby-identifier">gmail</span>.<span class="ruby-identifier">deliver</span> <span class="ruby-keyword kw">do</span>
|
265
|
+
<span class="ruby-identifier">to</span> <span class="ruby-node">"#{post.metaops[:site]}@posterous.com"</span>
|
266
|
+
<span class="ruby-identifier">subject</span> <span class="ruby-identifier">post</span>.<span class="ruby-identifier">subject</span>
|
267
|
+
<span class="ruby-identifier">text_part</span> <span class="ruby-keyword kw">do</span>
|
268
|
+
<span class="ruby-identifier">body</span> <span class="ruby-identifier">post</span>.<span class="ruby-identifier">html_o</span>
|
269
|
+
<span class="ruby-keyword kw">end</span>
|
270
|
+
<span class="ruby-keyword kw">end</span>
|
271
|
+
<span class="ruby-identifier">gmail</span>.<span class="ruby-identifier">logout</span>
|
272
|
+
<span class="ruby-identifier">post</span>.<span class="ruby-identifier">move_source</span>
|
273
|
+
<span class="ruby-identifier">post</span>.<span class="ruby-identifier">move_html</span>
|
274
|
+
<span class="ruby-keyword kw">end</span>
|
275
|
+
</pre>
|
276
|
+
</div>
|
277
|
+
</div>
|
278
|
+
</div>
|
279
|
+
|
280
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
281
|
+
|
282
|
+
<div id="method-M000010" class="method-detail">
|
283
|
+
<a name="M000010"></a>
|
284
|
+
|
285
|
+
<div class="method-heading">
|
286
|
+
<a href="#M000010" class="method-signature">
|
287
|
+
<span class="method-name">move_html</span><span class="method-args">()</span>
|
288
|
+
</a>
|
289
|
+
</div>
|
290
|
+
|
291
|
+
<div class="method-description">
|
292
|
+
<p><a class="source-toggle" href="#"
|
293
|
+
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
294
|
+
<div class="method-source-code" id="M000010-source">
|
295
|
+
<pre>
|
296
|
+
<span class="ruby-comment cmt"># File lib/rugpost/post.rb, line 53</span>
|
297
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">move_html</span>
|
298
|
+
<span class="ruby-identifier">target</span> = <span class="ruby-ivar">@metaops</span>[<span class="ruby-identifier">:site</span>]<span class="ruby-operator">/</span><span class="ruby-constant">OUTPUT</span><span class="ruby-operator">/</span><span class="ruby-ivar">@draftid</span><span class="ruby-operator">+</span><span class="ruby-value str">'.html'</span>
|
299
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>( <span class="ruby-identifier">target</span>, <span class="ruby-value str">'w'</span> ) {<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-ivar">@html_o</span>)}
|
300
|
+
<span class="ruby-keyword kw">end</span>
|
301
|
+
</pre>
|
302
|
+
</div>
|
303
|
+
</div>
|
304
|
+
</div>
|
305
|
+
|
306
|
+
<div id="method-M000009" class="method-detail">
|
307
|
+
<a name="M000009"></a>
|
308
|
+
|
309
|
+
<div class="method-heading">
|
310
|
+
<a href="#M000009" class="method-signature">
|
311
|
+
<span class="method-name">move_source</span><span class="method-args">()</span>
|
312
|
+
</a>
|
313
|
+
</div>
|
314
|
+
|
315
|
+
<div class="method-description">
|
316
|
+
<p><a class="source-toggle" href="#"
|
317
|
+
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
318
|
+
<div class="method-source-code" id="M000009-source">
|
319
|
+
<pre>
|
320
|
+
<span class="ruby-comment cmt"># File lib/rugpost/post.rb, line 49</span>
|
321
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">move_source</span>
|
322
|
+
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mv</span>(<span class="ruby-ivar">@draft</span>,<span class="ruby-ivar">@metaops</span>[<span class="ruby-identifier">:site</span>]<span class="ruby-operator">/</span><span class="ruby-constant">SOURCE</span>)
|
323
|
+
<span class="ruby-keyword kw">end</span>
|
324
|
+
</pre>
|
325
|
+
</div>
|
326
|
+
</div>
|
327
|
+
</div>
|
328
|
+
|
329
|
+
<div id="method-M000011" class="method-detail">
|
330
|
+
<a name="M000011"></a>
|
331
|
+
|
332
|
+
<div class="method-heading">
|
333
|
+
<a href="#M000011" class="method-signature">
|
334
|
+
<span class="method-name">remove</span><span class="method-args">()</span>
|
335
|
+
</a>
|
336
|
+
</div>
|
337
|
+
|
338
|
+
<div class="method-description">
|
339
|
+
<p><a class="source-toggle" href="#"
|
340
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
341
|
+
<div class="method-source-code" id="M000011-source">
|
342
|
+
<pre>
|
343
|
+
<span class="ruby-comment cmt"># File lib/rugpost/post.rb, line 58</span>
|
344
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove</span>
|
345
|
+
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">remove_file</span>(<span class="ruby-ivar">@draft</span>)
|
346
|
+
<span class="ruby-keyword kw">end</span>
|
347
|
+
</pre>
|
348
|
+
</div>
|
349
|
+
</div>
|
350
|
+
</div>
|
351
|
+
|
352
|
+
<div id="method-M000007" class="method-detail">
|
353
|
+
<a name="M000007"></a>
|
354
|
+
|
355
|
+
<div class="method-heading">
|
356
|
+
<a href="#M000007" class="method-signature">
|
357
|
+
<span class="method-name">set_body</span><span class="method-args">()</span>
|
358
|
+
</a>
|
359
|
+
</div>
|
360
|
+
|
361
|
+
<div class="method-description">
|
362
|
+
<p><a class="source-toggle" href="#"
|
363
|
+
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
364
|
+
<div class="method-source-code" id="M000007-source">
|
365
|
+
<pre>
|
366
|
+
<span class="ruby-comment cmt"># File lib/rugpost/post.rb, line 39</span>
|
367
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_body</span>
|
368
|
+
<span class="ruby-identifier">cnt</span> = <span class="ruby-value str">""</span>
|
369
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>( <span class="ruby-ivar">@draft</span>, <span class="ruby-value str">'r'</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">str</span><span class="ruby-operator">|</span> <span class="ruby-identifier">cnt</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">str</span>.<span class="ruby-identifier">read</span>() }
|
370
|
+
<span class="ruby-ivar">@src_body</span> = <span class="ruby-identifier">cnt</span>.<span class="ruby-identifier">sub</span> <span class="ruby-constant">META</span>, <span class="ruby-value str">""</span>
|
371
|
+
<span class="ruby-keyword kw">end</span>
|
372
|
+
</pre>
|
373
|
+
</div>
|
374
|
+
</div>
|
375
|
+
</div>
|
376
|
+
|
377
|
+
<div id="method-M000008" class="method-detail">
|
378
|
+
<a name="M000008"></a>
|
379
|
+
|
380
|
+
<div class="method-heading">
|
381
|
+
<a href="#M000008" class="method-signature">
|
382
|
+
<span class="method-name">set_html</span><span class="method-args">()</span>
|
383
|
+
</a>
|
384
|
+
</div>
|
385
|
+
|
386
|
+
<div class="method-description">
|
387
|
+
<p><a class="source-toggle" href="#"
|
388
|
+
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
389
|
+
<div class="method-source-code" id="M000008-source">
|
390
|
+
<pre>
|
391
|
+
<span class="ruby-comment cmt"># File lib/rugpost/post.rb, line 45</span>
|
392
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_html</span>
|
393
|
+
<span class="ruby-ivar">@html_o</span> = <span class="ruby-constant">RedCloth</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@src_body</span>).<span class="ruby-identifier">to_html</span>
|
394
|
+
<span class="ruby-keyword kw">end</span>
|
395
|
+
</pre>
|
396
|
+
</div>
|
397
|
+
</div>
|
398
|
+
</div>
|
399
|
+
|
400
|
+
<div id="method-M000005" class="method-detail">
|
401
|
+
<a name="M000005"></a>
|
402
|
+
|
403
|
+
<div class="method-heading">
|
404
|
+
<a href="#M000005" class="method-signature">
|
405
|
+
<span class="method-name">set_meta</span><span class="method-args">(ops)</span>
|
406
|
+
</a>
|
407
|
+
</div>
|
408
|
+
|
409
|
+
<div class="method-description">
|
410
|
+
<p><a class="source-toggle" href="#"
|
411
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
412
|
+
<div class="method-source-code" id="M000005-source">
|
413
|
+
<pre>
|
414
|
+
<span class="ruby-comment cmt"># File lib/rugpost/post.rb, line 27</span>
|
415
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_meta</span> <span class="ruby-identifier">ops</span>
|
416
|
+
<span class="ruby-identifier">projectops</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load_file</span>(<span class="ruby-constant">CONFIG</span>)
|
417
|
+
<span class="ruby-ivar">@metaops</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load_file</span>(<span class="ruby-ivar">@draft</span>)
|
418
|
+
<span class="ruby-ivar">@metaops</span>.<span class="ruby-identifier">merge!</span> <span class="ruby-identifier">projectops</span>
|
419
|
+
<span class="ruby-ivar">@metaops</span>.<span class="ruby-identifier">merge!</span> <span class="ruby-identifier">ops</span>
|
420
|
+
<span class="ruby-keyword kw">end</span>
|
421
|
+
</pre>
|
422
|
+
</div>
|
423
|
+
</div>
|
424
|
+
</div>
|
425
|
+
|
426
|
+
<div id="method-M000006" class="method-detail">
|
427
|
+
<a name="M000006"></a>
|
428
|
+
|
429
|
+
<div class="method-heading">
|
430
|
+
<a href="#M000006" class="method-signature">
|
431
|
+
<span class="method-name">set_subj</span><span class="method-args">()</span>
|
432
|
+
</a>
|
433
|
+
</div>
|
434
|
+
|
435
|
+
<div class="method-description">
|
436
|
+
<p><a class="source-toggle" href="#"
|
437
|
+
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
438
|
+
<div class="method-source-code" id="M000006-source">
|
439
|
+
<pre>
|
440
|
+
<span class="ruby-comment cmt"># File lib/rugpost/post.rb, line 34</span>
|
441
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_subj</span>
|
442
|
+
<span class="ruby-ivar">@subject</span> = <span class="ruby-node">"#{@metaops[:title]} ((tags:#{@metaops[:tags].join(',')}))"</span>
|
443
|
+
<span class="ruby-ivar">@subject</span> <span class="ruby-operator">+=</span> <span class="ruby-node">"((delay:#{@metaops[:delay]}))"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@metaops</span>[<span class="ruby-identifier">:delay</span>]
|
444
|
+
<span class="ruby-keyword kw">end</span>
|
445
|
+
</pre>
|
446
|
+
</div>
|
447
|
+
</div>
|
448
|
+
</div>
|
449
|
+
|
450
|
+
|
451
|
+
</div>
|
452
|
+
|
453
|
+
|
454
|
+
</div>
|
455
|
+
|
456
|
+
|
457
|
+
<div id="validator-badges">
|
458
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
459
|
+
</div>
|
460
|
+
|
461
|
+
</body>
|
462
|
+
</html>
|