rake gemspec (was: Next steps)

2 views
Skip to first unread message

Robert Citek

unread,
Jan 25, 2010, 1:55:18 PM1/25/10
to spec...@googlegroups.com
On Thu, Jan 21, 2010 at 11:32 AM, Ed Howland <ed.ho...@gmail.com> wrote:
> (2) Getting Rake gemspec task to add dependency for (at least) json
> and rest-client.

On to tackling this one. - Robert

Ed Howland

unread,
Jan 25, 2010, 4:24:38 PM1/25/10
to spec...@googlegroups.com
Cool.

Have you looked at the generator starting point?

It doesn't matter to me if you use Ruby or Bash.

Also, there is a starting point on github for the templates folder.
Would like it to be divided into (all potential) server types:

templates/php/spec
/server
... etc.
/ruby/spec
./server
... etc.
/python/spec

.. etc

Then the generator script will copy from which ever server type you
speciied with an option. The default should be 'php' if none given.

BTW, I think there is one usecase for a Ruby server. You might want to
test on a different machine/environment. You might not want to lug
RSpec/Cucumber and all their dependencies over there. If you can
install spec_qire with dependencies for sinatra and json and
rest-client, you can rub the server there and run your specs and cukes
locally,

BTW, add sinatra as a gemspec dependency.

Cheers,
Ed


Ed Howland
http://greenprogrammer.wordpress.com
http://twitter.com/ed_howland

> --
> Post: spec...@googlegroups.com
> Subscribe: spec_wire...@googlegroups.com
> Unsubscribe: spec_wire+...@googlegroups.com
> Website: http://groups.google.com/group/spec_wire
>

Robert Citek

unread,
Jan 26, 2010, 3:30:07 AM1/26/10
to spec...@googlegroups.com
On Mon, Jan 25, 2010 at 4:24 PM, Ed Howland <ed.ho...@gmail.com> wrote:
> Cool.
>
> Have you looked at the generator starting point?

I don't think so. What is a "generator starting point"?

I've been going through the pickaxe book, reading about gems, and the
web, reading about rake:

http://martinfowler.com/articles/rake.html

> It doesn't matter to me if you use Ruby or Bash.

I don't follow. Let's hook-up via IM/Skype sometime during the day on Tuesday.

Regards,
- Robert

Robert Citek

unread,
Jan 26, 2010, 4:26:38 PM1/26/10
to spec...@googlegroups.com
On Mon, Jan 25, 2010 at 1:55 PM, Robert Citek <robert...@gmail.com> wrote:

Added json and rest-client as dependencies to the rakefile. They seem
to work (see below), so I updated github with the new Rakefile and
gemspec.

What is a reasonable way to go about testing the gem? Should I try
installing it in a VM running a LiveCD?

Regards,
- Robert

-------

$ grep add_depend Rakefile
gem.add_dependency("json", ">= 1.2.0")
gem.add_dependency("rest-client", ">= 1.2.0")

$ rake build
(in /home/rwcitek/lang/ruby/spec_wire)
Generated: spec_wire.gemspec
spec_wire.gemspec is valid.
WARNING: no rubyforge_project specified
WARNING: bin/notes.txt is missing #! line
Successfully built RubyGem
Name: spec_wire
Version: 0.3.3
File: spec_wire-0.3.3.gem

$ gem specification -l pkg/spec_wire-0.3.3.gem | grep -B 2 -A6 :runtime
- !ruby/object:Gem::Dependency
name: json
type: :runtime
version_requirement:
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: 1.2.0
--
- !ruby/object:Gem::Dependency
name: rest-client
type: :runtime
version_requirement:
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: 1.2.0

Robert Citek

unread,
Jan 27, 2010, 12:40:37 AM1/27/10
to spec...@googlegroups.com
On Tue, Jan 26, 2010 at 9:26 PM, Robert Citek <robert...@gmail.com> wrote:
> What is a reasonable way to go about testing the gem?  Should I try
> installing it in a VM running a LiveCD?

Tried the LiveCD (Ubuntu 9.04 i386) in a VM approach and got this:

$ sudo gem install spec_wire-0.3.3.gem
Building native extensions. This could take a while...
ERROR: Error installing spec_wire-0.3.3.gem:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:1


Gem files will remain installed in
/usr/lib/ruby/gems/1.8/gems/json-1.2.0 for inspection.
Results logged to
/usr/lib/ruby/gems/1.8/gems/json-1.2.0/ext/json/ext/generator/gem_make.out


Any thoughts?

Regards,
- Robert

Ed Howland

unread,
Jan 27, 2010, 10:52:12 AM1/27/10
to spec...@googlegroups.com
You need to make sure ruby-dev is installed via apt=get. I posted
about this in an earlier bit about my history file on 9.04

"I also had to : sudo apt-get install ruby1.8-dev"

However, I am not sure why it needs to build native extensions. Maybe
due to a dependency?

HTH,

Ed

Robert Citek

unread,
Jan 28, 2010, 3:17:39 AM1/28/10
to spec...@googlegroups.com
On Wed, Jan 27, 2010 at 10:52 AM, Ed Howland <ed.ho...@gmail.com> wrote:
> You need to make sure ruby-dev is installed via apt=get. I posted
> about this in an earlier bit about my history file on 9.04
>
> "I also had to : sudo apt-get install ruby1.8-dev"
>
> However, I am not sure why it needs to build native extensions. Maybe
> due to a dependency?

That was it. Was able to build the gem and install it on a Ubuntu
LiveCD (see below).

I also added sinatra to the Jeweler::Task object in the rakefile.
Committed the rakefile to github. Updated the google group wiki page
to show how I installed the spec_wire gem. (at some point I need to
move the wiki page to github.)

Regards,
- Robert

-----

$ gem specification -l pkg/spec_wire-0.3.3.gem | grep -B 2 -A6 :runtime
- !ruby/object:Gem::Dependency
name: json
type: :runtime
version_requirement:
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: 1.2.0
--
- !ruby/object:Gem::Dependency
name: rest-client
type: :runtime
version_requirement:
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: 1.2.0
--
- !ruby/object:Gem::Dependency

name: sinatra


type: :runtime
version_requirement:
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version

version: 0.9.4

$ gem install spec_wire-0.3.3.gem


Building native extensions. This could take a while...

Successfully installed json-1.2.0
Successfully installed mime-types-1.16
Successfully installed rest-client-1.2.0
Successfully installed rack-1.1.0
Successfully installed sinatra-0.9.4
Successfully installed spec_wire-0.3.3
6 gems installed
Installing ri documentation for json-1.2.0...
Installing ri documentation for mime-types-1.16...
Installing ri documentation for rest-client-1.2.0...
Installing ri documentation for rack-1.1.0...
Installing ri documentation for sinatra-0.9.4...
Installing ri documentation for spec_wire-0.3.3...
Installing RDoc documentation for json-1.2.0...
Installing RDoc documentation for mime-types-1.16...
Installing RDoc documentation for rest-client-1.2.0...
Installing RDoc documentation for rack-1.1.0...
Installing RDoc documentation for sinatra-0.9.4...
Installing RDoc documentation for spec_wire-0.3.3...

$ gem list

*** LOCAL GEMS ***

json (1.2.0)
mime-types (1.16)
rack (1.1.0)
rest-client (1.2.0)
sinatra (0.9.4)
spec_wire (0.3.3)

Ed Howland

unread,
Jan 28, 2010, 12:26:27 PM1/28/10
to spec...@googlegroups.com
Excellent!

Have you tried testing the spec_wire gem, once installed?

Easiest way to test would be to copy the exsiting spec_wire/templates
folder somewhere. Start the ruby_server in that folder's server dir.
Start irb with -rspec_wire. then:

Bar.new
Should get a Class Bar not found.

In another terminal in the templates location you copied:
echo 'class Bar; end' > server/bar.php

Then in irb:
obj = Bar.new
Should get back a valid object.

Ed

Robert Citek

unread,
Jan 28, 2010, 12:58:07 PM1/28/10
to spec...@googlegroups.com
On Thu, Jan 28, 2010 at 12:26 PM, Ed Howland <ed.ho...@gmail.com> wrote:
> Excellent!
>
> Have you tried testing the spec_wire gem, once installed?

Have not. But will do.

Regards,
- Robert

Robert Citek

unread,
Jan 28, 2010, 12:58:42 PM1/28/10
to spec...@googlegroups.com
On Thu, Jan 28, 2010 at 12:43 PM, Robert Citek <robert...@gmail.com> wrote:
> On Thu, Jan 28, 2010 at 12:30 PM, Ed Howland <ed.ho...@gmail.com> wrote:
>> Excellent! and Excellent!
>>
>> Although, I only got spec_wire.gemspec when I pulled via git.
>
> That's because of me and my branching.  I have it in my experimental
> branch.  Let me merge and commit again.

Merged and committed.

http://github.com/edhowland/spec_wire/blob/master/Rakefile

Regards,
- Robert

Robert Citek

unread,
Jan 28, 2010, 1:54:15 PM1/28/10
to spec...@googlegroups.com
On Thu, Jan 28, 2010 at 12:26 PM, Ed Howland <ed.ho...@gmail.com> wrote:
> Have you tried testing the spec_wire gem, once installed?
>
> Easiest way to test would be to copy the exsiting spec_wire/templates
> folder somewhere. Start the ruby_server in that folder's server dir.
> Start irb with -rspec_wire. then:
>
> Bar.new
> Should get a Class Bar not found.
>
> In another terminal in the templates location you copied:
> echo 'class Bar; end' > server/bar.php
>
> Then in irb:
> obj = Bar.new
> Should get back a valid object.

Nope. Don't get that. I get this:

$ rm servers/bar.*

$ ./bin/server.start
starting service

$ cat servers/ruby_server.pid
7199

$ netstat -tanp | grep 4567
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 0.0.0.0:4567 0.0.0.0:*
LISTEN 7199/ruby

$ ruby -e 'require "rubygems" ; require "spec_wire" ; '

$ ruby -e 'require "rubygems" ; require "spec_wire" ; Bar.new'
/usr/lib/ruby/gems/1.8/gems/spec_wire-0.3.3/lib/spec_wire/const.rb:18:in
`join': can't convert nil into String (TypeError)
from /usr/lib/ruby/gems/1.8/gems/spec_wire-0.3.3/lib/spec_wire/const.rb:18:in
`const_missing'
from -e:1

$ echo 'class Bar ; end' > servers/bar.php

$ ruby -e 'require "rubygems" ; require "spec_wire" ; Bar.new'
/usr/lib/ruby/gems/1.8/gems/spec_wire-0.3.3/lib/spec_wire/const.rb:18:in
`join': can't convert nil into String (TypeError)
from /usr/lib/ruby/gems/1.8/gems/spec_wire-0.3.3/lib/spec_wire/const.rb:18:in
`const_missing'
from -e:1

$ echo 'class Bar ; end' > servers/bar.rb

$ ruby -e 'require "rubygems" ; require "spec_wire" ; Bar.new'
/usr/lib/ruby/gems/1.8/gems/spec_wire-0.3.3/lib/spec_wire/const.rb:18:in
`join': can't convert nil into String (TypeError)
from /usr/lib/ruby/gems/1.8/gems/spec_wire-0.3.3/lib/spec_wire/const.rb:18:in
`const_missing'
from -e:1

Regards,
- Robert

Ed Howland

unread,
Jan 28, 2010, 4:40:13 PM1/28/10
to spec...@googlegroups.com
Hmm,

did you copy the templates folder somewhere else? If you did, then the
ruby server would be in 'server' not 'servers' and there would be no
bin dir at all (and no server_start script (there),

I am going to try the same sxperiment on my end.

Ed

Ed Howland

unread,
Jan 28, 2010, 4:52:26 PM1/28/10
to spec...@googlegroups.com
Forgot one step. We need to load the spec_helper.rb only.

Here is my experiment:
mkdir rt
Mac:tmp$ cd rt
Mac:rt$ cp -r ~/ruby/spec_wire/templates/ .
Mac:rt$ ls
config server spec tmp
Mac:rt$ cat config/environment.rb
# environment.rb
# included from spec/spec_helper.rb

SpecWire::Initializer.run do |config|
config.class_cache =
File.join(File.expand_path(File.dirname(__FILE__)), '..', 'tmp',
'class_cache')
end


Mac:rt$ tree
.
|-- config
| `-- environment.rb
|-- server
| |-- ruby_server.rb
| `-- support
| |-- env.php
| `-- env.rb
|-- spec
| `-- spec_helper.rb
`-- tmp
`-- class_cache

6 directories, 5 files

Mac:rt$ cd spec/
Mac:spec$ irb -rspec_helper
irb(main):001:0> Bar.new
StandardError: class Bar not found
from /Users/edh/tmp/rt/config/../tmp/class_cache/bar.rb:14:in `rescue
in initialize'
from /Users/edh/tmp/rt/config/../tmp/class_cache/bar.rb:7:in `initialize'
from (irb):1:in `new'
from (irb):1
from /usr/local/bin/irb:12:in `<main>'

[.... this is where I echo'd the class file in another window ...]

irb(main):002:0> Bar.new
=> #<Bar:0x00000101700dd8 @meta={"json_class"=>"Bar", "data"=>[{}],
"id"=>2154285364}, @our_id=2154285364,
@session_cookies={"rack.session"=>"BAh7BmwrBzTJZ4BvOghCYXIA%0A"}>
irb(main):003:0>

HTH,
Ed

Reply all
Reply to author
Forward
0 new messages