ruby-config 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,54 @@
1
+
2
+ if HAVE_SPEC_RAKE_SPECTASK and not PROJ.spec.files.to_a.empty?
3
+ require 'spec/rake/verify_rcov'
4
+
5
+ namespace :spec do
6
+
7
+ desc 'Run all specs with basic output'
8
+ Spec::Rake::SpecTask.new(:run) do |t|
9
+ t.ruby_opts = PROJ.ruby_opts
10
+ t.spec_opts = PROJ.spec.opts
11
+ t.spec_files = PROJ.spec.files
12
+ t.libs += PROJ.libs
13
+ end
14
+
15
+ desc 'Run all specs with text output'
16
+ Spec::Rake::SpecTask.new(:specdoc) do |t|
17
+ t.ruby_opts = PROJ.ruby_opts
18
+ t.spec_opts = PROJ.spec.opts + ['--format', 'specdoc']
19
+ t.spec_files = PROJ.spec.files
20
+ t.libs += PROJ.libs
21
+ end
22
+
23
+ if HAVE_RCOV
24
+ desc 'Run all specs with RCov'
25
+ Spec::Rake::SpecTask.new(:rcov) do |t|
26
+ t.ruby_opts = PROJ.ruby_opts
27
+ t.spec_opts = PROJ.spec.opts
28
+ t.spec_files = PROJ.spec.files
29
+ t.libs += PROJ.libs
30
+ t.rcov = true
31
+ t.rcov_dir = PROJ.rcov.dir
32
+ t.rcov_opts = PROJ.rcov.opts + ['--exclude', 'spec']
33
+ end
34
+
35
+ RCov::VerifyTask.new(:verify) do |t|
36
+ t.threshold = PROJ.rcov.threshold
37
+ t.index_html = File.join(PROJ.rcov.dir, 'index.html')
38
+ t.require_exact_threshold = PROJ.rcov.threshold_exact
39
+ end
40
+
41
+ task :verify => :rcov
42
+ remove_desc_for_task %w(spec:clobber_rcov)
43
+ end
44
+
45
+ end # namespace :spec
46
+
47
+ desc 'Alias to spec:run'
48
+ task :spec => 'spec:run'
49
+
50
+ task :clobber => 'spec:clobber_rcov' if HAVE_RCOV
51
+
52
+ end # if HAVE_SPEC_RAKE_SPECTASK
53
+
54
+ # EOF
@@ -0,0 +1,47 @@
1
+
2
+ if HAVE_SVN
3
+
4
+ unless PROJ.svn.root
5
+ info = %x/svn info ./
6
+ m = %r/^Repository Root:\s+(.*)$/.match(info)
7
+ PROJ.svn.root = (m.nil? ? '' : m[1])
8
+ end
9
+ PROJ.svn.root = File.join(PROJ.svn.root, PROJ.svn.path) unless PROJ.svn.path.empty?
10
+
11
+ namespace :svn do
12
+
13
+ # A prerequisites task that all other tasks depend upon
14
+ task :prereqs
15
+
16
+ desc 'Show tags from the SVN repository'
17
+ task :show_tags => 'svn:prereqs' do |t|
18
+ tags = %x/svn list #{File.join(PROJ.svn.root, PROJ.svn.tags)}/
19
+ tags.gsub!(%r/\/$/, '')
20
+ tags = tags.split("\n").sort {|a,b| b <=> a}
21
+ puts tags
22
+ end
23
+
24
+ desc 'Create a new tag in the SVN repository'
25
+ task :create_tag => 'svn:prereqs' do |t|
26
+ v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
27
+ abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
28
+
29
+ svn = PROJ.svn
30
+ trunk = File.join(svn.root, svn.trunk)
31
+ tag = "%s-%s" % [PROJ.name, PROJ.version]
32
+ tag = File.join(svn.root, svn.tags, tag)
33
+ msg = "Creating tag for #{PROJ.name} version #{PROJ.version}"
34
+
35
+ puts "Creating SVN tag '#{tag}'"
36
+ unless system "svn cp -m '#{msg}' #{trunk} #{tag}"
37
+ abort "Tag creation failed"
38
+ end
39
+ end
40
+
41
+ end # namespace :svn
42
+
43
+ task 'gem:release' => 'svn:create_tag'
44
+
45
+ end # if PROJ.svn.path
46
+
47
+ # EOF
@@ -0,0 +1,40 @@
1
+
2
+ if test(?e, PROJ.test.file) or not PROJ.test.files.to_a.empty?
3
+ require 'rake/testtask'
4
+
5
+ namespace :test do
6
+
7
+ Rake::TestTask.new(:run) do |t|
8
+ t.libs = PROJ.libs
9
+ t.test_files = if test(?f, PROJ.test.file) then [PROJ.test.file]
10
+ else PROJ.test.files end
11
+ t.ruby_opts += PROJ.ruby_opts
12
+ t.ruby_opts += PROJ.test.opts
13
+ end
14
+
15
+ if HAVE_RCOV
16
+ desc 'Run rcov on the unit tests'
17
+ task :rcov => :clobber_rcov do
18
+ opts = PROJ.rcov.opts.dup << '-o' << PROJ.rcov.dir
19
+ opts = opts.join(' ')
20
+ files = if test(?f, PROJ.test.file) then [PROJ.test.file]
21
+ else PROJ.test.files end
22
+ files = files.join(' ')
23
+ sh "#{RCOV} #{files} #{opts}"
24
+ end
25
+
26
+ task :clobber_rcov do
27
+ rm_r 'coverage' rescue nil
28
+ end
29
+ end
30
+
31
+ end # namespace :test
32
+
33
+ desc 'Alias to test:run'
34
+ task :test => 'test:run'
35
+
36
+ task :clobber => 'test:clobber_rcov' if HAVE_RCOV
37
+
38
+ end
39
+
40
+ # EOF
@@ -0,0 +1,35 @@
1
+ class CommandlineSourceTest < Test::Unit::TestCase
2
+
3
+ def setup
4
+ reload #Reloads RubyConfig, because it stores variables in it's class
5
+ @conf = RubyConfig.new
6
+ @conf.add_source(UserChoices::CommandLineSource, :usage, 'as')
7
+ end
8
+
9
+ def test_getting_option
10
+ with_command_args('--no-ssh') do
11
+ @conf.add_option(:ssh, :type=>:boolean) { | command_line |
12
+ command_line.uses_switch("-s", "--ssh",
13
+ "Use ssh to open connection.")
14
+ }
15
+
16
+ @conf.build
17
+ assert @conf.ssh == false
18
+ end
19
+ end
20
+
21
+ def test_error_if_exact_arglist_number_is_wrong
22
+ with_command_args("testerdetest ok") do
23
+ @conf.add_option(:args, :length => 3) do |commandline|
24
+ commandline.uses_arglist
25
+ end
26
+ output = capturing_stderr do
27
+ assert_wants_to_exit do
28
+ @conf.build
29
+ end
30
+ end
31
+ assert_match(/^Error in the command line:.*2 arguments given, 3 expected./, output)
32
+ end #with_command_args
33
+ end
34
+
35
+ end
@@ -0,0 +1,9 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+
4
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
5
+
6
+ def reload
7
+ Object.send(:remove_const, :RubyConfig) if defined? RubyConfig
8
+ load 'lib/ruby-config.rb'
9
+ end
@@ -0,0 +1,43 @@
1
+ class RubyConfigTest < Test::Unit::TestCase
2
+ def setup
3
+ @conf = RubyConfig.new
4
+ end
5
+
6
+ def test_initialize_new_should_work
7
+ assert_nothing_raised do
8
+ RubyConfig.new
9
+ end
10
+ end
11
+
12
+ def test_conf_should_have_certain_public_methods
13
+ ['add_subconfig', 'add_source', 'add_option', 'build'].each do |method|
14
+ assert @conf.respond_to?(method)
15
+ end
16
+ end
17
+
18
+ def test_addding_a_subconfig_should_create_a_method_which_returns_a_rubyconfig_object
19
+ @conf.add_subconfig('subconfigtest')
20
+ assert @conf.respond_to? :subconfigtest
21
+ assert @conf.subconfigtest.is_a? RubyConfig
22
+ end
23
+
24
+ def test_adding_an_option_should_create_a_method_after_build
25
+ @conf.add_option(:testoption)
26
+ @conf.build
27
+ assert @conf.respond_to?(:testoption)
28
+ end
29
+
30
+ def test_adding_an_option_should_be_config_specific
31
+ #create config+subconfig + two options
32
+ @conf.add_subconfig('subconfig')
33
+ @conf.add_option('base_option')
34
+ @conf.subconfig.add_option('subconfig_option')
35
+ @conf.build
36
+
37
+ assert @conf.respond_to?(:base_option)
38
+ assert !@conf.respond_to?(:subconfig_option)
39
+ assert !@conf.subconfig.respond_to?(:base_option)
40
+ assert @conf.subconfig.respond_to?(:subconfig_option)
41
+ end
42
+
43
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-config
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Leon Bogaert
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-09 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: metaid
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: user-choices
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: bones
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 2.1.0
44
+ version:
45
+ description: A different interface for the user-choices gem. The config can now be instantiated as an object and supports sub-configs and can be build from different files. The advantage is that you can ruby-config in a kinda plugin structure.
46
+ email: leon@tim-online.nl
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - History.txt
53
+ - README.txt
54
+ files:
55
+ - History.txt
56
+ - Manifest.txt
57
+ - README.txt
58
+ - Rakefile
59
+ - lib/ruby-config.rb
60
+ - tasks/ann.rake
61
+ - tasks/bones.rake
62
+ - tasks/gem.rake
63
+ - tasks/git.rake
64
+ - tasks/manifest.rake
65
+ - tasks/notes.rake
66
+ - tasks/post_load.rake
67
+ - tasks/rdoc.rake
68
+ - tasks/rubyforge.rake
69
+ - tasks/setup.rb
70
+ - tasks/spec.rake
71
+ - tasks/svn.rake
72
+ - tasks/test.rake
73
+ - test/test_commandline_source.rb
74
+ - test/test_helper.rb
75
+ - test/test_ruby-config.rb
76
+ has_rdoc: true
77
+ homepage: www.vanutsteen.nl
78
+ post_install_message:
79
+ rdoc_options:
80
+ - --main
81
+ - README.txt
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "0"
95
+ version:
96
+ requirements: []
97
+
98
+ rubyforge_project: ruby-config
99
+ rubygems_version: 1.3.1
100
+ signing_key:
101
+ specification_version: 2
102
+ summary: A different interface for the user-choices gem
103
+ test_files:
104
+ - test/test_helper.rb
105
+ - test/test_ruby-config.rb
106
+ - test/test_commandline_source.rb