monk 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2008 Michel Martens and Damian Janowski
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -8,7 +8,7 @@ Description
8
8
 
9
9
  Monk is a glue framework for web development. It means that instead of
10
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
11
+ git repository and a list of dependencies, and Monk takes care of the
12
12
  rest. By default, it ships with a Sinatra application that includes
13
13
  Contest, Stories, Webrat, Ohm and some other niceties, along with a
14
14
  structure and helpful documentation to get your hands wet in no time.
@@ -28,7 +28,7 @@ Install the monk gem and create your project:
28
28
  $ cd myapp
29
29
  $ rake
30
30
 
31
- If the tests pass, it means that you can start hacking righ away. If
31
+ If the tests pass, it means that you can start hacking right away. If
32
32
  they don't, just follow the instructions. As the default skeleton
33
33
  is very opinionated, you will probably need to install and run
34
34
  [Redis](http://code.google.com/p/redis/), a key-value database.
data/bin/monk CHANGED
@@ -1,51 +1,13 @@
1
1
  #! /usr/bin/env ruby
2
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
3
+ require File.join(File.dirname(__FILE__), "..", "lib", "monk")
46
4
 
5
+ # A way to extend Monk is to write tasks in a Thorfile in the project's root directory.
6
+ # Monk loads the Thorfile if there is one, and all the tasks that are declared in the
7
+ # class Monk become available.
47
8
  if File.exists?("Thorfile")
48
9
  load("Thorfile")
49
10
  end
50
11
 
51
- MonkTasks.start
12
+ # Start the monk tasks.
13
+ Monk.start
@@ -1,56 +1,51 @@
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
1
+ #! /usr/bin/env ruby
2
+
3
+ require "thor"
12
4
 
13
- require "sinatra/base"
14
- require "haml"
15
- require "sass"
5
+ class Monk < Thor
6
+ include Thor::Actions
16
7
 
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")
8
+ desc "init", "Initialize a Monk application"
9
+ def init(target)
10
+ clone(source, target)
11
+ cleanup(target)
12
+ end
28
13
 
29
- use Rack::Session::Cookie
14
+ private
15
+
16
+ def clone(source, target)
17
+ say_status :fetching, source
18
+ system "git clone -q --depth 1 #{source} #{target}"
19
+ end
30
20
 
31
- configure :development do
32
- use Sinatra::Reloader
21
+ def cleanup(target)
22
+ inside(target) { remove_file ".git" }
23
+ say_status :create, target
33
24
  end
34
25
 
35
- configure :development, :test do
36
- require "ruby-debug" rescue LoadError
26
+ def source
27
+ monk_config["default"]
37
28
  end
38
29
 
39
- helpers do
30
+ def monk_config_file
31
+ @monk_config_file ||= File.join(Thor::Util.user_home, ".monk")
32
+ end
40
33
 
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)
34
+ def monk_config
35
+ @monk_config ||= begin
36
+ write_monk_config_file unless File.exists?(monk_config_file)
37
+ @monk_config = YAML.load_file(monk_config_file)
45
38
  end
39
+ end
46
40
 
47
- # TODO Add documentation.
48
- def partial(template, locals = {})
49
- haml(template, {:layout => false}, locals)
41
+ def write_monk_config_file
42
+ create_file monk_config_file do
43
+ config = { "default" => "git://github.com/monkrb/skeleton.git" }
44
+ config.to_yaml
50
45
  end
51
46
  end
52
- end
53
47
 
54
- require "monk/reloader"
55
- require "monk/logger"
56
- require "monk/settings"
48
+ def self.source_root
49
+ "."
50
+ end
51
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "monk"
3
- s.version = "0.0.2"
3
+ s.version = "0.0.3"
4
4
  s.summary = "Monk, the glue framework"
5
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
6
  s.authors = ["Damian Janowski", "Michel Martens"]
@@ -15,5 +15,5 @@ Gem::Specification.new do |s|
15
15
  s.add_dependency("dependencies", ">= 0.0.5")
16
16
  s.requirements << "git"
17
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"]
18
+ s.files = ["LICENSE", "README.markdown", "Rakefile", "bin/monk", "lib/monk.rb", "monk.gemspec", "test/integration_test.rb", "test/sinatra_test.rb"]
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damian Janowski
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-07-22 00:00:00 -03:00
13
+ date: 2009-07-23 00:00:00 -03:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -44,12 +44,10 @@ extensions: []
44
44
  extra_rdoc_files: []
45
45
 
46
46
  files:
47
+ - LICENSE
47
48
  - README.markdown
48
49
  - Rakefile
49
50
  - bin/monk
50
- - lib/monk/logger.rb
51
- - lib/monk/reloader.rb
52
- - lib/monk/settings.rb
53
51
  - lib/monk.rb
54
52
  - monk.gemspec
55
53
  - test/integration_test.rb
@@ -1,11 +0,0 @@
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
@@ -1,10 +0,0 @@
1
- require "rack/reloader"
2
-
3
- # TODO Add documentation.
4
- class Monk::Reloader < Rack::Reloader
5
- def safe_load(file, mtime, stderr = $stderr)
6
- super
7
- Monk.reset!
8
- super(Monk.app_file, mtime, stderr)
9
- end
10
- end
@@ -1,14 +0,0 @@
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
-