monk 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/bin/monk CHANGED
@@ -1,4 +1,4 @@
1
- #! /usr/bin/env ruby
1
+ #! /usr/bin/env ruby -rubygems
2
2
 
3
3
  require File.join(File.dirname(__FILE__), "..", "lib", "monk")
4
4
 
@@ -1,6 +1,7 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
3
  require "thor"
4
+ require "yaml"
4
5
 
5
6
  class Monk < Thor
6
7
  include Thor::Actions
@@ -57,7 +58,7 @@ private
57
58
  end
58
59
 
59
60
  def monk_config_file
60
- @monk_config_file ||= File.join(Thor::Util.user_home, ".monk")
61
+ @monk_config_file ||= File.join(monk_home, ".monk")
61
62
  end
62
63
 
63
64
  def monk_config
@@ -83,4 +84,8 @@ private
83
84
  "Couldn't clone repository into target directory '#{target}'. " +
84
85
  "You must have git installed and the target directory must be empty."
85
86
  end
87
+
88
+ def monk_home
89
+ ENV["MONK_HOME"] || File.join(Thor::Util.user_home)
90
+ end
86
91
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "monk"
3
- s.version = "0.0.5"
3
+ s.version = "0.0.6"
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"]
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
12
12
  s.executables << "monk"
13
13
 
14
14
  s.add_dependency("thor", "~> 0.11")
15
- s.add_dependency("dependencies", ">= 0.0.6")
15
+ s.add_dependency("dependencies", ">= 0.0.7")
16
16
  s.requirements << "git"
17
17
 
18
- s.files = ["LICENSE", "README.markdown", "Rakefile", "bin/monk", "lib/monk.rb", "monk.gemspec", "test/commands.rb", "test/integration_test.rb", "test/monk_test.rb"]
18
+ s.files = ["LICENSE", "README.markdown", "Rakefile", "bin/monk", "lib/monk.rb", "monk.gemspec", "test/commands.rb", "test/integration_test.rb", "test/monk_test.rb", "test/test_helper.rb"]
19
19
  end
@@ -13,11 +13,18 @@ module Test::Commands
13
13
  [out, err]
14
14
  end
15
15
 
16
+ # Runs a command in the background, silencing all output.
17
+ # For debugging purposes, set the environment variable VERBOSE.
16
18
  def sh_bg(cmd)
17
- silence_stream($stdout) do
18
- silence_stream($stderr) do
19
- (pid = fork) ? Process.detach(pid) : exec("#{cmd} 2>&1>/dev/null")
20
- end
19
+ if ENV["VERBOSE"]
20
+ streams_to_silence = []
21
+ else
22
+ streams_to_silence = [$stdout, $stderr]
23
+ cmd = "#{cmd} 2>&1>/dev/null"
24
+ end
25
+
26
+ silence_stream(*streams_to_silence) do
27
+ (pid = fork) ? Process.detach(pid) : exec(cmd)
21
28
  end
22
29
  end
23
30
 
@@ -50,12 +57,16 @@ module Test::Commands
50
57
  list.map {|s| s[/^.+? (\d+)/, 1] }
51
58
  end
52
59
 
53
- def silence_stream(stream)
54
- old_stream = stream.dup
55
- stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
56
- stream.sync = true
60
+ def silence_stream(*streams) #:yeild:
61
+ on_hold = streams.collect{ |stream| stream.dup }
62
+ streams.each do |stream|
63
+ stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
64
+ stream.sync = true
65
+ end
57
66
  yield
58
67
  ensure
59
- stream.reopen(old_stream)
68
+ streams.each_with_index do |stream, i|
69
+ stream.reopen(on_hold[i])
70
+ end
60
71
  end
61
72
  end
@@ -1,24 +1,6 @@
1
- require "rubygems"
2
- require "contest"
3
- require "hpricot"
4
-
5
- ROOT = File.expand_path(File.join(File.dirname(__FILE__), ".."))
6
-
7
- $:.unshift ROOT
8
-
9
- require "test/commands"
1
+ require File.join(File.dirname(__FILE__), "test_helper")
10
2
 
11
3
  class TestMonk < Test::Unit::TestCase
12
- include Test::Commands
13
-
14
- def root(*args)
15
- File.join(ROOT, *args)
16
- end
17
-
18
- def monk(args = nil)
19
- sh("ruby -rubygems #{root "bin/monk"} #{args}")
20
- end
21
-
22
4
  context "monk init NAME" do
23
5
  setup do
24
6
  @ports_to_close = []
@@ -77,8 +59,8 @@ class TestMonk < Test::Unit::TestCase
77
59
  sh "redis-server config/redis/development.conf"
78
60
  wait_for_service("0.0.0.0", 6379)
79
61
 
80
- assert sh("rake"), "the build didn't pass."
81
- assert sh("rake1.9"), "the build didn't pass under Ruby 1.9."
62
+ assert system("rake >/dev/null"), "the build didn't pass"
63
+ assert system("rake1.9 >/dev/null"), "the build didn't pass (1.9)"
82
64
 
83
65
  try_server "ruby init.rb", 4567
84
66
  try_reloading
@@ -87,6 +69,9 @@ class TestMonk < Test::Unit::TestCase
87
69
  try_server "ruby1.9 init.rb", 4567
88
70
  try_reloading
89
71
  try_server "rackup1.9", 9292
72
+
73
+ try_server "jruby init.rb", 4567
74
+ try_reloading
90
75
  end
91
76
  end
92
77
  end
@@ -96,6 +81,11 @@ class TestMonk < Test::Unit::TestCase
96
81
  sleep 0.2
97
82
  assert_match /Goodbye/, sh("curl 0.0.0.0:4567").first
98
83
  end
84
+
85
+ gsub_file("init.rb", "Main.run!", %Q(Main.get "/test" { 'test' }\n Main.run!)) do
86
+ sleep 0.2
87
+ assert_match /test/, sh("curl 0.0.0.0:4567/test").first
88
+ end
99
89
  end
100
90
 
101
91
  def gsub_file(file, *args)
@@ -1,24 +1,6 @@
1
- require "rubygems"
2
- require "contest"
3
- require "hpricot"
4
-
5
- ROOT = File.expand_path(File.join(File.dirname(__FILE__), ".."))
6
-
7
- $:.unshift ROOT
8
-
9
- require "test/commands"
1
+ require File.join(File.dirname(__FILE__), "test_helper")
10
2
 
11
3
  class TestMonk < Test::Unit::TestCase
12
- include Test::Commands
13
-
14
- def root(*args)
15
- File.join(ROOT, *args)
16
- end
17
-
18
- def monk(args = nil)
19
- sh("ruby -rubygems #{root "bin/monk"} #{args}")
20
- end
21
-
22
4
  context "monk init NAME" do
23
5
  should "fail if the target working directory is not empty" do
24
6
  Dir.chdir(root("test", "tmp")) do
@@ -0,0 +1,27 @@
1
+ require "rubygems"
2
+ require "contest"
3
+ require "hpricot"
4
+
5
+ ROOT = File.expand_path(File.join(File.dirname(__FILE__), ".."))
6
+
7
+ $:.unshift ROOT
8
+
9
+ require "test/commands"
10
+
11
+ class Test::Unit::TestCase
12
+ include Test::Commands
13
+
14
+ def root(*args)
15
+ File.join(ROOT, *args)
16
+ end
17
+
18
+ def setup
19
+ dot_monk = File.join(ROOT, "test", "tmp", ".monk")
20
+
21
+ FileUtils.rm(dot_monk) if File.exist?(dot_monk)
22
+ end
23
+
24
+ def monk(args = nil)
25
+ sh("env MONK_HOME=#{File.join(ROOT, "test", "tmp")} ruby -rubygems #{root "bin/monk"} #{args}")
26
+ end
27
+ 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.5
4
+ version: 0.0.6
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-08-07 00:00:00 -03:00
13
+ date: 2009-09-01 00:00:00 -03:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -31,7 +31,7 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 0.0.6
34
+ version: 0.0.7
35
35
  version:
36
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
37
  email:
@@ -53,6 +53,7 @@ files:
53
53
  - test/commands.rb
54
54
  - test/integration_test.rb
55
55
  - test/monk_test.rb
56
+ - test/test_helper.rb
56
57
  has_rdoc: true
57
58
  homepage: http://monkrb.com
58
59
  licenses: []