bitballoon 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8ffe0d3f3814d0e2a8371fc42af21e94c90d3f2f
4
+ data.tar.gz: 78d1599d7ef1b65c86afa0acf22a56e62dcc6844
5
+ SHA512:
6
+ metadata.gz: 6243f00aef2b92f34a259bbe2c8ab7ea40d0edc04b8a85e4c5a52741dc66276e73a7e2a50f1bb8dc81055c2a2c7c27638c88d463e43f83de857d1e80a2315b18
7
+ data.tar.gz: f22dad8ac289490050d5f3af663c340312237fa151bf20dcde70010554ce497db71abc19614f17af5476f3b9c13e31628afa73db9aecd4621fe5d456985385f2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bitballoon (0.1.0)
4
+ bitballoon (0.1.4)
5
5
  highline
6
6
  oauth2 (>= 0.9.2)
7
7
  slop
@@ -11,25 +11,23 @@ GEM
11
11
  specs:
12
12
  addressable (2.3.3)
13
13
  crack (0.3.2)
14
- faraday (0.8.8)
15
- multipart-post (~> 1.2.0)
16
- highline (1.6.20)
17
- httpauth (0.2.0)
18
- jwt (0.1.8)
14
+ faraday (0.9.0)
15
+ multipart-post (>= 1.2, < 3)
16
+ highline (1.6.21)
17
+ jwt (0.1.11)
19
18
  multi_json (>= 1.5)
20
19
  minitest (5.0.8)
21
- multi_json (1.8.2)
20
+ multi_json (1.9.2)
22
21
  multi_xml (0.5.5)
23
- multipart-post (1.2.0)
24
- oauth2 (0.9.2)
25
- faraday (~> 0.8)
26
- httpauth (~> 0.2)
27
- jwt (~> 0.1.4)
28
- multi_json (~> 1.0)
22
+ multipart-post (2.0.0)
23
+ oauth2 (0.9.3)
24
+ faraday (>= 0.8, < 0.10)
25
+ jwt (~> 0.1.8)
26
+ multi_json (~> 1.3)
29
27
  multi_xml (~> 0.5)
30
28
  rack (~> 1.2)
31
29
  rack (1.5.2)
32
- slop (3.4.6)
30
+ slop (3.5.0)
33
31
  webmock (1.11.0)
34
32
  addressable (>= 2.2.7)
35
33
  crack (>= 0.3.2)
data/README.md CHANGED
@@ -3,6 +3,16 @@ BitBalloon Ruby Client
3
3
 
4
4
  BitBalloon is a hosting service for the programmable web. It understands your documents, processes forms and lets you do deploys, manage forms submissions, inject javascript snippets into sites and do intelligent updates of HTML documents through it's API.
5
5
 
6
+ The basic flow to using the ruby client is:
7
+
8
+ 1. Authenticate (via credentials or a previously aquired access token)
9
+ 2. Get site (via id)
10
+ 3. Deploy
11
+ * If site has not been deployed to yet, then the above step will throw a `not found` exception, and you'll need to use `bitballoon.sites.create` to create the site and do the initial deploy.
12
+ * If the site has already been deployed and the above step was successful, you can simply use `site.update` to re-deploy.
13
+
14
+ If you'd rather, there's also a command line utility to handle most of these steps: `bitballoon deploy`.
15
+
6
16
  Installation
7
17
  ============
8
18
 
@@ -52,13 +62,15 @@ If you already have an OAuth2 `access_token` you can instantiate the client like
52
62
  bitballoon = BitBalloon::Client.new(:access_token => access_token)
53
63
  ```
54
64
 
55
- And the client will be ready to do requests. This means that once you've gotten a token via `authorize!` or `authorize_from_credentials!` you can store it and reuse it for later sessions.
65
+ And the client will be ready to do requests without having to use `authorize_from_credentials`. This means that once you've gotten a token via `authorize_from_credentials!` you can store it and reuse it for later sessions.
66
+
67
+ If you're authenticating via the `access_token` and you'd like to test if you have a valid `access_token`, you can attempt to make a request with the bitballoon client and if the token is invalid, a `BitBalloon::Client::AuthenticationError` will be raised. See Miles Matthias' [BitBalloon Rakefile](https://github.com/milesmatthias/bitballoon-rakefile) for an example.
56
68
 
57
69
 
58
70
  Command Line Utility
59
71
  ====================
60
72
 
61
- The BitBalloon gem comes with a handy command line utility for deploying and redeploying sites.
73
+ The BitBalloon gem comes with a handy command line utility for deploying and redeploying sites. (See the "Deploys" section below to deploy within a ruby script, like a Rakefile.)
62
74
 
63
75
  To deploy the site in the current working directory:
64
76
 
@@ -94,22 +106,26 @@ Getting a list of all sites you have access to:
94
106
 
95
107
  ```ruby
96
108
  bitballoon.sites.each do |site|
109
+ puts site.id
97
110
  puts site.url
98
111
  end
99
112
  ```
100
113
 
101
- Getting a specific site by id:
114
+ Each site has a unique, system generated id. Getting a specific site by id:
102
115
 
103
116
  ```ruby
104
117
  site = bitballoon.sites.get(id)
105
118
  ```
106
119
 
107
- Creating a site from a directory:
120
+ Creating a site from a directory: _(note the path given is a system path)_
108
121
 
109
122
  ```ruby
110
- site = bitballoon.sites.create(:dir => "/tmp/my-site")
123
+ site = bitballoon.sites.create(:dir => "my-site")
124
+ puts site.id
111
125
  ```
112
126
 
127
+ You'll want to then save that site id for future reference. Note that a site can also be looked up by its `url`.
128
+
113
129
  Creating a site from a zip file:
114
130
 
115
131
  ```ruby
@@ -129,7 +145,7 @@ Refresh a site to update the state:
129
145
  site.refresh
130
146
  ```
131
147
 
132
- Use `wait_until_ready` to wait until a site has finished processing.
148
+ Use `wait_for_ready` to wait until a site has finished processing.
133
149
 
134
150
  ```ruby
135
151
  site = bitballoon.sites.create(:dir => "/tmp/my-site")
@@ -43,6 +43,8 @@ opts = Slop.parse do
43
43
 
44
44
  attributes = zip ? {:zip => path} : {:dir => path}
45
45
 
46
+ puts "Deploying site"
47
+
46
48
  if credentials['site_id']
47
49
  site = client.sites.get(credentials['site_id'])
48
50
  site.update(attributes)
@@ -12,13 +12,14 @@ module BitBalloon
12
12
  class InternalServerError < BitBalloonError; end
13
13
  class AuthenticationError < BitBalloonError; end
14
14
 
15
- attr_accessor :client_id, :client_secret, :oauth, :access_token
15
+ attr_accessor :client_id, :client_secret, :oauth, :access_token, :endpoint
16
16
 
17
17
  def initialize(options)
18
18
  self.client_id = options[:client_id]
19
19
  self.client_secret = options[:client_secret]
20
20
  self.access_token = options[:access_token]
21
- self.oauth = OAuth2::Client.new(client_id, client_secret, :site => ENDPOINT, :connection_build => lambda {|f|
21
+ self.endpoint = options[:endpoint] || ENDPOINT
22
+ self.oauth = OAuth2::Client.new(client_id, client_secret, :site => endpoint, :connection_build => lambda {|f|
22
23
  f.request :multipart
23
24
  f.request :url_encoded
24
25
  f.adapter :net_http
@@ -109,4 +110,4 @@ module BitBalloon
109
110
  error.message.strip == "" ? default : error.message
110
111
  end
111
112
  end
112
- end
113
+ end
@@ -5,7 +5,7 @@ module BitBalloon
5
5
  :user_id, :required
6
6
 
7
7
  def restore
8
- response = client.request(:post, File.join(path, "restore"))
8
+ response = client.request(:post, ::File.join(path, "restore"))
9
9
  process(response.parsed)
10
10
  self
11
11
  end
@@ -9,7 +9,7 @@ module BitBalloon
9
9
  def initialize(multipass_secret)
10
10
  ### Use the Multipass secret to derive two cryptographic keys,
11
11
  ### one for encryption, one for signing
12
- key_material = OpenSSL::Digest::Digest.new("sha256").digest(multipass_secret)
12
+ key_material = OpenSSL::Digest.new("sha256").digest(multipass_secret)
13
13
  @encryption_key = key_material[ 0,16]
14
14
  @signature_key = key_material[16,16]
15
15
  end
@@ -67,4 +67,4 @@ module BitBalloon
67
67
  OpenSSL::HMAC.digest("sha256", @signature_key, data)
68
68
  end
69
69
  end
70
- end
70
+ end
@@ -11,7 +11,9 @@ module BitBalloon
11
11
  return unless state == "uploading"
12
12
 
13
13
  shas = Hash.new { [] }
14
- Dir[::File.join(dir, "**", "*")].each do |file|
14
+ glob = ::File.join(dir, "**", "*")
15
+
16
+ Dir.glob(glob) do |file|
15
17
  next unless ::File.file?(file)
16
18
  pathname = ::File.join("/", file[dir.length..-1])
17
19
  next if pathname.match(/(^\/?__MACOSX\/|\/\.)/)
@@ -22,7 +24,6 @@ module BitBalloon
22
24
 
23
25
  (required || []).each do |sha|
24
26
  shas[sha].each do |pathname|
25
- puts "Uploading #{pathname}"
26
27
  client.request(:put, ::File.join(path, "files", URI.encode(pathname)), :body => ::File.read(::File.join(dir, pathname)), :headers => {"Content-Type" => "application/octet-stream"})
27
28
  end
28
29
  end
@@ -95,4 +96,4 @@ module BitBalloon
95
96
  }.compact.flatten]
96
97
  end
97
98
  end
98
- end
99
+ end
@@ -1,3 +1,3 @@
1
1
  module BitBalloon
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -8,8 +8,12 @@ class ClientTest < MiniTest::Unit::TestCase
8
8
  end
9
9
 
10
10
  def test_authorize_url
11
- expected = "https://www.bitballoon.com/oauth/authorize?response_type=code&client_id=client_id&redirect_uri=http%3A%2F%2Fexample.com%2Fcallback"
12
- assert_equal expected, client.authorize_url(:redirect_uri => "http://example.com/callback")
11
+ expected = URI.parse("https://www.bitballoon.com/oauth/authorize?response_type=code&client_id=client_id&redirect_uri=http%3A%2F%2Fexample.com%2Fcallback")
12
+ actual = URI.parse(client.authorize_url(:redirect_uri => "http://example.com/callback"))
13
+ assert_equal expected.scheme, actual.scheme
14
+ assert_equal expected.host, actual.host
15
+ assert_equal expected.port, actual.port
16
+ assert_equal expected.query.split("&").sort, actual.query.split("&").sort
13
17
  end
14
18
 
15
19
  def test_authorize_from_code
@@ -70,4 +74,4 @@ class ClientTest < MiniTest::Unit::TestCase
70
74
  site = client.sites.get("1234")
71
75
  assert_equal "http://www.example.com", site.url
72
76
  end
73
- end
77
+ end
metadata CHANGED
@@ -1,94 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitballoon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
5
- prerelease:
4
+ version: 0.1.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mathias Biilmann Christensen
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-12-21 00:00:00.000000000 Z
11
+ date: 2014-03-21 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: oauth2
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.9.2
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.9.2
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: slop
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: highline
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: minitest
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: webmock
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  description: API Client for BitBalloon
@@ -140,27 +129,26 @@ files:
140
129
  - test/test_helper.rb
141
130
  homepage: https://www.bitballoon.com
142
131
  licenses: []
132
+ metadata: {}
143
133
  post_install_message:
144
134
  rdoc_options: []
145
135
  require_paths:
146
136
  - lib
147
137
  required_ruby_version: !ruby/object:Gem::Requirement
148
- none: false
149
138
  requirements:
150
- - - ! '>='
139
+ - - ">="
151
140
  - !ruby/object:Gem::Version
152
141
  version: '0'
153
142
  required_rubygems_version: !ruby/object:Gem::Requirement
154
- none: false
155
143
  requirements:
156
- - - ! '>='
144
+ - - ">="
157
145
  - !ruby/object:Gem::Version
158
146
  version: '0'
159
147
  requirements: []
160
148
  rubyforge_project:
161
- rubygems_version: 1.8.23
149
+ rubygems_version: 2.2.2
162
150
  signing_key:
163
- specification_version: 3
151
+ specification_version: 4
164
152
  summary: API Client for BitBalloon
165
153
  test_files:
166
154
  - test/client_test.rb
@@ -169,4 +157,3 @@ test_files:
169
157
  - test/multipass_test.rb
170
158
  - test/sites_test.rb
171
159
  - test/test_helper.rb
172
- has_rdoc: