monk 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +70 -0
- data/Rakefile +5 -0
- data/bin/monk +51 -0
- data/lib/monk.rb +56 -0
- data/lib/monk/logger.rb +11 -0
- data/lib/monk/reloader.rb +10 -0
- data/lib/monk/settings.rb +14 -0
- data/monk.gemspec +19 -0
- data/test/integration_test.rb +30 -0
- data/test/sinatra_test.rb +13 -0
- metadata +47 -16
data/README.markdown
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
Monk
|
2
|
+
====
|
3
|
+
|
4
|
+
The glue framework for web development.
|
5
|
+
|
6
|
+
Description
|
7
|
+
-----------
|
8
|
+
|
9
|
+
Monk is a glue framework for web development. It means that instead of
|
10
|
+
installing all the tools you need for your projects, you can rely on a
|
11
|
+
git repository and a list of dependencies, and Monk will care of the
|
12
|
+
rest. By default, it ships with a Sinatra application that includes
|
13
|
+
Contest, Stories, Webrat, Ohm and some other niceties, along with a
|
14
|
+
structure and helpful documentation to get your hands wet in no time.
|
15
|
+
|
16
|
+
But Monk also respects your tastes, and you are invited to create your
|
17
|
+
own versions of the skeleton app and your own list of dependencies. You
|
18
|
+
can add many different templates (different git repositories) and Monk
|
19
|
+
will help you manage them all.
|
20
|
+
|
21
|
+
Usage
|
22
|
+
-----
|
23
|
+
|
24
|
+
Install the monk gem and create your project:
|
25
|
+
|
26
|
+
$ sudo gem install monk
|
27
|
+
$ monk init myapp
|
28
|
+
$ cd myapp
|
29
|
+
$ rake
|
30
|
+
|
31
|
+
If the tests pass, it means that you can start hacking righ away. If
|
32
|
+
they don't, just follow the instructions. As the default skeleton
|
33
|
+
is very opinionated, you will probably need to install and run
|
34
|
+
[Redis](http://code.google.com/p/redis/), a key-value database.
|
35
|
+
|
36
|
+
Check the `dependencies` file in the root of your project to see what
|
37
|
+
else is there. Monk works with git almost exclusively, but your project
|
38
|
+
can also depend on gems. Check the dependencies file to see what options
|
39
|
+
you have, and run the `dep` command line tool to verify it.
|
40
|
+
|
41
|
+
Installation
|
42
|
+
------------
|
43
|
+
|
44
|
+
$ sudo gem install monk
|
45
|
+
|
46
|
+
License
|
47
|
+
-------
|
48
|
+
|
49
|
+
Copyright (c) 2009 Michel Martens and Damian Janowski
|
50
|
+
|
51
|
+
Permission is hereby granted, free of charge, to any person
|
52
|
+
obtaining a copy of this software and associated documentation
|
53
|
+
files (the "Software"), to deal in the Software without
|
54
|
+
restriction, including without limitation the rights to use,
|
55
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
56
|
+
copies of the Software, and to permit persons to whom the
|
57
|
+
Software is furnished to do so, subject to the following
|
58
|
+
conditions:
|
59
|
+
|
60
|
+
The above copyright notice and this permission notice shall be
|
61
|
+
included in all copies or substantial portions of the Software.
|
62
|
+
|
63
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
64
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
65
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
66
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
67
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
68
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
69
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
70
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/monk
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
class MonkTasks < Thor
|
6
|
+
namespace :monk
|
7
|
+
|
8
|
+
include Thor::Actions
|
9
|
+
|
10
|
+
desc "init", "Initialize a Monk application"
|
11
|
+
def init(target)
|
12
|
+
say_status :fetching, source
|
13
|
+
system "git clone -q --depth 1 #{source} #{target}"
|
14
|
+
inside(target) { remove_file ".git" }
|
15
|
+
say_status :create, target
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def source
|
21
|
+
monk_config["default"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def monk_config_file
|
25
|
+
@monk_config_file ||= File.join(Thor::Util.user_home, ".monk")
|
26
|
+
end
|
27
|
+
|
28
|
+
def monk_config
|
29
|
+
@monk_config ||= begin
|
30
|
+
write_monk_config_file unless File.exists?(monk_config_file)
|
31
|
+
@monk_config = YAML.load_file(monk_config_file)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def write_monk_config_file
|
36
|
+
create_file monk_config_file do
|
37
|
+
config = { "default" => "git://github.com/monkrb/skeleton.git" }
|
38
|
+
config.to_yaml
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.source_root
|
43
|
+
"."
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
if File.exists?("Thorfile")
|
48
|
+
load("Thorfile")
|
49
|
+
end
|
50
|
+
|
51
|
+
MonkTasks.start
|
data/lib/monk.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# This file contains the bootstraping code for a Monk application.
|
2
|
+
RACK_ENV = ENV["RACK_ENV"] ||= "development" unless defined? RACK_ENV
|
3
|
+
|
4
|
+
# Helper method for file references.
|
5
|
+
#
|
6
|
+
# @param args [Array] Path components relative to ROOT_DIR.
|
7
|
+
# @example Referencing a file in config called settings.yml:
|
8
|
+
# root_path("config", "settings.yml")
|
9
|
+
def root_path(*args)
|
10
|
+
File.join(ROOT_DIR, *args)
|
11
|
+
end
|
12
|
+
|
13
|
+
require "sinatra/base"
|
14
|
+
require "haml"
|
15
|
+
require "sass"
|
16
|
+
|
17
|
+
# TODO Add documentation.
|
18
|
+
class Monk < Sinatra::Base
|
19
|
+
set :dump_errors, true
|
20
|
+
set :logging, true
|
21
|
+
set :methodoverride, true
|
22
|
+
set :raise_errors, Proc.new { test? }
|
23
|
+
set :root, root_path
|
24
|
+
set :run, Proc.new { $0 == app_file }
|
25
|
+
set :show_exceptions, Proc.new { development? }
|
26
|
+
set :static, true
|
27
|
+
set :views, root_path("app", "views")
|
28
|
+
|
29
|
+
use Rack::Session::Cookie
|
30
|
+
|
31
|
+
configure :development do
|
32
|
+
use Sinatra::Reloader
|
33
|
+
end
|
34
|
+
|
35
|
+
configure :development, :test do
|
36
|
+
require "ruby-debug" rescue LoadError
|
37
|
+
end
|
38
|
+
|
39
|
+
helpers do
|
40
|
+
|
41
|
+
# TODO Add documentation.
|
42
|
+
def haml(template, options = {}, locals = {})
|
43
|
+
options[:escape_html] = true unless options.include?(:escape_html)
|
44
|
+
super(template, options, locals)
|
45
|
+
end
|
46
|
+
|
47
|
+
# TODO Add documentation.
|
48
|
+
def partial(template, locals = {})
|
49
|
+
haml(template, {:layout => false}, locals)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
require "monk/reloader"
|
55
|
+
require "monk/logger"
|
56
|
+
require "monk/settings"
|
data/lib/monk/logger.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
# TODO Add documentation.
|
4
|
+
def logger
|
5
|
+
$logger ||= begin
|
6
|
+
$logger = ::Logger.new(root_path("log", "#{RACK_ENV}.log"))
|
7
|
+
$logger.level = ::Logger.const_get((settings(:log_level) || :warn).to_s.upcase)
|
8
|
+
$logger.datetime_format = "%Y-%m-%d %H:%M:%S"
|
9
|
+
$logger
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
# TODO Add documentation.
|
4
|
+
def settings(key)
|
5
|
+
$settings ||= YAML.load_file(root_path("config", "settings.yml"))[RACK_ENV.to_sym]
|
6
|
+
|
7
|
+
unless $settings.include?(key)
|
8
|
+
message = "No setting defined for #{key.inspect}."
|
9
|
+
defined?(logger) ? logger.warn(message) : $stderr.puts(message)
|
10
|
+
end
|
11
|
+
|
12
|
+
$settings[key]
|
13
|
+
end
|
14
|
+
|
data/monk.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "monk"
|
3
|
+
s.version = "0.0.2"
|
4
|
+
s.summary = "Monk, the glue framework"
|
5
|
+
s.description = "Monk is a glue framework for web development. It means that instead of installing all the tools you need for your projects, you can rely on a git repository and a list of dependencies, and Monk will care of the rest. By default, it ships with a Sinatra application that includes Contest, Stories, Webrat, Ohm and some other niceties, along with a structure and helpful documentation to get your hands wet in no time."
|
6
|
+
s.authors = ["Damian Janowski", "Michel Martens"]
|
7
|
+
s.email = ["djanowski@dimaion.com", "michel@soveran.com"]
|
8
|
+
s.homepage = "http://monkrb.com"
|
9
|
+
|
10
|
+
s.rubyforge_project = "monk"
|
11
|
+
|
12
|
+
s.executables << "monk"
|
13
|
+
|
14
|
+
s.add_dependency("wycats-thor", "~> 0.11")
|
15
|
+
s.add_dependency("dependencies", ">= 0.0.5")
|
16
|
+
s.requirements << "git"
|
17
|
+
|
18
|
+
s.files = ["README.markdown", "Rakefile", "bin/monk", "lib/monk/logger.rb", "lib/monk/reloader.rb", "lib/monk/settings.rb", "lib/monk.rb", "monk.gemspec", "test/integration_test.rb", "test/sinatra_test.rb"]
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "contest"
|
3
|
+
require "open3"
|
4
|
+
|
5
|
+
BINARY = File.expand_path(File.join(File.dirname(__FILE__), "..", "bin", "monk"))
|
6
|
+
|
7
|
+
class TestMonk < Test::Unit::TestCase
|
8
|
+
context "monk init" do
|
9
|
+
def monk(args = nil)
|
10
|
+
out, err = nil
|
11
|
+
|
12
|
+
Open3.popen3("ruby -rubygems #{BINARY} #{args}") do |stdin, stdout, stderr|
|
13
|
+
out = stdout.read
|
14
|
+
err = stderr.read
|
15
|
+
end
|
16
|
+
|
17
|
+
[out, err]
|
18
|
+
end
|
19
|
+
|
20
|
+
should "create a skeleton app with all tests passing" do
|
21
|
+
Dir.chdir("/tmp") do
|
22
|
+
FileUtils.rm_rf("monk-test")
|
23
|
+
|
24
|
+
out, err = monk("init monk-test")
|
25
|
+
assert out[/create.* monk-test/]
|
26
|
+
assert !File.directory?("monk-test/.git")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class SinatraTest < Test::Unit::TestCase
|
4
|
+
it 'creates a new Sinatra::Base subclass on new' do
|
5
|
+
app =
|
6
|
+
Sinatra.new do
|
7
|
+
get '/' do
|
8
|
+
'Hello World'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
assert_same Sinatra::Base, app.superclass
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,30 +1,61 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Damian Janowski
|
8
|
+
- Michel Martens
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
|
12
|
-
date: 2009-07-
|
13
|
+
date: 2009-07-22 00:00:00 -03:00
|
13
14
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: wycats-thor
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0.11"
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: dependencies
|
28
|
+
type: :runtime
|
29
|
+
version_requirement:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.0.5
|
35
|
+
version:
|
36
|
+
description: Monk is a glue framework for web development. It means that instead of installing all the tools you need for your projects, you can rely on a git repository and a list of dependencies, and Monk will care of the rest. By default, it ships with a Sinatra application that includes Contest, Stories, Webrat, Ohm and some other niceties, along with a structure and helpful documentation to get your hands wet in no time.
|
37
|
+
email:
|
38
|
+
- djanowski@dimaion.com
|
39
|
+
- michel@soveran.com
|
40
|
+
executables:
|
41
|
+
- monk
|
20
42
|
extensions: []
|
21
43
|
|
22
44
|
extra_rdoc_files: []
|
23
45
|
|
24
|
-
files:
|
25
|
-
|
46
|
+
files:
|
47
|
+
- README.markdown
|
48
|
+
- Rakefile
|
49
|
+
- bin/monk
|
50
|
+
- lib/monk/logger.rb
|
51
|
+
- lib/monk/reloader.rb
|
52
|
+
- lib/monk/settings.rb
|
53
|
+
- lib/monk.rb
|
54
|
+
- monk.gemspec
|
55
|
+
- test/integration_test.rb
|
56
|
+
- test/sinatra_test.rb
|
26
57
|
has_rdoc: true
|
27
|
-
homepage:
|
58
|
+
homepage: http://monkrb.com
|
28
59
|
licenses: []
|
29
60
|
|
30
61
|
post_install_message:
|
@@ -44,12 +75,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
75
|
- !ruby/object:Gem::Version
|
45
76
|
version: "0"
|
46
77
|
version:
|
47
|
-
requirements:
|
48
|
-
|
49
|
-
rubyforge_project:
|
78
|
+
requirements:
|
79
|
+
- git
|
80
|
+
rubyforge_project: monk
|
50
81
|
rubygems_version: 1.3.4
|
51
82
|
signing_key:
|
52
83
|
specification_version: 3
|
53
|
-
summary:
|
84
|
+
summary: Monk, the glue framework
|
54
85
|
test_files: []
|
55
86
|
|