gitdocs 0.5.0.pre6 → 0.5.0.pre7
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.
- checksums.yaml +8 -8
- data/.gitignore +1 -0
- data/.haml-lint.yml +3 -0
- data/.jslint.yml +84 -0
- data/.rubocop.yml +13 -0
- data/CHANGELOG +11 -0
- data/README.md +6 -2
- data/Rakefile +22 -3
- data/gitdocs.gemspec +36 -29
- data/lib/gitdocs.rb +5 -2
- data/lib/gitdocs/cli.rb +31 -8
- data/lib/gitdocs/configuration.rb +95 -49
- data/lib/gitdocs/manager.rb +36 -28
- data/lib/gitdocs/migration/001_create_shares.rb +2 -0
- data/lib/gitdocs/migration/002_add_remote_branch.rb +2 -0
- data/lib/gitdocs/migration/003_create_configs.rb +2 -0
- data/lib/gitdocs/migration/004_add_index_for_path.rb +4 -0
- data/lib/gitdocs/migration/005_add_start_web_frontend.rb +2 -0
- data/lib/gitdocs/migration/006_add_web_port_to_config.rb +2 -0
- data/lib/gitdocs/migration/007_add_sync_type.rb +11 -0
- data/lib/gitdocs/notifier.rb +89 -6
- data/lib/gitdocs/public/img/file.png +0 -0
- data/lib/gitdocs/public/img/folder.png +0 -0
- data/lib/gitdocs/public/js/app.js +26 -11
- data/lib/gitdocs/public/js/edit.js +3 -3
- data/lib/gitdocs/public/js/settings.js +8 -5
- data/lib/gitdocs/public/js/util.js +21 -20
- data/lib/gitdocs/rendering.rb +14 -9
- data/lib/gitdocs/repository.rb +180 -216
- data/lib/gitdocs/repository/path.rb +166 -0
- data/lib/gitdocs/runner.rb +22 -65
- data/lib/gitdocs/search.rb +35 -0
- data/lib/gitdocs/server.rb +123 -86
- data/lib/gitdocs/version.rb +1 -1
- data/lib/gitdocs/views/_header.haml +6 -6
- data/lib/gitdocs/views/app.haml +17 -17
- data/lib/gitdocs/views/dir.haml +10 -10
- data/lib/gitdocs/views/edit.haml +8 -9
- data/lib/gitdocs/views/file.haml +1 -1
- data/lib/gitdocs/views/home.haml +4 -4
- data/lib/gitdocs/views/revisions.haml +6 -6
- data/lib/gitdocs/views/search.haml +6 -6
- data/lib/gitdocs/views/settings.haml +23 -16
- data/test/.rubocop.yml +13 -0
- data/test/integration/browse_test.rb +149 -0
- data/test/integration/full_sync_test.rb +3 -11
- data/test/integration/share_management_test.rb +59 -10
- data/test/integration/status_test.rb +2 -0
- data/test/integration/test_helper.rb +40 -7
- data/test/unit/configuration_test.rb +82 -0
- data/test/unit/notifier_test.rb +165 -0
- data/test/unit/repository_path_test.rb +368 -0
- data/test/{repository_test.rb → unit/repository_test.rb} +426 -245
- data/test/unit/runner_test.rb +122 -0
- data/test/unit/search_test.rb +52 -0
- data/test/{test_helper.rb → unit/test_helper.rb} +5 -0
- metadata +138 -41
- data/lib/gitdocs/docfile.rb +0 -23
- data/test/configuration_test.rb +0 -41
- data/test/notifier_test.rb +0 -68
- data/test/runner_test.rb +0 -123
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTBiOGM2MTgxYWMwYTBlZTkzMTRhNTAxYTMyMTgyYTM1NjdmNjgyMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTc1ZTFiNWVjZjVlYjk0MDgyYmE4NGNiNzJjZTQzNzdjY2Q2YTgwMg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Yzk2NDFmMmJkYmM4MDllOTVmOWZhYjM0NDM3MzFjNzY1NzUyNGE3Mzk5ZGE5
|
10
|
+
MWNhODBjN2U5YTA5YjkzZjIwZDI5YzAyNzIyM2RiZTYwYTMzYjIwYjhkYTY0
|
11
|
+
MmExYjFlNzFlN2VkOWUyNGYwNTg1MjUyYjU2ZmM5YTk1MTU0MzE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWZiZjNkOGZiYjc4NzcwNjAxYmRmNmExOTQwMTAzODYzYjBhNzRlYzI5ZjMy
|
14
|
+
MjczNTJlMDcwYjQwZGM0Y2NlMTg4N2MyYzlhMGIyOWY0N2M3MTQ2NDJhODJi
|
15
|
+
MDNhMzEyZDcxYjlhNTRhZDU2NGQxOTQwNDA2NGZiNDYwNjdjYWM=
|
data/.gitignore
CHANGED
data/.haml-lint.yml
ADDED
data/.jslint.yml
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# ------------ rake task options ------------
|
2
|
+
|
3
|
+
# JS files to check by default, if no parameters are passed to rake jslint
|
4
|
+
# (you may want to limit this only to your own scripts and exclude any external scripts and frameworks)
|
5
|
+
|
6
|
+
# this can be overridden by adding 'paths' and 'exclude_paths' parameter to rake command:
|
7
|
+
# rake jslint paths=path1,path2,... exclude_paths=library1,library2,...
|
8
|
+
|
9
|
+
paths:
|
10
|
+
- lib/gitdocs/public/js/**/*.js
|
11
|
+
|
12
|
+
exclude_paths:
|
13
|
+
- lib/gitdocs/public/js/ace/**/*.js
|
14
|
+
- lib/gitdocs/public/js/jquery.tablesorter.js
|
15
|
+
- lib/gitdocs/public/js/jquery.js
|
16
|
+
- lib/gitdocs/public/js/bootstrap-alerts.js
|
17
|
+
|
18
|
+
|
19
|
+
# ------------ jslint options ------------
|
20
|
+
# see http://www.jslint.com/lint.html#options for more detailed explanations
|
21
|
+
|
22
|
+
# "enforce" type options (true means potentially more warnings)
|
23
|
+
|
24
|
+
adsafe: false # true if ADsafe rules should be enforced. See http://www.ADsafe.org/
|
25
|
+
bitwise: true # true if bitwise operators should not be allowed
|
26
|
+
newcap: true # true if Initial Caps must be used with constructor functions
|
27
|
+
eqeqeq: false # true if === should be required (for ALL equality comparisons)
|
28
|
+
immed: false # true if immediate function invocations must be wrapped in parens
|
29
|
+
nomen: false # true if initial or trailing underscore in identifiers should be forbidden
|
30
|
+
onevar: false # true if only one var statement per function should be allowed
|
31
|
+
plusplus: false # true if ++ and -- should not be allowed
|
32
|
+
regexp: false # true if . and [^...] should not be allowed in RegExp literals
|
33
|
+
safe: false # true if the safe subset rules are enforced (used by ADsafe)
|
34
|
+
strict: false # true if the ES5 "use strict"; pragma is required
|
35
|
+
undef: false # true if variables must be declared before used
|
36
|
+
white: false # true if strict whitespace rules apply (see also 'indent' option)
|
37
|
+
|
38
|
+
# "allow" type options (false means potentially more warnings)
|
39
|
+
|
40
|
+
cap: false # true if upper case HTML should be allowed
|
41
|
+
css: true # true if CSS workarounds should be tolerated
|
42
|
+
debug: false # true if debugger statements should be allowed (set to false before going into production)
|
43
|
+
es5: false # true if ECMAScript 5 syntax should be allowed
|
44
|
+
evil: false # true if eval should be allowed
|
45
|
+
forin: true # true if unfiltered 'for in' statements should be allowed
|
46
|
+
fragment: true # true if HTML fragments should be allowed
|
47
|
+
laxbreak: false # true if statement breaks should not be checked
|
48
|
+
on: false # true if HTML event handlers (e.g. onclick="...") should be allowed
|
49
|
+
sub: false # true if subscript notation may be used for expressions better expressed in dot notation
|
50
|
+
|
51
|
+
# other options
|
52
|
+
|
53
|
+
maxlen: 120 # Maximum line length
|
54
|
+
indent: 2 # Number of spaces that should be used for indentation - used only if 'white' option is set
|
55
|
+
maxerr: 50 # The maximum number of warnings reported (per file)
|
56
|
+
passfail: false # true if the scan should stop on first error (per file)
|
57
|
+
# following are relevant only if undef = true
|
58
|
+
predef: '' # Names of predefined global variables - comma-separated string or a YAML array
|
59
|
+
browser: true # true if the standard browser globals should be predefined
|
60
|
+
rhino: false # true if the Rhino environment globals should be predefined
|
61
|
+
windows: false # true if Windows-specific globals should be predefined
|
62
|
+
widget: false # true if the Yahoo Widgets globals should be predefined
|
63
|
+
devel: true # true if functions like alert, confirm, console, prompt etc. are predefined
|
64
|
+
|
65
|
+
|
66
|
+
# ------------ jslint_on_rails custom lint options (switch to true to disable some annoying warnings) ------------
|
67
|
+
|
68
|
+
# ignores "missing semicolon" warning at the end of a function; this lets you write one-liners
|
69
|
+
# like: x.map(function(i) { return i + 1 }); without having to put a second semicolon inside the function
|
70
|
+
lastsemic: false
|
71
|
+
|
72
|
+
# allows you to use the 'new' expression as a statement (without assignment)
|
73
|
+
# so you can call e.g. new Ajax.Request(...), new Effect.Highlight(...) without assigning to a dummy variable
|
74
|
+
newstat: false
|
75
|
+
|
76
|
+
# ignores the "Expected an assignment or function call and instead saw an expression" warning,
|
77
|
+
# if the expression contains a proper statement and makes sense; this lets you write things like:
|
78
|
+
# element && element.show();
|
79
|
+
# valid || other || lastChance || alert('OMG!');
|
80
|
+
# selected ? show() : hide();
|
81
|
+
# although these will still cause a warning:
|
82
|
+
# element && link;
|
83
|
+
# selected ? 5 : 10;
|
84
|
+
statinexp: false
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Documentation:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
ClassAndModuleChildren:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
# Splitting method arguments across multiple lines can result in the containing
|
8
|
+
# method looking long, but not actually increasing the complexity at all.
|
9
|
+
MethodLength:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
EachWithObject:
|
13
|
+
Enabled: false
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
0.5.0.pre7 (August 3rd 2014)
|
2
|
+
|
3
|
+
* UI improvements to repo browser (@acant)
|
4
|
+
* upgrade dependencies (@acant)
|
5
|
+
* add integration testing for repo browser (@acant)
|
6
|
+
* include hidden files in directory listing (@acant)
|
7
|
+
* refactor the server, cleanup file manipulation (@acant)
|
8
|
+
* add fetch only syncing for repositories (@acant)
|
9
|
+
* add sync status for reach repository in the CLI status (@acant)
|
10
|
+
* fix display of hidden files in the web UI (@acant)
|
11
|
+
|
1
12
|
0.5.0.pre6 (May 24th 2014)
|
2
13
|
|
3
14
|
* Remove the load_browser_on_startup config option (@acant)
|
data/README.md
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
[](http://badge.fury.io/rb/gitdocs)
|
4
4
|
[](https://codeclimate.com/github/bazaarlabs/gitdocs)
|
5
5
|
[](https://travis-ci.org/nesquena/gitdocs)
|
6
|
+
[](http://inch-ci.org/github/nesquena/gitdocs)
|
7
|
+
[](https://gemnasium.com/nesquena/gitdocs)
|
8
|
+
[](https://coveralls.io/r/nesquena/gitdocs)
|
6
9
|
|
7
10
|
Open-source dropbox alternative powered by git. Collaborate on files and tasks without any extra hassle.
|
8
11
|
gitdocs will automatically keep everyone's repos in sync by pushing and pulling changes.
|
@@ -10,7 +13,7 @@ This allows any git repo to be used as a collaborative task list, file share, or
|
|
10
13
|
Supports a web front-end allowing each repo to be accessed through your browser.
|
11
14
|
|
12
15
|
**Note:** Gitdocs has been tested on multiple unix systems including Mac OS X and Ubuntu.
|
13
|
-
Windows support is [half-baked](https://github.com/
|
16
|
+
Windows support is [half-baked](https://github.com/nesquena/gitdocs/issues/7)
|
14
17
|
but we plan to tackle that shortly in an upcoming release.
|
15
18
|
|
16
19
|
## Why?
|
@@ -171,7 +174,8 @@ Gitdocs is a young project but we have many plans for it including:
|
|
171
174
|
|
172
175
|
## Contributors
|
173
176
|
|
174
|
-
Gitdocs was created at [Miso](http://engineering.gomiso.com) by [Joshua Hull](https://github.com/joshbuddy) and [Nathan Esquenazi](https://github.com/nesquena).
|
177
|
+
Gitdocs is now primarily being developed by [Andrew Sullivan Cant](https://github.com/acant). Gitdocs was created at [Miso](http://engineering.gomiso.com) by [Joshua Hull](https://github.com/joshbuddy) and [Nathan Esquenazi](https://github.com/nesquena).
|
178
|
+
|
175
179
|
We also have had several contributors:
|
176
180
|
|
177
181
|
* [Chris Kempson](https://github.com/ChrisKempson) - Encoding issues
|
data/Rakefile
CHANGED
@@ -1,10 +1,29 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
2
|
require 'rake/testtask'
|
3
|
+
require 'jslint/tasks'
|
3
4
|
|
5
|
+
JSLint.config_path = '.jslint.yml'
|
6
|
+
|
7
|
+
namespace :test do
|
8
|
+
# Separate the unit and integration tests when running the entire suite.
|
9
|
+
Rake::TestTask.new(:unit) do |t|
|
10
|
+
t.libs.push('lib')
|
11
|
+
t.test_files = FileList[File.expand_path('../test/unit/**/*_test.rb', __FILE__)]
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
|
15
|
+
Rake::TestTask.new(integration: :unit) do |t|
|
16
|
+
t.libs.push('lib')
|
17
|
+
t.test_files = FileList[File.expand_path('../test/integration/**/*_test.rb', __FILE__)]
|
18
|
+
t.verbose = true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Keep a default test task for manually running any test
|
4
23
|
Rake::TestTask.new do |t|
|
5
|
-
t.libs.push
|
24
|
+
t.libs.push('lib')
|
6
25
|
t.test_files = FileList[File.expand_path('../test/**/*_test.rb', __FILE__)]
|
7
26
|
t.verbose = true
|
8
27
|
end
|
9
28
|
|
10
|
-
task :
|
29
|
+
task default: 'test:integration'
|
data/gitdocs.gemspec
CHANGED
@@ -1,48 +1,55 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require
|
2
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'gitdocs/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
6
|
+
s.name = 'gitdocs'
|
7
7
|
s.version = Gitdocs::VERSION
|
8
|
-
s.authors = [
|
9
|
-
s.email = [
|
10
|
-
s.homepage =
|
11
|
-
s.summary =
|
12
|
-
s.description =
|
8
|
+
s.authors = ['Josh Hull', 'Nathan Esquenazi']
|
9
|
+
s.email = ['joshbuddy@gmail.com', 'nesquena@gmail.com']
|
10
|
+
s.homepage = 'http://engineering.gomiso.com/2011/11/30/collaborate-and-track-tasks-with-ease-using-gitdocs/'
|
11
|
+
s.summary = 'Open-source Dropbox using Ruby and Git.'
|
12
|
+
s.description = 'Open-source Dropbox using Ruby and Git.'
|
13
|
+
s.license = 'MIT'
|
13
14
|
|
14
|
-
s.rubyforge_project =
|
15
|
+
s.rubyforge_project = 'gitdocs'
|
15
16
|
|
16
17
|
s.files = `git ls-files`.split("\n")
|
17
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.require_paths = [
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
20
|
+
s.require_paths = ['lib']
|
20
21
|
|
21
22
|
s.required_ruby_version = '>= 1.9'
|
22
23
|
|
23
24
|
s.add_dependency 'joshbuddy-guard', '~> 0.10.0'
|
24
|
-
s.add_dependency 'thin',
|
25
|
-
s.add_dependency 'renee',
|
26
|
-
s.add_dependency 'redcarpet',
|
27
|
-
s.add_dependency 'thor',
|
28
|
-
s.add_dependency 'coderay',
|
29
|
-
s.add_dependency 'dante',
|
30
|
-
s.add_dependency 'growl',
|
31
|
-
s.add_dependency '
|
32
|
-
s.add_dependency '
|
33
|
-
s.add_dependency '
|
34
|
-
s.add_dependency '
|
35
|
-
s.add_dependency '
|
36
|
-
s.add_dependency '
|
37
|
-
s.add_dependency '
|
38
|
-
s.add_dependency '
|
39
|
-
s.add_dependency '
|
40
|
-
s.add_dependency '
|
25
|
+
s.add_dependency 'thin', '~> 1.6.2'
|
26
|
+
s.add_dependency 'renee', '~> 0.3.11'
|
27
|
+
s.add_dependency 'redcarpet', '~> 3.1.1'
|
28
|
+
s.add_dependency 'thor', '~> 0.14.6'
|
29
|
+
s.add_dependency 'coderay', '~> 1.1.0'
|
30
|
+
s.add_dependency 'dante', '~> 0.1.2'
|
31
|
+
s.add_dependency 'growl', '~> 1.0.3'
|
32
|
+
s.add_dependency 'haml', '~> 4.0.5'
|
33
|
+
s.add_dependency 'sqlite3', '~> 1.3.4'
|
34
|
+
s.add_dependency 'activerecord', '~> 4.1.4'
|
35
|
+
s.add_dependency 'grit', '~> 2.5.0'
|
36
|
+
s.add_dependency 'shell_tools', '~> 0.1.0'
|
37
|
+
s.add_dependency 'mimetype-fu', '~> 0.1.2'
|
38
|
+
s.add_dependency 'eventmachine', '>= 1.0.3'
|
39
|
+
s.add_dependency 'launchy', '~> 2.4.2'
|
40
|
+
s.add_dependency 'rugged', '~> 0.19.0'
|
41
|
+
s.add_dependency 'table_print', '~> 1.5.1'
|
41
42
|
|
42
|
-
s.add_development_dependency 'minitest',
|
43
|
+
s.add_development_dependency 'minitest', '~> 5.4.0'
|
44
|
+
s.add_development_dependency 'capybara_minitest_spec', '~> 1.0.2'
|
45
|
+
s.add_development_dependency 'poltergeist', '~> 1.5.1'
|
43
46
|
s.add_development_dependency 'rake'
|
44
47
|
s.add_development_dependency 'mocha'
|
45
48
|
s.add_development_dependency 'fakeweb'
|
46
49
|
s.add_development_dependency 'metric_fu'
|
47
50
|
s.add_development_dependency 'aruba'
|
51
|
+
s.add_development_dependency 'rubocop'
|
52
|
+
s.add_development_dependency 'haml-lint', '~> 0.6.0'
|
53
|
+
s.add_development_dependency 'jslint_on_rails', '~> 1.1.1'
|
54
|
+
s.add_development_dependency 'coveralls', '~> 0.7.0'
|
48
55
|
end
|
data/lib/gitdocs.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
1
3
|
require 'thread'
|
2
|
-
require 'yajl'
|
3
4
|
require 'dante'
|
4
5
|
require 'socket'
|
5
6
|
require 'shell_tools'
|
6
7
|
require 'guard'
|
7
8
|
require 'grit'
|
8
9
|
require 'rugged'
|
10
|
+
require 'table_print'
|
9
11
|
|
10
12
|
require 'gitdocs/version'
|
11
13
|
require 'gitdocs/configuration'
|
@@ -13,10 +15,11 @@ require 'gitdocs/runner'
|
|
13
15
|
require 'gitdocs/server'
|
14
16
|
require 'gitdocs/cli'
|
15
17
|
require 'gitdocs/manager'
|
16
|
-
require 'gitdocs/docfile'
|
17
18
|
require 'gitdocs/rendering'
|
18
19
|
require 'gitdocs/notifier'
|
19
20
|
require 'gitdocs/repository'
|
21
|
+
require 'gitdocs/repository/path'
|
22
|
+
require 'gitdocs/search'
|
20
23
|
|
21
24
|
module Gitdocs
|
22
25
|
DEBUG = ENV['DEBUG']
|
data/lib/gitdocs/cli.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
# rubocop:disable LineLength, ClassLength
|
4
|
+
|
1
5
|
module Gitdocs
|
2
6
|
require 'thor'
|
3
7
|
|
4
8
|
class Cli < Thor
|
5
9
|
include Thor::Actions
|
6
10
|
|
7
|
-
def self.source_root
|
11
|
+
def self.source_root
|
12
|
+
File.expand_path('../../', __FILE__)
|
13
|
+
end
|
8
14
|
|
9
15
|
desc 'start', 'Starts a daemonized gitdocs process'
|
10
16
|
method_option :debug, type: :boolean, aliases: '-D'
|
@@ -84,8 +90,25 @@ module Gitdocs
|
|
84
90
|
say "GitDoc v#{VERSION}"
|
85
91
|
say "Running: #{running?}"
|
86
92
|
say "File System Watch Method: #{file_system_watch_method}"
|
87
|
-
say '
|
88
|
-
|
93
|
+
say 'Watched repositories:'
|
94
|
+
tp.set(:max_width, 100)
|
95
|
+
status_display = lambda do |share|
|
96
|
+
repository = Gitdocs::Repository.new(share)
|
97
|
+
|
98
|
+
status = ''
|
99
|
+
status += '*' if repository.dirty?
|
100
|
+
status += '!' if repository.need_sync?
|
101
|
+
|
102
|
+
status = 'ok' if status.empty?
|
103
|
+
status
|
104
|
+
end
|
105
|
+
tp(
|
106
|
+
config.shares,
|
107
|
+
{ sync: { display_method: :sync_type } },
|
108
|
+
{ s: status_display },
|
109
|
+
:path
|
110
|
+
)
|
111
|
+
say "\n(Legend: ok everything synced, * change to commit, ! needs sync)"
|
89
112
|
end
|
90
113
|
|
91
114
|
desc 'open', 'Open the Web UI'
|
@@ -97,14 +120,14 @@ module Gitdocs
|
|
97
120
|
end
|
98
121
|
|
99
122
|
web_port = options[:port]
|
100
|
-
web_port ||= config.
|
123
|
+
web_port ||= config.web_frontend_port
|
101
124
|
Launchy.open("http://localhost:#{web_port}/")
|
102
125
|
end
|
103
126
|
|
104
127
|
# TODO: make this work
|
105
|
-
#desc 'config', 'Configuration options for gitdocs'
|
106
|
-
#def config
|
107
|
-
#end
|
128
|
+
# desc 'config', 'Configuration options for gitdocs'
|
129
|
+
# def config
|
130
|
+
# end
|
108
131
|
|
109
132
|
desc 'help', 'Prints out the help'
|
110
133
|
def help(task = nil, subcommand = false)
|
@@ -140,7 +163,7 @@ module Gitdocs
|
|
140
163
|
end
|
141
164
|
|
142
165
|
# @return [Symbol] to indicate how the file system is being watched
|
143
|
-
def file_system_watch_method
|
166
|
+
def file_system_watch_method # rubocop:disable CyclomaticComplexity
|
144
167
|
if Guard::Listener.mac? && Guard::Darwin.usable?
|
145
168
|
:notification
|
146
169
|
elsif Guard::Listener.linux? && Guard::Linux.usable?
|
@@ -1,66 +1,112 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
1
3
|
require 'active_record'
|
2
4
|
require 'grit'
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
attr_reader :config_root
|
7
|
-
|
8
|
-
def initialize(config_root = nil)
|
9
|
-
@config_root = config_root || File.expand_path('.gitdocs', ENV['HOME'])
|
10
|
-
FileUtils.mkdir_p(@config_root)
|
11
|
-
ActiveRecord::Base.establish_connection(
|
12
|
-
adapter: 'sqlite3',
|
13
|
-
database: ENV['TEST'] ? ':memory:' : File.join(@config_root, 'config.db')
|
14
|
-
)
|
15
|
-
ActiveRecord::Migrator.migrate(File.expand_path('../migration', __FILE__))
|
16
|
-
import_old_shares unless ENV['TEST']
|
17
|
-
end
|
6
|
+
class Gitdocs::Configuration
|
7
|
+
attr_reader :config_root
|
18
8
|
|
19
|
-
|
20
|
-
|
21
|
-
|
9
|
+
def initialize(config_root = nil)
|
10
|
+
@config_root = config_root || File.expand_path('.gitdocs', ENV['HOME'])
|
11
|
+
FileUtils.mkdir_p(@config_root)
|
12
|
+
ActiveRecord::Base.establish_connection(
|
13
|
+
adapter: 'sqlite3',
|
14
|
+
database: ENV['TEST'] ? ':memory:' : File.join(@config_root, 'config.db')
|
15
|
+
)
|
16
|
+
ActiveRecord::Migrator.migrate(File.expand_path('../migration', __FILE__))
|
17
|
+
import_old_shares unless ENV['TEST']
|
18
|
+
end
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
class Share < ActiveRecord::Base
|
21
|
+
#attr_accessible :polling_interval, :path, :notification, :branch_name, :remote_name, :sync_type
|
22
|
+
end
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
path_opts.merge!(opts) if opts
|
31
|
-
Share.new(path_opts).save!
|
32
|
-
end
|
24
|
+
class Config < ActiveRecord::Base
|
25
|
+
#attr_accessible :start_web_frontend, :web_frontend_port
|
26
|
+
end
|
33
27
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
28
|
+
# return [Boolean]
|
29
|
+
def start_web_frontend
|
30
|
+
global.start_web_frontend
|
31
|
+
end
|
38
32
|
|
39
|
-
|
40
|
-
|
41
|
-
|
33
|
+
# @return [Integer]
|
34
|
+
def web_frontend_port
|
35
|
+
global.web_frontend_port
|
36
|
+
end
|
42
37
|
|
43
|
-
|
44
|
-
|
45
|
-
|
38
|
+
# @param [String] path
|
39
|
+
# @param [Hash] opts
|
40
|
+
def add_path(path, opts = nil)
|
41
|
+
path = normalize_path(path)
|
42
|
+
path_opts = { path: path }
|
43
|
+
path_opts.merge!(opts) if opts
|
44
|
+
Share.new(path_opts).save!
|
45
|
+
end
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
# @param [Hash] new_config
|
48
|
+
# @option new_config [Hash] 'config'
|
49
|
+
# @option new_config [Array<Hash>] 'share'
|
50
|
+
def update_all(new_config)
|
51
|
+
global.update_attributes(new_config['config'])
|
52
|
+
new_config['share'].each do |index, share_config|
|
53
|
+
# Skip the share update if there is no path specified.
|
54
|
+
next unless share_config['path'] && !share_config['path'].empty?
|
52
55
|
|
53
|
-
|
54
|
-
|
56
|
+
# Split the remote_branch into remote and branch
|
57
|
+
remote_branch = share_config.delete('remote_branch')
|
58
|
+
if remote_branch
|
59
|
+
share_config['remote_name'], share_config['branch_name'] = remote_branch.split('/', 2)
|
60
|
+
end
|
61
|
+
shares[index.to_i].update_attributes(share_config)
|
55
62
|
end
|
63
|
+
end
|
56
64
|
|
57
|
-
|
65
|
+
# @param [String] path of the share to remove
|
66
|
+
def remove_path(path)
|
67
|
+
path = normalize_path(path)
|
68
|
+
Share.where(path: path).destroy_all
|
69
|
+
end
|
58
70
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
71
|
+
# @param [Integer] id of the share to remove
|
72
|
+
#
|
73
|
+
# @return [true] share was deleted
|
74
|
+
# @return [false] share does not exist
|
75
|
+
def remove_by_id(id)
|
76
|
+
Share.find(id).destroy
|
77
|
+
true
|
78
|
+
rescue ActiveRecord::RecordNotFound
|
79
|
+
false
|
80
|
+
end
|
81
|
+
|
82
|
+
def clear
|
83
|
+
Share.destroy_all
|
84
|
+
end
|
85
|
+
|
86
|
+
def shares
|
87
|
+
Share.all
|
88
|
+
end
|
89
|
+
|
90
|
+
##############################################################################
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def global
|
95
|
+
fail if Config.all.size > 1
|
96
|
+
Config.create! if Config.all.empty?
|
97
|
+
Config.all.first
|
98
|
+
end
|
99
|
+
|
100
|
+
def normalize_path(path)
|
101
|
+
File.expand_path(path, Dir.pwd)
|
102
|
+
end
|
103
|
+
|
104
|
+
def import_old_shares
|
105
|
+
full_path = File.expand_path('paths', config_root)
|
106
|
+
return unless File.exist?(full_path)
|
107
|
+
|
108
|
+
File.read(full_path).split("\n").each do |path|
|
109
|
+
Share.find_or_create_by_path(path)
|
64
110
|
end
|
65
111
|
end
|
66
112
|
end
|