Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use shared setup for examples.

  • Loading branch information...
commit e72497cae6dc483ccb2c9d88305dff54b13efe6d 1 parent 941f24a
@jnunemaker authored
Showing with 29 additions and 27 deletions.
  1. +2 −27 examples/cassanity.rb
  2. +27 −0 examples/shared_setup.rb
View
29 examples/cassanity.rb
@@ -1,31 +1,6 @@
-require 'rubygems'
-require 'pathname'
+require_relative 'shared_setup'
-root_path = Pathname(__FILE__).dirname.join('..').expand_path
-lib_path = root_path.join('lib')
-$:.unshift(lib_path)
-
-require 'adapter/cassanity'
-
-client = CassandraCQL::Database.new('127.0.0.1:9160')
-executor = Cassanity::Executors::CassandraCql.new(client: client)
-connection = Cassanity::Connection.new(executor: executor)
-keyspace = connection.keyspace('adapter_cassanity')
-keyspace.recreate
-
-apps = keyspace.column_family(:apps, {
- schema: Cassanity::Schema.new({
- primary_key: :id,
- columns: {
- id: :timeuuid,
- name: :text,
- }
- }),
-})
-
-apps.create
-
-client = apps
+client = AppsCF
adapter = Adapter[:cassanity].new(client)
adapter.clear
View
27 examples/shared_setup.rb
@@ -0,0 +1,27 @@
+require 'pp'
+require 'pathname'
+require 'rubygems'
+
+root_path = Pathname(__FILE__).dirname.join('..').expand_path
+lib_path = root_path.join('lib')
+$:.unshift(lib_path)
+
+require 'adapter/cassanity'
+
+client = CassandraCQL::Database.new('127.0.0.1:9160')
+executor = Cassanity::Executors::CassandraCql.new(client: client)
+connection = Cassanity::Connection.new(executor: executor)
+keyspace = connection.keyspace('adapter_cassanity')
+keyspace.recreate
+
+AppsCF = keyspace.column_family(:apps, {
+ schema: Cassanity::Schema.new({
+ primary_key: :id,
+ columns: {
+ id: :timeuuid,
+ name: :text,
+ }
+ }),
+})
+
+AppsCF.create
Please sign in to comment.
Something went wrong with that request. Please try again.