cloby 0.0.1-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ Usage:
2
+
3
+ 1. Install the gem
4
+ 2. Extend Clojure::Object
5
+
6
+ A top-level method called dosync will be defined that takes a block of code, and your class will have transactional semantics for its instance variables.
@@ -0,0 +1,28 @@
1
+ require 'ant'
2
+
3
+ directory "pkg/classes"
4
+
5
+ desc "Clean up build artifacts"
6
+ task :clean do
7
+ rm_rf "pkg/classes"
8
+ rm_rf "lib/cloby_ext.jar"
9
+ end
10
+
11
+ desc "Compile the extension"
12
+ task :compile => "pkg/classes" do |t|
13
+ ant.javac :srcdir => "src", :destdir => t.prerequisites.first,
14
+ :source => "1.5", :target => "1.5", :debug => true,
15
+ :classpath => "${java.class.path}:${sun.boot.class.path}:lib/clojure-1.2.0.jar"
16
+ end
17
+
18
+ desc "Build the jar"
19
+ task :jar => :compile do
20
+ ant.jar :basedir => "pkg/classes", :destfile => "javalib/cloby_ext.jar", :includes => "**/*.class"
21
+ end
22
+
23
+ task :package => :jar
24
+
25
+ desc "Run the specs"
26
+ task :spec => :jar do
27
+ ruby "-S", "spec", "spec"
28
+ end
@@ -0,0 +1,16 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{cloby}
5
+ s.version = "0.0.1"
6
+ s.authors = ["Charles Oliver Nutter"]
7
+ s.date = Time.now.strftime('YYYY-MM-DD')
8
+ s.description = "Clojure-based transactional semantics for Ruby instance variables"
9
+ s.email = ["headius@headius.com"]
10
+ s.files = Dir['{lib,examples,test}/**/*'] + Dir['{*.txt,*.gemspec,Rakefile}']
11
+ s.homepage = "http://github.com/headius/cloby"
12
+ s.require_paths = ["lib"]
13
+ s.summary = "Clojure-based transactional semantics for Ruby instance variables"
14
+ s.test_files = Dir["spec/*_spec.rb"]
15
+ s.platform = "java"
16
+ end
@@ -0,0 +1,25 @@
1
+ require 'cloby'
2
+
3
+ class MyClojureObj < Clojure::Object
4
+ def initialize
5
+ dosync { @foo = 'foo' }
6
+ end
7
+
8
+ attr_accessor :foo
9
+ end
10
+
11
+ obj = MyClojureObj.new
12
+ puts "obj.foo = " + obj.foo
13
+
14
+ begin
15
+ puts "Setting obj.foo to 'bar'"
16
+ obj.foo = 'bar'
17
+ rescue ConcurrencyError
18
+ puts "Oops, need a transaction"
19
+ end
20
+
21
+ puts "Trying again with a transaction"
22
+ dosync { obj.foo = 'bar' }
23
+ puts "Success"
24
+
25
+ puts "obj.foo = " + obj.foo
@@ -0,0 +1,13 @@
1
+ require 'java'
2
+ require 'jruby'
3
+
4
+ begin
5
+ Java::clojure.lang.Ref
6
+ rescue Exception
7
+ $stderr.puts "Clojure is not available, load it first"
8
+ raise
9
+ end
10
+
11
+ # load ClojureLibrary
12
+ require 'cloby_ext.jar'
13
+ org.jruby.clojure.ClojureLibrary.new.load(JRuby.runtime, false)
Binary file
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cloby
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: java
11
+ authors:
12
+ - Charles Oliver Nutter
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-12-08 19:59:05.532000 -06:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Clojure-based transactional semantics for Ruby instance variables
22
+ email:
23
+ - headius@headius.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - lib/cloby.rb
32
+ - lib/cloby_ext.jar
33
+ - examples/simple.rb
34
+ - README.txt
35
+ - cloby.gemspec
36
+ - Rakefile
37
+ has_rdoc: true
38
+ homepage: http://github.com/headius/cloby
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options: []
43
+
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirements: []
63
+
64
+ rubyforge_project:
65
+ rubygems_version: 1.3.7
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: Clojure-based transactional semantics for Ruby instance variables
69
+ test_files: []
70
+