bitballoon 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bitballoon (0.0.2)
4
+ bitballoon (0.0.3)
5
5
  highline
6
6
  oauth2 (>= 0.9.2)
7
7
  slop
data/README.md CHANGED
@@ -51,91 +51,145 @@ Sites
51
51
 
52
52
  Getting a list of all sites you have access to:
53
53
 
54
+ ```ruby
54
55
  bitballoon.sites.each do |site|
55
56
  puts site.url
56
57
  end
58
+ ```
57
59
 
58
60
  Getting a specific site by id:
59
61
 
62
+ ```ruby
60
63
  site = bitballoon.sites.get(id)
64
+ ```
61
65
 
62
66
  Creating a site from a directory:
63
67
 
68
+ ```ruby
64
69
  site = bitballoon.sites.create(:dir => "/tmp/my-site")
70
+ ```
65
71
 
66
72
  Creating a site from a zip file:
67
73
 
74
+ ```ruby
68
75
  site = bitballoon.sites.create(:zip => "/tmp/my-site.zip")
76
+ ```
69
77
 
70
78
  Both methods will create the site and upload the files. The site will then be processing.
71
79
 
80
+ ```ruby
72
81
  site.state == "processing"
73
82
  site.processing? == true
83
+ ```
74
84
 
75
85
  Refresh a site to update the state:
76
86
 
87
+ ```ruby
77
88
  site.refresh
89
+ ```
78
90
 
79
91
  Use `wait_until_ready` to wait until a site has finished processing.
80
92
 
93
+ ```ruby
81
94
  site = bitballoon.sites.create(:dir => "/tmp/my-site")
82
95
  site.wait_for_ready
83
96
  site.state == "ready"
97
+ ```
84
98
 
85
99
  Update the name of the site (its subdomain), the custom domain and the notification email for form submissions:
86
100
 
87
- site.update(:subdomain => "my-site", :custom_domain => "www.example.com", :notification_email => "me@example.com")
101
+ ```ruby
102
+ site.update(:name => "my-site", :custom_domain => "www.example.com", :notification_email => "me@example.com")
103
+ ```
88
104
 
89
105
  Deleting a site:
90
106
 
107
+ ```ruby
91
108
  site.destroy!
109
+ ```
92
110
 
93
111
  Forms
94
112
  =====
95
113
 
96
114
  Access all forms you have access to:
97
115
 
98
- bitballoon.forms
116
+ ```ruby
117
+ bitballoon.forms.all
118
+ ```
99
119
 
100
120
  Access forms for a specific site:
101
121
 
122
+ ```ruby
102
123
  site = bitballoon.sites.get(id)
103
- site.forms
104
-
124
+ site.forms.all
125
+ ```
126
+
105
127
  Access a specific form:
106
128
 
129
+ ```ruby
107
130
  form = bitballoon.forms.get(id)
131
+ ```
108
132
 
109
133
  Access a list of all form submissions you have access to:
110
134
 
111
- bitballoon.submissions
135
+ ```ruby
136
+ bitballoon.submissions.all
137
+ ```
112
138
 
113
139
  Access submissions from a specific site
114
140
 
141
+ ```ruby
115
142
  site = bitballoon.sites.get(id)
116
- site.submissions
143
+ site.submissions.all
144
+ ```
117
145
 
118
146
  Access submissions from a specific form
119
147
 
148
+ ```ruby
120
149
  form = bitballoon.forms.get(id)
121
- form.submissions
150
+ form.submissions.all
151
+ ```
122
152
 
123
153
  Get a specific submission
124
154
 
155
+ ```ruby
125
156
  bitballoon.submissions.get(id)
157
+ ```
126
158
 
127
159
  Files
128
160
  =====
129
161
 
130
162
  Access all files in a site:
131
163
 
164
+ ```ruby
132
165
  site = bitballoon.sites.get(id)
133
- site.files
166
+ site.files.all
167
+ ```
134
168
 
135
169
  Get a specific file:
136
170
 
171
+ ```ruby
137
172
  file = site.files.get(path) # Example paths: "/css/main.css", "/index.html"
173
+ ```
138
174
 
139
175
  Reading a file:
140
176
 
141
- file.read
177
+ ```ruby
178
+ file.read
179
+ ```
180
+
181
+ Snippets
182
+ ========
183
+
184
+ Snippets are small code snippets injected into all HTML pages of a site right before the closing head or body tag. To get all snippets for a site:
185
+
186
+ ```ruby
187
+ site = bitballoon.sites.get(id)
188
+ site.snippets.all
189
+ ```
190
+
191
+ Get a specific snippet
192
+
193
+ ```ruby
194
+ site.snippets.get(0)
195
+ ```
data/lib/bitballoon.rb CHANGED
@@ -7,7 +7,6 @@ require "bitballoon/sites"
7
7
  require "bitballoon/forms"
8
8
  require "bitballoon/submissions"
9
9
  require "bitballoon/files"
10
+ require "bitballoon/snippets"
10
11
 
11
- module BitBalloon
12
- # Your code goes here...
13
- end
12
+ module BitBalloon; end
@@ -1,7 +1,5 @@
1
1
  module BitBalloon
2
2
  class File < Model
3
3
  fields :id, :path, :sha, :mime_type, :size
4
-
5
-
6
4
  end
7
5
  end
@@ -32,7 +32,9 @@ module BitBalloon
32
32
 
33
33
  def process(attributes)
34
34
  self.class.fields.each do |field|
35
- @attributes[field] = attributes[field] || attributes[field.to_s]
35
+ if attributes.has_key?(field) || attributes.has_key?(field.to_s)
36
+ @attributes[field] = attributes[field] || attributes[field.to_s]
37
+ end
36
38
  end
37
39
  self
38
40
  end
@@ -40,7 +40,9 @@ module BitBalloon
40
40
  end
41
41
 
42
42
  def update(attributes)
43
- raise "Not implemented yet"
43
+ response = client.request(:put, path, :body => mutable_attributes(attributes))
44
+ process(response.parsed)
45
+ self
44
46
  end
45
47
 
46
48
  def destroy!
@@ -59,5 +61,18 @@ module BitBalloon
59
61
  def files
60
62
  Files.new(client, path)
61
63
  end
64
+
65
+ def snippets
66
+ Snippets.new(client, path)
67
+ end
68
+
69
+ private
70
+ def mutable_attributes(attributes)
71
+ Hash[*[:name, :custom_domain, :notification_email].map {|key|
72
+ if attributes.has_key?(key) || attributes.has_key?(key.to_s)
73
+ [key, attributes[key] || attributes[key.to_s]]
74
+ end
75
+ }.compact.flatten]
76
+ end
62
77
  end
63
78
  end
@@ -0,0 +1,5 @@
1
+ module BitBalloon
2
+ class Snippet < Model
3
+ fields :id, :title, :general, :general_position, :goal, :goal_position
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "bitballoon/snippet"
2
+
3
+ module BitBalloon
4
+ class Snippets < CollectionProxy
5
+ path "/snippets"
6
+ end
7
+ end
@@ -1,6 +1,6 @@
1
1
  module BitBalloon
2
2
  class Submission < Model
3
3
  fields :id, :number, :title, :email, :name, :first_name, :last_name,
4
- :company, :summary, :body, :data, :created_at, :site_url
4
+ :company, :summary, :body, :data, :created_at, :site_url
5
5
  end
6
6
  end
@@ -1,3 +1,3 @@
1
1
  module BitBalloon
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitballoon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -116,6 +116,8 @@ files:
116
116
  - lib/bitballoon/model.rb
117
117
  - lib/bitballoon/site.rb
118
118
  - lib/bitballoon/sites.rb
119
+ - lib/bitballoon/snippet.rb
120
+ - lib/bitballoon/snippets.rb
119
121
  - lib/bitballoon/submission.rb
120
122
  - lib/bitballoon/submissions.rb
121
123
  - lib/bitballoon/version.rb