From 51bdc73387eb9b64de57c451faba02862fe13b18 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Tue, 27 Jul 2010 20:59:27 +0300 Subject: [PATCH] added jeweler, yard, and more to rakefile --- .document | 5 ++++ LICENSE | 20 ++++++++++++++ README.md | 38 ++++++++++++++++++++++++++ Rakefile | 65 ++++++++++++++++++++++++++++++++++++--------- lib/redistat.rb | 38 ++++++++++++++------------ spec/spec.opts | 2 ++ spec/spec_helper.rb | 14 ++++++++-- 7 files changed, 150 insertions(+), 32 deletions(-) create mode 100644 .document create mode 100644 LICENSE create mode 100644 README.md create mode 100644 spec/spec.opts diff --git a/.document b/.document new file mode 100644 index 0000000..dd2904d --- /dev/null +++ b/.document @@ -0,0 +1,5 @@ +README.md +lib/**/*.rb +bin/* +features/**/*.feature +LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1147c56 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2010 Jim Myhrberg. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ff2f3ef --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# redistat + +Description goes here. + + +## Note on Patches/Pull Requests + +* Fork the project. +* Make your feature addition or bug fix. +* Add tests for it. This is important so I don't break it in a + future version unintentionally. +* Commit, do not mess with rakefile, version, or history. + (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull) +* Send me a pull request. Bonus points for topic branches. + + +## License and Copyright + +Copyright (c) 2010 Jim Myhrberg. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Rakefile b/Rakefile index 7352f59..37e9e42 100644 --- a/Rakefile +++ b/Rakefile @@ -1,22 +1,50 @@ -require "rubygems" +require 'rubygems' +require 'rake' -require "spec" -require "spec/rake/spectask" +begin + require 'jeweler' + Jeweler::Tasks.new do |gem| + gem.name = "redistat" + gem.summary = %Q{TODO: one-line summary of your gem} + gem.description = %Q{TODO: longer description of your gem} + gem.email = "contact@jimeh.me" + gem.homepage = "http://github.com/jimeh/redistat" + gem.authors = ["Jim Myhrberg"] + gem.add_dependency "activesupport", ">= 2.3.0" + gem.add_dependency "json", ">= 1.0.0" + gem.add_dependency "redis", ">= 2.0.0" + gem.add_dependency "time_ext", ">= 0.1.0" + gem.add_development_dependency "rspec", ">= 1.2.9" + gem.add_development_dependency "yard", ">= 0" + # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings + end + Jeweler::GemcutterTasks.new +rescue LoadError + puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler" +end -REDIS_DIR = File.expand_path(File.join("..", "spec"), __FILE__) -REDIS_CNF = File.join(REDIS_DIR, "redis-test.conf") -REDIS_PID = File.join(REDIS_DIR, "db", "redis.pid") +require 'spec/rake/spectask' +Spec::Rake::SpecTask.new(:spec) do |spec| + spec.libs << 'lib' << 'spec' + spec.spec_files = FileList['spec/**/*_spec.rb'] +end + +Spec::Rake::SpecTask.new(:rcov) do |spec| + spec.libs << 'lib' << 'spec' + spec.pattern = 'spec/**/*_spec.rb' + spec.rcov = true +end + +task :spec => :check_dependencies task :default => [:start, :spec, :stop] -# define the spec task -Spec::Rake::SpecTask.new do |t| - t.spec_opts = %w(--format specdoc --colour) - t.libs = ["spec"] -end - +# Start/stop Redis test server +REDIS_DIR = File.expand_path(File.join("..", "spec"), __FILE__) +REDIS_CNF = File.join(REDIS_DIR, "redis-test.conf") +REDIS_PID = File.join(REDIS_DIR, "db", "redis.pid") desc "Start the Redis test server" task :start do @@ -31,4 +59,15 @@ task :stop do system "kill #{File.read(REDIS_PID)}" system "rm #{REDIS_PID}" end -end \ No newline at end of file +end + + +# YARD Documentation +begin + require 'yard' + YARD::Rake::YardocTask.new +rescue LoadError + task :yardoc do + abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard" + end +end diff --git a/lib/redistat.rb b/lib/redistat.rb index 60186f3..a8af42a 100644 --- a/lib/redistat.rb +++ b/lib/redistat.rb @@ -1,21 +1,25 @@ -require "redis" -require "date" -require "time" -require "json/pure" -require "digest/sha1" +require 'rubygems' +require 'active_support' +require 'redis' +require 'date' +require 'time' +require 'time/ext' +require 'json' +require 'digest/sha1' -require "redistat/database" -require "redistat/date" -require "redistat/event" -require "redistat/extensions/date" -require "redistat/extensions/time" -require "redistat/extensions/fixnum" -require "redistat/key" -require "redistat/label" -require "redistat/model" -require "redistat/scope" -require "redistat/summary" +require 'redistat/database' +require 'redistat/date' +require 'redistat/event' +require 'redistat/key' +require 'redistat/label' +require 'redistat/model' +require 'redistat/scope' +require 'redistat/summary' + +require 'redistat/core_ext/date' +require 'redistat/core_ext/time' +require 'redistat/core_ext/fixnum' module Redistat @@ -45,7 +49,7 @@ module Redistat # @option options [#to_s] :db (0) Database number. # @option options [#to_s] :timeout (0) Database timeout in seconds. # @example Connect to a database in port 6380. - # Ohm.connect(:port => 6380) + # Redistat.connect(:port => 6380) def connect(*options) self.redis = nil @options = options diff --git a/spec/spec.opts b/spec/spec.opts new file mode 100644 index 0000000..5b2e8d9 --- /dev/null +++ b/spec/spec.opts @@ -0,0 +1,2 @@ +--format specdoc +--color diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9afd4ca..4701020 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,15 @@ -require "rubygems" -require File.dirname(__FILE__) + "/../lib/redistat" +# require "rubygems" +# require File.dirname(__FILE__) + "/../lib/redistat" +$LOAD_PATH.unshift(File.dirname(__FILE__)) +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) +require 'redistat' +require 'spec' +require 'spec/autorun' + +Spec::Runner.configure do |config| + +end + Redistat.connect({:port => 8379, :db => 15}) Redistat.flush \ No newline at end of file