Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set things up so you can specify a particular rig using the global va…
…r. wrote spec tests
- Loading branch information
Showing
9 changed files
with
149 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2009 dougsko | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
= rham | ||
|
||
A ruby wrapper for libham. | ||
|
||
== Note on Patches/Pull Requests | ||
|
||
* Fork the project. | ||
* Make your feature addition or bug fix. | ||
* Add tests for it. This is important so I don't break it in a | ||
future version unintentionally. | ||
* Commit, do not mess with rakefile, version, or history. | ||
(if you want to have your own version, that is fine but | ||
bump version in a commit by itself I can ignore when I pull) | ||
* Send me a pull request. Bonus points for topic branches. | ||
|
||
== Copyright | ||
|
||
Copyright (c) 2009 dougsko. See LICENSE for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,50 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'rake/rdoctask' | ||
require 'rake/testtask' | ||
require 'rake/gempackagetask' | ||
|
||
# Define global vars | ||
PROJECT = "Rham" | ||
MY_NAME = "Doug Prostko" | ||
MY_EMAIL = "dougtko@gmail.com" | ||
PROJECT_SUMMARY = "libham wrapper" | ||
UNIX_NAME = "rham" | ||
WEBSITE_DIR = "." | ||
RDOC_HTML_DIR = "#{WEBSITE_DIR}/rdoc" | ||
DEPS = "" | ||
|
||
# Find version info | ||
REQUIRE_PATHS = ["."] | ||
$LOAD_PATH.concat(REQUIRE_PATHS) | ||
# This library file defines the MyProject::VERSION constant. | ||
require_files = FileList["ext/*.so", "lib/*.rb"] | ||
require_files.each do |file| | ||
require file | ||
require 'rubygems' | ||
require 'rake' | ||
|
||
begin | ||
require 'jeweler' | ||
Jeweler::Tasks.new do |gem| | ||
gem.name = "rham" | ||
gem.summary = %Q{A ruby wrapper for libham} | ||
gem.description = %Q{ruby wrapper for libham} | ||
gem.email = "dougtko@gmail.com" | ||
gem.homepage = "http://github.com/dougsko/rham" | ||
gem.authors = ["dougsko"] | ||
gem.add_development_dependency "rspec" | ||
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings | ||
end | ||
rescue LoadError | ||
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler" | ||
end | ||
PROJECT_VERSION = eval("#{PROJECT}::VERSION") | ||
|
||
# Options common to RDocTask AND Gem::Specification. | ||
# The --main argument specifies which file appears on the index.html page | ||
GENERAL_RDOC_OPTS = { | ||
"--title" => "#{PROJECT} Documentation", | ||
"--main" => "README", | ||
} | ||
|
||
# Extra RDOC files | ||
RDOC_FILES = FileList["README", "LICENSE"] | ||
|
||
# Filelist with Test::Unit test cases. | ||
TEST_FILES = FileList["test/**/*.rb"] | ||
|
||
# Executable scripts, all non-garbage files under bin/. | ||
BIN_FILES = FileList["**/*.rb"] | ||
|
||
# This filelist is used to create source packages. | ||
# Include all Ruby and RDoc files. | ||
DIST_FILES = FileList["**/*.rdoc", "README", "LICENSE"] | ||
DIST_FILES.include("Rakefile") | ||
DIST_FILES.include(BIN_FILES) | ||
DIST_FILES.include("ext/*.so", "lib/*.rb", "lib/*.so") | ||
|
||
# Run the tests if rake is invoked without arguments. | ||
task "default" => ["test"] | ||
test_task_name = "test" | ||
Rake::TestTask.new(test_task_name) do |t| | ||
t.test_files = TEST_FILES | ||
t.libs = REQUIRE_PATHS | ||
require 'spec/rake/spectask' | ||
Spec::Rake::SpecTask.new(:spec) do |spec| | ||
spec.libs << 'lib' << 'spec' | ||
spec.spec_files = FileList['spec/**/*_spec.rb'] | ||
spec.spec_opts = ['--color'] | ||
end | ||
|
||
# The "rdoc" task generates API documentation. | ||
Rake::RDocTask.new("rdoc") do |t| | ||
t.rdoc_files = RDOC_FILES + BIN_FILES | ||
t.title = GENERAL_RDOC_OPTS["--title"] | ||
t.main = GENERAL_RDOC_OPTS["--main"] | ||
t.rdoc_dir = RDOC_HTML_DIR | ||
Spec::Rake::SpecTask.new(:rcov) do |spec| | ||
spec.libs << 'lib' << 'spec' | ||
spec.pattern = 'spec/**/*_spec.rb' | ||
spec.rcov = true | ||
spec.spec_opts = ['--color'] | ||
end | ||
|
||
GEM_SPEC = Gem::Specification.new do |s| | ||
s.name = UNIX_NAME | ||
s.version = PROJECT_VERSION | ||
s.summary = PROJECT_SUMMARY | ||
s.author = MY_NAME | ||
s.email = MY_EMAIL | ||
s.files = DIST_FILES | ||
s.test_files = TEST_FILES | ||
s.has_rdoc = true | ||
s.extra_rdoc_files = RDOC_FILES | ||
s.rdoc_options = GENERAL_RDOC_OPTS.to_a.flatten | ||
s.add_dependency(DEPS) | ||
end | ||
task :spec => :check_dependencies | ||
|
||
# Now we can generate the package-related tasks. | ||
Rake::GemPackageTask.new(GEM_SPEC) do |pkg| | ||
pkg.need_zip = true | ||
pkg.need_tar = true | ||
end | ||
task :default => :spec | ||
|
||
# The "prepare-release" task makes sure your tests run, and then generates | ||
# files for a new release. | ||
desc "Run tests, generate RDoc and create packages." | ||
task "prepare-release" => ["clobber"] do | ||
puts "Preparing release of #{PROJECT} version #{PROJECT_VERSION}" | ||
Rake::Task["test"].invoke | ||
Rake::Task["rdoc"].invoke | ||
Rake::Task["package"].invoke | ||
require 'rake/rdoctask' | ||
Rake::RDocTask.new do |rdoc| | ||
if File.exist?('VERSION') | ||
version = File.read('VERSION') | ||
else | ||
version = "" | ||
end | ||
|
||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = "rham #{version}" | ||
rdoc.rdoc_files.include('README*') | ||
rdoc.rdoc_files.include('lib/**/*.rb, ext/**/*.c') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') | ||
|
||
describe "Rham" do | ||
before(:all) do | ||
$model = "dummy" | ||
@rig = Rham.new | ||
@rig.rig_open | ||
end | ||
|
||
after(:all) do | ||
@rig.rig_close | ||
end | ||
|
||
it "setsi/gets the mode" do | ||
@rig.rig_set_mode("AM", "normal") | ||
@rig.rig_get_mode.should == "AM" | ||
end | ||
|
||
it "sets/gets the freq" do | ||
@rig.rig_set_freq(20000) | ||
@rig.rig_get_freq.should == "20000.000000" | ||
end | ||
|
||
it "checks stats" do | ||
stats = @rig.stats | ||
stats["mode"].should == "AM" | ||
stats["freq"].should == "20000.000000" | ||
end | ||
|
||
it "checks powerstat" do | ||
@rig.rig_get_powerstat.should == "on" | ||
end | ||
|
||
it "checks vfo" do | ||
@rig.rig_get_vfo.should == 0 | ||
end | ||
|
||
it "checks info" do | ||
@rig.rig_get_info.should == "Nothing much (dummy)" | ||
end | ||
|
||
it "checks strength" do | ||
@rig.rig_get_strength.should == 0 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
$LOAD_PATH.unshift(File.dirname(__FILE__)) | ||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
require 'rham' | ||
require 'spec' | ||
require 'spec/autorun' | ||
|
||
Spec::Runner.configure do |config| | ||
|
||
end |
This file was deleted.
Oops, something went wrong.