Skip to content

Commit

Permalink
Working to make tests run again after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
tallakt committed Mar 26, 2009
1 parent c25906b commit 31b62ba
Show file tree
Hide file tree
Showing 20 changed files with 68 additions and 37 deletions.
2 changes: 2 additions & 0 deletions .profile
@@ -0,0 +1,2 @@
export RUBYOPT=rubygems

19 changes: 13 additions & 6 deletions Rakefile
@@ -1,16 +1,16 @@
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
require File.dirname(__FILE__) + '/lib/ruby-plc'
require File.dirname(__FILE__) + '/lib/machines'

# Generate all the Rake tasks
# Run 'rake -T' to see list of generated tasks (from gem root directory)
$hoe = Hoe.new('ruby-plc', RubyPlc::VERSION) do |p|
p.developer('FIXME full name', 'FIXME email')
$hoe = Hoe.new('machines', Machines::VERSION) do |p|
p.developer('Tallak Tveide', 'tallak@tveide.net')
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
p.rubyforge_name = p.name # TODO this is default value
# p.extra_deps = [
# ['activesupport','>= 2.0.2'],
# ]
p.extra_deps = [
['rbtree','>= 0.2.1'],
]
p.extra_dev_deps = [
['newgem', ">= #{::Newgem::VERSION}"]
]
Expand All @@ -24,5 +24,12 @@ end
require 'newgem/tasks' # load /tasks/*.rake
Dir['tasks/**/*.rake'].each { |t| load t }

desc "Look for TODO and FIXME tags in the code"
task :todo do
FileList['**/*.rb'].egrep(/#.*(FIXME|TODO|TBD)/)
end


# TODO - want other tests/tasks run by default? Add them to the list
# task :default => [:spec, :features]
task :default => [:spec, :todo]
4 changes: 3 additions & 1 deletion lib/machines/timedomain/analog.rb
@@ -1,8 +1,10 @@
require 'machines/timedomain/timer'
require 'machines/etc/notify'
require 'machines/timedomain/discrete'


module Machines
module TimeDomain
module Timedomain
class Analog
extend Notify
attr_accessor :name, :description
Expand Down
16 changes: 5 additions & 11 deletions lib/machines/timedomain/analog_value.rb
@@ -1,16 +1,10 @@
include 'machines/timedomain/analog'
include 'machines/timedomain/timer'
include 'machines/etc/notify'
require 'machines/timedomain/analog'
require 'machines/timedomain/timer'
require 'machines/etc/notify'

module Machines
module Physical
module AnalogValue < Analog
extend Notify
include Analog

attr_accessor :name, :description
notify :change

module Timedomain
class AnalogValue < Analog
def initialize(value = nil)
@name, @description = nil
@v = value
Expand Down
2 changes: 1 addition & 1 deletion lib/machines/timedomain/binary_op_discrete.rb
@@ -1,7 +1,7 @@
require 'machines/timedomain/discrete_base'

module Machines
module TimeDomain
module Timedomain
class DiscreteBase #:nodoc:
# forward Declaration
end
Expand Down
2 changes: 1 addition & 1 deletion lib/machines/timedomain/discrete.rb
@@ -1,7 +1,7 @@
require 'machines/timedomain/discrete_base'

module Machines
module TimeDomain
module Timedomain
class Discrete < DiscreteBase
def initialize(vv = false)
@v = vv
Expand Down
2 changes: 1 addition & 1 deletion lib/machines/timedomain/discrete_base.rb
Expand Up @@ -4,7 +4,7 @@
require 'machines/etc/notify'

module Machines
module TimeDomain
module Timedomain
class DiscreteBase
extend Notify

Expand Down
2 changes: 1 addition & 1 deletion lib/machines/timedomain/discrete_sink.rb
@@ -1,7 +1,7 @@
require 'machines/timedomain/discrete_base'

module Machines
module TimeDomain
module Timedomain
class DiscreteSink < DiscreteBase
attr_reader :source

Expand Down
2 changes: 1 addition & 1 deletion lib/machines/timedomain/negated_discrete.rb
@@ -1,7 +1,7 @@
require 'machines/timedomain/discrete_base'

module Machines
module TimeDomain
module Timedomain
class DiscreteBase #:nodoc:
# forward Declaration
end
Expand Down
2 changes: 1 addition & 1 deletion lib/machines/timedomain/sampler.rb
Expand Up @@ -2,7 +2,7 @@
include 'machines/timedomain/sequencer'

module Machines
module TimeDomain
module Timedomain

# The Sample class will notify all listeners to the #on_sample function
# at even intervals
Expand Down
2 changes: 1 addition & 1 deletion lib/machines/timedomain/scheduler.rb
Expand Up @@ -2,7 +2,7 @@
require 'monitor'

module Machines
module TimeDomain
module Timedomain
class Scheduler
class Entry
attr_accessor :time, :tag, :callback
Expand Down
2 changes: 1 addition & 1 deletion lib/machines/timedomain/timer.rb
Expand Up @@ -2,7 +2,7 @@
require 'machines/etc/notify'

module Machines
module TimeDomain
module Timedomain
class Timer
extend Notify

Expand Down
6 changes: 3 additions & 3 deletions script/console
Expand Up @@ -5,6 +5,6 @@ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
libs = " -r irb/completion"
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
libs << " -r #{File.dirname(__FILE__) + '/../lib/ruby-plc.rb'}"
puts "Loading ruby-plc gem"
exec "#{irb} #{libs} --simple-prompt"
libs << " -r #{File.dirname(__FILE__) + '/../lib/machines.rb'}"
puts "Loading machines gem"
exec "#{irb} #{libs} --simple-prompt"
24 changes: 24 additions & 0 deletions spec/analog_2_spec.rb
@@ -0,0 +1,24 @@
require File.dirname(__FILE__) + '/spec_helper.rb'
require 'machines/timedomain/analog_value'

include Machines::Timedomain


describe 'Analog signals' do
before(:each) do
@a = AnalogValue.new 0.0
@b = AnalogValue.new 0.0
@d = Discrete.new
end

it 'should report on change' do
ok = nil
@a.on_change { ok = :ok }
@a.v = 5.0
ok.should == :ok
ok = nil
@a.v = 10.0
ok.should == :ok
end

end
8 changes: 4 additions & 4 deletions spec/analog_spec.rb
@@ -1,13 +1,13 @@
require File.dirname(__FILE__) + '/spec_helper.rb'
require 'machines/timedomain/analog'
require 'machines/timedomain/analog_value'

include Machines::TimeDomain
include Machines::Timedomain


describe 'Analog signals' do
before(:each) do
@a = Analog.new 0.0
@b = Analog.new 0.0
@a = AnalogValue.new 0.0
@b = AnalogValue.new 0.0
@d = Discrete.new
end

Expand Down
2 changes: 1 addition & 1 deletion spec/discrete_spec.rb
Expand Up @@ -2,7 +2,7 @@
require 'machines/timedomain/discrete'
require 'machines/timedomain/discrete_sink'

include Machines::TimeDomain
include Machines::Timedomain


describe 'Discrete signals' do
Expand Down
2 changes: 1 addition & 1 deletion spec/scheduler_nowait_spec.rb
Expand Up @@ -3,7 +3,7 @@
require 'benchmark'
require 'timeout'

include Machines::TimeDomain
include Machines::Timedomain

describe Scheduler do
before(:each) do
Expand Down
2 changes: 2 additions & 0 deletions spec/scheduler_spec.rb
Expand Up @@ -3,6 +3,8 @@
require 'benchmark'
require 'timeout'

include Machines::Timedomain

describe Scheduler do
before(:each) do
end
Expand Down
2 changes: 1 addition & 1 deletion spec/step_base_spec.rb
Expand Up @@ -3,7 +3,7 @@
require 'machines/sequences/step'

include Machines::Sequences
include Machines::TimeDomain
include Machines::Timedomain

describe StepBase do
before(:each) do
Expand Down
2 changes: 1 addition & 1 deletion spec/timer_spec.rb
@@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/spec_helper.rb'
require 'machines/timedomain/timer'

include Machines::TimeDomain
include Machines::Timedomain

describe Timer do
before(:each) do
Expand Down

0 comments on commit 31b62ba

Please sign in to comment.