Class: Gemify::VCS
- Inherits:
-
Object
- Object
- Gemify::VCS
- Defined in:
- lib/gemify/vcs.rb
Class Method Summary collapse
- .determine_vcs ⇒ Object
- .files(forced_vcs = false) ⇒ Object
- .get_files_from_command(command) ⇒ Object
Class Method Details
.determine_vcs ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gemify/vcs.rb', line 7 def self.determine_vcs vcs = :unknown if File.exist?(".git") vcs = :git elsif File.exist?("_darcs") vcs = :darcs elsif File.exist?(".hg") vcs = :hg elsif File.exist?(".bzr") vcs = :bzr elsif File.exist?(".svn") vcs = :svn elsif File.exist?("CVSROOT") vcs = :cvs end vcs end |
.files(forced_vcs = false) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/gemify/vcs.rb', line 38 def self.files(forced_vcs = false) case (forced_vcs || determine_vcs) when :git get_files_from_command("git-ls-files").delete_if { |w| w == ".gitignore" or w == ".gitattributes" } when :darcs get_files_from_command("darcs query manifest") when :bzr get_files_from_command("bzr ls").delete_if { |w| w == ".bzrignore" } when :hg get_files_from_command("hg manifest") when :svn get_files_from_command("svn ls") when :cvs get_files_from_command("cvs ls") when :unknown Dir['bin/*'] + Dir['lib/**/**'] end end |
.get_files_from_command(command) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/gemify/vcs.rb', line 26 def self.get_files_from_command(command) files = [] Open3.popen3(command) do |stdin, stdout, stderr| stdout.each { |line| file = line.strip files << file if File.exist?(file) } end files end |