gitdocs 0.4.15 → 0.5.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MThmNzE5OWRhMDk2OThhMTdlMmU2MWQ2YzhmY2RkZjUwODM5ZmI0NQ==
5
+ data.tar.gz: !binary |-
6
+ NTk2ZDg1ODhiMGNhYzI4NTJjYmU2NWU4ZDM0MDBhMzE4NjQzYWI2Mg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MmY3NzdkYjQ1NzA0MjA0NGY4ZmRkZWE2NGQ2YWM2MTYzNDg0ZjdmYWU4MzJh
10
+ ODc5YmEyMDI0ZGE2YjY1ZDk4ZDI0MDAzZDg0MWU1YjNiMTAwOTZhOWE5NjNj
11
+ NWRiNDM4YjVkNTBlOGI2ZGVhZTU4MTFhNTg3MjA5NjZjMWVjZDA=
12
+ data.tar.gz: !binary |-
13
+ NDhjOGYxOGMwMzUxMDg5ZWQwZWQwNmVhYWIyOTBiNGZmNjFhNzI1ZGE0Mjkz
14
+ YjVhODlmNDRlZDIwM2Q4YjJiYWZkYTFkODNmY2IwM2NjOWVjMDYyZjRmOWFh
15
+ ZWYyMjdlOTBmM2RhNTY2MmQyZjQ4Y2ZhYWViY2JiZDEwNzcwMzM=
data/.gitignore CHANGED
@@ -2,4 +2,5 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
- .DS_Store
5
+ .DS_Store
6
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - ruby-head
6
+ matrix:
7
+ allow_failures:
8
+ - rvm: ruby-head
data/CHANGELOG CHANGED
@@ -1,4 +1,16 @@
1
- 0.4.15 (Unreleased)
1
+ 0.5.0.pre1 (11/25/2013)
2
+
3
+ * Upgrade thin gem to v1.5.1 (Thanks @acant)
4
+ * Add TravisCI configuration (Thanks @acant)
5
+ * Rescue StandardError and better error notifications to fix crashes (@acant)
6
+ * Reduce unexpected exists caused by repository and file system errors
7
+ * Add notification of unexpected daemon exist
8
+ * Add 'open' command to CLI for opening web app (@acant)
9
+ * Drop support for Ruby 1.8 (@acant)
10
+ * Code style updates (@acant)
11
+ * Display file system watch method in status (@acant)
12
+
13
+ 0.4.15 (8/29/2012)
2
14
 
3
15
  * Adds a 'new directory' function to front-end [thanks Kale Worsley]
4
16
  * Change 'New file' function to actually create a blank file [thanks Kale Worsley]
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Gitdocs
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/gitdocs.png)](http://badge.fury.io/rb/gitdocs)
4
+ [![Code Climate](https://codeclimate.com/github/bazaarlabs/gitdocs.png)](https://codeclimate.com/github/bazaarlabs/gitdocs)
5
+
3
6
  Open-source dropbox alternative powered by git. Collaborate on files and tasks without any extra hassle.
4
7
  gitdocs will automatically keep everyone's repos in sync by pushing and pulling changes.
5
8
  This allows any git repo to be used as a collaborative task list, file share, or wiki for a team.
@@ -43,7 +46,7 @@ synchronized across all gitdocs-enabled clients.
43
46
 
44
47
  ## Installation
45
48
 
46
- Requires ruby and rubygems. Install as a gem:
49
+ Requires ruby1.9+ and rubygems. Install as a gem:
47
50
 
48
51
  ```
49
52
  gem install gitdocs
@@ -181,12 +184,21 @@ Gitdocs is still a young project with a lot of opportunity for contributions. Pa
181
184
  Gitdocs is a fresh project that we originally spiked on in a few days time. Our primary goals are to keep the code as simple as possible,
182
185
  but provide the features that makes Dropbox great. If you are interested in other Dropbox alternatives, be sure to checkout our notes below:
183
186
 
184
- * [SparkleShare](http://sparkleshare.org/) is an open source, self-hosted Dropbox alternative written using C# and the [Mono Project](http://www.mono-project.com/Main_Page).
187
+ * [SparkleShare](http://sparkleshare.org/) is an open source, self-hosted Dropbox alternative written using C# and the [Mono Project](http://www.mono-project.com/Main_Page).
185
188
  More mature but has a lot of dependencies, and lacks some of the features planned in Gitdocs.
186
- * [DVCS-Autosync](http://mayrhofer.eu.org/dvcs-autosync) is a project to create an open source replacement for Dropbox based on distributed version control systems.
189
+ * [DVCS-Autosync](http://mayrhofer.eu.org/dvcs-autosync) is a project to create an open source replacement for Dropbox based on distributed version control systems.
187
190
  Very similar project but again we have features planned that are out of scope (local tunnel file sharing, complete web ui for browsing, uploading and editing).
188
- * [Lipsync](https://github.com/philcryer/lipsync) is another similar project. We haven't looked at this too closely, but thought we would mention it in this list.
189
- * [bitpocket](https://github.com/sickill/bitpocket) is a project that uses rsync to synchronize data. Interesting concept, but
191
+ * [Lipsync](https://github.com/philcryer/lipsync) is another similar project. We haven't looked at this too closely, but thought we would mention it in this list.
192
+ * [bitpocket](https://github.com/sickill/bitpocket) is a project that uses rsync to synchronize data. Interesting concept, but
190
193
  lacks revision history, author tracking, etc and we have features planned that are out of scope for this project
194
+ * [RubyDrop](https://github.com/meltingice/RubyDrop) git backed DropBox clone
195
+ * [git-sync](http://tychoish.com/essay/git-sync/) manual git syncing tool,
196
+ which also use XMPP notifications
197
+ * [git-annex-assistant](http://git-annex.branchable.com/design/assistant/)
198
+ directory sync tool based on [git-annex](http://git-annex.branchable.com/). (written in Haskel)
199
+ * [BitTorrent Sync](http://www.bittorrent.com/sync) BitTorrent based syncing
200
+ tool, not open source or publicly defined protocol
201
+ * [StrongSync](https://secure.expandrive.com/strongsync) Dropbox clone utility,
202
+ proprietary
191
203
 
192
204
  If any other open-source dropbox alternatives are available, we would love to hear about them so let us know!
data/Rakefile CHANGED
@@ -6,3 +6,5 @@ Rake::TestTask.new do |t|
6
6
  t.test_files = FileList[File.expand_path('../test/**/*_test.rb', __FILE__)]
7
7
  t.verbose = true
8
8
  end
9
+
10
+ task :default => [:test]
data/bin/gitdocs CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require 'gitdocs'
4
4
 
5
- Gitdocs::Cli.start(ARGV)
5
+ Gitdocs::Cli.start(ARGV)
data/gitdocs.gemspec CHANGED
@@ -18,9 +18,11 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
+ s.required_ruby_version = '>= 1.9'
22
+
21
23
  s.add_dependency 'joshbuddy-guard', '~> 0.10.0'
22
- s.add_dependency 'thin', '~> 1.3.1'
23
- s.add_dependency 'renee', '~> 0.3.7'
24
+ s.add_dependency 'thin', '~> 1.5.1'
25
+ s.add_dependency 'renee', '~> 0.3.11'
24
26
  s.add_dependency 'redcarpet', '~> 2.0.0'
25
27
  s.add_dependency 'thor', '~> 0.14.6'
26
28
  s.add_dependency 'coderay', '~> 1.0.4'
@@ -33,11 +35,12 @@ Gem::Specification.new do |s|
33
35
  s.add_dependency 'grit', "~> 2.4.1"
34
36
  s.add_dependency 'shell_tools', "~> 0.1.0"
35
37
  s.add_dependency 'mimetype-fu', "~> 0.1.2"
36
- s.add_dependency 'eventmachine', '>= 1.0.0.beta.3'
37
- s.add_dependency 'bigdecimal', '~> 1.1.0'
38
+ s.add_dependency 'eventmachine', '>= 1.0.3'
39
+ s.add_dependency 'launchy', '~> 2.4.2'
38
40
 
39
- s.add_development_dependency 'minitest', "~> 2.6.1"
41
+ s.add_development_dependency 'minitest', "~> 5.0.8"
40
42
  s.add_development_dependency 'rake'
41
43
  s.add_development_dependency 'mocha'
42
44
  s.add_development_dependency 'fakeweb'
45
+ s.add_development_dependency 'metric_fu'
43
46
  end
data/lib/gitdocs.rb CHANGED
@@ -15,12 +15,11 @@ require 'gitdocs/docfile'
15
15
  require 'gitdocs/rendering'
16
16
 
17
17
  module Gitdocs
18
-
19
18
  DEBUG = ENV['DEBUG']
20
19
 
21
20
  # Gitdocs.start(:config_root => "...", :debug => true)
22
- def self.start(options={}, &blk)
23
- options = { :debug => DEBUG, :config_root => nil }.merge(options)
21
+ def self.start(options = {}, &blk)
22
+ options = { debug: DEBUG, config_root: nil }.merge(options)
24
23
  @manager.stop if @manager
25
24
  @manager = Manager.new(options[:config_root], options[:debug], &blk)
26
25
  @manager.start(options[:port])
data/lib/gitdocs/cli.rb CHANGED
@@ -6,79 +6,101 @@ module Gitdocs
6
6
 
7
7
  def self.source_root; File.expand_path('../../', __FILE__); end
8
8
 
9
- desc "start", "Starts a daemonized gitdocs process"
10
- method_option :debug, :type => :boolean, :aliases => "-D"
11
- method_option :port, :type => :string, :aliases => "-p"
9
+ desc 'start', 'Starts a daemonized gitdocs process'
10
+ method_option :debug, type: :boolean, aliases: '-D'
11
+ method_option :port, type: :string, aliases: '-p'
12
12
  def start
13
- if self.stopped? && !options[:debug]
14
- self.runner.execute { Gitdocs.start(:port => options[:port]) }
15
- self.running? ? say("Started gitdocs", :green) : say("Failed to start gitdocs", :red)
16
- elsif self.stopped? && options[:debug]
17
- say "Starting in debug mode", :yellow
18
- Gitdocs.start(:debug => true, :port => options[:port])
19
- else # already running
20
- say "Gitdocs is already running, please use restart", :red
13
+ unless stopped?
14
+ say 'Gitdocs is already running, please use restart', :red
15
+ return
16
+ end
17
+
18
+ if options[:debug]
19
+ say 'Starting in debug mode', :yellow
20
+ Gitdocs.start(debug: true, port: options[:port])
21
+ else
22
+ runner.execute { Gitdocs.start(port: options[:port]) }
23
+ if running?
24
+ say 'Started gitdocs', :green
25
+ else
26
+ say 'Failed to start gitdocs', :red
27
+ end
21
28
  end
22
29
  end
23
30
 
24
- desc "stop", "Stops the gitdocs process"
31
+ desc 'stop', 'Stops the gitdocs process'
25
32
  def stop
26
- if self.running?
27
- self.runner.execute(:kill => true)
28
- say "Stopped gitdocs", :red
29
- else # not running
30
- say "Gitdocs is not running", :red
33
+ unless running?
34
+ say 'Gitdocs is not running', :red
35
+ return
31
36
  end
37
+
38
+ runner.execute(kill: true)
39
+ say 'Stopped gitdocs', :red
32
40
  end
33
41
 
34
- desc "restart", "Restarts the gitdocs process"
42
+ desc 'restart', 'Restarts the gitdocs process'
35
43
  def restart
36
- self.stop
37
- self.start
44
+ stop
45
+ start
38
46
  end
39
47
 
40
- desc "add PATH", "Adds a path to gitdocs"
48
+ desc 'add PATH', 'Adds a path to gitdocs'
41
49
  def add(path)
42
- self.config.add_path(path)
50
+ config.add_path(path)
43
51
  say "Added path #{path} to doc list"
44
- self.restart if self.running?
52
+ restart if running?
45
53
  end
46
54
 
47
- desc "rm PATH", "Removes a path from gitdocs"
55
+ desc 'rm PATH', 'Removes a path from gitdocs'
48
56
  def rm(path)
49
- self.config.remove_path(path)
57
+ config.remove_path(path)
50
58
  say "Removed path #{path} from doc list"
51
- self.restart if self.running?
59
+ restart if running?
52
60
  end
53
61
 
54
- desc "clear", "Clears all paths from gitdocs"
62
+ desc 'clear', 'Clears all paths from gitdocs'
55
63
  def clear
56
- self.config.clear
57
- say "Cleared paths from gitdocs"
64
+ config.clear
65
+ say 'Cleared paths from gitdocs'
58
66
  end
59
67
 
60
- desc "create PATH REMOTE", "Creates a new gitdoc root based on an existing remote"
68
+ desc 'create PATH REMOTE', 'Creates a new gitdoc root based on an existing remote'
61
69
  def create(path, remote)
62
70
  FileUtils.mkdir_p(File.dirname(path))
63
- system("git clone -q #{remote} #{ShellTools.escape(path)}") or raise "Unable to clone into #{path}"
64
- self.add(path)
71
+ system("git clone -q #{remote} #{ShellTools.escape(path)}") || fail("Unable to clone into #{path}")
72
+ add(path)
65
73
  say "Created #{path} path for gitdoc"
66
74
  end
67
75
 
68
- desc "status", "Retrieve gitdocs status"
76
+ desc 'status', 'Retrieve gitdocs status'
69
77
  def status
70
78
  say "GitDoc v#{VERSION}"
71
- say "Running: #{self.running?}"
72
- say "Watching paths:"
73
- say self.config.shares.map { |s| " - #{s.path}" }.join("\n")
79
+ say "Running: #{running?}"
80
+ say "File System Watch Method: #{file_system_watch_method}"
81
+ say 'Watching paths:'
82
+ say config.shares.map { |s| " - #{s.path}" }.join("\n")
83
+ end
84
+
85
+ desc 'open', 'Open the Web UI'
86
+ method_option :port, type: :string, aliases: '-p'
87
+ def open
88
+ unless running?
89
+ say 'Gitdocs is not running, cannot open the UI', :red
90
+ return
91
+ end
92
+
93
+ web_port = options[:port]
94
+ web_port ||= config.global.web_frontend_port
95
+ Launchy.open("http://localhost:#{web_port}/")
74
96
  end
75
97
 
76
- desc "config", "Configuration options for gitdocs"
98
+ desc 'config', 'Configuration options for gitdocs'
77
99
  def config
78
- # TODO make this work
100
+ # TODO: make this work
79
101
  end
80
102
 
81
- desc "help", "Prints out the help"
103
+ desc 'help', 'Prints out the help'
82
104
  def help(task = nil, subcommand = false)
83
105
  say "\nGitdocs: Collaborate with ease.\n\n"
84
106
  task ? self.class.task_help(shell, task) : self.class.help(shell, subcommand)
@@ -86,8 +108,13 @@ module Gitdocs
86
108
 
87
109
  # Helpers for thor
88
110
  no_tasks do
89
- def runner(options={})
90
- Dante::Runner.new('gitdocs', options.merge(:debug => false, :daemonize => true, :pid_path => self.pid_path))
111
+ def runner
112
+ Dante::Runner.new(
113
+ 'gitdocs',
114
+ debug: false,
115
+ daemonize: true,
116
+ pid_path: pid_path
117
+ )
91
118
  end
92
119
 
93
120
  def config
@@ -95,17 +122,34 @@ module Gitdocs
95
122
  end
96
123
 
97
124
  def running?
98
- self.runner.daemon_running?
125
+ runner.daemon_running?
99
126
  end
100
127
 
101
128
  def stopped?
102
- self.runner.daemon_stopped?
129
+ runner.daemon_stopped?
103
130
  end
104
131
 
105
132
  def pid_path
106
- "/tmp/gitdocs.pid"
133
+ '/tmp/gitdocs.pid'
107
134
  end
108
- end
109
135
 
136
+ # @return [Symbol] to indicate how the file system is being watched
137
+ def file_system_watch_method
138
+ if Guard::Listener.mac?
139
+ begin
140
+ return :notification if Guard::Listener::Darwin.usable?
141
+ rescue NameError ; end
142
+ elsif Guard::Listener.linux?
143
+ begin
144
+ return :notification if Guard::Listener::Linux.usable?
145
+ rescue NameError ; end
146
+ elsif Guard::Listener.windows?
147
+ begin
148
+ return :notification if Guard::Listener::Windows.usable?
149
+ rescue NameError ; end
150
+ end
151
+ :polling
152
+ end
153
+ end
110
154
  end
111
155
  end
@@ -6,14 +6,14 @@ module Gitdocs
6
6
  attr_reader :config_root
7
7
 
8
8
  def initialize(config_root = nil)
9
- @config_root = config_root || File.expand_path(".gitdocs", ENV["HOME"])
9
+ @config_root = config_root || File.expand_path('.gitdocs', ENV['HOME'])
10
10
  FileUtils.mkdir_p(@config_root)
11
11
  ActiveRecord::Base.establish_connection(
12
- :adapter => 'sqlite3',
13
- :database => ENV["TEST"] ? ':memory:' : File.join(@config_root, 'config.db')
12
+ adapter: 'sqlite3',
13
+ database: ENV['TEST'] ? ':memory:' : File.join(@config_root, 'config.db')
14
14
  )
15
- ActiveRecord::Migrator.migrate(File.expand_path("../migration", __FILE__))
16
- import_old_shares unless ENV["TEST"]
15
+ ActiveRecord::Migrator.migrate(File.expand_path('../migration', __FILE__))
16
+ import_old_shares unless ENV['TEST']
17
17
  end
18
18
 
19
19
  class Share < ActiveRecord::Base
@@ -21,14 +21,14 @@ module Gitdocs
21
21
 
22
22
  def available_remotes
23
23
  repo = Grit::Repo.new(path)
24
- repo.remotes.map{|r| r.name}
24
+ repo.remotes.map { |r| r.name }
25
25
  rescue
26
26
  nil
27
27
  end
28
28
 
29
29
  def available_branches
30
30
  repo = Grit::Repo.new(path)
31
- repo.heads.map{|r| r.name}
31
+ repo.heads.map { |r| r.name }
32
32
  rescue
33
33
  nil
34
34
  end
@@ -39,15 +39,15 @@ module Gitdocs
39
39
  end
40
40
 
41
41
  def add_path(path, opts = nil)
42
- path = self.normalize_path(path)
43
- path_opts = {:path => path}
42
+ path = normalize_path(path)
43
+ path_opts = { path: path }
44
44
  path_opts.merge!(opts) if opts
45
45
  Share.new(path_opts).save!
46
46
  end
47
47
 
48
48
  def remove_path(path)
49
- path = self.normalize_path(path)
50
- Share.where(:path => path).destroy_all
49
+ path = normalize_path(path)
50
+ Share.where(path: path).destroy_all
51
51
  end
52
52
 
53
53
  def clear
@@ -59,7 +59,7 @@ module Gitdocs
59
59
  end
60
60
 
61
61
  def global
62
- raise if Config.all.size > 1
62
+ fail if Config.all.size > 1
63
63
  Config.create! if Config.all.empty?
64
64
  Config.all.first
65
65
  end
@@ -69,6 +69,7 @@ module Gitdocs
69
69
  end
70
70
 
71
71
  private
72
+
72
73
  def import_old_shares
73
74
  full_path = File.expand_path('paths', config_root)
74
75
  if File.exist?(full_path)
@@ -20,4 +20,4 @@ module Gitdocs
20
20
  File.directory?(@path)
21
21
  end
22
22
  end
23
- end
23
+ end
@@ -23,59 +23,54 @@ module Gitdocs
23
23
  results
24
24
  end
25
25
 
26
- def start(web_port=nil)
27
- self.log "Starting Gitdocs v#{VERSION}..."
28
- self.log "Using configuration root: '#{self.config.config_root}'"
29
- self.log "Shares: #{config.shares.map(&:inspect).join(", ")}"
30
- # Start the repo watchers
31
- runners = nil
32
- retrying = false
26
+ def start(web_port = nil)
27
+ log("Starting Gitdocs v#{VERSION}...")
28
+ log("Using configuration root: '#{config.config_root}'")
29
+ log("Shares: (#{config.shares.length}) #{config.shares.map(&:inspect).join(', ')}")
30
+
31
+ restarting = false
33
32
  begin
34
33
  EM.run do
35
- self.log "Starting EM loop..."
36
- @runners = config.shares.map { |share|
37
- self.log "Starting #{share}"
38
- Runner.new(share)
39
- }
40
- self.log "Running runners... #{@runners.size}"
41
- @runners.each(&:run)
34
+ log('Starting EM loop...')
35
+
36
+ @runners = Runner.start_all(config.shares)
37
+
42
38
  # Start the web front-end
43
- if self.config.global.start_web_frontend
44
- web_port ||= self.config.global.web_frontend_port
45
- Server.new(self, *@runners).start(web_port.to_i)
46
- EM.defer( proc {
47
- i = 0
48
- web_started = false
49
- begin
50
- TCPSocket.open('127.0.0.1', web_port.to_i).close
51
- web_started = true
52
- rescue Errno::ECONNREFUSED
53
- self.log "Retrying server loop..."
54
- sleep 0.2
55
- i += 1
56
- retry if i <= 20
57
- end
58
- system("open http://localhost:#{web_port}/") if !retrying && self.config.global.load_browser_on_startup && web_started
59
- }, proc {
60
- self.log "Web server running!"
61
- })
39
+ if config.global.start_web_frontend
40
+ web_port ||= config.global.web_frontend_port
41
+ web_server = Server.new(self, web_port, *@runners)
42
+ web_server.start
43
+ web_server.wait_for_start_and_open(restarting)
62
44
  end
63
45
  end
64
46
  rescue Restart
65
- retrying = true
47
+ restarting = true
66
48
  retry
67
49
  end
68
50
  rescue Exception => e # Report all errors in log
69
- self.log(e.class.inspect + " - " + e.inspect + " - " + e.message.inspect, :error)
70
- self.log(e.backtrace.join("\n"), :error)
51
+ log(e.class.inspect + ' - ' + e.inspect + ' - ' + e.message.inspect, :error)
52
+ log(e.backtrace.join("\n"), :error)
53
+
54
+ # HACK: duplicating the error notification code from the Runner
55
+ begin
56
+ title = 'Unexpected exit'
57
+ msg = 'Something went wrong. Please see the log for details.'
58
+
59
+ Guard::Notifier.notify(msg, title: title, image: :failure)
60
+ Kernel.warn("#{title}: #{msg}")
61
+ rescue
62
+ # do nothing, This contain any exceptions which might be thrown by
63
+ # the notification.
64
+ end
65
+
71
66
  raise
72
67
  ensure
73
- self.log("Gitdocs is terminating...goodbye\n\n")
68
+ log("Gitdocs is terminating...goodbye\n\n")
74
69
  end
75
70
 
76
71
  def restart
77
72
  Thread.new do
78
- Thread.main.raise Restart, "restarting ... "
73
+ Thread.main.raise Restart, 'restarting ... '
79
74
  sleep 0.1 while EM.reactor_running?
80
75
  start
81
76
  end
@@ -85,12 +80,10 @@ module Gitdocs
85
80
  EM.stop
86
81
  end
87
82
 
88
- protected
89
-
90
83
  # Logs and outputs to file or stdout based on debugging state
91
84
  # log("message")
92
- def log(msg, level=:info)
85
+ def log(msg, level = :info)
93
86
  @debug ? puts(msg) : @logger.send(level, msg)
94
87
  end
95
88
  end
96
- end
89
+ end