Skip to content

Commit

Permalink
* Rakefile first attempt.
Browse files Browse the repository at this point in the history
* Button, Animation moved into place, then moved to ./todo
  • Loading branch information
pjfitzgibbons committed Feb 1, 2012
1 parent 3d6d098 commit 519dbd1
Show file tree
Hide file tree
Showing 29 changed files with 338 additions and 76 deletions.
19 changes: 19 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }

# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara request specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
end

81 changes: 65 additions & 16 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
require 'rubygems'
require 'rake'
require 'rspec'

# thanks Dan Lucraft!
def jruby_run(cmd, swt = false)
opts = "-J-XstartOnFirstThread" if swt && Config::CONFIG["host_os"] =~ /darwin/
sh("jruby --debug --1.9 #{opts} -S #{cmd}; echo 'done'")
end

def rspec(options = "")
#files = Dir['plugins/*/spec/*/*_spec.rb'] + Dir['plugins/*/spec/*/*/*_spec.rb'] + Dir['plugins/*/spec/*/*/*/*_spec.rb']
#rspec_opts = "#{options} -c #{files.join(" ")}"
rspec_opts = "-c #{options}"
"./bin/rspec #{rspec_opts}"
end


desc "Run the specs with JUnit output for the Hudson reporter"
task :specs do
rspec_opts = { :spec => ["/swing_shoes/*.rb"] }
jruby_run(rspec(rspec_opts))
end


task :default => ["spec:all"]

desc "Run Specs on Shoes + All Frameworks"
task "spec:all" do

end

desc "Specs for SWT Framework"
task "spec:swt" do
ruby %{--1.9 --debug -J-XstartOnFirstThread} do

ARGV = ["spec/swt_shoes"]
require 'rubygems'

version = ">= 0"

#if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
# version = $1
# ARGV.shift
#end

gem 'rspec-core', version
load Gem.bin_path('rspec-core', 'rspec', version)

end
end
#<<<<<<< HEAD
#require 'rake/clean'
## require_relative 'platform/skel'
Expand Down Expand Up @@ -522,22 +571,22 @@ require 'rake'
#rescue LoadError
# puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
#end

require 'spec/rake/spectask'
Spec::Rake::SpecTask.new(:spec) do |spec|
spec.libs << 'lib' << 'spec'
spec.spec_files = FileList['spec/**/*_spec.rb']
end

Spec::Rake::SpecTask.new(:rcov) do |spec|
spec.libs << 'lib' << 'spec'
spec.pattern = 'spec/**/*_spec.rb'
spec.rcov = true
end

task :spec => :check_dependencies

task :default => :spec
#
#require 'spec/rake/spectask'
#Spec::Rake::SpecTask.new(:spec) do |spec|
# spec.libs << 'lib' << 'spec'
# spec.spec_files = FileList['spec/**/*_spec.rb']
#end
#
#Spec::Rake::SpecTask.new(:rcov) do |spec|
# spec.libs << 'lib' << 'spec'
# spec.pattern = 'spec/**/*_spec.rb'
# spec.rcov = true
#end
#
#task :spec => :check_dependencies
#
#task :default => :spec

#
#require 'rake/rdoctask'
Expand Down
1 change: 1 addition & 0 deletions bin/rspec
17 changes: 0 additions & 17 deletions lib/shoes-archive/swt_constants.rb

This file was deleted.

18 changes: 0 additions & 18 deletions lib/shoes/button.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/swing_shoes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require 'swing_shoes/flow'

require 'swing_shoes/common_methods'
require 'swing_shoes/button'
#require 'swing_shoes/button'

module SwingShoes

Expand Down
34 changes: 34 additions & 0 deletions lib/swing_shoes/animation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require 'shoes/timer_base'
#require 'runnable_block'

module Shoes
class Animation < TimerBase

import javax.swing.Timer

attr_reader :jtimer

def initialize this, fps, &blk
ms_per_frame = 1000 / fps

if block_given?
@runnable = RunnableBlock.new(this, blk)
@jtimer = Timer.new(ms_per_frame, @runnable )

#@runnable.init
@jtimer.start
end
end

def stop
#@runnable.stop
@jtimer.stop
end

def start
#@runnable.start
@jtimer.start
end

end
end
2 changes: 1 addition & 1 deletion lib/swing_shoes/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def gui_init

frame = JFrame.new()

self.gui_container = container = frame.get_content_pane
@gui_container = container = frame.get_content_pane

layout = FlowLayout.new(FlowLayout::LEFT)

Expand Down
File renamed without changes.
File renamed without changes.
15 changes: 0 additions & 15 deletions spec/shoes/todo/swt_constants_spec.rb

This file was deleted.

9 changes: 9 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

$:<< '../lib'
require 'java'

require 'rspec'

require 'shoes'

Dir["./spec/white_shoes/shared_examples/**/*.rb"].each {|f| require f}
8 changes: 4 additions & 4 deletions spec/support/shared_examples_for_common_elements_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
shared_examples_for "A Common Element" do

describe "basic dimensions" do
let(:display) { SWT::Widgets::Display.getDefault }
let(:shell) { SWT::Widgets::Shell.new(display) }
let(:flow) { Shoes::Flow.new(shell) }
let(:container) { flow.container }
#let(:display) { SWT::Widgets::Display.getDefault }
#let(:shell) { SWT::Widgets::Shell.new(display) }
#let(:flow) { Shoes::Flow.new(shell) }
#let(:container) { flow.container }

subject { described_class.new(container, "text") }

Expand Down
5 changes: 5 additions & 0 deletions spec/swing_shoes/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
it_behaves_like "A WhiteShoes Shoes::App"


after :each do
debugger
subject
end

end
2 changes: 1 addition & 1 deletion spec/swing_shoes/flow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class FlowShoeLaces
end

after :all do
SWT::Widgets::Display.getDefault.dispose
#SWT::Widgets::Display.getDefault.dispose
end

end
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions spec/white_shoes/shared_examples/shared_shoes_animation_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

shared_examples_for "A WhiteShoes Shoes::Animation" do
class ShoeLacesAnimation
#attr_accessor :blk, :gui_container
#attr_accessor :width, :height, :margin
#attr_accessor :parent_gui_container
end

let(:shoelaces) {
shoelaces = ShoeLacesAnimation.new({}) {}
#shoelaces.stub_chain(:logger, :debug)
shoelaces.extend described_class
shoelaces
}

subject { shoelaces }

describe "gui_animation_init" do
#it "should leave a reference to the container" do
# subject.should_receive(:gui_container=).with(anything)
# subject.gui_flow_init
#end
end
end
1 change: 1 addition & 0 deletions spec/white_shoes/shared_examples/shared_shoes_app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def initialize(opts, &blk)
it "should leave a reference to the framework object for further operations" do
subject.should_receive(:gui_container=).with(anything)
subject.gui_init
debugger; 1
end
end
describe "gui_open" do
Expand Down
24 changes: 24 additions & 0 deletions spec/white_shoes/shared_examples/shared_shoes_button_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

shared_examples_for "A WhiteShoes Shoes::Button" do
class ShoeLacesButton
attr_accessor :parent_gui_container, :blk
attr_accessor :gui_element
attr_accessor :text, :width, :height
end

let(:shoelaces) {
shoelaces = ShoeLacesButton.new({}) {}
#shoelaces.stub_chain(:logger, :debug)
shoelaces.extend described_class
shoelaces
}

subject { shoelaces }

describe "gui_button_init" do
it "should leave a reference to the container" do
subject.should_receive(:gui_container=).with(anything)
subject.gui_button_init
end
end
end
14 changes: 14 additions & 0 deletions testing/swt_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'java'
require 'swt'
class Object
include_package 'org.eclipse.swt'
include_package 'org.eclipse.swt.widgets'
end
display = Swt.display
shell = Shell.new display
shell.setSize 300, 300
shell.open
while !shell.isDisposed do
display.sleep unless display.readAndDispatch
end
display.dispose
16 changes: 16 additions & 0 deletions todo/shoes_button.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#debugger
#require 'native'
module Shoes
class Button

attr_accessor :parent_gui_container, :blk
attr_accessor :gui_element
attr_accessor :text, :width, :height

def initialize(parent_gui_container, text = 'Button', opts={}, &blk)

gui_button_init
end

end
end
File renamed without changes.
Loading

0 comments on commit 519dbd1

Please sign in to comment.