mr_hyde 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.ruby-version +1 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +77 -0
- data/Rakefile +12 -0
- data/bin/mrhyde +80 -0
- data/lib/mr_hyde/blog.rb +146 -0
- data/lib/mr_hyde/command.rb +22 -0
- data/lib/mr_hyde/commands/build.rb +20 -0
- data/lib/mr_hyde/commands/new.rb +43 -0
- data/lib/mr_hyde/commands/remove.rb +14 -0
- data/lib/mr_hyde/configuration.rb +30 -0
- data/lib/mr_hyde/extensions/.new.rb.swp +0 -0
- data/lib/mr_hyde/extensions/new.rb +23 -0
- data/lib/mr_hyde/version.rb +3 -0
- data/lib/mr_hyde.rb +93 -0
- data/lib/site_template/_mrhyde.yml +11 -0
- data/lib/site_template/site/css/main.css +0 -0
- data/lib/site_template/site/index.html +0 -0
- data/mr_hyde.gemspec +26 -0
- data/spec/build_spec.rb +49 -0
- data/spec/new_spec.rb +55 -0
- data/spec/rm_spec.rb +75 -0
- data/test/blog_test.rb +46 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ec62071e2cf42fc9b179c84964c68874b92babab
|
4
|
+
data.tar.gz: 6c6470ac9a73127c09b80618ec54c5b45ca0e25f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6ed4ab1d0e48757ec3640cbb0b099ac58b0ce2541eec6b38eb79847e3d917faee12e2291dd997fa64ed7eb2bf10779665a706edddf63f3b9f8c56284ceeb6920
|
7
|
+
data.tar.gz: b18c81a9d1d4923dbd8d0afe491909d711ba35587a094d472ea68fcbd8b0cee27050fcce25d559e1cdcb0fb356bd1156b5d52cf1d848f32d35dd7e29fe4bddb1
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.0
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 TODO: Write your name
|
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,77 @@
|
|
1
|
+
# MrHyde
|
2
|
+
|
3
|
+
Mr. Hyde lets you generate and manage as many sites as you want.
|
4
|
+
|
5
|
+
It's based on [Jekyll](https://github.com/jekyll/jekyll), in fact Mr. Hyde wraps Jekyll to give you the possibilty of managing many sites.
|
6
|
+
|
7
|
+
The current version is based on [Jekyll 2.5.3](https://github.com/jekyll/jekyll/tree/v2.5.3).
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'mr_hyde'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
$ bundle
|
21
|
+
```
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
```bash
|
26
|
+
$ gem install mr_hyde
|
27
|
+
```
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
In order to use Mr. Hyde the first thing you must do is creating the Mr. Hyde rootl folder with the next command:
|
32
|
+
|
33
|
+
```bash
|
34
|
+
$ mrhyde new [PATH]
|
35
|
+
```
|
36
|
+
|
37
|
+
The previuos command creates the basic structure folder in the passed in PATH or in the same folder if no PATH given.
|
38
|
+
|
39
|
+
Once created get in the Mr. Hyde root folder and you can execute the next commands:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
$ cd PATH
|
43
|
+
$ mrhyde site new SITE_NAME
|
44
|
+
$ mrhyde site build SITE_NAME
|
45
|
+
```
|
46
|
+
|
47
|
+
The above commands give you first site, by now if you want to run on a server get in the site/SITE_NAME and executes:
|
48
|
+
|
49
|
+
```bash
|
50
|
+
$ cd root_folder/site/site_name
|
51
|
+
$ jekyll serve
|
52
|
+
```
|
53
|
+
|
54
|
+
If you want to know more about this, please refer to [Jekyll](http://jekyllrb.com/).
|
55
|
+
|
56
|
+
Removing the built site is:
|
57
|
+
|
58
|
+
```bash
|
59
|
+
$ mrhyde site rm SITE_NAME
|
60
|
+
$ mrhyde site rm SITE_NAME --full
|
61
|
+
```
|
62
|
+
|
63
|
+
The last command with the _--full_ option removes the site source as well, so take care with this option.
|
64
|
+
|
65
|
+
You can see more information about the commands with the command line _--help_ option:
|
66
|
+
|
67
|
+
```bash
|
68
|
+
$ mrhyde site new --help
|
69
|
+
```
|
70
|
+
|
71
|
+
## Contributing
|
72
|
+
|
73
|
+
1. Fork it ( https://github.com/[my-github-username]/mr_hyde/fork )
|
74
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
75
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
76
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
77
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
ENV["JEKYLL_LOG_LEVEL"] = "error"
|
5
|
+
|
6
|
+
Rake::TestTask.new do |t|
|
7
|
+
t.libs.push "lib"
|
8
|
+
t.test_files = FileList["spec/*_spec.rb"]
|
9
|
+
#t.test_files = FileList["test/*_test.rb"]
|
10
|
+
#t.pattern = "test/*_test.rb"
|
11
|
+
t.verbose = true
|
12
|
+
end
|
data/bin/mrhyde
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
STDOUT.sync = true
|
4
|
+
|
5
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w{ .. lib })
|
6
|
+
|
7
|
+
require 'io/console'
|
8
|
+
require 'mercenary'
|
9
|
+
require 'mr_hyde'
|
10
|
+
require 'mr_hyde/commands/remove'
|
11
|
+
|
12
|
+
Mercenary.program(:mrhyde) do |p|
|
13
|
+
p.version MrHyde::VERSION
|
14
|
+
p.description "Mr. Hyde is a tool intended to manage as many blog as you want powered by Jekyll."
|
15
|
+
p.syntax "mrhyde <subcommand>"
|
16
|
+
|
17
|
+
p.command(:new) do |c|
|
18
|
+
c.syntax "new <subcommand>"
|
19
|
+
c.description "Creates a new Mr. Hyde site scaffold in path"
|
20
|
+
c.option "force", "--force", "Force creation even if PATH already exists"
|
21
|
+
|
22
|
+
c.action do |args, options|
|
23
|
+
MrHyde::Commands::New.process(args, options)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
p.command(:site) do |site|
|
28
|
+
site.syntax "site <subcommand>"
|
29
|
+
site.description "Manage all sites from command line"
|
30
|
+
|
31
|
+
site.command(:new) do |snew|
|
32
|
+
snew.syntax "new name[ name ... n]"
|
33
|
+
snew.description "Creates a new Jekyll site or sites"
|
34
|
+
|
35
|
+
snew.option "force", "--force", "Force creation even if PATH already exists"
|
36
|
+
snew.option "blank", "--blank", "Creates scaffolding but with empty files"
|
37
|
+
|
38
|
+
snew.action do |args, options|
|
39
|
+
MrHyde::Commands::New.process({ :type => :site, :args => args }, options)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
site.command(:remove) do |srm|
|
44
|
+
srm.syntax "remove name[ name ... n] "
|
45
|
+
srm.description "Remove a Jekyll site when on Mr.Hyde root folder. By default it removes just the built site."
|
46
|
+
|
47
|
+
srm.alias(:rm)
|
48
|
+
|
49
|
+
srm.option "force", "--force", "Don't ask for remove blog"
|
50
|
+
srm.option "all", "--all", "Remove all built sites. This option works alone."
|
51
|
+
srm.option "full", "--full", "Remove all built and draft site or sites. This option can be used with the rest of options."
|
52
|
+
|
53
|
+
srm.action do |args, options|
|
54
|
+
MrHyde::Commands::Remove.process(args, options)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
site.command(:build) do |sbuild|
|
59
|
+
sbuild.syntax "build name[ name ... n] "
|
60
|
+
sbuild.description "Build the named blog or blogs, by default if no name is indicated then all blog will be built"
|
61
|
+
|
62
|
+
sbuild.option "all", "--all", "Build all blogs"
|
63
|
+
|
64
|
+
sbuild.action do |args, options|
|
65
|
+
MrHyde::Commands::Build.process args, options
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
p.action do |args, options|
|
72
|
+
if args.empty?
|
73
|
+
puts p
|
74
|
+
else
|
75
|
+
unless p.has_command?(args.first)
|
76
|
+
MrHyde.logger.abort_with "Invalid command. Use --help for more information"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/lib/mr_hyde/blog.rb
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
require "jekyll"
|
2
|
+
require "fileutils"
|
3
|
+
require "mr_hyde"
|
4
|
+
require "mr_hyde/configuration"
|
5
|
+
|
6
|
+
# TODO: The site place must be taken from the default config or the one provided by user
|
7
|
+
module MrHyde
|
8
|
+
class Blog
|
9
|
+
|
10
|
+
class << self
|
11
|
+
# Creates the directory and necessary files for the blog
|
12
|
+
# args
|
13
|
+
# :name
|
14
|
+
# String => creates the concrete blog
|
15
|
+
# Array[String] => creates the correspondings blog names
|
16
|
+
# Returns
|
17
|
+
# boolean
|
18
|
+
def create(args, opts = {})
|
19
|
+
opts = MrHyde.configuration(opts)
|
20
|
+
|
21
|
+
if args.kind_of? Array and not args.empty?
|
22
|
+
args.each do |bn|
|
23
|
+
begin
|
24
|
+
create_blog(bn, opts)
|
25
|
+
rescue Exception => e
|
26
|
+
raise e unless e.class == SystemExit
|
27
|
+
end
|
28
|
+
end
|
29
|
+
elsif args.kind_of? String
|
30
|
+
create_blog args, opts
|
31
|
+
end
|
32
|
+
rescue Exception => e
|
33
|
+
MrHyde.logger.error "cannot create blog: #{e}"
|
34
|
+
end
|
35
|
+
|
36
|
+
# Removes the blog directory
|
37
|
+
# Params:
|
38
|
+
# Hash[:path] (String)
|
39
|
+
# Returns
|
40
|
+
# boolean
|
41
|
+
def remove(args, opts = {})
|
42
|
+
opts = MrHyde.configuration(opts)
|
43
|
+
|
44
|
+
if opts['all']
|
45
|
+
list(opts['sources']).each do |sm|
|
46
|
+
remove_blog sm, opts
|
47
|
+
end
|
48
|
+
elsif args.kind_of? Array
|
49
|
+
args.each do |sm|
|
50
|
+
remove_blog sm, opts
|
51
|
+
end
|
52
|
+
else
|
53
|
+
remove_blog args, opts
|
54
|
+
end
|
55
|
+
rescue Exception => e
|
56
|
+
MrHyde.logger.error "cannot remove the blog: #{e}"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Builds the blog
|
60
|
+
# Params:
|
61
|
+
# :name
|
62
|
+
# String => builds the concrete blog
|
63
|
+
# Array[String] => builds the correspondings blog names
|
64
|
+
# empty => It builds all blogs
|
65
|
+
# Returns
|
66
|
+
# boolean
|
67
|
+
def build(args, opts = {})
|
68
|
+
args = [args] if args.kind_of? String
|
69
|
+
opts = MrHyde.configuration(opts)
|
70
|
+
|
71
|
+
if opts["all"]
|
72
|
+
build_blogs list(opts['sources']), opts
|
73
|
+
elsif args.kind_of? Array
|
74
|
+
build_blogs args, opts
|
75
|
+
elsif args.kind_of? String
|
76
|
+
build_blog args
|
77
|
+
end
|
78
|
+
rescue Exception => e
|
79
|
+
MrHyde.logger.error "cannot build site: #{e}"
|
80
|
+
MrHyde.logger.error e.backtrace
|
81
|
+
end
|
82
|
+
|
83
|
+
def list(path)
|
84
|
+
entries = Dir.entries(path)
|
85
|
+
entries.reject! { |item| item == '.' or item == '..' }
|
86
|
+
entries
|
87
|
+
end
|
88
|
+
|
89
|
+
def exist?(name, opts)
|
90
|
+
File.exist? File.join(opts['sources'], name)
|
91
|
+
end
|
92
|
+
|
93
|
+
def built?(name, opts)
|
94
|
+
File.exist? File.join(opts['destination'], name)
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def create_blog(args, opts = {})
|
100
|
+
Jekyll::Commands::New.process [File.join(opts['sources'], args)], opts
|
101
|
+
exist? args, opts
|
102
|
+
end
|
103
|
+
|
104
|
+
def remove_blog(name, opts = {})
|
105
|
+
if opts['full'] and File.exist? File.join(opts['sources'], name)
|
106
|
+
FileUtils.remove_dir File.join(opts['sources'], name)
|
107
|
+
MrHyde.logger.info "#{name} removed from #{opts['sources']}"
|
108
|
+
end
|
109
|
+
if File.exist? File.join(opts['destination'], name)
|
110
|
+
FileUtils.remove_dir File.join(opts['destination'], name)
|
111
|
+
MrHyde.logger.info "#{name} removed from #{opts['destination']}"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def build_blogs(site_names, opts)
|
116
|
+
site_names.each do |sn|
|
117
|
+
begin
|
118
|
+
build_blog(sn, opts)
|
119
|
+
rescue Exception => e
|
120
|
+
MrHyde.logger.error e
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def build_blog(name, opts)
|
126
|
+
Jekyll::Commands::Build.process 'source' => File.join(opts['sources'], name),
|
127
|
+
'destination' => File.join(opts['destination'], name)
|
128
|
+
built? name, opts
|
129
|
+
end
|
130
|
+
|
131
|
+
def site?
|
132
|
+
File.exist? MrHyde.configuration.root
|
133
|
+
end
|
134
|
+
|
135
|
+
def check_blog(blog_name, method, message)
|
136
|
+
if not send(method, blog_name)
|
137
|
+
MrHyde.logger.debug message
|
138
|
+
return false
|
139
|
+
end
|
140
|
+
true
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "jekyll/command"
|
2
|
+
|
3
|
+
def command_class; Jekyll::Command; end
|
4
|
+
|
5
|
+
module MrHyde
|
6
|
+
class Command < command_class
|
7
|
+
class << self
|
8
|
+
# Create a full Jekyll configuration with the options passed in as overrides
|
9
|
+
#
|
10
|
+
# options - the configuration overrides
|
11
|
+
#
|
12
|
+
# Returns a full MrHyde configuration
|
13
|
+
def configuration_from_options(options)
|
14
|
+
MrHyde.configuration(options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def configuration
|
18
|
+
MrHyde.configuration
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
3
|
+
require "mr_hyde"
|
4
|
+
require "mr_hyde/configuration"
|
5
|
+
require "mr_hyde/extensions/new"
|
6
|
+
require "mr_hyde/command"
|
7
|
+
require "mr_hyde/blog"
|
8
|
+
|
9
|
+
module MrHyde
|
10
|
+
module Commands
|
11
|
+
class Build < MrHyde::Command
|
12
|
+
class << self
|
13
|
+
# Options
|
14
|
+
def process(args, opts = {})
|
15
|
+
MrHyde::Blog.build args, opts
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
3
|
+
require "jekyll"
|
4
|
+
|
5
|
+
require "mr_hyde"
|
6
|
+
require "mr_hyde/configuration"
|
7
|
+
require "mr_hyde/extensions/new"
|
8
|
+
require "mr_hyde/command"
|
9
|
+
require "mr_hyde/blog"
|
10
|
+
|
11
|
+
module MrHyde
|
12
|
+
module Commands
|
13
|
+
class New < MrHyde::Command
|
14
|
+
class << self
|
15
|
+
# Options
|
16
|
+
# :type => what type of element we want to create [:blog|:site]
|
17
|
+
# by default it creates a new MrHyde site
|
18
|
+
# if :type is :blog then
|
19
|
+
# :name => blog's name
|
20
|
+
#
|
21
|
+
def process(args, opts = {})
|
22
|
+
case args.delete(:type)
|
23
|
+
when :site then new_site(args[:args], opts)
|
24
|
+
else scaffold(args, opts)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def scaffold(args, opts)
|
31
|
+
new_site_path = MrHyde.create args, opts
|
32
|
+
MrHyde.logger.info "New Mr. Hyde Site installed in #{new_site_path}"
|
33
|
+
rescue SystemExit => se
|
34
|
+
MrHyde.logger.abort_with "Conflict:", se.message
|
35
|
+
end
|
36
|
+
|
37
|
+
def new_site(args, opts)
|
38
|
+
Blog.create(args, opts)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "jekyll/configuration"
|
2
|
+
|
3
|
+
module MrHyde
|
4
|
+
|
5
|
+
class Configuration < Jekyll::Configuration
|
6
|
+
|
7
|
+
DEFAULTS = {
|
8
|
+
'sources' => 'sources',
|
9
|
+
'destination' => 'site',
|
10
|
+
'config' => '_mrhyde.yml',
|
11
|
+
'jekyll_config' => '_jekyll.yml'
|
12
|
+
}
|
13
|
+
|
14
|
+
def read_config_files(files)
|
15
|
+
configuration = clone
|
16
|
+
|
17
|
+
begin
|
18
|
+
files.each do |config_file|
|
19
|
+
new_config = read_config_file(config_file)
|
20
|
+
configuration = Jekyll::Utils.deep_merge_hashes(configuration, new_config)
|
21
|
+
end
|
22
|
+
rescue ArgumentError => err
|
23
|
+
MrHyde.logger.warn "WARNING:", "Error reading configuration. " +
|
24
|
+
"Using defaults (and options)."
|
25
|
+
$stderr.puts "#{err}"
|
26
|
+
end
|
27
|
+
configuration
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
Binary file
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'jekyll/command'
|
2
|
+
require 'jekyll/commands/new'
|
3
|
+
|
4
|
+
module MrHyde
|
5
|
+
module Extensions
|
6
|
+
class New < Jekyll::Commands::New
|
7
|
+
class << self
|
8
|
+
def template
|
9
|
+
site_template
|
10
|
+
end
|
11
|
+
|
12
|
+
def default_config_file
|
13
|
+
File.join template, '_config.yml'
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_sample_site
|
17
|
+
create_sample_files
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/mr_hyde.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
require "mr_hyde/version"
|
2
|
+
require "mr_hyde/blog"
|
3
|
+
require "mr_hyde/configuration"
|
4
|
+
require "mr_hyde/commands/new"
|
5
|
+
require "mr_hyde/commands/build"
|
6
|
+
|
7
|
+
require "logger"
|
8
|
+
require "fileutils"
|
9
|
+
|
10
|
+
require "jekyll/stevenson"
|
11
|
+
require "jekyll/log_adapter"
|
12
|
+
require "jekyll/utils"
|
13
|
+
|
14
|
+
module MrHyde
|
15
|
+
class << self
|
16
|
+
attr_accessor :configuration
|
17
|
+
|
18
|
+
def configure
|
19
|
+
self.configuration ||= Configuration.new
|
20
|
+
yield(configuration) if block_given?
|
21
|
+
end
|
22
|
+
|
23
|
+
def configuration(override = Hash.new)
|
24
|
+
config = Configuration[Configuration::DEFAULTS]
|
25
|
+
override = Configuration[override].stringify_keys
|
26
|
+
|
27
|
+
unless override.delete('skip_config_files')
|
28
|
+
override['config'] ||= config['config']
|
29
|
+
config = config.read_config_files(config.config_files(override))
|
30
|
+
end
|
31
|
+
# Merge DEFAULTS < _config.yml < override
|
32
|
+
config = Jekyll::Utils.deep_merge_hashes(config, override).stringify_keys
|
33
|
+
set_timezone(config['timezone']) if config['timezone']
|
34
|
+
|
35
|
+
config
|
36
|
+
end
|
37
|
+
|
38
|
+
# Public: Fetch the logger instance for this Jekyll process.
|
39
|
+
#
|
40
|
+
# Returns the LogAdapter instance.
|
41
|
+
def logger
|
42
|
+
Jekyll.logger
|
43
|
+
end
|
44
|
+
|
45
|
+
# Creates the folders for the sources and destination,
|
46
|
+
# by default will be created under root folder.
|
47
|
+
# Copies the default _config.yml for all blogs, in root folder.
|
48
|
+
#
|
49
|
+
# Throws a SystemExit exception
|
50
|
+
#
|
51
|
+
def create(args, opts = {})
|
52
|
+
args = [args] if args.kind_of? String
|
53
|
+
new_site_path = File.expand_path(args.join(" "), Dir.pwd)
|
54
|
+
FileUtils.mkdir_p new_site_path
|
55
|
+
if preserve_source_location?(new_site_path, opts)
|
56
|
+
raise SystemExit.new "#{new_site_path} exists and is not empty."
|
57
|
+
end
|
58
|
+
|
59
|
+
if opts['blank']
|
60
|
+
create_black_site new_site_path
|
61
|
+
else
|
62
|
+
create_sample_files new_site_path
|
63
|
+
end
|
64
|
+
new_site_path
|
65
|
+
end
|
66
|
+
|
67
|
+
def build(opts = {})
|
68
|
+
Commands::Build.process opts
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def preserve_source_location?(path, opts)
|
74
|
+
!opts["force"] && !Dir["#{path}/**/*"].empty?
|
75
|
+
end
|
76
|
+
|
77
|
+
def create_sample_files(path)
|
78
|
+
FileUtils.cp_r site_template + '/.', path
|
79
|
+
FileUtils.copy_file MrHyde::Extensions::New.default_config_file,
|
80
|
+
File.join(path, '_jekyll.yml')
|
81
|
+
Dir.chdir(path) do
|
82
|
+
FileUtils.mkdir(%w(sources)) unless File.exist? 'sources'
|
83
|
+
Blog.create ['welcome_site'], { 'force' => 'force' }
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
def site_template
|
89
|
+
File.expand_path("./site_template", File.dirname(__FILE__))
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Site settings
|
2
|
+
title: Your awesome title
|
3
|
+
email: your-email@domain.com
|
4
|
+
description: > # this means to ignore newlines until "baseurl:"
|
5
|
+
Write an awesome description for your new site here. You can edit this
|
6
|
+
line in _config.yml. It will appear in your document head meta (for
|
7
|
+
Google search results) and in your feed.xml site description.
|
8
|
+
baseurl: "" # the subpath of your site, e.g. /blog/
|
9
|
+
url: "http://yourdomain.com" # the base hostname & protocol for your site
|
10
|
+
twitter_username: mrhyderb
|
11
|
+
github_username: mrhyde
|
File without changes
|
File without changes
|
data/mr_hyde.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mr_hyde/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mr_hyde"
|
8
|
+
spec.version = MrHyde::VERSION
|
9
|
+
spec.authors = ["Enrique Arias Cervero"]
|
10
|
+
spec.email = ["enrique.arias.cervero@gmail.com"]
|
11
|
+
spec.summary = %q{Mr. Hyde lets you generate and manage as many sites as you want.}
|
12
|
+
spec.description = %q{Mr. Hyde lets you generate and manage as many sites as you want, something similar like Medium. It's based on Jekyll.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "minitest", "~> 5.4", ">= 5.4.3"
|
24
|
+
|
25
|
+
spec.add_runtime_dependency "jekyll", "~> 2.5", "2.5.3"
|
26
|
+
end
|
data/spec/build_spec.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "minitest/pride"
|
3
|
+
require "mr_hyde"
|
4
|
+
require "mr_hyde/blog"
|
5
|
+
require "fileutils"
|
6
|
+
|
7
|
+
describe "MrHyde" do
|
8
|
+
before do
|
9
|
+
@path = 'mthyde_build_test'
|
10
|
+
MrHyde.create @path
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
FileUtils.remove_dir(@path) if File.exist? @path
|
15
|
+
end
|
16
|
+
|
17
|
+
it "can build a single site" do
|
18
|
+
Dir.chdir(File.join Dir.pwd, @path) do
|
19
|
+
MrHyde::Blog.create 'site_test'
|
20
|
+
MrHyde::Blog.build 'site_test'
|
21
|
+
File.exist?(File.join MrHyde::Configuration::DEFAULTS['destination'], 'site_test').must_be :==, true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "can build an array of sites" do
|
26
|
+
Dir.chdir(File.join Dir.pwd, @path) do
|
27
|
+
site_names = []
|
28
|
+
5.times { |i| site_names << "site_test_#{i}" }
|
29
|
+
MrHyde::Blog.create site_names
|
30
|
+
MrHyde::Blog.build site_names
|
31
|
+
site_names.each do |bn|
|
32
|
+
File.exist?(File.join MrHyde::Configuration::DEFAULTS['destination'], bn).must_be :==, true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "can build all sites in sources path" do
|
38
|
+
Dir.chdir(File.join Dir.pwd, @path) do
|
39
|
+
site_names = []
|
40
|
+
5.times { |i| site_names << "blog_test_#{i}" }
|
41
|
+
MrHyde::Blog.create site_names
|
42
|
+
MrHyde::Blog.build [], { 'all' => 'all' }
|
43
|
+
site_names.each do |bn|
|
44
|
+
File.exist?(File.join MrHyde::Configuration::DEFAULTS['destination'], bn).must_be :==, true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/spec/new_spec.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "minitest/pride"
|
3
|
+
require "mr_hyde"
|
4
|
+
require "mr_hyde/blog"
|
5
|
+
require "fileutils"
|
6
|
+
|
7
|
+
describe "MrHyde" do
|
8
|
+
before do
|
9
|
+
#@path = Dir.mktmpdir('mrhyde_new_test')
|
10
|
+
@path = 'mrhyde_new_test'
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
FileUtils.remove_dir(@path) if File.exist? @path
|
15
|
+
end
|
16
|
+
|
17
|
+
it "creates a new MrHyde folder with the basics" do
|
18
|
+
MrHyde.create @path
|
19
|
+
|
20
|
+
File.exist?(@path).must_be :==, true
|
21
|
+
File.exist?(File.join @path, MrHyde::Configuration::DEFAULTS['sources']).must_be :==, true
|
22
|
+
File.exist?(File.join @path, MrHyde::Configuration::DEFAULTS['destination']).must_be :==, true
|
23
|
+
File.exist?(File.join @path, MrHyde::Configuration::DEFAULTS['config']).must_be :==, true
|
24
|
+
File.exist?(File.join @path, MrHyde::Configuration::DEFAULTS['jekyll_config']).must_be :==, true
|
25
|
+
end
|
26
|
+
|
27
|
+
it "cannot create over an existing project" do
|
28
|
+
MrHyde.create @path
|
29
|
+
lambda { MrHyde.create @path }.must_raise SystemExit
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "creating new sites" do
|
33
|
+
before do
|
34
|
+
MrHyde.create @path
|
35
|
+
end
|
36
|
+
|
37
|
+
it "can create a single site" do
|
38
|
+
Dir.chdir(File.join Dir.pwd, @path) do
|
39
|
+
MrHyde::Blog.create 'site_test'
|
40
|
+
File.exist?(File.join MrHyde::Configuration::DEFAULTS['sources'], 'site_test').must_be :==, true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it "can create an array of sites" do
|
45
|
+
Dir.chdir(File.join Dir.pwd, @path) do
|
46
|
+
arr_blog_names = []
|
47
|
+
10.times { |i| arr_blog_names << "site_test_#{i}" }
|
48
|
+
MrHyde::Blog.create arr_blog_names
|
49
|
+
arr_blog_names.each do |bn|
|
50
|
+
File.exist?(File.join MrHyde::Configuration::DEFAULTS['sources'], bn).must_be :==, true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/spec/rm_spec.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "minitest/pride"
|
3
|
+
require "mr_hyde"
|
4
|
+
require "mr_hyde/blog"
|
5
|
+
require "fileutils"
|
6
|
+
|
7
|
+
describe "MrHyde" do
|
8
|
+
before do
|
9
|
+
#@path = Dir.mktmpdir('mrhyde_new_test')
|
10
|
+
@path = 'mrhyde_new_test'
|
11
|
+
@site = 'site_test'
|
12
|
+
MrHyde.create @path
|
13
|
+
end
|
14
|
+
|
15
|
+
after do
|
16
|
+
FileUtils.remove_dir(@path) if File.exist? @path
|
17
|
+
end
|
18
|
+
|
19
|
+
# Helpers
|
20
|
+
def create_build_remove(site, opts = {})
|
21
|
+
MrHyde::Blog.create site
|
22
|
+
MrHyde::Blog.build site
|
23
|
+
if opts['all']
|
24
|
+
MrHyde::Blog.remove [], opts
|
25
|
+
else
|
26
|
+
MrHyde::Blog.remove site, opts
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def remove_site(path, site, opts = {})
|
31
|
+
Dir.chdir(File.join Dir.pwd, path) do
|
32
|
+
create_build_remove site, opts
|
33
|
+
File.exist?(File.join MrHyde::Configuration::DEFAULTS['sources'], site).must_be :==, (opts['full'] ? false : true)
|
34
|
+
File.exist?(File.join MrHyde::Configuration::DEFAULTS['destination'], site).must_be :==, false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def remove_sites(path, sites_number, opts = {})
|
39
|
+
site_names = []
|
40
|
+
sites_number.times { |i| site_names << "site_test_#{i}" }
|
41
|
+
|
42
|
+
Dir.chdir(File.join Dir.pwd, path) do
|
43
|
+
create_build_remove site_names, opts
|
44
|
+
site_names.each do |sn|
|
45
|
+
File.exist?(File.join MrHyde::Configuration::DEFAULTS['sources'], sn).must_be :==, (opts['full'] ? false : true)
|
46
|
+
File.exist?(File.join MrHyde::Configuration::DEFAULTS['destination'], sn).must_be :==, false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Specs
|
52
|
+
it "can remove a built site" do
|
53
|
+
remove_site @path, @site
|
54
|
+
end
|
55
|
+
|
56
|
+
it "can remove a list of built sites" do
|
57
|
+
remove_sites @path, 5
|
58
|
+
end
|
59
|
+
|
60
|
+
it "can remove all built sites" do
|
61
|
+
remove_sites @path, 5, { 'all' => 'all' }
|
62
|
+
end
|
63
|
+
|
64
|
+
it "can remove a site completely" do
|
65
|
+
remove_site @path, @site, { 'full' => 'full' }
|
66
|
+
end
|
67
|
+
|
68
|
+
it "can remove a list of sites completely" do
|
69
|
+
remove_sites @path, 5, { 'full' => 'full' }
|
70
|
+
end
|
71
|
+
|
72
|
+
it "can remove all sites completely" do
|
73
|
+
remove_sites @path, 5, { 'all' => 'all', 'full' => 'full' }
|
74
|
+
end
|
75
|
+
end
|
data/test/blog_test.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require "mr_hyde"
|
2
|
+
require "mr_hyde/blog"
|
3
|
+
require "minitest/autorun"
|
4
|
+
require "minitest/unit"
|
5
|
+
require "minitest/pride"
|
6
|
+
|
7
|
+
require "fileutils"
|
8
|
+
|
9
|
+
class TestBlog < Minitest::Test
|
10
|
+
def setup
|
11
|
+
@tmp_dir = File.join(File.expand_path(File.dirname(__FILE__)), 'tmp')
|
12
|
+
@blog_dir = 'test_blog'
|
13
|
+
MrHyde.configure do |config|
|
14
|
+
config.root_path = @tmp_dir
|
15
|
+
end
|
16
|
+
MrHyde::Blog.create name: @blog_dir
|
17
|
+
end
|
18
|
+
|
19
|
+
def teardown
|
20
|
+
FileUtils.remove_dir @tmp_dir
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_create
|
24
|
+
assert File.exist?(File.join MrHyde.configuration.source_path, @blog_dir)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_remove
|
28
|
+
MrHyde::Blog.remove name: @blog_dir
|
29
|
+
assert !Dir.entries(MrHyde.configuration.source_path).include?(@blog_dir)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_build
|
33
|
+
MrHyde::Blog.build name: @blog_dir
|
34
|
+
assert File.exist?(File.join MrHyde.configuration.destination_path, @blog_dir)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_exists
|
38
|
+
assert MrHyde::Blog.exist? @blog_dir
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_is_build
|
42
|
+
MrHyde::Blog.build name: @blog_dir
|
43
|
+
assert MrHyde::Blog.built? @blog_dir
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mr_hyde
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Enrique Arias Cervero
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.4'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 5.4.3
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '5.4'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 5.4.3
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: jekyll
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '2.5'
|
68
|
+
- - '='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 2.5.3
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '2.5'
|
78
|
+
- - '='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 2.5.3
|
81
|
+
description: Mr. Hyde lets you generate and manage as many sites as you want, something
|
82
|
+
similar like Medium. It's based on Jekyll.
|
83
|
+
email:
|
84
|
+
- enrique.arias.cervero@gmail.com
|
85
|
+
executables:
|
86
|
+
- mrhyde
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".ruby-version"
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/mrhyde
|
97
|
+
- lib/mr_hyde.rb
|
98
|
+
- lib/mr_hyde/blog.rb
|
99
|
+
- lib/mr_hyde/command.rb
|
100
|
+
- lib/mr_hyde/commands/build.rb
|
101
|
+
- lib/mr_hyde/commands/new.rb
|
102
|
+
- lib/mr_hyde/commands/remove.rb
|
103
|
+
- lib/mr_hyde/configuration.rb
|
104
|
+
- lib/mr_hyde/extensions/.new.rb.swp
|
105
|
+
- lib/mr_hyde/extensions/new.rb
|
106
|
+
- lib/mr_hyde/version.rb
|
107
|
+
- lib/site_template/_mrhyde.yml
|
108
|
+
- lib/site_template/site/css/main.css
|
109
|
+
- lib/site_template/site/index.html
|
110
|
+
- mr_hyde.gemspec
|
111
|
+
- spec/build_spec.rb
|
112
|
+
- spec/new_spec.rb
|
113
|
+
- spec/rm_spec.rb
|
114
|
+
- test/blog_test.rb
|
115
|
+
homepage: ''
|
116
|
+
licenses:
|
117
|
+
- MIT
|
118
|
+
metadata: {}
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
requirements: []
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 2.4.5
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: Mr. Hyde lets you generate and manage as many sites as you want.
|
139
|
+
test_files:
|
140
|
+
- spec/build_spec.rb
|
141
|
+
- spec/new_spec.rb
|
142
|
+
- spec/rm_spec.rb
|
143
|
+
- test/blog_test.rb
|