ask_awesomely 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f05c9c5cdae79172a5a1bcddbef1f3c6fa488033
4
- data.tar.gz: 798898689f330e31f28685a690180813797c84d5
3
+ metadata.gz: 70509a7f4e01e364e2e6177430566f5853fb4bb9
4
+ data.tar.gz: 5348d34668d7a5ad781707d297ad08c7579f245d
5
5
  SHA512:
6
- metadata.gz: cf064d4f65fb1d9bcc6e9a41f979aa16c5621ae3dbcd482c55371bad955aeba199c6fb34351f368507c2c9eb1f60d0d49b955eadf7923fde6c4ae0617313d097
7
- data.tar.gz: ed9e1bd633c56fbf521a8fc521a61c49d0073269241b7fcfa47397cd5c894c031e452b42b5c7916a426c2ce2ac858f89f33dcf0ba2956b0f5b35ada56477cd63
6
+ metadata.gz: 2ba0944f97f24d5d291704e381e00f6539b85d5d1056e8cd13d1cca2da9d3fbb22d59a29ee9c5c4c14c9fb3fd70cb882781ebfc8cf6ec9ec46ad03af423ed928
7
+ data.tar.gz: 5016b441a5fc79fdd3dbff2682e7c6a44915798c54ea8a910530633783cdff1a856b69ccdc533b86c3ac39facb3c789a64dfd59835933e0a88ac3166f2c4de2b
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Lee Machin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -8,6 +8,7 @@ Build Typeforms awesomely. In Ruby.
8
8
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
9
9
  ## Table of Contents
10
10
 
11
+ - [Before you start](#before-you-start)
11
12
  - [Installation](#installation)
12
13
  - [Usage](#usage)
13
14
  - [Authentication](#authentication)
@@ -27,7 +28,7 @@ Build Typeforms awesomely. In Ruby.
27
28
  - [Email](#email)
28
29
  - [Website](#website)
29
30
  - [Legal](#legal)
30
- - [Common Customisations](#common-customisations)
31
+ - [Common Customisations](#common-customisations)
31
32
  - [Passing Context](#passing-context)
32
33
  - [Rendering the Typeform](#rendering-the-typeform)
33
34
  - [Getting the URL](#getting-the-url)
@@ -36,25 +37,26 @@ Build Typeforms awesomely. In Ruby.
36
37
  - [Widget](#widget)
37
38
  - [Drawer](#drawer)
38
39
  - [Fullscreen](#fullscreen)
39
- - [Todo](#todo)
40
40
  - [Development](#development)
41
- - [Contributing](#contributing)
41
+ - [Feedback and Contributions](#feedback-and-contributions)
42
42
 
43
43
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
44
44
 
45
+ ## Before you start
46
+
45
47
 
46
48
  ## Installation
47
49
 
48
- I wouldn't recommend you do this yet, because it doesn't actually work. Nevertheless, add this line to your application's Gemfile:
50
+ Prepare your best [Jamie Oliver](https://en.wikipedia.org/wiki/Jamie_Oliver) impression and bang this in yer Gemfile:
49
51
 
50
52
  ```ruby
51
53
  gem 'ask_awesomely'
52
54
  ```
53
55
 
54
- And then execute:
56
+ Turn your CPU up to 80ºC and let it simmer for a while with this:
55
57
 
56
58
  ```shell
57
- bundle
59
+ bundle install
58
60
  ```
59
61
 
60
62
  Or install it yourself as:
@@ -63,6 +65,11 @@ Or install it yourself as:
63
65
  gem install ask_awesomely
64
66
  ```
65
67
 
68
+ Then include it in your code like this:
69
+
70
+ ```ruby
71
+ require "ask_awesomely"
72
+ ```
66
73
 
67
74
  ## Usage
68
75
 
@@ -134,8 +141,6 @@ After that, it's simply a matter of calling `build` on the class:
134
141
  typeform = MyNewTypeform.build
135
142
  ```
136
143
 
137
- Check the rest of the (not currently finished) documentation to find out what else you can do.
138
-
139
144
  Check out [Typeform I/O](https://typeform.io) for detailed information about the API, and how to get your API key.
140
145
 
141
146
 
@@ -329,7 +334,7 @@ end
329
334
  ```
330
335
 
331
336
 
332
- #### Common Customisations
337
+ ## Common Customisations
333
338
 
334
339
  Every field type allows you customize the following things:
335
340
 
@@ -349,8 +354,6 @@ end
349
354
 
350
355
  ## Passing Context
351
356
 
352
- **note: not yet supported**
353
-
354
357
  Building a form full of hard-coded data is all well and good, but it doesn't offer much benefit over using a web interface. What if you want to build personalised forms based on, say, an `ActiveRecord` model?
355
358
 
356
359
  Lets create the basic form, with a title and a single question:
@@ -409,7 +412,7 @@ end
409
412
 
410
413
  You can also embed a form straight away if you prefer. `AskAwesomely` generates the correct embed code for you, with the correct URL and Typeform title. The style can be customised with CSS but some aspects of the embed itself are not currently customisable (e.g. changing button text and widget size).
411
414
 
412
- To see what each embedding option looks like, check out the `Embedding Modes`[http://docs.typeform.io/docs/embedding-introduction) documentation at Typeform I/O. It has pictures and everything.
415
+ To see what each embedding option looks like, check out the [`Embedding Modes`](http://docs.typeform.io/docs/embedding-introduction) documentation at Typeform I/O. It has pictures and everything.
413
416
 
414
417
  Assuming you have built a Typeform as in the other examples, rendering the embed code is simple:
415
418
 
@@ -447,25 +450,22 @@ Note that this outputs a **complete** HTML document, CSS and all. If you're work
447
450
  typeform.embed_as(:fullscreen)
448
451
  ```
449
452
 
453
+ ## Development
450
454
 
451
- ## Todo
452
-
453
- - implement and test dynamic fields
454
- - test the API interaction behaves well
455
- - deal with errors from the API
456
- - allow webhook URL to be configured
457
- - allow design to be configured
455
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
458
456
 
457
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
459
458
 
460
459
 
461
- ## Development
460
+ ## Feedback and Contributions
462
461
 
463
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
462
+ Practically every aspect of this gem (save for image uploading) is an extension of the Typeform I/O API. If the API has it, `AskAwesomely` eventually will. Here's what the Typeform I/O peeps say:
464
463
 
465
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
464
+ > We are continuously working on and improving Typeform I/O, and we're heavily focused on making the API as simple as possible, but also feature-rich so you can make good use of it. We would be forever grateful if you can leave us feedback. We welcome all questions, and we'd love to talk to you about how you're using Typeform I/O, what you hope for from us in the future, or anything else!
466
465
 
466
+ > We recommend you join our [#Slack group](http://docs.typeform.io/v0.4/page/slack-invite) to chat with us, and with other people using Typeform I/O. You can also ask us questions in our [Q&A section](http://docs.typeform.io/v0.4/discuss), or you can simply send us an email to [support@typeform.io](mailto:support@typeform.io).
467
467
 
468
- ## Contributing
468
+ That doesn't preclude contributing to the gem itself by fixing bugs or offering improvements. If you'd like to do that, follow these simple steps:
469
469
 
470
470
  1. Fork it (https://github.com/leemachin/ask_awesomely/fork)
471
471
  2. Create your feature branch (`git checkout -b my-new-feature`)
@@ -38,12 +38,27 @@ module AskAwesomely
38
38
 
39
39
  attr_reader :context, :json
40
40
 
41
- private def initialize(context = nil)
41
+ def build_json
42
+ state.to_h.reduce({}) do |json, (k, v)|
43
+ json[k] = case k
44
+ when :title, :tags
45
+ v.respond_to?(:call) ? v.call(@context) : v
46
+ when :fields
47
+ v.map {|f| f.build_json(@context) }
48
+ end
49
+
50
+ json
51
+ end.to_json
52
+ end
53
+
54
+ private
55
+
56
+ def initialize(context = nil)
42
57
  @context = context
43
58
  end
44
59
 
45
- def to_json
46
- self.class._state.to_h.to_json
60
+ def state
61
+ self.class._state
47
62
  end
48
63
 
49
64
  end
@@ -61,8 +61,12 @@ module AskAwesomely
61
61
  @state.tags = tags
62
62
  end
63
63
 
64
- def to_json(*args)
65
- @state.to_h.to_json(*args)
64
+ def build_json(context = nil)
65
+ state.to_h.reduce({}) do |json, (k, v)|
66
+ json[k] = v.respond_to?(:call) ? v.call(context) : v
67
+ json
68
+ end
66
69
  end
70
+
67
71
  end
68
72
  end
@@ -33,7 +33,7 @@ module AskAwesomely
33
33
  end
34
34
 
35
35
  def to_json
36
- @structure.to_json
36
+ @structure.build_json
37
37
  end
38
38
 
39
39
  def get_binding
@@ -1,3 +1,3 @@
1
1
  module AskAwesomely
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ask_awesomely
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Machin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-26 00:00:00.000000000 Z
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -106,6 +106,7 @@ files:
106
106
  - ".ruby-version"
107
107
  - ".travis.yml"
108
108
  - Gemfile
109
+ - LICENSE
109
110
  - README.md
110
111
  - Rakefile
111
112
  - ask_awesomely.gemspec