simperium 0.0.2.3 → 0.0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2.3
1
+ 0.0.2.3
@@ -366,7 +366,7 @@ module Simperium
366
366
  options = defaults
367
367
  end
368
368
 
369
- @bucket = Bucket.new(appname, auth_token, 'user',
369
+ @bucket = Simperium::Bucket.new(appname, auth_token, 'spuser',
370
370
  options=options)
371
371
 
372
372
  url = "#{appname}/user"
@@ -397,9 +397,9 @@ module Simperium
397
397
  #the first argument is a Symbol, so you need to_s it you want to pattern match
398
398
  unless method_sym.to_s =~ /=$/
399
399
  if method_sym.to_s == 'spuser'
400
- @getitem[method_sym] ||= SPUser.new(@appname, @token)
400
+ @getitem[method_sym] ||= Simperium::SPUser.new(@appname, @token)
401
401
  else
402
- @getitem[method_sym] ||= Bucket.new(@appname, @token, method_sym)
402
+ @getitem[method_sym] ||= Simperium::Bucket.new(@appname, @token, method_sym)
403
403
  end
404
404
  end
405
405
  end
@@ -421,7 +421,7 @@ module Simperium
421
421
  end
422
422
 
423
423
  def as_user(userid)
424
- return Api.new(@appname, @token, userid=userid, @_options)
424
+ return Simperium::Api.new(@appname, @token, userid=userid, @_options)
425
425
  end
426
426
  end
427
427
  end
@@ -3,7 +3,6 @@ require 'rubygems'
3
3
  require 'simperium'
4
4
  require 'uri'
5
5
  require 'mongo'
6
- require 'optparse'
7
6
 
8
7
  MONGOHQ_URL = ENV['MONGOHQ_URL']
9
8
 
@@ -12,7 +11,7 @@ conn = Mongo::Connection.from_uri(MONGOHQ_URL)
12
11
  $db = conn.db(uri.path.gsub(/^\//, ''))
13
12
 
14
13
  def main(appname, admin_key, bucket)
15
- _bucket = Bucket.new(appname, admin_key, bucket)
14
+ _bucket = Simperium::Bucket.new(appname, admin_key, bucket)
16
15
 
17
16
  begin
18
17
  cv = $db['__meta__'].find_one
@@ -1,3 +1,3 @@
1
1
  module Simperium
2
- VERSION = '0.0.2.3'
2
+ VERSION = '0.0.2.4'
3
3
  end
@@ -15,8 +15,7 @@ spec = Gem::Specification.new do |s|
15
15
  s.add_dependency('rest-client', '~> 1.4')
16
16
  s.add_dependency('uuid')
17
17
  s.add_dependency('json')
18
- s.add_dependency('mongo')
19
-
18
+
20
19
  s.files = `git ls-files`.split("\n")
21
20
  s.require_paths = ['lib']
22
21
  end
@@ -10,31 +10,31 @@ require 'simperium'
10
10
  @@_auth_token = nil
11
11
  def get_auth_token
12
12
  if @@_auth_token.nil?
13
- auth = Simperium::Auth.new(@@appname, @@api_key)
13
+ auth = Simperium::Auth.new(@@appname, @@api_key)
14
14
  uuid = UUID.new
15
- username = uuid.generate(:compact) + '@foo.com'
16
- password = uuid.generate(:compact)
15
+ username = uuid.generate(:compact) + '@foo.com'
16
+ password = uuid.generate(:compact)
17
17
  @@_auth_token = auth.create(username, password)
18
18
  end
19
19
  return @@_auth_token
20
20
  end
21
21
 
22
22
  class TestSimperiumRuby < Test::Unit::TestCase
23
- def test_auth_create
24
- get_auth_token
25
- end
23
+ def test_auth_create
24
+ get_auth_token
25
+ end
26
26
 
27
- def test_bucket_get
28
- uuid = UUID.new
29
- bucket = Simperium::Bucket.new(@@appname, get_auth_token, uuid.generate(:compact))
27
+ def test_bucket_get
28
+ uuid = UUID.new
29
+ bucket = Simperium::Bucket.new(@@appname, get_auth_token, uuid.generate(:compact))
30
30
  bucket.post('item1', {'x'=> 1})
31
31
  assert_equal(bucket.get('item1'), {'x' => 1})
32
- end
32
+ end
33
33
 
34
- def test_bucket_index
35
- uuid = UUID.new
36
- bucket = Simperium::Bucket.new(@@appname, get_auth_token, uuid.generate(:compact))
37
- (0..2).each { |i| bucket.post("item#{i}", {'x' => i}) }
34
+ def test_bucket_index
35
+ uuid = UUID.new
36
+ bucket = Simperium::Bucket.new(@@appname, get_auth_token, uuid.generate(:compact))
37
+ (0..2).each { |i| bucket.post("item#{i}", {'x' => i}) }
38
38
 
39
39
  got = bucket.index(:data=>false, :mark=>nil, :limit=>2, :since=>nil)
40
40
  want = {
@@ -50,11 +50,11 @@ class TestSimperiumRuby < Test::Unit::TestCase
50
50
  'current'=> got['current'],
51
51
  'index' => [
52
52
  {'id' => 'item0', 'v' => 1}] }
53
- end
53
+ end
54
54
 
55
- def test_bucket_post
56
- uuid = UUID.new
57
- bucket = Simperium::Bucket.new(@@appname, get_auth_token, uuid.generate(:compact))
55
+ def test_bucket_post
56
+ uuid = UUID.new
57
+ bucket = Simperium::Bucket.new(@@appname, get_auth_token, uuid.generate(:compact))
58
58
  bucket.post('item1', {'a'=>1})
59
59
  assert_equal(bucket.get('item1'), {'a'=>1})
60
60
 
@@ -63,15 +63,15 @@ class TestSimperiumRuby < Test::Unit::TestCase
63
63
 
64
64
  bucket.post('item1', {'c'=>3}, :replace=>true)
65
65
  assert_equal(bucket.get('item1'), {'c'=>3})
66
- end
66
+ end
67
67
 
68
- def test_user_get
69
- user = Simperium::SPUser.new(@@appname, get_auth_token)
68
+ def test_user_get
69
+ user = Simperium::SPUser.new(@@appname, get_auth_token)
70
70
  user.post({'x'=> 1})
71
71
  assert_equal(user.get, {'x'=> 1})
72
- end
72
+ end
73
73
 
74
- def test_api_getitem
74
+ def test_api_getitem
75
75
  api = Simperium::Api.new(@@appname, get_auth_token)
76
76
  assert_instance_of(Simperium::Bucket, api['bucket'], "api[bucket] should be an instance of Bucket")
77
77
  end
@@ -83,6 +83,6 @@ class TestSimperiumRuby < Test::Unit::TestCase
83
83
 
84
84
  def test_api_user
85
85
  api = Simperium::Api.new(@@appname, get_auth_token)
86
- assert_instance_of(Simperium::SPUser, api.spuser, "api.spuser should be an instance of SPUser")
86
+ assert_instance_of(Simperium::SPUser, api.spuser, "api.user should be an instance of User")
87
87
  end
88
88
  end
@@ -3,10 +3,9 @@ require 'simperium/listener-export-mongohq'
3
3
 
4
4
  @admin_key = ENV['SIMPERIUM_CLIENT_TEST_ADMINKEY']
5
5
  @appname = ENV['SIMPERIUM_CLIENT_TEST_APPNAME']
6
- @bucket = 'todo'
7
6
 
8
7
  class TestMirror < Test::Unit::TestCase
9
8
  def test_simperium_mirror
10
- main(@admin_key, @appname, @bucket)
9
+ Listener::mirror(@appname, @admin_key, 'todo')
11
10
  end
12
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simperium
3
3
  version: !ruby/object:Gem::Version
4
- hash: 65
4
+ hash: 79
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
9
  - 2
10
- - 3
11
- version: 0.0.2.3
10
+ - 4
11
+ version: 0.0.2.4
12
12
  platform: ruby
13
13
  authors:
14
14
  - Ray Ventura
@@ -61,20 +61,6 @@ dependencies:
61
61
  version: "0"
62
62
  type: :runtime
63
63
  version_requirements: *id003
64
- - !ruby/object:Gem::Dependency
65
- name: mongo
66
- prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
76
- type: :runtime
77
- version_requirements: *id004
78
64
  description: Simperium moves data instantly and automatically everywhere it's needed. See https://simperium.com for details.
79
65
  email:
80
66
  - ray@simperium.com
@@ -86,12 +72,10 @@ extra_rdoc_files: []
86
72
 
87
73
  files:
88
74
  - Gemfile
89
- - README.md
90
75
  - VERSION
91
76
  - lib/simperium.rb
92
77
  - lib/simperium/changes.rb
93
78
  - lib/simperium/error_handling.rb
94
- - lib/simperium/heroku-addon-doc.md
95
79
  - lib/simperium/listener-export-mongohq
96
80
  - lib/simperium/version.rb
97
81
  - simperium.gemspec
data/README.md DELETED
@@ -1,2 +0,0 @@
1
- simperium-ruby-prviate
2
- ======================
@@ -1,152 +0,0 @@
1
- Simperium(http://addons.heroku.com/simperium) is an [add-on](http://addons.heroku.com) for circulating your data between mobile, web, and desktop versions of your app.
2
-
3
- Adding Simpierum to your app makes your code simpler and your users happier:
4
-
5
- * Data transparently moves across mobile, web, and desktop versions of your app
6
- * Your users can read and write data even when they're offline
7
- * Multiple users can collaborate with the same data at the same time
8
- * You can build unique backend services that read and write data
9
-
10
- Simperium is accessible via an API and has supported backend libraries for Ruby and Python and client libraries for Javascript and iOS/OS X. This add-on lets you mirror data circulated by Simpierum directly into your datastore.
11
-
12
- ## Provisioning the add-on
13
-
14
- Simperium can be attached to a Heroku application via the CLI:
15
-
16
- <div class="callout" markdown="1">
17
- A list of all plans available can be found [here](http://addons.heroku.com/simperium).
18
- </div>
19
-
20
- :::term
21
- $ heroku addons:add simperium
22
- -----> Adding simperium to sharp-mountain-4005... done, v18 (free)
23
-
24
- Once Simperium has been added a `SIMPERIUM_APP_ID` and `SIMPERIUM_ADMIN_KEY` setting will be available in the app configuration and will contain keys to access the newly provisioned Simperium app instance. This can be confirmed using the `heroku config` command.
25
-
26
- :::term
27
- $ heroku config | grep SIMPERIUM_APP_ID
28
- SIMPERIUM_APP_ID => frogs-criteria-4c4
29
-
30
- :::term
31
- $ heroku config | grep SIMPERIUM_ADMIN_KEY
32
- SIMPERIUM_ADMIN_KEY => cbbae31841ac4d44a93cd82081a5b74f
33
-
34
- After installing Simpierum your application can begin mirroring data to your datastore.
35
-
36
- ## Local setup
37
-
38
- ### Environment setup
39
-
40
- After provisioning the add-on you'll want to locally replicate the config vars so your development environment can operate against the service.
41
-
42
- <div class="callout" markdown="1">
43
- Though less portable it’s also possible to set local environment variables using `export SIMPERIUM_APP_ID=value` and `export SIMPERIUM_APP_KEY=value`.
44
- </div>
45
-
46
- Use [Foreman](config-vars#local_setup) to reliably configure and run the process formation specified in your app’s [Procfile](procfile). Foreman reads configuration variables from an .env file. Use the following command to add the SIMPERIUM_APP_ID and SIMPERIUM_ADMIN_KEY values retrieved from heroku config to `.env`.
47
-
48
- :::term
49
- $ heroku config -s | grep SIMPERIUM_APP_ID >> .env
50
- $ heroku config -s | grep SIMPERIUM_ADMIN_KEY >> .env
51
- $ more .env
52
-
53
- <p class="warning" markdown="1">
54
- Credentials and other sensitive configuration values should not be committed to source-control. In Git exclude the .env file with: `echo .env >> .gitignore`.
55
- </p>
56
-
57
- ### Mirroring Data from Simperium to MongoHQ
58
-
59
- In order to begin mirroring data from Simperium to MongoHQ, we need to install the simperium gem.
60
-
61
- :::term
62
- sudo gem install simperium
63
-
64
- Grab a copy of the listner file that handles mirroring between MongoHQ and Simperium:
65
-
66
- :::term
67
- $ curl -O https://raw.github.com/Simperium/simperium/master/ruby/lib/simperium/listener-export-mongohq
68
-
69
- Install the mongo gem and bson_ext dependency:
70
-
71
- :::term
72
- $ sudo gem update --system
73
-
74
- :::term
75
- sudo gem install mongo
76
- sudo gem install bson_ext
77
-
78
- Now, let Heroku know we want to run this new listener:
79
-
80
- :::term
81
- $ echo "worker: ruby listener-export-mongohq SIMPERIUM_APP_ID SIMPERIUM_ADMIN_KEY BUCKET_NAME" > Procfile
82
-
83
- Note, BUCKET_NAME is the name of the bucket you want to mirror.
84
-
85
- Start up our mongo instance with MongoHQ:
86
-
87
- :::term
88
- heroku addons:add mongohq:free
89
-
90
- Finally, commit and re-push to Heroku:
91
-
92
- :::term
93
- $ git add .
94
- $ git commit -m "realtime export to MongoHQ"
95
- $ git push heroku master
96
-
97
- Simperium activity can be observed within the Heroku log-stream by running the following:
98
-
99
- :::term
100
- $ heroku logs --tail
101
-
102
- ## Dashboard
103
-
104
- <div class="callout" markdown="1">
105
- For more information on the features available within the Simperium dashboard please see the docs at [simperium.com/docs/reference](http://simperium.com/docs/reference).
106
- </div>
107
-
108
- The Simpierum dashboard allows you to delete app data, debug with our data browser, and invite developers to your Simperium app.
109
-
110
- ![Simperium Dashboard](http://i.imgur.com/FkuUw.png "Simpierum Dashboard")
111
-
112
- The dashboard can be accessed via the CLI:
113
-
114
- :::term
115
- $ heroku addons:open simperium
116
- Opening simpierum for sharp-mountain-4005…
117
-
118
- or by visiting the [Heroku apps web interface](http://heroku.com/myapps) and selecting the application in question. Select Simperium from the Add-ons menu.
119
-
120
- ![Simperium Add-ons Dropdown](http://f.cl.ly/items/1B090n1P0d3W0I0R172r/addons.png "Simperium Add-ons Dropdown")
121
-
122
-
123
- ## Migrating between plans
124
-
125
- <div class="note" markdown="1">Application owners should carefully manage the migration timing to ensure proper application function during the migration process.</div>
126
-
127
- Use the `heroku addons:upgrade` command to migrate to a new plan.
128
-
129
- :::term
130
- $ heroku addons:upgrade simperium:pro
131
- -----> Upgrading simperium:pro to sharp-mountain-4005... done, v18 ($XX/mo)
132
- Your plan has been updated to: simperium:pro
133
-
134
- ## Removing the add-on
135
-
136
- Simperium can be removed via the CLI.
137
-
138
- <div class="warning" markdown="1">This will destroy all associated data and cannot be undone!</div>
139
-
140
- :::term
141
- $ heroku addons:remove simperium
142
- -----> Removing simperium from sharp-mountain-4005... done, v20 (free)
143
-
144
- ## Support
145
-
146
- All Simperium support and runtime issues should be logged with Heroku Support at https://support.heroku.com. Any non-support related issues or product feedback is welcome at help@simperium.com.
147
-
148
- ## Additional resources
149
-
150
- Additional resources are available at:
151
-
152
- * [Site docs](http://simperium.com/docs/reference)