RuGPost 0.1.0.beta.2
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/.document +5 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +20 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +53 -0
- data/RuGPost.gemspec +74 -0
- data/VERSION +1 -0
- data/bin/rugpost +6 -0
- data/lib/.RuGPost.rb.swp +0 -0
- data/lib/RuGPost.rb +30 -0
- data/lib/rugpost/commands/post_commands.rb +19 -0
- data/lib/rugpost/commands/project_commands.rb +24 -0
- data/lib/rugpost/on_error.rb +6 -0
- data/lib/rugpost/post.rb +92 -0
- data/lib/rugpost/prepost.rb +10 -0
- data/lib/rugpost/project.rb +37 -0
- data/lib/rugpost/site.rb +6 -0
- data/lib/rugpost/utilis.rb +20 -0
- data/pkg/RuGPost-0.1.0.1.beta.gem +0 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/spec_post.rb +78 -0
- data/spec/spec_project.rb +43 -0
- data/test/helper.rb +18 -0
- data/test/test_RuGPost.rb +7 -0
- metadata +153 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.6.0"
|
12
|
+
gem "rcov", ">= 0"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.6.0)
|
6
|
+
bundler (~> 1.0.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
rake (0.8.7)
|
10
|
+
rcov (0.9.9)
|
11
|
+
shoulda (2.11.3)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
ruby
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
bundler (~> 1.0.0)
|
18
|
+
jeweler (~> 1.6.0)
|
19
|
+
rcov
|
20
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 emime
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= RuGPost
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to RuGPost
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 emime. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "RuGPost"
|
18
|
+
gem.homepage = "http://github.com/3mime/RuGPost"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Ru(by) G(mail) Post(erous) command line facility for creating posts on Posterous}
|
21
|
+
gem.description = %Q{Ru(by) G(mail) Post(erous) command line facility}
|
22
|
+
gem.email = "e.141592@gmail.com"
|
23
|
+
gem.authors = ["emime"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "RuGPost #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/RuGPost.gemspec
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{RuGPost}
|
8
|
+
s.version = "0.1.0.beta.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = [%q{emime}]
|
12
|
+
s.date = %q{2011-05-08}
|
13
|
+
s.description = %q{Ru(by) G(mail) Post(erous) command line facility}
|
14
|
+
s.email = %q{e.141592@gmail.com}
|
15
|
+
s.executables = [%q{rugpost}]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"RuGPost.gemspec",
|
28
|
+
"VERSION",
|
29
|
+
"bin/rugpost",
|
30
|
+
"lib/.RuGPost.rb.swp",
|
31
|
+
"lib/RuGPost.rb",
|
32
|
+
"lib/rugpost/commands/post_commands.rb",
|
33
|
+
"lib/rugpost/commands/project_commands.rb",
|
34
|
+
"lib/rugpost/on_error.rb",
|
35
|
+
"lib/rugpost/post.rb",
|
36
|
+
"lib/rugpost/prepost.rb",
|
37
|
+
"lib/rugpost/project.rb",
|
38
|
+
"lib/rugpost/site.rb",
|
39
|
+
"lib/rugpost/utilis.rb",
|
40
|
+
"pkg/RuGPost-0.1.0.1.beta.gem",
|
41
|
+
"spec/spec_helper.rb",
|
42
|
+
"spec/spec_post.rb",
|
43
|
+
"spec/spec_project.rb",
|
44
|
+
"test/helper.rb",
|
45
|
+
"test/test_RuGPost.rb"
|
46
|
+
]
|
47
|
+
s.homepage = %q{http://github.com/3mime/RuGPost}
|
48
|
+
s.licenses = [%q{MIT}]
|
49
|
+
s.require_paths = [%q{lib}]
|
50
|
+
s.rubygems_version = %q{1.8.1}
|
51
|
+
s.summary = %q{Ru(by) G(mail) Post(erous) command line facility for creating posts on Posterous}
|
52
|
+
|
53
|
+
if s.respond_to? :specification_version then
|
54
|
+
s.specification_version = 3
|
55
|
+
|
56
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
57
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
58
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
59
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
|
60
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
63
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
64
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
65
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
66
|
+
end
|
67
|
+
else
|
68
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
69
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
70
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
71
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0.beta.2
|
data/bin/rugpost
ADDED
data/lib/.RuGPost.rb.swp
ADDED
Binary file
|
data/lib/RuGPost.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'gli'
|
3
|
+
require 'redcloth'
|
4
|
+
require 'gmail'
|
5
|
+
require 'pathname'
|
6
|
+
require 'extlib'
|
7
|
+
|
8
|
+
module RuGPost
|
9
|
+
|
10
|
+
include GLI
|
11
|
+
|
12
|
+
# directory containing RuGPost library files
|
13
|
+
LIB = Pathname(__FILE__).dirname.expand_path/'rugpost'
|
14
|
+
|
15
|
+
# requires
|
16
|
+
require LIB/'utilis'
|
17
|
+
require LIB/'site'
|
18
|
+
require LIB/'project'
|
19
|
+
require LIB/'post'
|
20
|
+
require LIB/'commands/project_commands'
|
21
|
+
require LIB/'commands/post_commands'
|
22
|
+
|
23
|
+
# includes
|
24
|
+
include RuGPost::Utilis
|
25
|
+
|
26
|
+
# project configuration file
|
27
|
+
CONFIG = 'config.yaml'
|
28
|
+
TEMPLATE = 'template'
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
desc 'Create a new draft on the indicated site repository.'
|
2
|
+
arg_name '<post-name>'
|
3
|
+
command :draft do |c|
|
4
|
+
c.desc 'Target site repository where the post draft will be created.'
|
5
|
+
c.flag [:site]
|
6
|
+
c.action do |glob, ops, args|
|
7
|
+
Post.draft(args,ops)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'Publish a repository draft on the corresponding posterous site.'
|
12
|
+
arg_name '<draft-name>'
|
13
|
+
command :publish do |c|
|
14
|
+
c.desc 'Repository where the draft is stored.'
|
15
|
+
c.flag [:site]
|
16
|
+
c.action do |glob, ops, args|
|
17
|
+
Post.publish(Post.new(args, ops))
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
desc 'Create a new RuGPost project.'
|
2
|
+
arg_name '<project-name>'
|
3
|
+
command :new do |c|
|
4
|
+
c.action do |glob, ops, args|
|
5
|
+
Project.create(args)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
desc 'Create a repo for a posterous site.'
|
10
|
+
arg_name '<site-name>'
|
11
|
+
command :repo do |c|
|
12
|
+
c.action do |glob, ops, args|
|
13
|
+
Project.add_repo(args)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Configure project global options'
|
18
|
+
command :config do |c|
|
19
|
+
c.desc 'Configure gmail account used to post on posterous sites. Needs the gmail (without @gmail).'
|
20
|
+
c.flag [:gmail]
|
21
|
+
c.action do |glob,ops,args|
|
22
|
+
Project.config(args,ops)
|
23
|
+
end
|
24
|
+
end
|
data/lib/rugpost/post.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
module RuGPost
|
2
|
+
|
3
|
+
META = /--- \n.*\n---\n/m
|
4
|
+
|
5
|
+
DRAFTS = 'drafts'
|
6
|
+
PUBLISHED = 'published'
|
7
|
+
SOURCE = PUBLISHED/'source'
|
8
|
+
OUTPUT = PUBLISHED/'output'
|
9
|
+
|
10
|
+
class Post
|
11
|
+
|
12
|
+
attr_accessor :src_body, :draft, :subject, :html_o, :metaops
|
13
|
+
|
14
|
+
def initialize(args,ops)
|
15
|
+
@draftid = args[0]
|
16
|
+
@draft = Dir.glob(ops[:site]/DRAFTS/@draftid+".*")
|
17
|
+
raise "Draft not found! Searched for '#{args[0]}' in '#{ops[:site]}/drafts'" unless @draft
|
18
|
+
@draft = @draft[0]
|
19
|
+
set_body
|
20
|
+
set_html
|
21
|
+
set_meta ops
|
22
|
+
set_subj
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_meta ops
|
26
|
+
projectops = YAML.load_file(CONFIG)
|
27
|
+
@metaops = YAML.load_file(@draft)
|
28
|
+
@metaops.merge! projectops
|
29
|
+
@metaops.merge! ops
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_subj
|
33
|
+
@subject = "#{@metaops[:title]} ((tags:#{@metaops[:tags].join(',')})) ((delay:#{@metaops[:delay]}))"
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_body
|
37
|
+
cnt = ""
|
38
|
+
File.open( @draft, 'r' ) { |str| cnt << str.read() }
|
39
|
+
@src_body = cnt.sub META, ""
|
40
|
+
end
|
41
|
+
|
42
|
+
def set_html
|
43
|
+
@html_o = RedCloth.new(@src_body).to_html
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_pwd
|
47
|
+
puts "Please type gmail account password:"
|
48
|
+
gets.chomp
|
49
|
+
end
|
50
|
+
|
51
|
+
def send_gmail(gmail)
|
52
|
+
gmail.deliver do
|
53
|
+
to "rugpost@posterous.com"
|
54
|
+
subject post.subject
|
55
|
+
text_part do
|
56
|
+
body post.html_o
|
57
|
+
end
|
58
|
+
end
|
59
|
+
gmail.logout
|
60
|
+
end
|
61
|
+
|
62
|
+
def move_source
|
63
|
+
FileUtils.mv(@draft,@metaops[:site]/SOURCE)
|
64
|
+
end
|
65
|
+
|
66
|
+
def move_html
|
67
|
+
target = @metaops[:site]/OUTPUT/@draftid+'.html'
|
68
|
+
File.open( target, 'w' ) {|f| f.write(@html_o)}
|
69
|
+
end
|
70
|
+
|
71
|
+
def remove
|
72
|
+
FileUtils.remove_file(@draft)
|
73
|
+
end
|
74
|
+
|
75
|
+
def Post.draft(args,ops)
|
76
|
+
target_file = ops[:site]/'drafts'/args[0]+'.textile'
|
77
|
+
raise "File already exists!\n\t#{target_file}\n\tPlease indicate a different draft name." if File.exists?(target_file)
|
78
|
+
FileUtils.copy_file(TEMPLATE, target_file)
|
79
|
+
end
|
80
|
+
|
81
|
+
def Post.publish(post)
|
82
|
+
account = post.meta[:gmail]
|
83
|
+
gmail = Gmail.new(account,get_pwd)
|
84
|
+
post.send_gmail(gmail)
|
85
|
+
post.move_source
|
86
|
+
post.move_html
|
87
|
+
post.remove
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module RuGPost
|
2
|
+
|
3
|
+
class Project
|
4
|
+
|
5
|
+
def Project.create(args=[],ops={})
|
6
|
+
raise "Must supply poject name" unless args.size==1
|
7
|
+
Dir.mkdir( args[0] )
|
8
|
+
File.open( args[0]/CONFIG, 'w' ) { |f| f.write("---\n:gmail: e.141592") }
|
9
|
+
File.open( args[0]/TEMPLATE, 'w' ) {|f| f.write(template_meta + "---\n" + template_body)}
|
10
|
+
end
|
11
|
+
|
12
|
+
def Project.add_repo(args=[],ops={})
|
13
|
+
raise "Must supply repo name" unless args.size == 1
|
14
|
+
raise "Site repo already exists" if File.exist?(args[0])
|
15
|
+
# create repository structure
|
16
|
+
puts args[0]
|
17
|
+
repo = args[0]
|
18
|
+
Dir.mkdir(repo)
|
19
|
+
Dir.mkdir(repo/'drafts')
|
20
|
+
Dir.mkdir(repo/'published')
|
21
|
+
Dir.mkdir(repo/'published/source')
|
22
|
+
Dir.mkdir(repo/'published/output')
|
23
|
+
# display respositories collections
|
24
|
+
end
|
25
|
+
|
26
|
+
def Project.config(args=[],ops={})
|
27
|
+
# load configuration as hash
|
28
|
+
config = YAML.load_file( CONFIG )
|
29
|
+
# set key
|
30
|
+
config.merge!(ops)
|
31
|
+
# hash to config
|
32
|
+
File.open( CONFIG,'w' ) {|f| f.write( config.to_yaml )}
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/lib/rugpost/site.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module RuGPost
|
2
|
+
|
3
|
+
module Utilis
|
4
|
+
|
5
|
+
def template_meta
|
6
|
+
metahash = {
|
7
|
+
:title => "Hello World",
|
8
|
+
:tags => ["Hello World", "Sample test"],
|
9
|
+
:delay => "now"
|
10
|
+
}
|
11
|
+
metahash.to_yaml
|
12
|
+
end
|
13
|
+
|
14
|
+
def template_body
|
15
|
+
"Hello from new *RuGPost* test!"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
Binary file
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$: << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
4
|
+
|
5
|
+
SAMPLE = '../sample'
|
6
|
+
|
7
|
+
require 'rugpost'
|
8
|
+
require 'spec'
|
9
|
+
require 'mail'
|
10
|
+
|
11
|
+
$: << File.expand_path(File.dirname(__FILE__))
|
12
|
+
|
13
|
+
include RuGPost
|
14
|
+
include RuGPost::Utilis
|
15
|
+
|
16
|
+
FileUtils.remove_dir( SAMPLE, true ) if File.exists?( SAMPLE )
|
17
|
+
|
18
|
+
require 'spec_project'
|
19
|
+
require 'spec_post'
|
data/spec/spec_post.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
DRAFT_NAME = 'helloworld'
|
2
|
+
DRAFT_MARKUP = 'textile'
|
3
|
+
DRAFT = SAMPLE/'RuGPost/drafts'/DRAFT_NAME+"."+DRAFT_MARKUP
|
4
|
+
|
5
|
+
describe Post do
|
6
|
+
|
7
|
+
context "creating a draft" do
|
8
|
+
it "should add a new blank file into the indicated repository" do
|
9
|
+
Post.draft( ['helloworld'], {:site=>"rugpost", :markup=>"textile"} )
|
10
|
+
File.exists?( DRAFT ).should be true
|
11
|
+
# should raise exception if file already exists in source or output folder
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "creating new post instance" do
|
16
|
+
before do
|
17
|
+
@post = Post.new( [DRAFT_NAME], {:site=>"rugpost"} )
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have metadata" do
|
21
|
+
@post.metaops[:title].should == "Hello World"
|
22
|
+
@post.metaops[:delay].should == "now"
|
23
|
+
@post.metaops[:tags].should == ["Hello World", "Sample test"]
|
24
|
+
@post.metaops[:gmail].should == "project"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have body" do
|
28
|
+
@post.src_body.should == "Hello from new *RuGPost* test!"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should have html output" do
|
32
|
+
@post.html_o.should == "<p>Hello from new <strong>RuGPost</strong> test!</p>"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should write right subject from metadata" do
|
36
|
+
@post.subject.should == "Hello World ((tags:Hello World,Sample test)) ((delay:now))"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "sending mail" do
|
41
|
+
it "should be able to send mail" do
|
42
|
+
Mail.defaults do
|
43
|
+
delivery_method :test
|
44
|
+
end
|
45
|
+
Mail::TestMailer.deliveries.length.should == 0
|
46
|
+
email = Mail.deliver do
|
47
|
+
to 'mikel@me.com'
|
48
|
+
from 'you@you.com'
|
49
|
+
subject 'testing'
|
50
|
+
body 'hello'
|
51
|
+
end
|
52
|
+
email.body.should == 'hello'
|
53
|
+
Mail::TestMailer.deliveries.length.should == 1
|
54
|
+
Mail::TestMailer.deliveries.first.should equal email
|
55
|
+
Mail::TestMailer.deliveries.clear
|
56
|
+
Mail::TestMailer.deliveries.length.should == 0
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "publishing a draft" do
|
61
|
+
before do
|
62
|
+
@post = Post.new([DRAFT_NAME] , {:site=>'rugpost'})
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should move html to published/output folder" do
|
66
|
+
@post.move_html
|
67
|
+
html = SAMPLE/'rugpost'/'published/output'/DRAFT_NAME + ".html"
|
68
|
+
File.exists?(html).should be true
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should move source to published/source" do
|
72
|
+
@post.move_source
|
73
|
+
File.exists?(SAMPLE/'rugpost'/'published/source'/DRAFT_NAME+'.'+DRAFT_MARKUP).should be true
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
describe Project do
|
2
|
+
context 'Creating a project' do
|
3
|
+
it 'should create test project' do
|
4
|
+
RuGPost::Project.create( [SAMPLE] )
|
5
|
+
File.exists?( SAMPLE ).should be true
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'After creating a project' do
|
10
|
+
before {Dir.chdir( SAMPLE )}
|
11
|
+
|
12
|
+
it 'should have template and configuration files' do
|
13
|
+
File.exists?( CONFIG ).should be true
|
14
|
+
File.exists?( TEMPLATE ).should be true
|
15
|
+
( YAML.load_file( TEMPLATE ).to_yaml ).should match template_meta
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should set configuration value' do
|
19
|
+
RuGPost::Project.config([],{:gmail=>'mygmail'})
|
20
|
+
YAML.load_file( CONFIG )[:gmail].should match 'mygmail'
|
21
|
+
RuGPost::Project.config([],{:gmail=>'project'})
|
22
|
+
YAML.load_file( CONFIG )[:gmail].should match 'project'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'Creating a repository' do
|
27
|
+
|
28
|
+
it 'should create rugpost repo' do
|
29
|
+
RuGPost::Project.add_repo(['rugpost'])
|
30
|
+
items=Dir.glob("*")
|
31
|
+
items.should include('rugpost')
|
32
|
+
substruct = Dir.glob("*/*")
|
33
|
+
substruct.should include('rugpost/drafts')
|
34
|
+
substruct.should include('rugpost/published')
|
35
|
+
published = Dir.glob("*/*/*")
|
36
|
+
published.should include('rugpost/published/source')
|
37
|
+
published.should include('rugpost/published/output')
|
38
|
+
lambda {RuGPost::Project.add_repo( ['rugpost'] )}.should raise_exception
|
39
|
+
lambda {RuGPost::Project.add_repo( [] )}.should raise_exception
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'RuGPost'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: RuGPost
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 62196407
|
5
|
+
prerelease: 6
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
- beta
|
11
|
+
- 2
|
12
|
+
version: 0.1.0.beta.2
|
13
|
+
platform: ruby
|
14
|
+
authors:
|
15
|
+
- emime
|
16
|
+
autorequire:
|
17
|
+
bindir: bin
|
18
|
+
cert_chain: []
|
19
|
+
|
20
|
+
date: 2011-05-08 00:00:00 Z
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :development
|
33
|
+
prerelease: false
|
34
|
+
requirement: *id001
|
35
|
+
name: shoulda
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 23
|
43
|
+
segments:
|
44
|
+
- 1
|
45
|
+
- 0
|
46
|
+
- 0
|
47
|
+
version: 1.0.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
requirement: *id002
|
51
|
+
name: bundler
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 15
|
59
|
+
segments:
|
60
|
+
- 1
|
61
|
+
- 6
|
62
|
+
- 0
|
63
|
+
version: 1.6.0
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
requirement: *id003
|
67
|
+
name: jeweler
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
requirement: *id004
|
81
|
+
name: rcov
|
82
|
+
description: Ru(by) G(mail) Post(erous) command line facility
|
83
|
+
email: e.141592@gmail.com
|
84
|
+
executables:
|
85
|
+
- rugpost
|
86
|
+
extensions: []
|
87
|
+
|
88
|
+
extra_rdoc_files:
|
89
|
+
- LICENSE.txt
|
90
|
+
- README.rdoc
|
91
|
+
files:
|
92
|
+
- .document
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.rdoc
|
97
|
+
- Rakefile
|
98
|
+
- RuGPost.gemspec
|
99
|
+
- VERSION
|
100
|
+
- bin/rugpost
|
101
|
+
- lib/.RuGPost.rb.swp
|
102
|
+
- lib/RuGPost.rb
|
103
|
+
- lib/rugpost/commands/post_commands.rb
|
104
|
+
- lib/rugpost/commands/project_commands.rb
|
105
|
+
- lib/rugpost/on_error.rb
|
106
|
+
- lib/rugpost/post.rb
|
107
|
+
- lib/rugpost/prepost.rb
|
108
|
+
- lib/rugpost/project.rb
|
109
|
+
- lib/rugpost/site.rb
|
110
|
+
- lib/rugpost/utilis.rb
|
111
|
+
- pkg/RuGPost-0.1.0.1.beta.gem
|
112
|
+
- spec/spec_helper.rb
|
113
|
+
- spec/spec_post.rb
|
114
|
+
- spec/spec_project.rb
|
115
|
+
- test/helper.rb
|
116
|
+
- test/test_RuGPost.rb
|
117
|
+
homepage: http://github.com/3mime/RuGPost
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
hash: 3
|
131
|
+
segments:
|
132
|
+
- 0
|
133
|
+
version: "0"
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ">"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
hash: 25
|
140
|
+
segments:
|
141
|
+
- 1
|
142
|
+
- 3
|
143
|
+
- 1
|
144
|
+
version: 1.3.1
|
145
|
+
requirements: []
|
146
|
+
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 1.8.1
|
149
|
+
signing_key:
|
150
|
+
specification_version: 3
|
151
|
+
summary: Ru(by) G(mail) Post(erous) command line facility for creating posts on Posterous
|
152
|
+
test_files: []
|
153
|
+
|