stickler 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,36 @@
1
+ #--
2
+ # Copyright (c) 2008 Jeremy Hinegardner
3
+ # All rights reserved. Licensed under the same terms as Ruby. No warranty is
4
+ # provided. See LICENSE and COPYING for details.
5
+ #++
6
+ #
7
+ module Stickler
8
+
9
+ # Version access in every possibly way that people might want to get it.
10
+ #
11
+ module Version
12
+
13
+ MAJOR = 0
14
+ MINOR = 1
15
+ BUILD = 0
16
+
17
+ def self.to_ary
18
+ [ MAJOR, MINOR, BUILD ]
19
+ end
20
+
21
+ def self.to_s
22
+ self.to_ary.join(".")
23
+ end
24
+
25
+ def self.to_hash
26
+ { :major => MAJOR, :minor => MINOR, :build => BUILD }
27
+ end
28
+
29
+ # Version string constant
30
+ STRING = Version.to_s.freeze
31
+
32
+ end
33
+
34
+ # Version string constant
35
+ VERSION = Version.to_s.freeze
36
+ end
@@ -0,0 +1,68 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper.rb"))
2
+ require 'stickler'
3
+
4
+ describe Stickler::Configuration do
5
+ before( :each ) do
6
+ @config_file_name = "/tmp/stickler.#{Process.pid}.yml"
7
+ FileUtils.cp Stickler::Paths.data_path( "stickler.yml"), @config_file_name
8
+ @config = Stickler::Configuration.new( @config_file_name )
9
+ end
10
+
11
+ after( :each ) do
12
+ FileUtils.rm_f @config_file_name
13
+ end
14
+
15
+ %w[ downstream_source sources ].each do |key|
16
+ it "has a value for #{key}" do
17
+ @config.send( key ).should_not == nil
18
+ end
19
+ end
20
+
21
+ it "has an array of sources" do
22
+ @config.sources.should be_instance_of( Array )
23
+ end
24
+
25
+ it "can assign an arbitrary key/value pair like a hash" do
26
+ @config[:foo] = 'bar'
27
+ @config['foo'].should == 'bar'
28
+ end
29
+
30
+ it "lists its keys" do
31
+ @config.keys.size.should > 0
32
+ end
33
+
34
+ it "can have gems added to it and reloaded" do
35
+ d = ::Gem::Dependency.new( 'rake', ">= 0.8.0" )
36
+ @config.gem_dependencies << d
37
+ @config.write
38
+
39
+ @config = Stickler::Configuration.new( @config_file_name )
40
+ @config.gem_dependencies.size.should == 1
41
+
42
+ @config.gem_dependencies.should be_include d
43
+
44
+ end
45
+
46
+ it "can have multiple requirements for each gem" do
47
+ d1 = ::Gem::Dependency.new( 'rake', ">= 0.8.0" )
48
+ @config.gem_dependencies << d1
49
+ d2 = ::Gem::Dependency.new( 'rake', ">= 0.8.0" )
50
+ @config.gem_dependencies << d2
51
+ @config.write
52
+
53
+ @config = Stickler::Configuration.new( @config_file_name )
54
+ @config.gem_dependencies.size.should == 2
55
+ @config.gem_dependencies.should be_include( d1 )
56
+ @config.gem_dependencies.should be_include( d2 )
57
+ end
58
+
59
+
60
+ it "can write the configuration back out to a file" do
61
+ @config.sources << "http://gems.github.com"
62
+ @config.write
63
+ @config = Stickler::Configuration.new( @config_file_name )
64
+ @config.sources.size.should == 2
65
+ @config.sources.should be_include( "http://gems.github.com/" )
66
+ end
67
+
68
+ end
@@ -0,0 +1,25 @@
1
+ require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
2
+
3
+ describe Stickler::Paths do
4
+ before(:each) do
5
+ @root_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
6
+ @root_dir += "/"
7
+ end
8
+
9
+ it "root dir should be correct" do
10
+ Stickler::Paths.root_dir.should == @root_dir
11
+ end
12
+
13
+ it "config_path should be correct" do
14
+ Stickler::Paths.config_path.should == File.join(@root_dir, "config/")
15
+ end
16
+
17
+ it "data path should be correct" do
18
+ Stickler::Paths.data_path.should == File.join(@root_dir, "data/")
19
+ end
20
+
21
+ it "lib path should be correct" do
22
+ Stickler::Paths.lib_path.should == File.join(@root_dir, "lib/")
23
+ end
24
+
25
+ end
@@ -0,0 +1,55 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper.rb"))
2
+ require 'stickler'
3
+
4
+ describe Stickler::Repository do
5
+
6
+ before( :each ) do
7
+ @top_dir = File.join( "/tmp/stickler" )
8
+ @repo = Stickler::Repository.new( 'directory' => @top_dir )
9
+ Stickler::Console.silent { @repo.setup }
10
+ end
11
+
12
+ after( :each ) do
13
+ FileUtils.rm_rf( @top_dir )
14
+ end
15
+
16
+
17
+ describe "#setup" do
18
+ %w[ gems log specifications dist cache].each do |sub_dir|
19
+ it "creates #{sub_dir} directory" do
20
+ new_dir = File.join( @top_dir , sub_dir )
21
+ File.directory?( new_dir ).should == true
22
+ end
23
+ end
24
+
25
+ it "setup creates a default stickler.yml file" do
26
+ s_yml = File.join( @top_dir, 'stickler.yml' )
27
+ s = YAML.load_file( s_yml )
28
+ s['sources'].size.should == 1
29
+ s['sources'].first.should == "http://gems.rubyforge.org"
30
+ end
31
+ end
32
+
33
+ describe "validity checks" do
34
+ %w[ gems log specifications dist cache].each do |sub_dir|
35
+ it "raises error if #{sub_dir} is missing" do
36
+ FileUtils.rmdir( File.join( @top_dir, sub_dir ) )
37
+ lambda { Stickler::Console.silent { @repo.valid! } }.should raise_error( Stickler::Repository::Error )
38
+ end
39
+
40
+ it "return false if #{sub_dir} is missing" do
41
+ FileUtils.rmdir( File.join( @top_dir, sub_dir ) )
42
+ Stickler::Console.silent{ @repo.should_not be_valid }
43
+ end
44
+ end
45
+
46
+ it "can create a valid directory system" do
47
+ @repo.should be_valid
48
+ end
49
+ end
50
+
51
+ it "creates a configuration" do
52
+ @repo.configuration['sources'].size.should == 1
53
+ @repo.configuration['sources'].first.should == "http://gems.rubyforge.org/"
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+
4
+ $: << File.expand_path( File.join( File.dirname( __FILE__ ), "..", "lib" ) )
5
+ require 'stickler'
@@ -0,0 +1,17 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper.rb"))
2
+ require 'stickler/version'
3
+
4
+ describe "Stickler::Version" do
5
+ it "should have a version string" do
6
+ Stickler::Version.to_s.should =~ /\d+\.\d+\.\d+/
7
+ Stickler::VERSION.should =~ /\d+\.\d+\.\d+/
8
+ end
9
+
10
+ describe "has the version accessible as a hash" do
11
+ [ :major, :minor, :build ].each do |part|
12
+ it "#{part}" do
13
+ Stickler::Version.to_hash[ part ].to_s.should =~ /\d+/
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,39 @@
1
+ require 'tasks/config'
2
+ #-------------------------------------------------------------------------------
3
+ # announcement methods
4
+ #-------------------------------------------------------------------------------
5
+
6
+ proj_config = Configuration.for('project')
7
+ namespace :announce do
8
+ desc "create email for ruby-talk"
9
+ task :email do
10
+ info = Utils.announcement
11
+
12
+ File.open("email.txt", "w") do |mail|
13
+ mail.puts "From: #{proj_config.author} <#{proj_config.email}>"
14
+ mail.puts "To: ruby-talk@ruby-lang.org"
15
+ mail.puts "Date: #{Time.now.rfc2822}"
16
+ mail.puts "Subject: [ANN] #{info[:subject]}"
17
+ mail.puts
18
+ mail.puts info[:title]
19
+ mail.puts
20
+ mail.puts " gem install #{Stickler::GEM_SPEC.name}"
21
+ mail.puts
22
+ mail.puts info[:urls]
23
+ mail.puts
24
+ mail.puts info[:description]
25
+ mail.puts
26
+ mail.puts "{{ Release notes for Version #{Stickler::VERSION} }}"
27
+ mail.puts
28
+ mail.puts info[:release_notes]
29
+ mail.puts
30
+ end
31
+ puts "Created the following as email.txt:"
32
+ puts "-" * 72
33
+ puts File.read("email.txt")
34
+ puts "-" * 72
35
+ end
36
+
37
+ CLOBBER << "email.txt"
38
+ end
39
+
data/tasks/config.rb ADDED
@@ -0,0 +1,107 @@
1
+ require 'configuration'
2
+
3
+ require 'rake'
4
+ require 'tasks/utils'
5
+
6
+ #-----------------------------------------------------------------------
7
+ # General project configuration
8
+ #-----------------------------------------------------------------------
9
+ Configuration.for('project') {
10
+ name "stickler"
11
+ version Stickler::Version.to_s
12
+ author "Jeremy Hinegardner"
13
+ email "jeremy at copiousfreetime dot org"
14
+ homepage "http://copiousfreetime.rubyforge.org/stickler"
15
+ description Utils.section_of("README", "description")
16
+ summary description.split(".").first
17
+ history "HISTORY"
18
+ license FileList["LICENSE", "COPYING"]
19
+ readme "README"
20
+ }
21
+
22
+ #-----------------------------------------------------------------------
23
+ # Packaging
24
+ #-----------------------------------------------------------------------
25
+ Configuration.for('packaging') {
26
+ # files in the project
27
+ proj_conf = Configuration.for('project')
28
+ files {
29
+ bin FileList["bin/*"]
30
+ ext FileList["ext/*.{c,h,rb}"]
31
+ lib FileList["lib/**/*.rb"]
32
+ test FileList["spec/**/*.rb", "test/**/*.rb"]
33
+ data FileList["data/**/*"]
34
+ tasks FileList["tasks/**/*.r{ake,b}"]
35
+ rdoc FileList[proj_conf.readme, proj_conf.history,
36
+ proj_conf.license] + lib
37
+ all bin + ext + lib + test + data + rdoc + tasks
38
+ }
39
+
40
+ # ways to package the results
41
+ formats {
42
+ tgz true
43
+ zip true
44
+ gem Configuration::Table.has_key?('gem')
45
+ }
46
+ }
47
+
48
+ #-----------------------------------------------------------------------
49
+ # Gem packaging
50
+ #-----------------------------------------------------------------------
51
+ Configuration.for("gem") {
52
+ spec "gemspec.rb"
53
+ Configuration.for('packaging').files.all << spec
54
+ }
55
+
56
+ #-----------------------------------------------------------------------
57
+ # Testing
58
+ # - change mode to 'testunit' to use unit testing
59
+ #-----------------------------------------------------------------------
60
+ Configuration.for('test') {
61
+ mode "spec"
62
+ files Configuration.for("packaging").files.test
63
+ options %w[ --format specdoc --color ]
64
+ ruby_opts %w[ ]
65
+ }
66
+
67
+ #-----------------------------------------------------------------------
68
+ # Rcov
69
+ #-----------------------------------------------------------------------
70
+ Configuration.for('rcov') {
71
+ output_dir "coverage"
72
+ libs %w[ lib ]
73
+ rcov_opts %w[ --html ]
74
+ ruby_opts %w[ ]
75
+ test_files Configuration.for('packaging').files.test
76
+ }
77
+
78
+ #-----------------------------------------------------------------------
79
+ # Rdoc
80
+ #-----------------------------------------------------------------------
81
+ Configuration.for('rdoc') {
82
+ files Configuration.for('packaging').files.rdoc
83
+ main_page files.first
84
+ title Configuration.for('project').name
85
+ options %w[ --line-numbers --inline-source ]
86
+ output_dir "doc"
87
+ }
88
+
89
+ #-----------------------------------------------------------------------
90
+ # Extensions
91
+ #-----------------------------------------------------------------------
92
+ Configuration.for('extension') {
93
+ configs Configuration.for('packaging').files.ext.find_all { |x|
94
+ %w[ mkrf_conf.rb extconf.rb ].include?( File.basename(x) )
95
+ }
96
+ }
97
+ #-----------------------------------------------------------------------
98
+ # Rubyforge
99
+ #-----------------------------------------------------------------------
100
+ Configuration.for('rubyforge') {
101
+ project "copiousfreetime"
102
+ user "jjh"
103
+ host "rubyforge.org"
104
+ rdoc_location "#{user}@#{host}:/var/www/gforge-projects/#{project}/stickler"
105
+ }
106
+
107
+
@@ -0,0 +1,38 @@
1
+ require 'tasks/config'
2
+
3
+ #-------------------------------------------------------------------------------
4
+ # Distribution and Packaging
5
+ #-------------------------------------------------------------------------------
6
+ if pkg_config = Configuration.for_if_exist?("packaging") then
7
+
8
+ require 'gemspec'
9
+ require 'rake/gempackagetask'
10
+ require 'rake/contrib/sshpublisher'
11
+
12
+ namespace :dist do
13
+
14
+ Rake::GemPackageTask.new(Stickler::GEM_SPEC) do |pkg|
15
+ pkg.need_tar = pkg_config.formats.tgz
16
+ pkg.need_zip = pkg_config.formats.zip
17
+ end
18
+
19
+ desc "Install as a gem"
20
+ task :install => [:clobber, :package] do
21
+ sh "sudo gem install pkg/#{Stickler::GEM_SPEC.full_name}.gem"
22
+ end
23
+
24
+ desc "Uninstall gem"
25
+ task :uninstall do
26
+ sh "sudo gem uninstall -x #{Stickler::GEM_SPEC.name}"
27
+ end
28
+
29
+ desc "dump gemspec"
30
+ task :gemspec do
31
+ puts Stickler::GEM_SPEC.to_ruby
32
+ end
33
+
34
+ desc "reinstall gem"
35
+ task :reinstall => [:uninstall, :repackage, :install]
36
+
37
+ end
38
+ end
@@ -0,0 +1,31 @@
1
+ require 'tasks/config'
2
+
3
+ #-----------------------------------------------------------------------
4
+ # Documentation
5
+ #-----------------------------------------------------------------------
6
+
7
+ if rdoc_config = Configuration.for_if_exist?('rdoc') then
8
+
9
+ namespace :doc do
10
+
11
+ require 'rake/rdoctask'
12
+
13
+ # generating documentation locally
14
+ Rake::RDocTask.new do |rdoc|
15
+ rdoc.rdoc_dir = rdoc_config.output_dir
16
+ rdoc.options = rdoc_config.options
17
+ rdoc.rdoc_files = rdoc_config.files
18
+ rdoc.title = rdoc_config.title
19
+ rdoc.main = rdoc_config.main_page
20
+ end
21
+
22
+ if rubyforge_config = Configuration.for_if_exist?('rubyforge') then
23
+ desc "Deploy the RDoc documentation to #{rubyforge_config.rdoc_location}"
24
+ task :deploy => :rerdoc do
25
+ sh "rsync -zav --delete #{rdoc_config.output_dir}/ #{rubyforge_config.rdoc_location}"
26
+ end
27
+ end
28
+
29
+ end
30
+ end
31
+
data/tasks/rspec.rake ADDED
@@ -0,0 +1,29 @@
1
+
2
+ require 'tasks/config'
3
+
4
+ #--------------------------------------------------------------------------------
5
+ # configuration for running rspec. This shows up as the test:default task
6
+ #--------------------------------------------------------------------------------
7
+ if spec_config = Configuration.for_if_exist?("test") then
8
+ if spec_config.mode == "spec" then
9
+ namespace :test do
10
+
11
+ task :default => :spec
12
+
13
+ require 'spec/rake/spectask'
14
+ Spec::Rake::SpecTask.new do |r|
15
+ r.ruby_opts = spec_config.ruby_opts
16
+ r.libs = [ Stickler::Paths.lib_path,
17
+ Stickler::Paths.root_dir ]
18
+ r.spec_files = spec_config.files
19
+ r.spec_opts = spec_config.options
20
+
21
+ if rcov_config = Configuration.for_if_exist?('rcov') then
22
+ r.rcov = true
23
+ r.rcov_dir = rcov_config.output_dir
24
+ r.rcov_opts = rcov_config.rcov_opts
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end