ginatra 2.2.6 → 2.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler"
4
- Bundler.setup(:default)
5
3
  require "ginatra"
6
4
 
7
5
  module Ginatra::Executable
8
6
  HELP = <<HELP
9
- Usage: ginatra [ version | server <options> <command> |
10
- daemon <command> | directory <command> <args> ]
7
+ Usage: ginatra [ version |
8
+ server <options> <command> |
9
+ daemon <command> |
10
+ directory <command> <globs> ]
11
11
 
12
12
  Ginatra Commands:
13
13
  version - Pretty Self explanatory. Print version number and exit
@@ -32,29 +32,37 @@ Ginatra Directory Commands:
32
32
 
33
33
  HELP
34
34
 
35
- @current_path = File.expand_path(File.dirname(__FILE__))
36
-
37
- def self.daemon(*args)
38
- system("#{@current_path}/ginatra-daemon #{args.join(" ")}")
35
+ def self.daemon
36
+ path = File.expand_path(File.dirname(__FILE__))
37
+ load "#{path}/ginatra-daemon"
39
38
  end
40
39
 
41
- def self.directory(*args)
42
- system("#{@current_path}/ginatra-directory #{args.join(" ")}")
40
+ def self.directory
41
+ path = File.expand_path(File.dirname(__FILE__))
42
+ load "#{path}/ginatra-directory"
43
43
  end
44
44
 
45
- def self.server(*args)
46
- system("#{@current_path}/ginatra-server #{args.join(" ")}")
45
+ def self.server
46
+ path = File.expand_path(File.dirname(__FILE__))
47
+ load("#{path}/ginatra-server")
47
48
  end
48
49
 
49
- def self.version(*args)
50
- puts Ginatra::VERSION
50
+ def self.execute(command, args)
51
+ case command
52
+ when "version"
53
+ puts Ginatra::VERSION
54
+ when "daemon"
55
+ daemon
56
+ when "directory"
57
+ directory
58
+ when "server"
59
+ server
60
+ else
61
+ puts Ginatra::Executable::HELP
62
+ end
51
63
  end
52
64
  end
53
65
 
54
- command, *args = ARGV[0], ARGV[1..-1]
55
- if command !~ /^(version|daemon|directory|server)$/
56
- puts Ginatra::Executable::HELP
57
- exit
58
- end
59
- Ginatra::Executable.send(command, *args)
66
+ Ginatra::Executable.execute ARGV.shift, ARGV
67
+
60
68
 
@@ -1,17 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler"
4
- Bundler.setup(:default)
5
3
  require "ginatra"
6
- require "logger"
7
-
8
- def logger
9
- return @logger if @logger
10
- @logger = Logger.new(STDOUT)
11
- @logger.level = Logger::INFO
12
- @logger.formatter = Proc.new {|s, t, n, msg| "[#{t}] #{msg}\n"}
13
- @logger
14
- end
15
4
 
16
5
  module Ginatra::Daemon
17
6
 
@@ -63,6 +52,7 @@ HELP
63
52
  end
64
53
 
65
54
  def self.status
55
+ logger.level = Logger::INFO
66
56
  if File.exists?(PID_FILE)
67
57
  logger.info "Ginatra Daemon running at pid:#{File.new(PID_FILE).read}"
68
58
  else
@@ -70,13 +60,28 @@ HELP
70
60
  end
71
61
  end
72
62
 
73
- end
63
+ def self.logger
64
+ Ginatra::Config.logger
65
+ end
66
+
67
+ def self.execute(command)
68
+ case command
69
+ when "start"
70
+ start
71
+ when "stop"
72
+ stop
73
+ when "restart"
74
+ restart
75
+ when "status"
76
+ status
77
+ else
78
+ puts Ginatra::Daemon::HELP
79
+ end
80
+ end
74
81
 
75
- command = ARGV[0]
76
- if command !~ /^(stop|status|start|restart)$/
77
- puts Ginatra::Daemon::HELP
78
- else
79
- Ginatra::Daemon.send(command)
80
82
  end
81
83
 
84
+ Ginatra::Daemon.execute ARGV[0]
85
+
86
+
82
87
 
@@ -1,17 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler"
4
- Bundler.setup(:default)
5
3
  require "ginatra"
6
- require "logger"
7
-
8
- def logger
9
- return @logger if @logger
10
- @logger = Logger.new(STDOUT)
11
- @logger.level = Logger::INFO
12
- @logger.formatter = Proc.new {|s, t, n, msg| "[#{t}] #{msg}\n"}
13
- @logger
14
- end
15
4
 
16
5
  module Ginatra::Directory
17
6
 
@@ -29,7 +18,7 @@ HELP
29
18
  def self.add(globs)
30
19
  Ginatra::Config.load!
31
20
  Ginatra::Config[:git_dirs] += globs
32
- logger.info "Added #{globs.join(" ")} to your config"
21
+ Ginatra::Config.logger.info "Added #{globs.join(" ")} to your config"
33
22
  Ginatra::Config.dump!
34
23
  end
35
24
 
@@ -38,21 +27,29 @@ HELP
38
27
  globs.each do |glob|
39
28
  Ginatra::Config[:git_dirs].delete(glob)
40
29
  end
41
- logger.info "Removed #{globs.join(" ")} from your config"
30
+ Ginatra::Config.logger.info "Removed #{globs.join(" ")} from your config"
42
31
  Ginatra::Config.dump!
43
32
  end
44
33
 
45
- def self.list(args)
34
+ def self.list
46
35
  Ginatra::Config.load!
47
36
  puts "Directories Ginatra will look for repos in:"
48
37
  puts Ginatra::Config[:git_dirs].map{|r| " - #{r}"}.join("\n")
49
38
  puts ""
50
39
  end
51
- end
52
40
 
53
- command, args = ARGV[0], ARGV[1..-1]
54
- if command !~ /^(add|remove|list)$/
55
- puts Ginatra::Directory::HELP
56
- else
57
- Ginatra::Directory.send(command, args)
41
+ def self.execute(command, args)
42
+ case command
43
+ when "add"
44
+ add(args)
45
+ when "remove"
46
+ remove(args)
47
+ when "list"
48
+ list
49
+ else
50
+ puts Ginatra::Directory::HELP
51
+ end
52
+ end
58
53
  end
54
+
55
+ Ginatra::Directory.execute ARGV[0], ARGV[1..-1]
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler"
4
- Bundler.setup(:default)
5
3
  require "ginatra"
6
4
  require "vegas"
7
5
 
data/config.ru CHANGED
@@ -1,5 +1,3 @@
1
- require "bundler"
2
- Bundler.setup(:default)
3
1
  require "ginatra"
4
2
 
5
3
  map '/' do
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "ginatra"
3
- s.version = "2.2.6"
3
+ s.version = "2.2.7"
4
4
  s.summary = "A Gitweb Clone in Sinatra and Grit"
5
5
  s.description = "Host your own git repository browser through the power of Sinatra and Grit"
6
6
  s.email = "sam@lenary.co.uk"
@@ -1,6 +1,4 @@
1
1
 
2
- require "bundler"
3
- Bundler.setup(:default)
4
2
  require 'sinatra/base'
5
3
  require "sinatra/partials"
6
4
 
@@ -30,6 +28,8 @@ module Ginatra
30
28
  end
31
29
  end
32
30
 
31
+ VERSION = "2.2.7"
32
+
33
33
  # The main application class.
34
34
  #
35
35
  # This class contains all the core application logic
@@ -1,5 +1,6 @@
1
1
  require "yaml"
2
- require 'fileutils'
2
+ require "fileutils"
3
+ require "logger"
3
4
 
4
5
  module Ginatra
5
6
 
@@ -26,7 +27,7 @@ module Ginatra
26
27
  def self.logger
27
28
  return @logger if @logger
28
29
 
29
- log_file = Ginatra::Config[:log_file].to_s || STDOUT
30
+ log_file = Ginatra::Config[:log_file] || STDOUT
30
31
 
31
32
  # create log_file location
32
33
  # The log_file config option should be an absolute file system path
data/rackup.ru CHANGED
@@ -1,5 +1,3 @@
1
- require "bundler"
2
- Bundler.setup(:default)
3
1
  require "ginatra"
4
2
 
5
3
  map '/' do
@@ -1,5 +1,4 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2
- require "grit"
3
2
 
4
3
  describe "Ginatra" do
5
4
  describe "Repo" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ginatra
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 2
9
- - 6
10
- version: 2.2.6
9
+ - 7
10
+ version: 2.2.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sam Elliott