prefinery 0.1.0
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/CONFIG +15 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +21 -0
- data/MIT-LICENSE +20 -0
- data/README +82 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/init.rb +3 -0
- data/install.rb +1 -0
- data/lib/helpers/invitation_helper.rb +33 -0
- data/lib/prefinery.rb +167 -0
- metadata +108 -0
data/CONFIG
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
Configuration
|
4
|
+
=============
|
5
|
+
|
6
|
+
Sign up for a free account on http://www.prefinery.com and create a new web beta. Once you
|
7
|
+
do this, you'll configure Prefinery Ruby API as follows:
|
8
|
+
|
9
|
+
You should have something like this in config/initializers/prefinery.rb.
|
10
|
+
|
11
|
+
Prefinery.configure do |config|
|
12
|
+
config.subdomain = 'compulsivo'
|
13
|
+
config.api_key = '8cc4aae2a2fc0e1278a2079ea95b219e26f6beba'
|
14
|
+
end
|
15
|
+
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
# gem "shoulda", ">= 0"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler", "~> 1.1.0"
|
12
|
+
gem "jeweler", "~> 1.8.4"
|
13
|
+
# gem "rcov", ">= 0"
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.8.4)
|
6
|
+
bundler (~> 1.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
rdoc
|
10
|
+
json (1.7.3)
|
11
|
+
rake (0.9.2.2)
|
12
|
+
rdoc (3.12)
|
13
|
+
json (~> 1.4)
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
ruby
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
bundler (~> 1.1.0)
|
20
|
+
jeweler (~> 1.8.4)
|
21
|
+
rdoc (~> 3.12)
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Compulsivo, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
Prefinery Ruby API
|
2
|
+
==================
|
3
|
+
|
4
|
+
The official Ruby library for interacting with the Prefinery REST API.
|
5
|
+
|
6
|
+
Prefinery (http://www.prefinery.com) helps you launch a private beta in minutes.
|
7
|
+
Prefinery collects email addresses, generates invitation codes, and sends
|
8
|
+
invitations for your web beta. Your customers never leave your site and
|
9
|
+
e-mail invitations are sent from your address.
|
10
|
+
|
11
|
+
The Prefinery Ruby API gets Prefinery integrated into your Rails website in seconds.
|
12
|
+
|
13
|
+
|
14
|
+
Installation
|
15
|
+
============
|
16
|
+
|
17
|
+
gem 'prefinery'
|
18
|
+
|
19
|
+
|
20
|
+
Configuration
|
21
|
+
=============
|
22
|
+
|
23
|
+
Sign up for a free account on http://www.prefinery.com and create a new web beta. Once you
|
24
|
+
do this, you'll configure Prefinery Ruby API as follows:
|
25
|
+
|
26
|
+
You should have something like this in config/initializers/prefinery.rb.
|
27
|
+
|
28
|
+
Prefinery.configure do |config|
|
29
|
+
config.subdomain = 'compulsivo'
|
30
|
+
config.api_key = '8cc4aae2a2fc0e1278a2079ea95b219e26f6beba'
|
31
|
+
end
|
32
|
+
|
33
|
+
Documentation
|
34
|
+
=============
|
35
|
+
|
36
|
+
See lib/prefinery.rb
|
37
|
+
|
38
|
+
Also, documentation on the REST API can be found at http://app.prefinery.com/api
|
39
|
+
|
40
|
+
|
41
|
+
Examples
|
42
|
+
========
|
43
|
+
|
44
|
+
List testers
|
45
|
+
|
46
|
+
Prefinery::Tester.find(:all, :params => { :beta_id => 74 })
|
47
|
+
Prefinery::Tester.find(:all, :params => { :beta_id => 74, :email => "justin@prefinery.com" })
|
48
|
+
|
49
|
+
Show a single tester
|
50
|
+
|
51
|
+
tester = Prefinery::Tester.find(1259, :params => { :beta_id => 74 })
|
52
|
+
|
53
|
+
Creating a tester
|
54
|
+
|
55
|
+
tester = Prefinery::Tester.new(:beta_id => 74)
|
56
|
+
tester.email = 'justin@prefinery.com'
|
57
|
+
tester.profile = {:first_name => 'Justin', :last_name => 'Britten'}
|
58
|
+
tester.save
|
59
|
+
|
60
|
+
Updating a tester
|
61
|
+
|
62
|
+
tester = Prefinery::Tester.find(1259, :params => { :beta_id => 74 })
|
63
|
+
tester.profile = {:city => 'Austin', :state => 'TX'}
|
64
|
+
tester.save
|
65
|
+
|
66
|
+
|
67
|
+
Helpers
|
68
|
+
=======
|
69
|
+
|
70
|
+
To include Prefinery's invitation javascript on your site's signup page:
|
71
|
+
|
72
|
+
<%= prefinery_invitation_javascript(:subdomain => 'acme', :beta_id => 74) %>
|
73
|
+
|
74
|
+
To place a link on your site's signup page which will launch the Prefinery invitation widget:
|
75
|
+
|
76
|
+
<%= link_to_prefinery_invitation 'Sign up for the beta now!', '#' %>
|
77
|
+
|
78
|
+
|
79
|
+
License
|
80
|
+
=======
|
81
|
+
|
82
|
+
Copyright (c) 2009-2012 Compulsivo, Inc. Released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "prefinery"
|
18
|
+
gem.homepage = "https://github.com/compulsivo/prefinery-ruby-api"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Launch a private beta for your web site in minutes with Prefinery.}
|
21
|
+
gem.description = %Q{Ruby API for Prefinery.com}
|
22
|
+
gem.email = "support@prefinery.com"
|
23
|
+
gem.authors = ["Justin Britten"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
36
|
+
|
37
|
+
require 'rdoc/task'
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
+
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = "prefinery #{version}"
|
43
|
+
rdoc.rdoc_files.include('README*')
|
44
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/init.rb
ADDED
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
puts IO.read(File.join(File.dirname(__FILE__), 'CONFIG'))
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Prefinery
|
2
|
+
module ViewHelper
|
3
|
+
def prefinery_invitation_javascript(options = {})
|
4
|
+
options.symbolize_keys!
|
5
|
+
<<-HTML
|
6
|
+
<script type="text/javascript">
|
7
|
+
var prefineryJsHost = 'http://www.prefinery.com/';
|
8
|
+
document.write(unescape("%3Cscript src='" + prefineryJsHost + "javascripts/widget.js' type='text/javascript'%3E%3C/script%3E"))
|
9
|
+
</script>
|
10
|
+
<script type='text/javascript' charset='utf-8'>
|
11
|
+
var prefinery_apply_options = {
|
12
|
+
account: "#{options[:subdomain]}",
|
13
|
+
beta_id: "#{options[:beta_id]}",
|
14
|
+
link_id: "prefinery_apply_link"
|
15
|
+
};
|
16
|
+
Prefinery.apply(prefinery_apply_options);
|
17
|
+
</script>
|
18
|
+
HTML
|
19
|
+
end
|
20
|
+
|
21
|
+
def prefinery_embed_invitation_form(options = {})
|
22
|
+
options.symbolize_keys!
|
23
|
+
<<-HTML
|
24
|
+
<iframe id='prefinery_iframe_inline' allowTransparency='true' width='100%' height='600' scrolling='no' frameborder='0' src="#{Prefinery.url}/betas/#{options[:beta_id]}/testers/new?display=inline"></iframe>
|
25
|
+
HTML
|
26
|
+
end
|
27
|
+
|
28
|
+
def link_to_prefinery_invitation(name, options = {}, html_options = {})
|
29
|
+
html_options.merge!({:id => 'prefinery_invite_link'})
|
30
|
+
link_to name, options, html_options
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/prefinery.rb
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
# Ruby lib for working with the Prefinery API's XML interface.
|
2
|
+
#
|
3
|
+
# You should have something like this in config/initializers/prefinery.rb.
|
4
|
+
#
|
5
|
+
# Prefinery.configure do |config|
|
6
|
+
# config.subdomain = 'compulsivo'
|
7
|
+
# config.secure = false
|
8
|
+
# config.api_key = 8cc4aae2a2fc0e1278a2079ea95b219e26f6beba
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
#
|
12
|
+
# Read the docs at:
|
13
|
+
# http://app.prefinery.com/api
|
14
|
+
#
|
15
|
+
|
16
|
+
if Rails::VERSION::STRING.to_i < 3
|
17
|
+
require 'rubygems'
|
18
|
+
require 'activesupport'
|
19
|
+
require 'activeresource'
|
20
|
+
end
|
21
|
+
|
22
|
+
module Prefinery
|
23
|
+
|
24
|
+
class << self
|
25
|
+
attr_accessor :subdomain, :host, :port, :secure, :api_key, :host_format
|
26
|
+
|
27
|
+
def configure
|
28
|
+
yield self
|
29
|
+
resources.each do |klass|
|
30
|
+
klass.site = klass.site_format % (host_format % [protocol, host, port])
|
31
|
+
klass.user = api_key
|
32
|
+
klass.password = "X"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def subdomain
|
37
|
+
@subdomain
|
38
|
+
end
|
39
|
+
|
40
|
+
def host
|
41
|
+
@host ||= "#{subdomain}.prefinery.com"
|
42
|
+
end
|
43
|
+
|
44
|
+
def port
|
45
|
+
@port || (secure ? 443 : 80)
|
46
|
+
end
|
47
|
+
|
48
|
+
def api_key
|
49
|
+
@api_key
|
50
|
+
end
|
51
|
+
|
52
|
+
def protocol
|
53
|
+
secure ? "https" : "http"
|
54
|
+
end
|
55
|
+
|
56
|
+
def url
|
57
|
+
URI.parse("#{protocol}://#{host}:#{port}")
|
58
|
+
end
|
59
|
+
|
60
|
+
def resources
|
61
|
+
@resources ||= []
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
self.host_format = '%s://%s:%s/api/v1'
|
66
|
+
|
67
|
+
class Base < ActiveResource::Base
|
68
|
+
def self.inherited(base)
|
69
|
+
Prefinery.resources << base
|
70
|
+
class << base
|
71
|
+
attr_accessor :site_format
|
72
|
+
end
|
73
|
+
base.site_format = '%s'
|
74
|
+
super
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# List betas
|
79
|
+
#
|
80
|
+
# Prefinery::Beta.find(:all)
|
81
|
+
#
|
82
|
+
# Show a single beta
|
83
|
+
#
|
84
|
+
# beta = Prefinery::Beta.find(1)
|
85
|
+
#
|
86
|
+
# List testers
|
87
|
+
#
|
88
|
+
# beta.testers
|
89
|
+
#
|
90
|
+
# Find a tester by email
|
91
|
+
#
|
92
|
+
# beta.testers(:email => 'justin@prefinery.com')
|
93
|
+
#
|
94
|
+
class Beta < Base
|
95
|
+
def testers(options = {})
|
96
|
+
Tester.find(:all, :params => options.update(:beta_id => id))
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# List testers
|
101
|
+
#
|
102
|
+
# Prefinery::Tester.find(:all, :params => { :beta_id => 74 })
|
103
|
+
# Prefinery::Tester.find(:all, :params => { :beta_id => 74, :email => "justin@prefinery.com" })
|
104
|
+
#
|
105
|
+
# Show a single tester
|
106
|
+
#
|
107
|
+
# tester = Prefinery::Tester.find(1259, :params => { :beta_id => 74 })
|
108
|
+
#
|
109
|
+
# Creating a tester
|
110
|
+
#
|
111
|
+
# tester = Prefinery::Tester.new(:beta_id => 74)
|
112
|
+
# tester.email = 'justin@prefinery.com'
|
113
|
+
# tester.status = 'active'
|
114
|
+
# tester.invitation_code = 'TECHCRUNCH'
|
115
|
+
# tester.profile = {:first_name => 'Justin', :last_name => 'Britten'}
|
116
|
+
# tester.save
|
117
|
+
#
|
118
|
+
# Updating a tester
|
119
|
+
#
|
120
|
+
# tester = Prefinery::Tester.find(1259, :params => { :beta_id => 74 })
|
121
|
+
# tester.profile = {:city => 'Austin', :state => 'TX'}
|
122
|
+
# tester.save
|
123
|
+
#
|
124
|
+
# Deleting a tester
|
125
|
+
#
|
126
|
+
# tester = Prefinery::Tester.find(1259, :params => { :beta_id => 74 })
|
127
|
+
# tester.destroy
|
128
|
+
#
|
129
|
+
# Check-in a tester
|
130
|
+
#
|
131
|
+
# tester = Prefinery::Tester.find(1259, :params => { :beta_id => 74 })
|
132
|
+
# tester.checkin
|
133
|
+
class Tester < Base
|
134
|
+
site_format << '/betas/:beta_id'
|
135
|
+
|
136
|
+
def profile=(profile_attributes)
|
137
|
+
attributes['profile'] = profile_attributes
|
138
|
+
end
|
139
|
+
|
140
|
+
def verified?(invitation_code)
|
141
|
+
begin
|
142
|
+
get(:verify, :invitation_code => invitation_code)
|
143
|
+
true
|
144
|
+
rescue
|
145
|
+
false
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def checkin
|
150
|
+
begin
|
151
|
+
post(:checkin)
|
152
|
+
true
|
153
|
+
rescue
|
154
|
+
false
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
# Check-in a tester by email address
|
161
|
+
#
|
162
|
+
# Prefinery::Checkin.create(:beta_id => 74, :email => 'justin@prefinery.com')
|
163
|
+
class Checkin < Base
|
164
|
+
site_format << '/betas/:beta_id'
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: prefinery
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Justin Britten
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rdoc
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.12'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.12'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.1.0
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.1.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: jeweler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.8.4
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.4
|
62
|
+
description: Ruby API for Prefinery.com
|
63
|
+
email: support@prefinery.com
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files:
|
67
|
+
- README
|
68
|
+
files:
|
69
|
+
- CONFIG
|
70
|
+
- Gemfile
|
71
|
+
- Gemfile.lock
|
72
|
+
- MIT-LICENSE
|
73
|
+
- README
|
74
|
+
- Rakefile
|
75
|
+
- VERSION
|
76
|
+
- init.rb
|
77
|
+
- install.rb
|
78
|
+
- lib/helpers/invitation_helper.rb
|
79
|
+
- lib/prefinery.rb
|
80
|
+
homepage: https://github.com/compulsivo/prefinery-ruby-api
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
hash: 319700071470589539
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 1.8.24
|
105
|
+
signing_key:
|
106
|
+
specification_version: 3
|
107
|
+
summary: Launch a private beta for your web site in minutes with Prefinery.
|
108
|
+
test_files: []
|