classx 0.0.1

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 (31) hide show
  1. data/ChangeLog +4 -0
  2. data/README +39 -0
  3. data/Rakefile +52 -0
  4. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-block_rb.html +661 -0
  5. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-callbacks_rb.html +932 -0
  6. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-change_rb.html +779 -0
  7. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-hunk_rb.html +867 -0
  8. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs_rb.html +1715 -0
  9. data/doc/output/coverage/-Library-Ruby-Gems-gems-rcov-0_8_1_2_0-lib-rcov_rb.html +1598 -0
  10. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-drb_rb.html +2373 -0
  11. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-eq_rb.html +626 -0
  12. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-invokemethod_rb.html +646 -0
  13. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-forwardable_rb.html +828 -0
  14. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-pp_rb.html +1257 -0
  15. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-prettyprint_rb.html +1506 -0
  16. data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-timeout_rb.html +715 -0
  17. data/doc/output/coverage/index.html +603 -0
  18. data/doc/output/coverage/lib-classx-validate_rb.html +645 -0
  19. data/doc/output/coverage/lib-classx_rb.html +752 -0
  20. data/lib/classx.rb +142 -0
  21. data/lib/classx.rb.new +102 -0
  22. data/lib/classx/attributes.rb +13 -0
  23. data/lib/classx/commandable.rb +8 -0
  24. data/lib/classx/validate.rb +35 -0
  25. data/spec/classx_spec.rb +261 -0
  26. data/spec/classx_validate_spec.rb +40 -0
  27. data/spec/spec.opts +1 -0
  28. data/spec/spec_helper.rb +4 -0
  29. data/tasks/basic_config.rake +22 -0
  30. data/tasks/basic_tasks.rake +139 -0
  31. metadata +107 -0
@@ -0,0 +1,40 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+ require 'classx'
3
+ require 'classx/validate'
4
+
5
+ describe ClassX::Validate do
6
+ include ClassX::Validate
7
+ before do
8
+ @class = Class.new
9
+ @class.class_eval do
10
+ include ClassX::Validate
11
+
12
+ def run params
13
+ validate params do
14
+ has :x
15
+ has :y, :kind_of => Integer
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ it 'should raise ArgumentError without param is not kind of Hash instance' do
22
+ lambda { @class.new.run([]) }.should raise_error(ArgumentError)
23
+ end
24
+
25
+ it 'should raise ClassX::AttrRequiredError' do
26
+ lambda { @class.new.run({}) }.should raise_error(ClassX::AttrRequiredError)
27
+ end
28
+
29
+ it 'should raise ClassX::InvalidArgumentError with InvalidAttrArgument' do
30
+ lambda { @class.new.run(:x => 'hoge', :y => 'fuga') }.should raise_error(ClassX::InvalidAttrArgument)
31
+ end
32
+
33
+ it 'should not raise Exception' do
34
+ lambda { @class.new.run(:x => 10, :y => 20) }.should_not raise_error(Exception)
35
+ end
36
+
37
+ it 'should be cached auto generated class' do
38
+ @class.new.run(:x => 10, :y => 20).class.should == @class.new.run(:x => 11, :y => 21).class
39
+ end
40
+ end
@@ -0,0 +1 @@
1
+ -Du -c -fs
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib/'))
4
+
@@ -0,0 +1,22 @@
1
+ AUTHOR = "Keiji, Yoshimi"
2
+ EMAIL = "walf443 at gmail.com"
3
+ RUBYFORGE_PROJECT = "akasakarb"
4
+ RUBYFORGE_PROJECT_ID = 4314
5
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
6
+ RDOC_OPTS = [
7
+ "--charset", "utf-8",
8
+ "--opname", "index.html",
9
+ "--line-numbers",
10
+ "--main", "README",
11
+ "--inline-source",
12
+ '--exclude', '^(example|extras)/'
13
+ ]
14
+ DEFAULT_EXTRA_RDOC_FILES = ['README', 'ChangeLog']
15
+ PKG_FILES = [ 'Rakefile' ] +
16
+ DEFAULT_EXTRA_RDOC_FILES +
17
+ Dir.glob('{bin,lib,test,spec,doc,tasks,script,generator,templates,extras,website}/**/*') +
18
+ Dir.glob('ext/**/*.{h,c,rb}') +
19
+ Dir.glob('examples/**/*.rb') +
20
+ Dir.glob('tools/*.rb')
21
+
22
+ EXTENSIONS = FileList['ext/**/extconf.rb'].to_a
@@ -0,0 +1,139 @@
1
+
2
+ REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
3
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config']
4
+
5
+ Rake::GemPackageTask.new(SPEC) do |p|
6
+ p.need_tar = true
7
+ p.gem_spec = SPEC
8
+ end
9
+
10
+ task :default => [:spec]
11
+ task :test => [:spec]
12
+ task :package => [:clean]
13
+
14
+ require 'spec/rake/spectask'
15
+ Spec::Rake::SpecTask.new(:spec) do |t|
16
+ t.spec_files = FileList['spec/**/*_spec.rb']
17
+ t.spec_opts = ['--options', 'spec/spec.opts']
18
+ t.warning = true
19
+ t.rcov = true
20
+ t.rcov_dir = 'doc/output/coverage'
21
+ t.rcov_opts = ['--exclude', 'spec,\.autotest']
22
+ end
23
+
24
+ desc "Heckle each module and class in turn"
25
+ task :heckle => :spec do
26
+ root_modules = HECKLE_ROOT_MODULES
27
+ spec_files = FileList['spec/**/*_spec.rb']
28
+
29
+ current_module, current_method = nil, nil
30
+ heckle_caught_modules = Hash.new { |hash, key| hash[key] = [] }
31
+ unhandled_mutations = 0
32
+
33
+ root_modules.each do |root_module|
34
+ IO.popen("heckle #{root_module} -t #{spec_files}") do |pipe|
35
+ while line = pipe.gets
36
+ line = line.chomp
37
+
38
+ if line =~ /^\*\*\* ((?:\w+(?:::)?)+)#(\w+)/
39
+ current_module, current_method = $1, $2
40
+ elsif line == "The following mutations didn't cause test failures:"
41
+ heckle_caught_modules[current_module] << current_method
42
+ elsif line == "+++ mutation"
43
+ unhandled_mutations += 1
44
+ end
45
+
46
+ puts line
47
+ end
48
+ end
49
+ end
50
+
51
+ if unhandled_mutations > 0
52
+ error_message_lines = ["*************\n"]
53
+
54
+ error_message_lines <<
55
+ "Heckle found #{unhandled_mutations} " +
56
+ "mutation#{"s" unless unhandled_mutations == 1} " +
57
+ "that didn't cause spec violations\n"
58
+
59
+ heckle_caught_modules.each do |mod, methods|
60
+ error_message_lines <<
61
+ "#{mod} contains the following poorly-specified methods:"
62
+ methods.each do |m|
63
+ error_message_lines << " - #{m}"
64
+ end
65
+ error_message_lines << ""
66
+ end
67
+
68
+ error_message_lines <<
69
+ "Get your act together and come back " +
70
+ "when your specs are doing their job!"
71
+
72
+ puts "*************"
73
+ raise error_message_lines.join("\n")
74
+ else
75
+ puts "Well done! Your code withstood a heckling."
76
+ end
77
+ end
78
+
79
+ require 'spec/rake/verify_rcov'
80
+ RCov::VerifyTask.new(:rcov => :spec) do |t|
81
+ t.index_html = "doc/output/coverage/index.html"
82
+ t.threshold = 100
83
+ end
84
+
85
+ task :install do
86
+ name = "#{NAME}-#{VERS}.gem"
87
+ sh %{rake package}
88
+ sh %{sudo gem install pkg/#{name}}
89
+ end
90
+
91
+ task :uninstall => [:clean] do
92
+ sh %{sudo gem uninstall #{NAME}}
93
+ end
94
+
95
+
96
+ Rake::RDocTask.new do |rdoc|
97
+ rdoc.rdoc_dir = 'html'
98
+ rdoc.options += RDOC_OPTS
99
+ rdoc.template = "resh"
100
+ #rdoc.template = "#{ENV['template']}.rb" if ENV['template']
101
+ if ENV['DOC_FILES']
102
+ rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
103
+ else
104
+ rdoc.rdoc_files.include('README', 'ChangeLog')
105
+ rdoc.rdoc_files.include('lib/**/*.rb')
106
+ rdoc.rdoc_files.include('ext/**/*.c')
107
+ end
108
+ end
109
+
110
+ desc "Publish to RubyForge"
111
+ task :rubyforge => [:rdoc, :package] do
112
+ require 'rubyforge'
113
+ Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, 'yoshimi').upload
114
+ end
115
+
116
+ desc 'Package and upload the release to rubyforge.'
117
+ task :release => [:clean, :package] do |t|
118
+ require 'rubyforge'
119
+ v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
120
+ abort "Versions don't match #{v} vs #{VERS}" unless v == VERS
121
+ pkg = "pkg/#{NAME}-#{VERS}"
122
+
123
+ rf = RubyForge.new
124
+ puts "Logging in"
125
+ rf.login
126
+
127
+ c = rf.userconfig
128
+ # c["release_notes"] = description if description
129
+ # c["release_changes"] = changes if changes
130
+ c["preformatted"] = true
131
+
132
+ files = [
133
+ "#{pkg}.tgz",
134
+ "#{pkg}.gem"
135
+ ].compact
136
+
137
+ puts "Releasing #{NAME} v. #{VERS}"
138
+ rf.add_release RUBYFORGE_PROJECT_ID, RUBYFORGE_PACKAGE_ID, VERS, *files
139
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: classx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Keiji, Yoshimi
8
+ autorequire: ""
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-05-28 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: date_time-duration
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.0.1
23
+ version:
24
+ description: ""
25
+ email: walf443 at gmail.com
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files:
31
+ - README
32
+ - ChangeLog
33
+ files:
34
+ - Rakefile
35
+ - README
36
+ - ChangeLog
37
+ - lib/classx
38
+ - lib/classx/attributes.rb
39
+ - lib/classx/commandable.rb
40
+ - lib/classx/include
41
+ - lib/classx/validate.rb
42
+ - lib/classx.rb
43
+ - lib/classx.rb.new
44
+ - spec/classx_spec.rb
45
+ - spec/classx_validate_spec.rb
46
+ - spec/spec.opts
47
+ - spec/spec_helper.rb
48
+ - doc/output
49
+ - doc/output/coverage
50
+ - doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-block_rb.html
51
+ - doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-callbacks_rb.html
52
+ - doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-change_rb.html
53
+ - doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-hunk_rb.html
54
+ - doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs_rb.html
55
+ - doc/output/coverage/-Library-Ruby-Gems-gems-rcov-0_8_1_2_0-lib-rcov_rb.html
56
+ - doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-drb_rb.html
57
+ - doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-eq_rb.html
58
+ - doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-invokemethod_rb.html
59
+ - doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-forwardable_rb.html
60
+ - doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-pp_rb.html
61
+ - doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-prettyprint_rb.html
62
+ - doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-timeout_rb.html
63
+ - doc/output/coverage/index.html
64
+ - doc/output/coverage/lib-classx-validate_rb.html
65
+ - doc/output/coverage/lib-classx_rb.html
66
+ - tasks/basic_config.rake
67
+ - tasks/basic_tasks.rake
68
+ has_rdoc: true
69
+ homepage: http://akasakarb.rubyforge.org
70
+ post_install_message:
71
+ rdoc_options:
72
+ - --charset
73
+ - utf-8
74
+ - --opname
75
+ - index.html
76
+ - --line-numbers
77
+ - --main
78
+ - README
79
+ - --inline-source
80
+ - --exclude
81
+ - ^(example|extras)/
82
+ - --title
83
+ - classx documentation
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: "0"
91
+ version:
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: "0"
97
+ version:
98
+ requirements: []
99
+
100
+ rubyforge_project: akasakarb
101
+ rubygems_version: 1.0.1
102
+ signing_key:
103
+ specification_version: 2
104
+ summary: ""
105
+ test_files:
106
+ - spec/classx_spec.rb
107
+ - spec/classx_validate_spec.rb