Skip to content

Commit

Permalink
Rename Scm modules to OhlohScm
Browse files Browse the repository at this point in the history
  • Loading branch information
notalex committed Oct 16, 2014
1 parent 528b35b commit b4043f8
Show file tree
Hide file tree
Showing 79 changed files with 234 additions and 234 deletions.
2 changes: 1 addition & 1 deletion lib/ohloh_scm/adapters/svn/commits.rb
Expand Up @@ -96,7 +96,7 @@ def deepen_diff(diff, rev)
if (diff.action == 'D' or diff.action == 'A') && is_directory?(diff.path, recurse_rev)
# Deleting or adding a directory. Expand it out to show every file.
recurse_files(diff.path, recurse_rev).collect do |f|
Scm::Diff.new(:action => diff.action, :path => File.join(diff.path, f))
OhlohScm::Diff.new(:action => diff.action, :path => File.join(diff.path, f))
end
else
# An ordinary file action. Just return the diff.
Expand Down
2 changes: 1 addition & 1 deletion lib/ohloh_scm/commit.rb
@@ -1,4 +1,4 @@
module Scm
module OhlohScm
# A commit is a collection of diffs united by a single timestamp, author, and
# message.
#
Expand Down
8 changes: 4 additions & 4 deletions lib/ohloh_scm/diff.rb
@@ -1,10 +1,10 @@
module Scm
module OhlohScm
# A +Diff+ represents a change to a single file. It can represent the addition or
# deletion of a file, or it can represent a modification of the file contents.
#
#
# Ohloh does not track filename changes. If a file is renamed, Ohloh treats this
# as the deletion of one file and the creation of another.
#
#
# Ohloh does not track directories, only the files within directories.
#
# Don't confuse our use of the word "Diff" with a patch file or the output of the
Expand All @@ -22,7 +22,7 @@ class Diff
# 'M' modified
# 'D' deleted
attr_accessor :action

# The SHA1 hash of the file contents both before and after the change.
# These must be computed using the same method as Git.
attr_accessor :parent_sha1, :sha1
Expand Down
8 changes: 4 additions & 4 deletions lib/ohloh_scm/parsers/bzr_parser.rb
Expand Up @@ -30,7 +30,7 @@ def self.internal_parse(buffer, opts)
e.diffs = remove_dupes(e.diffs)
yield e
end
e = Scm::Commit.new
e = OhlohScm::Commit.new
e.diffs = []
next_state = :data
when /^#{indent}revno:\s+(\d+)$/
Expand Down Expand Up @@ -98,10 +98,10 @@ def self.parse_diffs(action, line)
# Note that is possible to be renamed to the empty string!
# This happens when a subdirectory is moved to become the root.
before, after = line.scan(/(.+) => ?(.*)/).first
[ Scm::Diff.new(:action => 'D', :path => before),
Scm::Diff.new(:action => 'A', :path => after || '' )]
[ OhlohScm::Diff.new(:action => 'D', :path => before),
OhlohScm::Diff.new(:action => 'A', :path => after || '' )]
else
[Scm::Diff.new(:action => action, :path => line)]
[OhlohScm::Diff.new(:action => action, :path => line)]
end.each do |d|
d.path = strip_trailing_asterisk(d.path)
end
Expand Down
26 changes: 13 additions & 13 deletions lib/ohloh_scm/parsers/bzr_xml_parser.rb
Expand Up @@ -18,7 +18,7 @@ def initialize(callback)
def tag_start(name, attrs)
case name
when 'log'
@commit = Scm::Commit.new
@commit = OhlohScm::Commit.new
@commit.diffs = []
when 'affected-files'
@diffs = []
Expand Down Expand Up @@ -87,18 +87,18 @@ def parse_diff(action, path, before_path)
case action
# A rename action requires two diffs: one to remove the old filename,
# another to add the new filename.
#
#
# Note that is possible to be renamed to the empty string!
# This happens when a subdirectory is moved to become the root.
when 'renamed'
diffs = [ Scm::Diff.new(:action => 'D', :path => before_path),
Scm::Diff.new(:action => 'A', :path => path || '')]
diffs = [ OhlohScm::Diff.new(:action => 'D', :path => before_path),
OhlohScm::Diff.new(:action => 'A', :path => path || '')]
when 'added'
diffs = [Scm::Diff.new(:action => 'A', :path => path)]
diffs = [OhlohScm::Diff.new(:action => 'A', :path => path)]
when 'modified'
diffs = [Scm::Diff.new(:action => 'M', :path => path)]
diffs = [OhlohScm::Diff.new(:action => 'M', :path => path)]
when 'removed'
diffs = [Scm::Diff.new(:action => 'D', :path => path)]
diffs = [OhlohScm::Diff.new(:action => 'D', :path => path)]
end
diffs.each do |d|
d.path = strip_trailing_asterisk(d.path)
Expand All @@ -108,11 +108,11 @@ def parse_diff(action, path, before_path)

def strip_trailing_asterisk(path)
path[-1..-1] == '*' ? path[0..-2] : path
end
end

def remove_dupes(diffs)
BzrXmlParser.remove_dupes(diffs)
end
end

end

Expand All @@ -133,14 +133,14 @@ def self.scm
def self.remove_dupes(diffs)
# Bazaar may report that a file was added and modified in a single commit.
# Reduce these cases to a single 'A' action.
diffs.delete_if do |d|
diffs.delete_if do |d|
d.action == 'M' && diffs.select { |x| x.path == d.path && x.action == 'A' }.any?
end
end

# Bazaar may report that a file was both deleted and added in a single commit.
# Reduce these cases to a single 'M' action.
diffs.each do |d|
d.action = 'M' if diffs.select { |x| x.path == d.path }.size > 1
diffs.each do |d|
d.action = 'M' if diffs.select { |x| x.path == d.path }.size > 1
end.uniq
end

Expand Down
2 changes: 1 addition & 1 deletion lib/ohloh_scm/parsers/cvs_parser.rb
Expand Up @@ -139,7 +139,7 @@ def self.read_commit(io, filename, commit_number, should_yield)
should_yield = false if commit_number == '1.1' and state == 'dead'
message = read_message(io)
if should_yield
commit = Scm::Commit.new
commit = OhlohScm::Commit.new
commit.token = committer_date[0..18]
commit.committer_date = Time.parse(committer_date[0..18] + ' +0000').utc
commit.committer_name = committer_name
Expand Down
4 changes: 2 additions & 2 deletions lib/ohloh_scm/parsers/git_parser.rb
Expand Up @@ -27,7 +27,7 @@ def self.internal_parse(io, opts)
when /^commit ([a-z0-9]{40,40})$/
sha1 = $1
yield e if e
e = Scm::Commit.new
e = OhlohScm::Commit.new
e.diffs = []
e.token = sha1
e.author_name = ANONYMOUS
Expand All @@ -53,7 +53,7 @@ def self.internal_parse(io, opts)

elsif state == :diffs
if line =~ /^([ADM])\t(.+)$/
e.diffs << Scm::Diff.new( :action => $1, :path => $2)
e.diffs << OhlohScm::Diff.new( :action => $1, :path => $2)
end

else
Expand Down
4 changes: 2 additions & 2 deletions lib/ohloh_scm/parsers/git_styled_parser.rb
Expand Up @@ -35,7 +35,7 @@ def self.internal_parse(io, opts)
if line =~ /^Commit: ([a-z0-9]+)$/
sha1 = $1
yield e if e
e = Scm::Commit.new
e = OhlohScm::Commit.new
e.diffs = []
e.token = sha1
e.author_name = ANONYMOUS
Expand Down Expand Up @@ -70,7 +70,7 @@ def self.internal_parse(io, opts)
elsif line =~ /:([0-9]+) ([0-9]+) ([a-z0-9]+) ([a-z0-9]+) ([A-Z])\t"?(.+[^"])"?$/
# Submodules have a file mode of '160000', which indicates a "gitlink"
# We ignore submodules completely.
e.diffs << Scm::Diff.new( :action => $5, :path => $6, :sha1 => $4, :parent_sha1 => $3 ) unless $1=='160000' || $2=='160000'
e.diffs << OhlohScm::Diff.new( :action => $5, :path => $6, :sha1 => $4, :parent_sha1 => $3 ) unless $1=='160000' || $2=='160000'
end

else
Expand Down
4 changes: 2 additions & 2 deletions lib/ohloh_scm/parsers/hg_parser.rb
Expand Up @@ -17,7 +17,7 @@ def self.internal_parse(buffer, opts)
case l
when /^changeset:\s+\d+:([0-9a-f]+)/
yield e if e && block_given?
e = Scm::Commit.new
e = OhlohScm::Commit.new
e.diffs = []
e.token = $1
when /^user:\s+(.+?)(\s+<(.+)>)?$/
Expand All @@ -27,7 +27,7 @@ def self.internal_parse(buffer, opts)
e.committer_date = Time.parse($1).utc
when /^files:\s+(.+)/
($1 || '').split(' ').each do |file|
e.diffs << Scm::Diff.new(:action => '?', :path => file)
e.diffs << OhlohScm::Diff.new(:action => '?', :path => file)
end
when /^summary:\s+(.+)/
e.message = $1
Expand Down
4 changes: 2 additions & 2 deletions lib/ohloh_scm/parsers/hg_styled_parser.rb
Expand Up @@ -25,7 +25,7 @@ def self.internal_parse(buffer, opts)
if state == :data
case l
when /^changeset:\s+([0-9a-f]+)/
e = Scm::Commit.new
e = OhlohScm::Commit.new
e.diffs = []
e.token = $1
when /^user:\s+(.+?)(\s+<(.+)>)?$/
Expand All @@ -46,7 +46,7 @@ def self.internal_parse(buffer, opts)
if l == "__END_FILES__\n"
next_state = :data
elsif l =~ /^([MAD]) (.+)$/
e.diffs << Scm::Diff.new(:action => $1, :path => $2)
e.diffs << OhlohScm::Diff.new(:action => $1, :path => $2)
end

elsif state == :long_comment
Expand Down
4 changes: 2 additions & 2 deletions lib/ohloh_scm/parsers/svn_parser.rb
Expand Up @@ -13,7 +13,7 @@ def self.internal_parse(buffer, opts)
next_state = state
if state == :data
if l =~ /^r(\d+) \| (.*) \| (\d+-\d+-\d+ .*) \(.*\) \| .*/
e = Scm::Commit.new
e = OhlohScm::Commit.new
e.token = $1.to_i
e.committer_name = $2
e.committer_date = Time.parse($3).utc
Expand All @@ -26,7 +26,7 @@ def self.internal_parse(buffer, opts)
elsif state == :diffs
if l =~ /^ (\w) ([^\(\)]+)( \(from (.+):(\d+)\))?$/
e.diffs ||= []
e.diffs << Scm::Diff.new(:action => $1, :path => $2, :from_path => $4, :from_revision => $5.to_i)
e.diffs << OhlohScm::Diff.new(:action => $1, :path => $2, :from_path => $4, :from_revision => $5.to_i)
else
next_state = :comment
end
Expand Down
4 changes: 2 additions & 2 deletions lib/ohloh_scm/parsers/svn_xml_parser.rb
Expand Up @@ -15,11 +15,11 @@ def initialize(callback)
def tag_start(name, attrs)
case name
when 'logentry'
@commit = Scm::Commit.new
@commit = OhlohScm::Commit.new
@commit.diffs = []
@commit.token = attrs['revision'].to_i
when 'path'
@diff = Scm::Diff.new(:action => attrs['action'],
@diff = OhlohScm::Diff.new(:action => attrs['action'],
:from_path => attrs['copyfrom-path'],
:from_revision => attrs['copyfrom-rev'].to_i)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ohloh_scm/scratch_dir.rb
@@ -1,7 +1,7 @@
require 'fileutils'

# A utility class to manage the creation and automatic cleanup of temporary directories.
module Scm
module OhlohScm
class ScratchDir
attr_reader :path

Expand Down
2 changes: 1 addition & 1 deletion lib/ohloh_scm/version.rb
@@ -1,4 +1,4 @@
module Scm
module OhlohScm
module Version
STRING = '2.0.0'
end
Expand Down
2 changes: 1 addition & 1 deletion ohloh_scm.gemspec
Expand Up @@ -4,7 +4,7 @@ require 'ohloh_scm/version'

Gem::Specification.new do |gem|
gem.name = 'ohloh_scm'
gem.version = Scm::Version::STRING
gem.version = OhlohScm::Version::STRING
gem.authors = ["BlackDuck Software"]
gem.email = ["info@openhub.net"]
gem.summary = %[Source Control Management]
Expand Down
4 changes: 2 additions & 2 deletions test/test_helper.rb
Expand Up @@ -17,7 +17,7 @@
DATA_DIR = File.expand_path(File.join(TEST_DIR, 'data'))
end

class Scm::Test < Test::Unit::TestCase
class OhlohScm::Test < Test::Unit::TestCase
# For reasons unknown, the base class defines a default_test method to throw a failure.
# We override it with a no-op to prevent this 'helpful' feature.
def default_test
Expand Down Expand Up @@ -48,7 +48,7 @@ def assert_buffers_equal(expected, actual)
end

def with_repository(type, name)
Scm::ScratchDir.new do |dir|
OhlohScm::ScratchDir.new do |dir|
if Dir.entries(REPO_DIR).include?(name)
`cp -R #{File.join(REPO_DIR, name)} #{dir}`
elsif Dir.entries(REPO_DIR).include?(name + '.tgz')
Expand Down
8 changes: 4 additions & 4 deletions test/unit/abstract_adapter_test.rb
@@ -1,7 +1,7 @@
require_relative '../test_helper'

module OhlohScm::Adapters
class AbstractAdapterTest < Scm::Test
class AbstractAdapterTest < OhlohScm::Test
def test_simple_validation
scm = AbstractAdapter.new()
assert !scm.valid?
Expand Down Expand Up @@ -74,15 +74,15 @@ def test_shellout
stdout = AbstractAdapter.run(cmd)
assert_equal "Hello World\n", stdout
end

def test_shellout_with_stderr
cmd = %q( ruby -e" t = 'Hello World'; STDOUT.puts t; STDERR.puts t " )
stdout, stderr, status = AbstractAdapter.run_with_err(cmd)
assert_equal 0, status.exitstatus
assert_equal "Hello World\n", stdout
assert_equal "Hello World\n", stderr
end

def test_shellout_large_output
cat = 'ruby -e" puts Array.new(65536){ 42 } "'
stdout = AbstractAdapter.run(cat)
Expand All @@ -91,7 +91,7 @@ def test_shellout_large_output

def test_shellout_error
cmd = "false"
assert_raise RuntimeError do
assert_raise RuntimeError do
stdout = AbstractAdapter.run(cmd)
end
end
Expand Down
14 changes: 7 additions & 7 deletions test/unit/adapter_factory_test.rb
@@ -1,10 +1,10 @@
require_relative '../test_helper'

module OhlohScm::Adapters
class FactoryTest < Scm::Test
class FactoryTest < OhlohScm::Test

def test_factory_hg
Scm::ScratchDir.new do |path|
OhlohScm::ScratchDir.new do |path|
`cd #{path} && hg init`
hg = Factory.from_path(path)
assert hg.is_a?(HgAdapter)
Expand All @@ -13,7 +13,7 @@ def test_factory_hg
end

def test_factory_bzr
Scm::ScratchDir.new do |path|
OhlohScm::ScratchDir.new do |path|
`cd #{path} && bzr init`
bzr = Factory.from_path(path)
assert bzr.is_a?(BzrAdapter)
Expand All @@ -22,7 +22,7 @@ def test_factory_bzr
end

def test_factory_git
Scm::ScratchDir.new do |path|
OhlohScm::ScratchDir.new do |path|
`cd #{path} && git init`
git = Factory.from_path(path)
assert git.is_a?(GitAdapter)
Expand All @@ -31,7 +31,7 @@ def test_factory_git
end

def test_factory_svn
Scm::ScratchDir.new do |path|
OhlohScm::ScratchDir.new do |path|
`cd #{path} && svnadmin create foo`
svn = Factory.from_path(File.join(path, 'foo'))
assert svn.is_a?(SvnAdapter)
Expand All @@ -40,7 +40,7 @@ def test_factory_svn
end

def test_factory_svn_checkout
Scm::ScratchDir.new do |path|
OhlohScm::ScratchDir.new do |path|
`cd #{path} && svnadmin create foo`
`cd #{path} && svn co file://#{File.expand_path(File.join(path, 'foo'))} bar`
svn = Factory.from_path(File.join(path, 'bar'))
Expand All @@ -53,7 +53,7 @@ def test_factory_svn_checkout

def test_factory_from_cvs_checkout
with_cvs_repository('cvs', 'simple') do |cvs|
Scm::ScratchDir.new do |path|
OhlohScm::ScratchDir.new do |path|
`cd #{path} && cvsnt -d #{File.expand_path(cvs.url)} co simple 2> /dev/null`
factory_response = Factory.from_path(File.join(path, 'simple'))
assert factory_response.is_a?(CvsAdapter)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/array_writer_test.rb
@@ -1,7 +1,7 @@
require_relative '../test_helper'

module OhlohScm::Parsers
class ArrayWriterTest < Scm::Test
class ArrayWriterTest < OhlohScm::Test

def test_basic

Expand Down

0 comments on commit b4043f8

Please sign in to comment.