Skip to content

Commit

Permalink
use bundler instead of jeweler to manage gem
Browse files Browse the repository at this point in the history
  • Loading branch information
anna committed Apr 6, 2011
1 parent 150ac7f commit d4f9a4d
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 223 deletions.
6 changes: 4 additions & 2 deletions .gitignore
@@ -1,3 +1,5 @@
*.gem
.bundle
Gemfile.lock
pkg/*
couch_potato_js_runner.js
pkg
.rvmrc
1 change: 1 addition & 0 deletions .rvmrc
@@ -0,0 +1 @@
rvm 1.9.2@couch_potato
4 changes: 4 additions & 0 deletions Gemfile
@@ -0,0 +1,4 @@
source "http://rubygems.org"

# Specify your gem's dependencies in couch_potato.gemspec
gemspec
36 changes: 10 additions & 26 deletions Rakefile
@@ -1,5 +1,8 @@
require 'bundler'
Bundler::GemHelper.install_tasks

require 'rake'
require 'spec/rake/spectask'
require "rspec/core/rake_task"
require 'rake/rdoctask'

def with_validatable(&block)
Expand Down Expand Up @@ -45,15 +48,15 @@ task :spec_unit_active_model do
end

desc "Run functional specs with default validation framework, override with VALIDATION_FRAMEWORK"
Spec::Rake::SpecTask.new(:spec_functional_default) do |t|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
t.spec_files = FileList['spec/*_spec.rb']
RSpec::Core::RakeTask.new(:spec_functional_default) do |spec|
spec.pattern = 'spec/*_spec.rb'
spec.rspec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
end

desc "Run unit specs with default validation framework, override with VALIDATION_FRAMEWORK"
Spec::Rake::SpecTask.new(:spec_unit_default) do |t|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
t.spec_files = FileList['spec/unit/*_spec.rb']
RSpec::Core::RakeTask.new(:spec_unit_default) do |spec|
spec.pattern = 'spec/unit/*_spec.rb'
spec.rspec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
end

desc "Run functional specs with all validation frameworks"
Expand All @@ -77,22 +80,3 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('lib/couch_potato.rb')
rdoc.rdoc_files.include('lib/couch_potato/**/*.rb')
end


begin
require 'jeweler'
Jeweler::Tasks.new do |s|
s.name = "couch_potato"
s.summary = %Q{Ruby persistence layer for CouchDB}
s.email = "alex@upstream-berlin.com"
s.homepage = "http://github.com/langalex/couch_potato"
s.description = "Ruby persistence layer for CouchDB"
s.authors = ["Alexander Lang"]
s.files = FileList["[A-Z]*.*", "{lib,spec,rails}/**/*", "init.rb"]
s.add_dependency 'json'
s.add_dependency 'couchrest', '>=1.0.1'
s.add_dependency 'activemodel'
end
rescue LoadError
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
end
5 changes: 0 additions & 5 deletions VERSION.yml

This file was deleted.

176 changes: 19 additions & 157 deletions couch_potato.gemspec
@@ -1,163 +1,25 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "couch_potato/version"

Gem::Specification.new do |s|
s.name = %q{couch_potato}
s.version = "0.4.0"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.name = "couch_potato"
s.summary = %Q{Ruby persistence layer for CouchDB}
s.email = "alex@upstre.am"
s.homepage = "http://github.com/langalex/couch_potato"
s.description = "Ruby persistence layer for CouchDB"
s.authors = ["Alexander Lang"]
s.date = %q{2010-12-10}
s.description = %q{Ruby persistence layer for CouchDB}
s.email = %q{alex@upstream-berlin.com}
s.extra_rdoc_files = [
"README.md"
]
s.files = [
"CHANGES.md",
"MIT-LICENSE.txt",
"README.md",
"VERSION.yml",
"init.rb",
"lib/core_ext/date.rb",
"lib/core_ext/object.rb",
"lib/core_ext/string.rb",
"lib/core_ext/symbol.rb",
"lib/core_ext/time.rb",
"lib/couch_potato.rb",
"lib/couch_potato/database.rb",
"lib/couch_potato/persistence.rb",
"lib/couch_potato/persistence/active_model_compliance.rb",
"lib/couch_potato/persistence/attachments.rb",
"lib/couch_potato/persistence/callbacks.rb",
"lib/couch_potato/persistence/dirty_attributes.rb",
"lib/couch_potato/persistence/ghost_attributes.rb",
"lib/couch_potato/persistence/json.rb",
"lib/couch_potato/persistence/magic_timestamps.rb",
"lib/couch_potato/persistence/properties.rb",
"lib/couch_potato/persistence/simple_property.rb",
"lib/couch_potato/persistence/type_caster.rb",
"lib/couch_potato/railtie.rb",
"lib/couch_potato/rspec.rb",
"lib/couch_potato/rspec/matchers.rb",
"lib/couch_potato/rspec/matchers/json2.js",
"lib/couch_potato/rspec/matchers/list_as_matcher.rb",
"lib/couch_potato/rspec/matchers/map_to_matcher.rb",
"lib/couch_potato/rspec/matchers/print_r.js",
"lib/couch_potato/rspec/matchers/reduce_to_matcher.rb",
"lib/couch_potato/rspec/stub_db.rb",
"lib/couch_potato/validation.rb",
"lib/couch_potato/validation/with_active_model.rb",
"lib/couch_potato/validation/with_validatable.rb",
"lib/couch_potato/view/base_view_spec.rb",
"lib/couch_potato/view/custom_view_spec.rb",
"lib/couch_potato/view/custom_views.rb",
"lib/couch_potato/view/lists.rb",
"lib/couch_potato/view/model_view_spec.rb",
"lib/couch_potato/view/properties_view_spec.rb",
"lib/couch_potato/view/raw_view_spec.rb",
"lib/couch_potato/view/view_query.rb",
"rails/init.rb",
"rails/reload_classes.rb",
"spec/attachments_spec.rb",
"spec/callbacks_spec.rb",
"spec/create_spec.rb",
"spec/custom_view_spec.rb",
"spec/default_property_spec.rb",
"spec/destroy_spec.rb",
"spec/fixtures/address.rb",
"spec/fixtures/person.rb",
"spec/property_spec.rb",
"spec/rails_spec.rb",
"spec/railtie_spec.rb",
"spec/spec.opts",
"spec/spec_helper.rb",
"spec/unit/active_model_compliance_spec.rb",
"spec/unit/attributes_spec.rb",
"spec/unit/base_view_spec_spec.rb",
"spec/unit/callbacks_spec.rb",
"spec/unit/couch_potato_spec.rb",
"spec/unit/create_spec.rb",
"spec/unit/custom_views_spec.rb",
"spec/unit/database_spec.rb",
"spec/unit/date_spec.rb",
"spec/unit/dirty_attributes_spec.rb",
"spec/unit/initialize_spec.rb",
"spec/unit/json_create_id_spec.rb",
"spec/unit/lists_spec.rb",
"spec/unit/model_view_spec_spec.rb",
"spec/unit/properties_view_spec_spec.rb",
"spec/unit/rspec_matchers_spec.rb",
"spec/unit/rspec_stub_db_spec.rb",
"spec/unit/string_spec.rb",
"spec/unit/time_spec.rb",
"spec/unit/validation_spec.rb",
"spec/unit/view_query_spec.rb",
"spec/update_spec.rb",
"spec/view_updates_spec.rb"
]
s.homepage = %q{http://github.com/langalex/couch_potato}
s.rdoc_options = ["--charset=UTF-8"]
s.version = CouchPotato::VERSION
s.platform = Gem::Platform::RUBY

s.add_dependency 'json'
s.add_dependency 'couchrest', '>=1.0.1'
s.add_dependency 'activemodel'

s.add_development_dependency 'rspec', '>=2.0'

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.7}
s.summary = %q{Ruby persistence layer for CouchDB}
s.test_files = [
"spec/attachments_spec.rb",
"spec/callbacks_spec.rb",
"spec/create_spec.rb",
"spec/custom_view_spec.rb",
"spec/default_property_spec.rb",
"spec/destroy_spec.rb",
"spec/fixtures/address.rb",
"spec/fixtures/person.rb",
"spec/property_spec.rb",
"spec/rails_spec.rb",
"spec/railtie_spec.rb",
"spec/spec_helper.rb",
"spec/unit/active_model_compliance_spec.rb",
"spec/unit/attributes_spec.rb",
"spec/unit/base_view_spec_spec.rb",
"spec/unit/callbacks_spec.rb",
"spec/unit/couch_potato_spec.rb",
"spec/unit/create_spec.rb",
"spec/unit/custom_views_spec.rb",
"spec/unit/database_spec.rb",
"spec/unit/date_spec.rb",
"spec/unit/dirty_attributes_spec.rb",
"spec/unit/initialize_spec.rb",
"spec/unit/json_create_id_spec.rb",
"spec/unit/lists_spec.rb",
"spec/unit/model_view_spec_spec.rb",
"spec/unit/properties_view_spec_spec.rb",
"spec/unit/rspec_matchers_spec.rb",
"spec/unit/rspec_stub_db_spec.rb",
"spec/unit/string_spec.rb",
"spec/unit/time_spec.rb",
"spec/unit/validation_spec.rb",
"spec/unit/view_query_spec.rb",
"spec/update_spec.rb",
"spec/view_updates_spec.rb"
]

if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<json>, [">= 0"])
s.add_runtime_dependency(%q<couchrest>, [">= 1.0.1"])
s.add_runtime_dependency(%q<activemodel>, [">= 0"])
else
s.add_dependency(%q<json>, [">= 0"])
s.add_dependency(%q<couchrest>, [">= 1.0.1"])
s.add_dependency(%q<activemodel>, [">= 0"])
end
else
s.add_dependency(%q<json>, [">= 0"])
s.add_dependency(%q<couchrest>, [">= 1.0.1"])
s.add_dependency(%q<activemodel>, [">= 0"])
end
end

40 changes: 19 additions & 21 deletions lib/couch_potato.rb
Expand Up @@ -7,30 +7,28 @@

JSON.create_id = 'ruby_class'

unless defined?(CouchPotato)
module CouchPotato
Config = Struct.new(:database_name, :validation_framework).new
Config.validation_framework = :active_model

# Returns a database instance which you can then use to create objects and query views. You have to set the CouchPotato::Config.database_name before this works.
def self.database
@@__database ||= Database.new(self.couchrest_database)
end
module CouchPotato
Config = Struct.new(:database_name, :validation_framework).new
Config.validation_framework = :active_model

# Returns the underlying CouchRest database object if you want low level access to your CouchDB. You have to set the CouchPotato::Config.database_name before this works.
def self.couchrest_database
@@__couchrest_database ||= CouchRest.database(full_url_to_database)
end
# Returns a database instance which you can then use to create objects and query views. You have to set the CouchPotato::Config.database_name before this works.
def self.database
@@__database ||= Database.new(self.couchrest_database)
end

# Returns the underlying CouchRest database object if you want low level access to your CouchDB. You have to set the CouchPotato::Config.database_name before this works.
def self.couchrest_database
@@__couchrest_database ||= CouchRest.database(full_url_to_database)
end

private
private

def self.full_url_to_database
raise('No Database configured. Set CouchPotato::Config.database_name') unless CouchPotato::Config.database_name
if CouchPotato::Config.database_name.match(%r{https?://})
CouchPotato::Config.database_name
else
"http://127.0.0.1:5984/#{CouchPotato::Config.database_name}"
end
def self.full_url_to_database
raise('No Database configured. Set CouchPotato::Config.database_name') unless CouchPotato::Config.database_name
if CouchPotato::Config.database_name.match(%r{https?://})
CouchPotato::Config.database_name
else
"http://127.0.0.1:5984/#{CouchPotato::Config.database_name}"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/couch_potato/rspec/matchers.rb
Expand Up @@ -17,7 +17,7 @@ def run_js(js)
require 'couch_potato/rspec/matchers/reduce_to_matcher'
require 'couch_potato/rspec/matchers/list_as_matcher'

module Spec
module RSpec
module Matchers
def map(document)
CouchPotato::RSpec::MapToProxy.new(document)
Expand Down
4 changes: 2 additions & 2 deletions lib/couch_potato/rspec/stub_db.rb
Expand Up @@ -14,7 +14,7 @@ def with(*args)
end

def and_return(return_value)
view_stub = Spec::Mocks::Mock.new("#{@clazz}.#{@view}(#{@args.try(:join, ', ')}) view")
view_stub = RSpec::Mocks::Mock.new("#{@clazz}.#{@view}(#{@args.try(:join, ', ')}) view")
_stub = @clazz.stub(@view)
_stub.with(*@args) if @args
_stub.and_return(view_stub)
Expand All @@ -37,7 +37,7 @@ def stub_db(options = {})
end
end

module Spec
module RSpec
module Mocks
module ExampleMethods
include CouchPotato::RSpec::StubDb
Expand Down
3 changes: 3 additions & 0 deletions lib/couch_potato/version.rb
@@ -0,0 +1,3 @@
module CouchPotato
VERSION = "0.4.0"
end
3 changes: 2 additions & 1 deletion spec/create_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'

describe "create" do
before(:all) do
before(:each) do
recreate_db
end
describe "succeeds" do
Expand All @@ -23,6 +23,7 @@
CouchPotato.couchrest_database.get(@comment.id).updated_at.should == Time.parse('2010-01-02 12:34:48 +0000')
end
end

describe "fails" do
it "should not store anything" do
@comment = Comment.new
Expand Down
2 changes: 1 addition & 1 deletion spec/railtie_spec.rb
Expand Up @@ -10,7 +10,7 @@ def self.initializer(*args)
end

def self.root
Spec::Mocks::Mock.new :join => ''
RSpec::Mocks::Mock.new :join => ''
end
end

Expand Down
2 changes: 0 additions & 2 deletions spec/spec.opts
@@ -1,4 +1,2 @@
--colour
--format progress
--loadby mtime
--reverse
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
@@ -1,5 +1,5 @@
require 'rubygems'
require 'spec'
require 'rspec'
require 'time'

$:.unshift(File.dirname(__FILE__) + '/../lib')
Expand Down Expand Up @@ -41,7 +41,7 @@ def recreate_db
end
recreate_db

Spec::Matchers.define :string_matching do |regex|
RSpec::Matchers.define :string_matching do |regex|
match do |string|
string =~ regex
end
Expand Down

0 comments on commit d4f9a4d

Please sign in to comment.