Skip to content

Commit

Permalink
Merge pull request #24 from stevenkaras/steven-dev
Browse files Browse the repository at this point in the history
Steven dev
  • Loading branch information
dancar committed Sep 25, 2013
2 parents c45d3df + 7ae4496 commit c0fc928
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 38 deletions.
25 changes: 25 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'rake/testtask'

require File.expand_path("../lib/grib/version", __FILE__)

Rake::TestTask.new do |t|
t.test_files = FileList['test/*_test.rb']
t.test_files = FileList['test/test_*.rb']
# t.test_files = FileList['spec/*_spec.rb']
# t.test_files = FileList['spec/spec_*.rb']
# t.libs << 'spec'
t.libs << 'test'
end

desc "Run tests"
task :default => :test

desc "Build the gem"
task :build do
system "gem build grib.gemspec"
end

task :gem => :build do
system "gem uninstall -a grib"
system "gem install grib-#{Grib::VERSION}.gem"
end
5 changes: 5 additions & 0 deletions bin/grib
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env ruby

require File.expand_path("../../lib/grib", __FILE__)

Grib.new.run
21 changes: 21 additions & 0 deletions grib.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require File.expand_path("../lib/grib/version", __FILE__)

Gem::Specification.new do |s|
s.version = Grib::VERSION

s.name = "grib"
s.summary = "Git RevIewBoard script"
s.description = "Wraps reviewboard's post-review command line tool to remember previous invocations, and do some basic sanity checks prior to posting a review"

s.authors = ["Dan Carmon"]
s.email = "dan.carmon@trusteer.com"
s.homepage = "http://dancar.github.com/grib"
s.license = "MIT"

s.files = []
s.files += Dir["lib/**/*.rb", "tests/**/*.rb"]
s.files += Dir["[A-Z]*"]

s.bindir = "bin"
s.executables = Dir["bin/*"].map { |e| File.basename(e) }
end
17 changes: 6 additions & 11 deletions grib.rb → lib/grib.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
#!/usr/bin/env ruby
# Grib - Git Reviewboard script
$:.unshift File.dirname(__FILE__)
require 'lib/grib_conf'
require 'lib/grib_repo_conf'
require 'lib/grib_command_conf'
require 'lib/logger'
require 'lib/repo_interfaces/git'

lib_dir = File.expand_path("../grib", __FILE__)
%w{ version grib_conf grib_repo_conf grib_command_conf logger repo_interfaces/grib_repo_interface }.each do |lib|
require File.expand_path(lib, lib_dir)
end

require 'shellwords'

class Grib
# Constants:
VERSION = "2.1.1"
USER_CONF_FILE = ".grib" # Will be concatenated to the HOME environment variable
REPO_CONF_FILE = "gribdata.yml" # Will reside in the repository folder
REPO_INTERFACES = {
Expand Down Expand Up @@ -205,5 +202,3 @@ def read_char()
return str.chr
end
end

Grib.new().run()
1 change: 0 additions & 1 deletion lib/grib_command_conf.rb → lib/grib/grib_command_conf.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'optparse'
require 'lib/grib_conf'
class GribCommandConf < GribConf
UNFLAG_PREFIX = "dont".freeze
UNOPTION_PREFIX = "no".freeze
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion lib/grib_repo_conf.rb → lib/grib/grib_repo_conf.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'lib/grib_conf'
require 'yaml'
# GribRepoConf contains a GribData per each branch and a general GribData for all branches
# It is used to store both repository-based settings and branch-based settings
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'lib/repo_interfaces/grib_repo_interface'
module GribRepoInterfaces
class Git < GribRepoInterfaces::GribRepoInterface
def get_data_folder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ def get_current_branch
throw "Abstract method called"
end
end
end

%w{ git }.each do |lib|
require File.expand_path("../#{lib}", __FILE__)
end
3 changes: 3 additions & 0 deletions lib/grib/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Grib
VERSION = "2.1.1"
end
6 changes: 3 additions & 3 deletions tests/test_logger.rb → test/mock_logger.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'logger'
class TestLogger < Logger
class MockLogger < Logger
attr_accessor :last_log
@@last_log = nil

Expand All @@ -24,8 +24,8 @@ def self.last_log
end
end

class Test::Unit::TestCase
class MiniTest::Unit::TestCase
def assert_last_log (type)
assert_equal(type, TestLogger.last_log)
assert_equal(type, MockLogger.last_log)
end
end
12 changes: 7 additions & 5 deletions tests/tc_GribCommandConf.rb → test/test_GribCommandConf.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
require "lib/grib_command_conf"
require "lib/grib_conf"
require "test/unit"
require 'tests/test_logger'
class TestGribConf < Test::Unit::TestCase
require "rubygems" if RUBY_VERSION < "1.9"
begin; gem "minitest"; rescue Gem::LoadError; end
require File.expand_path("../../lib/grib", __FILE__)
require "minitest/autorun"
require File.expand_path("../mock_logger", __FILE__)

class TestGribConf < MiniTest::Unit::TestCase
PARENT_GRIBCONF = GribConf.new({
"server" => "my_server",
"target-people" => "me"
Expand Down
12 changes: 7 additions & 5 deletions tests/tc_GribConf.rb → test/test_GribConf.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
require "lib/grib_conf"
require "test/unit"
require 'tests/test_logger'
class TestGribConf < Test::Unit::TestCase
require "rubygems" if RUBY_VERSION < "1.9"
begin; gem "minitest"; rescue Gem::LoadError; end
require File.expand_path("../../lib/grib", __FILE__)
require "minitest/autorun"
require File.expand_path("../mock_logger", __FILE__)

class TestGribConf < MiniTest::Unit::TestCase

def setup
$LOG = TestLogger.new()
$LOG = MockLogger.new()
end

def test_conf_simple
Expand Down
13 changes: 8 additions & 5 deletions tests/tc_GribRepoConf.rb → test/test_GribRepoConf.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
require 'lib/grib_repo_conf'
require "test/unit"
require 'tests/test_logger'
require "rubygems" if RUBY_VERSION < "1.9"
begin; gem "minitest"; rescue Gem::LoadError; end
require File.expand_path("../../lib/grib", __FILE__)
require "minitest/autorun"
require File.expand_path("../mock_logger", __FILE__)
require 'yaml'
class TestGribRepoConf < Test::Unit::TestCase

class TestGribRepoConf < MiniTest::Unit::TestCase
@@FILE1 = "file1.yml"
@@DATA1 = {
"branches" => {
Expand All @@ -18,7 +21,7 @@ class TestGribRepoConf < Test::Unit::TestCase
}

def setup()
$LOG = TestLogger.new()
$LOG = MockLogger.new()
@file1_path = File.join(File.dirname(__FILE__),@@FILE1)
file1 = File.new(@file1_path, "w")
file1.write YAML.dump(@@DATA1)
Expand Down
6 changes: 0 additions & 6 deletions tests/ts_grib.rb

This file was deleted.

0 comments on commit c0fc928

Please sign in to comment.