ginatra 2.2.0 → 2.2.1
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/Rakefile +1 -1
- data/config.ru +2 -0
- data/features/support/env.rb +2 -2
- data/lib/ginatra.rb +1 -1
- data/lib/ginatra/helpers.rb +4 -0
- data/rackup.ru +2 -0
- data/spec/repo_list_spec.rb +19 -15
- data/spec/repo_spec.rb +13 -9
- data/spec/spec_helper.rb +10 -8
- metadata +1 -1
data/Rakefile
CHANGED
@@ -48,7 +48,7 @@ namespace :setup do
|
|
48
48
|
|
49
49
|
desc "Clones the Test Repository"
|
50
50
|
task :repo do |t|
|
51
|
-
FileUtils.cd(File.join(
|
51
|
+
FileUtils.cd(File.join(Dir.pwd, "repos")) do
|
52
52
|
puts `git clone git://github.com/atmos/hancock-client.git test`
|
53
53
|
end
|
54
54
|
end
|
data/config.ru
CHANGED
data/features/support/env.rb
CHANGED
data/lib/ginatra.rb
CHANGED
data/lib/ginatra/helpers.rb
CHANGED
@@ -242,6 +242,8 @@ module Ginatra
|
|
242
242
|
[stdout, stderr].each {|io| io.close }
|
243
243
|
end
|
244
244
|
html_output
|
245
|
+
rescue Errno::ENOENT
|
246
|
+
return "<div class=\"highlight\"><pre>#{content}</pre></div>"
|
245
247
|
end
|
246
248
|
|
247
249
|
def pygmentize_type(filename)
|
@@ -251,6 +253,8 @@ module Ginatra
|
|
251
253
|
[stdin, stdout, stderr].each {|io| io.close }
|
252
254
|
end
|
253
255
|
type
|
256
|
+
rescue Errno::ENOENT
|
257
|
+
return "text"
|
254
258
|
end
|
255
259
|
end
|
256
260
|
end
|
data/rackup.ru
CHANGED
data/spec/repo_list_spec.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe "Ginatra" do
|
5
5
|
|
6
6
|
describe "RepoList" do
|
7
7
|
|
8
|
+
def current_path
|
9
|
+
File.expand_path(File.dirname(__FILE__))
|
10
|
+
end
|
11
|
+
|
8
12
|
before do
|
9
13
|
@repo_list = Ginatra::RepoList.list
|
10
14
|
@repo = Ginatra::RepoList.find("test")
|
@@ -28,9 +32,6 @@ describe "Ginatra" do
|
|
28
32
|
|
29
33
|
describe "New repos added to repo directory" do
|
30
34
|
|
31
|
-
NEW_REPO_NAME = "temp-new-repo"
|
32
|
-
REPO_DIR = File.join(current_path, "..", "repos")
|
33
|
-
|
34
35
|
def print_repos_found
|
35
36
|
Ginatra::Config.git_dirs.map! do |git_dir|
|
36
37
|
files = Dir.glob(git_dir)
|
@@ -39,9 +40,12 @@ describe "Ginatra" do
|
|
39
40
|
end
|
40
41
|
|
41
42
|
before(:each) do
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
@new_repo_name = "temp-new-repo"
|
44
|
+
@repo_dir = File.join(current_path, "..", "repos")
|
45
|
+
|
46
|
+
FileUtils.cd(@repo_dir) do |dir|
|
47
|
+
FileUtils.mkdir(@new_repo_name)
|
48
|
+
FileUtils.cd(@new_repo_name) do |dir|
|
45
49
|
`git init`
|
46
50
|
end
|
47
51
|
end
|
@@ -50,31 +54,31 @@ describe "Ginatra" do
|
|
50
54
|
it "should detect new repo after refresh" do
|
51
55
|
repo_list = Ginatra::RepoList.list # calling this should refresh the list
|
52
56
|
|
53
|
-
Ginatra::RepoList.instance.has_repo?(
|
57
|
+
Ginatra::RepoList.instance.has_repo?(@new_repo_name).should == true
|
54
58
|
|
55
|
-
new_repo = Ginatra::RepoList.find(
|
59
|
+
new_repo = Ginatra::RepoList.find(@new_repo_name)
|
56
60
|
repo_list.should include(new_repo)
|
57
61
|
end
|
58
62
|
|
59
63
|
it "should detect when a repo has been removed after refresh" do
|
60
64
|
repo_list = Ginatra::RepoList.list # calling this should refresh the list
|
61
65
|
|
62
|
-
Ginatra::RepoList.instance.has_repo?(
|
66
|
+
Ginatra::RepoList.instance.has_repo?(@new_repo_name).should == true
|
63
67
|
|
64
|
-
new_repo = Ginatra::RepoList.find(
|
68
|
+
new_repo = Ginatra::RepoList.find(@new_repo_name)
|
65
69
|
repo_list.should include(new_repo)
|
66
70
|
|
67
71
|
# remove the new repository from the file system
|
68
|
-
FileUtils.rm_rf File.join(
|
72
|
+
FileUtils.rm_rf File.join(@repo_dir, @new_repo_name), :secure => true
|
69
73
|
|
70
74
|
repo_list = Ginatra::RepoList.list # refresh the repo list
|
71
75
|
|
72
|
-
Ginatra::RepoList.instance.has_repo?(
|
76
|
+
Ginatra::RepoList.instance.has_repo?(@new_repo_name).should == false
|
73
77
|
repo_list.should_not include(new_repo)
|
74
78
|
end
|
75
79
|
|
76
80
|
after(:each) do
|
77
|
-
FileUtils.rm_rf File.join(
|
81
|
+
FileUtils.rm_rf File.join(@repo_dir, @new_repo_name), :secure => true
|
78
82
|
end
|
79
83
|
end
|
80
84
|
end
|
data/spec/repo_spec.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe "Ginatra" do
|
5
5
|
describe "Repo" do
|
6
|
-
|
6
|
+
|
7
|
+
def current_path
|
8
|
+
File.expand_path(File.dirname(__FILE__))
|
9
|
+
end
|
10
|
+
|
7
11
|
before do
|
8
12
|
@repo_list = Ginatra::RepoList
|
9
13
|
@ginatra_repo = @repo_list.find("test")
|
@@ -31,28 +35,28 @@ describe "Ginatra" do
|
|
31
35
|
it "should be the same thing using #find or #new" do
|
32
36
|
@repo_list.find("test") == Ginatra::Repo.new(File.join(current_path, "..", "repos", "test"))
|
33
37
|
end
|
34
|
-
|
38
|
+
|
35
39
|
it "should contain this commit" do
|
36
40
|
@commit.refs.should_not be_empty
|
37
41
|
end
|
38
|
-
|
42
|
+
|
39
43
|
it "should not contain this other commit" do
|
40
44
|
lambda { @ginatra_repo.commit("totallyinvalid") }.should raise_error(Ginatra::InvalidCommit, "Could not find a commit with the id of totallyinvalid")
|
41
45
|
end
|
42
|
-
|
46
|
+
|
43
47
|
it "should have a list of commits" do
|
44
48
|
@ginatra_repo.commits.should_not be_blank
|
45
49
|
end
|
46
|
-
|
50
|
+
|
47
51
|
it "should raise an error when asked to invert itself" do
|
48
52
|
lambda { @ginatra_repo.commits("master", -1) }.should raise_error(Ginatra::Error, "max_count cannot be less than 0")
|
49
53
|
end
|
50
|
-
|
54
|
+
|
51
55
|
it "should be able to add refs to a commit" do
|
52
56
|
@commit.refs = []
|
53
57
|
@ginatra_repo.add_refs(@commit)
|
54
58
|
@commit.refs.should_not be_empty
|
55
59
|
end
|
56
|
-
|
60
|
+
|
57
61
|
end
|
58
62
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
|
-
gem 'rspec'
|
3
|
+
#gem 'rspec'
|
4
4
|
require 'spec'
|
5
5
|
|
6
|
-
|
7
|
-
require "
|
6
|
+
$:.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib")
|
7
|
+
require "ginatra"
|
8
8
|
|
9
|
-
gem 'webrat', '>=0.4.4'
|
9
|
+
#gem 'webrat', '>=0.4.4'
|
10
10
|
begin
|
11
11
|
# When using webrat 0.6.0, there is no webrat/sinatra.rb file.
|
12
12
|
# Looking at the gem's code, it looks like it autoloads the sinatra adapter at webrat/adapters/sinatra.rb.
|
@@ -17,23 +17,25 @@ rescue LoadError
|
|
17
17
|
require 'webrat'
|
18
18
|
end
|
19
19
|
|
20
|
-
gem 'rack-test', '>=0.3.0'
|
20
|
+
#gem 'rack-test', '>=0.3.0'
|
21
21
|
require 'rack/test'
|
22
22
|
|
23
23
|
Webrat.configure do |config|
|
24
24
|
config.mode = :sinatra
|
25
25
|
end
|
26
26
|
|
27
|
+
current_path = File.expand_path(File.dirname(__FILE__))
|
28
|
+
|
27
29
|
Ginatra::App.set :environment, :test
|
28
30
|
Ginatra::Config[:git_dirs] = ["#{current_path}/../repos/*"]
|
29
|
-
|
31
|
+
|
30
32
|
Spec::Runner.configure do |config|
|
31
33
|
def app
|
32
34
|
Ginatra::App
|
33
35
|
end
|
34
|
-
|
36
|
+
|
35
37
|
config.include(Rack::Test::Methods)
|
36
38
|
config.include(Webrat::Methods)
|
37
39
|
config.include(Webrat::Matchers)
|
38
|
-
end
|
40
|
+
end
|
39
41
|
|