jrsplenda 0.1.0

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.
Files changed (43) hide show
  1. data/History.txt +4 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +46 -0
  4. data/PostInstall.txt +7 -0
  5. data/README.txt +23 -0
  6. data/Rakefile +27 -0
  7. data/build.xml +15 -0
  8. data/config/hoe.rb +75 -0
  9. data/config/requirements.rb +15 -0
  10. data/lib/jrsplenda.rb +36 -0
  11. data/lib/jrsplenda/jrsplenda_field_helper.rb +43 -0
  12. data/lib/jrsplenda/jrsplenda_method_helper.rb +35 -0
  13. data/lib/jrsplenda/jrsplenda_mock_helper.rb +34 -0
  14. data/lib/jrsplenda/mocha/jrsplenda_mocha_support.rb +108 -0
  15. data/lib/jrsplenda/version.rb +9 -0
  16. data/script/console +10 -0
  17. data/script/destroy +14 -0
  18. data/script/generate +14 -0
  19. data/script/txt2html +82 -0
  20. data/setup.rb +1585 -0
  21. data/spec/field_helper_spec.rb +96 -0
  22. data/spec/fixtures/PackageField.java +12 -0
  23. data/spec/fixtures/PackageInstanceMethod.java +7 -0
  24. data/spec/fixtures/PackageStaticMethod.java +7 -0
  25. data/spec/fixtures/PrivateField.java +12 -0
  26. data/spec/fixtures/PrivateInstanceMethod.java +7 -0
  27. data/spec/fixtures/PrivateStaticMethod.java +7 -0
  28. data/spec/fixtures/ProtectedField.java +12 -0
  29. data/spec/fixtures/ProtectedInstanceMethod.java +7 -0
  30. data/spec/fixtures/ProtectedStaticMethod.java +7 -0
  31. data/spec/fixtures/PublicField.java +9 -0
  32. data/spec/method_helper_spec.rb +45 -0
  33. data/spec/mock_helper_spec.rb +42 -0
  34. data/spec/spec_helper.rb +5 -0
  35. data/tasks/deployment.rake +34 -0
  36. data/tasks/environment.rake +7 -0
  37. data/tasks/website.rake +17 -0
  38. data/website/index.html +11 -0
  39. data/website/index.txt +83 -0
  40. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  41. data/website/stylesheets/screen.css +138 -0
  42. data/website/template.html.erb +48 -0
  43. metadata +107 -0
@@ -0,0 +1,96 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ import 'fixtures.PrivateField'
4
+ import 'fixtures.ProtectedField'
5
+ import 'fixtures.PackageField'
6
+
7
+ describe "A field helper" do
8
+ include JRSplenda::FieldHelper
9
+
10
+ describe "for a private field" do
11
+ before(:each) do
12
+ @f = PrivateField.new
13
+ wrap_java_fields @f
14
+ end
15
+
16
+ it "should provide an attr set method" do
17
+ lambda { @f.str_field = "42" }.should_not raise_error
18
+ end
19
+
20
+ it "should not provide an attr set method if the field is final" do
21
+ lambda { @f.final_field == "42" }.should raise_error
22
+ end
23
+ end
24
+
25
+ describe "for a protected field" do
26
+ before(:each) do
27
+ @f = ProtectedField.new
28
+ wrap_java_fields @f
29
+ end
30
+
31
+ it "should provide an attr set method" do
32
+ lambda { @f.str_field = "42" }.should_not raise_error
33
+ end
34
+
35
+ it "should not provide an attr set method if the field is final" do
36
+ lambda { @f.final_field == "42" }.should raise_error
37
+ end
38
+ end
39
+
40
+ describe "for a package-scoped field" do
41
+ before(:each) do
42
+ @f = PackageField.new
43
+ wrap_java_fields @f
44
+ end
45
+
46
+ it "should provide an attr set method" do
47
+ lambda { @f.str_field = "42" }.should_not raise_error
48
+ end
49
+
50
+ it "should not provide an attr set method if the field is final" do
51
+ lambda { @f.final_field == "42" }.should raise_error
52
+ end
53
+ end
54
+
55
+ describe "for a static private field" do
56
+ before(:all) do
57
+ wrap_java_fields PrivateField
58
+ end
59
+
60
+ it "should provide an attr set method" do
61
+ lambda { PrivateField.static_field = "42" }.should_not raise_error
62
+ end
63
+
64
+ it "should not provide an attr set method if the field is final" do
65
+ lambda { PrivateField.static_final_field == "42" }.should raise_error
66
+ end
67
+ end
68
+
69
+ describe "for a static protected field" do
70
+ before(:all) do
71
+ wrap_java_fields ProtectedField
72
+ end
73
+
74
+ it "should provide an attr set method" do
75
+ lambda { ProtectedField.static_field = "42" }.should_not raise_error
76
+ end
77
+
78
+ it "should not provide an attr set method if the field is final" do
79
+ lambda { ProtectedField.static_final_field == "42" }.should raise_error
80
+ end
81
+ end
82
+
83
+ describe "for a static package-scoped field" do
84
+ before(:all) do
85
+ wrap_java_fields PackageField
86
+ end
87
+
88
+ it "should provide an attr set method" do
89
+ lambda { PackageField.static_field = "42" }.should_not raise_error
90
+ end
91
+
92
+ it "should not provide an attr set method if the field is final" do
93
+ lambda { PackageField.static_final_field == "42" }.should raise_error
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,12 @@
1
+ package fixtures;
2
+
3
+ public class PackageField {
4
+ String strField = "42";
5
+ final String finalField = "foo";
6
+ static String staticField = "42";
7
+ static final String staticFinalField = "42";
8
+
9
+ public String getStrField() {
10
+ return strField;
11
+ }
12
+ }
@@ -0,0 +1,7 @@
1
+ package fixtures;
2
+
3
+ public class PackageInstanceMethod {
4
+ String thePackageScopeMethod() {
5
+ return "42";
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ package fixtures;
2
+
3
+ public class PackageStaticMethod {
4
+ static String thePackageScopeMethod() {
5
+ return "42";
6
+ }
7
+ }
@@ -0,0 +1,12 @@
1
+ package fixtures;
2
+
3
+ public class PrivateField {
4
+ private String strField = "42";
5
+ private final String finalField = "foo";
6
+ private static String staticField = "42";
7
+ private static final String staticFinalField = "42";
8
+
9
+ public String getStrField() {
10
+ return strField;
11
+ }
12
+ }
@@ -0,0 +1,7 @@
1
+ package fixtures;
2
+
3
+ public class PrivateInstanceMethod {
4
+ private String thePrivateMethod() {
5
+ return "42";
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ package fixtures;
2
+
3
+ public class PrivateStaticMethod {
4
+ public static String thePrivateMethod() {
5
+ return "42";
6
+ }
7
+ }
@@ -0,0 +1,12 @@
1
+ package fixtures;
2
+
3
+ public class ProtectedField {
4
+ protected String strField = "42";
5
+ protected final String finalField = "foo";
6
+ protected static String staticField = "42";
7
+ protected static final String staticFinalField = "42";
8
+
9
+ public String getStrField() {
10
+ return strField;
11
+ }
12
+ }
@@ -0,0 +1,7 @@
1
+ package fixtures;
2
+
3
+ public class ProtectedInstanceMethod {
4
+ protected String theProtectedMethod() {
5
+ return "42";
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ package fixtures;
2
+
3
+ public class ProtectedStaticMethod {
4
+ protected static String theProtectedMethod() {
5
+ return "42";
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ package fixtures;
2
+
3
+ public class PublicField {
4
+ public String strField;
5
+
6
+ public String getStrField() {
7
+ return strField;
8
+ }
9
+ }
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ import 'fixtures.PrivateInstanceMethod'
4
+ import 'fixtures.PrivateStaticMethod'
5
+ import 'fixtures.ProtectedInstanceMethod'
6
+ import 'fixtures.ProtectedStaticMethod'
7
+ import 'fixtures.PackageInstanceMethod'
8
+ import 'fixtures.PackageStaticMethod'
9
+
10
+ describe "A method helper" do
11
+ include JRSplenda::MethodHelper
12
+
13
+ it "should provide the ability to invoke private Java class methods" do
14
+ wrap_java_methods PrivateStaticMethod
15
+ lambda { PrivateStaticMethod.thePrivateMethod }.should_not raise_error
16
+ end
17
+
18
+ it "should provide the ability to invoke protected Java class methods" do
19
+ wrap_java_methods ProtectedStaticMethod
20
+ lambda { ProtectedStaticMethod.theProtectedMethod }.should_not raise_error
21
+ end
22
+
23
+ it "should provide the ability to invoke package scope Java class methods" do
24
+ wrap_java_methods PackageStaticMethod
25
+ lambda { PackageStaticMethod.thePackageScopeMethod }.should_not raise_error
26
+ end
27
+
28
+ it "should provide the ability to invoke private Java instance methods" do
29
+ o = PrivateInstanceMethod.new
30
+ wrap_java_methods o
31
+ lambda { o.thePrivateMethod }.should_not raise_error
32
+ end
33
+
34
+ it "should provide the ability to invoke protected Java instance methods" do
35
+ o = ProtectedInstanceMethod.new
36
+ wrap_java_methods o
37
+ lambda { o.theProtectedMethod }.should_not raise_error
38
+ end
39
+
40
+ it "should provide the ability to invoke package scope Java instance methods" do
41
+ o = PackageInstanceMethod.new
42
+ wrap_java_methods o
43
+ lambda { o.thePackageScopeMethod }.should_not raise_error
44
+ end
45
+ end
@@ -0,0 +1,42 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "A mock helper" do
4
+ include JRSplenda::MockHelper
5
+
6
+ it "should create a mock of a Java class when give a Java class name when the Java class has not been imported" do
7
+ splenda_mock('fixtures.PrivateField').class.name.should include("Mock")
8
+ end
9
+
10
+ it "should create a mock of a Java class when give a Java class name when the Java class has been imported" do
11
+ splenda_mock('fixtures.PrivateField').class.name.should include("Mock")
12
+ end
13
+
14
+ it "should create a mock of a Java class when given a Ruby class wrapping the Java class" do
15
+ import 'fixtures.PrivateField'
16
+ splenda_mock(PrivateField).class.name.should include("Mock")
17
+ end
18
+
19
+ it "should create a mock of a Java class when given a Java class" do
20
+ import 'fixtures.PrivateField'
21
+ splenda_mock(PrivateField.java_class).class.name.should include("Mock")
22
+ end
23
+
24
+ describe "when creating a mock object" do
25
+ it "should optionally store the created mock in a Ruby member variable by convention" do
26
+ splenda_mock_attr('fixtures.PrivateField')
27
+ @private_field.should_not be_nil
28
+ end
29
+
30
+ it "should optionally store the created mock in a Ruby member variable specified by the caller" do
31
+ splenda_mock_attr('fixtures.PrivateField', :store_in => :another_field)
32
+ @another_field.should_not be_nil
33
+ end
34
+
35
+ it "should optionally not overwrite existing member variables" do
36
+ splenda_mock_attr('fixtures.PrivateField')
37
+ p1 = @private_field
38
+ splenda_mock_attr('fixtures.PrivateField', :preserve_existing_attr => true)
39
+ p1.should == @private_field
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,5 @@
1
+ require File.dirname(__FILE__) + "/../lib/jrsplenda.rb"
2
+
3
+ require File.dirname(__FILE__) + "/../build/jrsplenda-fixtures.jar"
4
+
5
+ include Java
@@ -0,0 +1,34 @@
1
+ desc 'Release the website and new gem version'
2
+ task :deploy => [:check_version, :website, :release] do
3
+ puts "Remember to create SVN tag:"
4
+ puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
5
+ "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
6
+ puts "Suggested comment:"
7
+ puts "Tagging release #{CHANGES}"
8
+ end
9
+
10
+ desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
11
+ task :local_deploy => [:website_generate, :install_gem]
12
+
13
+ task :check_version do
14
+ unless ENV['VERSION']
15
+ puts 'Must pass a VERSION=x.y.z release version'
16
+ exit
17
+ end
18
+ unless ENV['VERSION'] == VERS
19
+ puts "Please update your version.rb to match the release version, currently #{VERS}"
20
+ exit
21
+ end
22
+ end
23
+
24
+ desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
25
+ task :install_gem_no_doc => [:clean, :package] do
26
+ sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
27
+ end
28
+
29
+ namespace :manifest do
30
+ desc 'Recreate Manifest.txt to include ALL files'
31
+ task :refresh do
32
+ `rake check_manifest | patch -p0 > Manifest.txt`
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ task :ruby_env do
2
+ RUBY_APP = if RUBY_PLATFORM =~ /java/
3
+ "jruby"
4
+ else
5
+ "ruby"
6
+ end unless defined? RUBY_APP
7
+ end
@@ -0,0 +1,17 @@
1
+ desc 'Generate website files'
2
+ task :website_generate => :ruby_env do
3
+ (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
4
+ sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
5
+ end
6
+ end
7
+
8
+ desc 'Upload website files to rubyforge'
9
+ task :website_upload do
10
+ host = "#{rubyforge_username}@rubyforge.org"
11
+ remote_dir = "/var/www/gforge-projects/#{PATH}/"
12
+ local_dir = 'website'
13
+ sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
14
+ end
15
+
16
+ desc 'Generate and upload website files'
17
+ task :website => [:website_generate, :website_upload, :publish_docs]
@@ -0,0 +1,11 @@
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
4
+ <title>jrsplenda</title>
5
+
6
+ </head>
7
+ <body id="body">
8
+ <p>This page has not yet been created for RubyGem <code>jrsplenda</code></p>
9
+ <p>To the developer: To generate it, update website/index.txt and run the rake task <code>website</code> to generate this <code>index.html</code> file.</p>
10
+ </body>
11
+ </html>
data/website/index.txt ADDED
@@ -0,0 +1,83 @@
1
+ h1. jrsplenda
2
+
3
+ h1. &#x2192; 'jrsplenda'
4
+
5
+
6
+ h2. What
7
+
8
+
9
+ h2. Installing
10
+
11
+ <pre syntax="ruby">sudo gem install jrsplenda</pre>
12
+
13
+ h2. The basics
14
+
15
+
16
+ h2. Demonstration of usage
17
+
18
+
19
+
20
+ h2. Forum
21
+
22
+ "http://groups.google.com/group/jrsplenda":http://groups.google.com/group/jrsplenda
23
+
24
+ TODO - create Google Group - jrsplenda
25
+
26
+ h2. How to submit patches
27
+
28
+ Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
29
+
30
+ TODO - pick SVN or Git instructions
31
+
32
+ The trunk repository is <code>svn://rubyforge.org/var/svn/jrsplenda/trunk</code> for anonymous access.
33
+
34
+ OOOORRRR
35
+
36
+ You can fetch the source from either:
37
+
38
+ <% if rubyforge_project_id %>
39
+
40
+ * rubyforge: "http://rubyforge.org/scm/?group_id=<%= rubyforge_project_id %>":http://rubyforge.org/scm/?group_id=<%= rubyforge_project_id %>
41
+
42
+ <pre>git clone git://rubyforge.org/jrsplenda.git</pre>
43
+
44
+ <% else %>
45
+
46
+ * rubyforge: MISSING IN ACTION
47
+
48
+ TODO - You can not created a RubyForge project, OR have not run <code>rubyforge config</code>
49
+ yet to refresh your local rubyforge data with this projects' id information.
50
+
51
+ When you do this, this message will magically disappear!
52
+
53
+ Or you can hack website/index.txt and make it all go away!!
54
+
55
+ <% end %>
56
+
57
+ * github: "http://github.com/GITHUB_USERNAME/jrsplenda/tree/master":http://github.com/GITHUB_USERNAME/jrsplenda/tree/master
58
+
59
+ <pre>git clone git://github.com/GITHUB_USERNAME/jrsplenda.git</pre>
60
+
61
+
62
+ TODO - add "github_username: username" to ~/.rubyforge/user-config.yml and newgem will reuse it for future projects.
63
+
64
+
65
+ * gitorious: "git://gitorious.org/jrsplenda/mainline.git":git://gitorious.org/jrsplenda/mainline.git
66
+
67
+ <pre>git clone git://gitorious.org/jrsplenda/mainline.git</pre>
68
+
69
+ h3. Build and test instructions
70
+
71
+ <pre>cd jrsplenda
72
+ rake test
73
+ rake install_gem</pre>
74
+
75
+
76
+ h2. License
77
+
78
+ This code is free to use under the terms of the MIT license.
79
+
80
+ h2. Contact
81
+
82
+ Comments are welcome. Send an email to "FIXME full name":mailto:FIXME email via the "forum":http://groups.google.com/group/jrsplenda
83
+