dolt 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/Gemfile.lock +10 -0
  2. data/bin/dolt +112 -51
  3. data/dolt.gemspec +3 -2
  4. data/lib/dolt/ruby19.rb +24 -0
  5. metadata +21 -4
@@ -4,6 +4,7 @@ PATH
4
4
  dolt (0.12.0)
5
5
  json (~> 1.5)
6
6
  libdolt (~> 0.17)
7
+ main (~> 5.2)
7
8
  sinatra (~> 1.0)
8
9
  thin (~> 1.4)
9
10
  tiltout (~> 1.4)
@@ -11,8 +12,11 @@ PATH
11
12
  GEM
12
13
  remote: http://rubygems.org/
13
14
  specs:
15
+ arrayfields (4.9.0)
16
+ chronic (0.9.1)
14
17
  daemons (1.1.9)
15
18
  eventmachine (1.0.3)
19
+ fattr (2.2.1)
16
20
  github-markup (0.7.5)
17
21
  htmlentities (4.3.1)
18
22
  json (1.8.0)
@@ -23,10 +27,16 @@ GEM
23
27
  mime-types (~> 1.19)
24
28
  rugged (= 0.17.0.b6)
25
29
  tzinfo (~> 0.3)
30
+ main (5.2.0)
31
+ arrayfields (>= 4.7.4)
32
+ chronic (>= 0.6.2)
33
+ fattr (>= 2.2.0)
34
+ map (>= 5.1.0)
26
35
  makeup (0.3.0)
27
36
  github-markup (~> 0.7)
28
37
  htmlentities (~> 4.3)
29
38
  pygments.rb (~> 0.2)
39
+ map (6.5.1)
30
40
  mime-types (1.23)
31
41
  minitest (2.12.1)
32
42
  posix-spawn (0.3.6)
data/bin/dolt CHANGED
@@ -3,67 +3,128 @@ require "libdolt"
3
3
  require "tiltout"
4
4
  require "thin"
5
5
  require "sinatra/base"
6
-
7
- if ARGV.length == 0
8
- puts("Dolt should be run with a directory as its sole argument")
9
- puts("The directory should either be a Git repository or a directory")
10
- puts("that holds Git repositories.")
11
- exit(1)
6
+ require "cgi"
7
+ require "main"
8
+ if RUBY_VERSION < "1.9"
9
+ require "dolt/ruby19"
12
10
  end
13
-
14
11
  ### TODO: Extract this into a testable API
15
12
 
16
- def is_git_repo?(dir)
17
- File.exists?(File.join(dir, ".git"))
18
- end
19
13
 
20
- def create_app(dir, view)
21
- if is_git_repo?(dir)
22
- dir = File.expand_path(dir)
23
- resolver = Dolt::DiskRepoResolver.new(File.dirname(dir))
24
- actions = Dolt::RepoActions.new(resolver)
25
- view.helper(Dolt::View::SingleRepository)
26
- require "dolt/sinatra/single_repo_browser"
27
- Dolt::Sinatra::SingleRepoBrowser.new(File.basename(dir), actions, view)
28
- else
29
- resolver = Dolt::DiskRepoResolver.new(dir)
30
- actions = Dolt::RepoActions.new(resolver)
31
- view.helper(Dolt::View::MultiRepository)
32
- require "dolt/sinatra/multi_repo_browser"
33
- Dolt::Sinatra::MultiRepoBrowser.new(actions, view)
14
+ class DoltApp
15
+ def initialize(layout_base)
16
+ @layout_base = layout_base
17
+ end
18
+
19
+ def is_git_repo?(dir)
20
+ File.exists?(File.join(dir, ".git"))
21
+ end
22
+
23
+ def create_app(dir, view)
24
+ if is_git_repo?(dir)
25
+ dir = File.expand_path(dir)
26
+ resolver = Dolt::DiskRepoResolver.new(File.dirname(dir))
27
+ actions = Dolt::RepoActions.new(resolver)
28
+ view.helper(Dolt::View::SingleRepository)
29
+ require "dolt/sinatra/single_repo_browser"
30
+ Dolt::Sinatra::SingleRepoBrowser.new(File.basename(dir), actions, view)
31
+ else
32
+ resolver = Dolt::DiskRepoResolver.new(dir)
33
+ actions = Dolt::RepoActions.new(resolver)
34
+ view.helper(Dolt::View::MultiRepository)
35
+ require "dolt/sinatra/multi_repo_browser"
36
+ Dolt::Sinatra::MultiRepoBrowser.new(actions, view)
37
+ end
34
38
  end
35
- end
36
39
 
37
- base = File.join(File.dirname(__FILE__), "..")
40
+ def run(root, options)
41
+ view = Tiltout.new(Dolt.template_dir, {
42
+ :cache => false,
43
+ :layout => "layout"
44
+ })
38
45
 
39
- view = Tiltout.new(Dolt.template_dir, {
40
- :cache => false,
41
- :layout => "layout"
42
- })
46
+ view.helper(Dolt::View::Object)
47
+ view.helper(Dolt::View::Urls)
48
+ view.helper(Dolt::View::Blob)
49
+ view.helper(Dolt::View::Blame)
50
+ view.helper(Dolt::View::Breadcrumb)
51
+ view.helper(Dolt::View::Tree)
52
+ view.helper(Dolt::View::Commit)
53
+ view.helper(Dolt::View::Gravatar)
54
+ view.helper(Dolt::View::TabWidth)
55
+ view.helper(Dolt::View::BinaryBlobEmbedder)
56
+ view.helper(:tab_width => options[:tab_width], :maxdepth => 3)
43
57
 
44
- view.helper(Dolt::View::Object)
45
- view.helper(Dolt::View::Urls)
46
- view.helper(Dolt::View::Blob)
47
- view.helper(Dolt::View::Blame)
48
- view.helper(Dolt::View::Breadcrumb)
49
- view.helper(Dolt::View::Tree)
50
- view.helper(Dolt::View::Commit)
51
- view.helper(Dolt::View::Gravatar)
52
- view.helper(Dolt::View::TabWidth)
53
- view.helper(Dolt::View::BinaryBlobEmbedder)
54
- view.helper(:tab_width => 4, :maxdepth => 3)
58
+ # Configure blob rendering module
55
59
 
56
- # Configure blob rendering module
60
+ # Attempt to syntax highlight every blob
61
+ # view.helper(Dolt::View::SyntaxHighlight)
57
62
 
58
- # Attempt to syntax highlight every blob
59
- # view.helper(Dolt::View::SyntaxHighlight)
63
+ # Attempt to render every blob as markup
64
+ # view.helper(Dolt::View::Markup)
60
65
 
61
- # Attempt to render every blob as markup
62
- # view.helper(Dolt::View::Markup)
66
+ # Render supported formats as markup, syntax highlight the rest
67
+ view.helper(Dolt::View::SmartBlobRenderer)
68
+ Sinatra::Base.set(:public_folder, File.join(@layout_base, "vendor/ui"))
69
+ server = create_app(root, view)
70
+ thin_server = if options[:socket]
71
+ Thin::Server.new(options[:socket], server)
72
+ else
73
+ Thin::Server.new("0.0.0.0", options[:port], server)
74
+ end
75
+ if options[:pidfile]
76
+ thin_server.pid_file = options[:pidfile]
77
+ thin_server.log_file = options[:logfile]
78
+ thin_server.daemonize
79
+ end
80
+ thin_server.start
81
+ end
82
+ end
83
+
84
+ Main {
85
+ argument("root") {
86
+ required
87
+ validate {|dir| File.exists?(dir) }
88
+ description "The base directory to serve repositories from"
89
+ }
90
+
91
+ option("socket=[socket]") {
92
+ cast :string
93
+ description "A socket to listen to"
94
+ }
63
95
 
64
- # Render supported formats as markup, syntax highlight the rest
65
- view.helper(Dolt::View::SmartBlobRenderer)
96
+ option("port=[port]") {
97
+ cast :int
98
+ description "A port to listen to"
99
+ default 3000
100
+ }
66
101
 
67
- Sinatra::Base.set(:public_folder, File.join(base, "vendor/ui"))
68
- server = create_app(ARGV[0], view)
69
- Thin::Server.start("0.0.0.0", 3000, server)
102
+ option("tabwidth=[tabwidth]") {
103
+ cast :int
104
+ description "The number of spaces to use as a tab"
105
+ default 4
106
+ }
107
+
108
+ option("pidfile=[pidfile]") {
109
+ description "Run as daemon with pidfile stored here."
110
+ }
111
+
112
+ option("logfile=[logfile]") {
113
+ description "Use as log file. Assumes --pidfile option"
114
+ }
115
+
116
+ def run
117
+ options = {}
118
+ if params[:socket].given?
119
+ options[:socket] = params[:socket].value
120
+ else
121
+ options[:port] = params[:port].value
122
+ end
123
+ if params[:pidfile].given?
124
+ options[:pidfile] = params[:pidfile].value
125
+ options[:logfile] = params[:logfile].value || "/tmp/dolt.log"
126
+ end
127
+ options[:tab_width] = params[:tabwidth].value
128
+ DoltApp.new(File.join(File.dirname(__FILE__), "..")).run(params[:root].value, options)
129
+ end
130
+ }
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  Gem::Specification.new do |s|
13
13
  s.name = "dolt"
14
- s.version = "0.12.0"
14
+ s.version = "0.13.0"
15
15
  s.authors = ["Christian Johansen"]
16
16
  s.email = ["christian@gitorious.org"]
17
17
  s.homepage = "http://gitorious.org/gitorious/dolt"
@@ -20,11 +20,12 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.rubyforge_project = "dolt"
22
22
 
23
- s.add_dependency "libdolt", "~>0.17"
23
+ s.add_dependency "libdolt", "~>0.18"
24
24
  s.add_dependency "thin", "~>1.4"
25
25
  s.add_dependency "sinatra", "~>1.0"
26
26
  s.add_dependency "tiltout", "~>1.4"
27
27
  s.add_dependency "json", "~>1.5"
28
+ s.add_dependency "main", "~>5.2"
28
29
 
29
30
  s.add_development_dependency "minitest", "~> 2.0"
30
31
  s.add_development_dependency "rake", "~> 0.9"
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+ #--
3
+ # Copyright (C) 2013 Gitorious AS
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #++
18
+ unless defined?(Encoding)
19
+ class Encoding
20
+ def self.default_external
21
+ nil
22
+ end
23
+ end
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dolt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-31 00:00:00.000000000 Z
12
+ date: 2013-06-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: libdolt
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0.17'
21
+ version: '0.18'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: '0.17'
29
+ version: '0.18'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: thin
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -91,6 +91,22 @@ dependencies:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
93
  version: '1.5'
94
+ - !ruby/object:Gem::Dependency
95
+ name: main
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '5.2'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '5.2'
94
110
  - !ruby/object:Gem::Dependency
95
111
  name: minitest
96
112
  requirement: !ruby/object:Gem::Requirement
@@ -154,6 +170,7 @@ files:
154
170
  - ./Readme.md
155
171
  - ./bin/dolt
156
172
  - ./dolt.gemspec
173
+ - ./lib/dolt/ruby19.rb
157
174
  - ./lib/dolt/sinatra/actions.rb
158
175
  - ./lib/dolt/sinatra/base.rb
159
176
  - ./lib/dolt/sinatra/multi_repo_browser.rb