gfrom 0.1.9 → 0.2.01

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.
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  Gem::Specification.new do |spec|
6
6
  spec.platform = Gem::Platform::RUBY
7
7
  spec.name = "gfrom"
8
- spec.version = "0.1.9"
8
+ spec.version = "0.2.01"
9
9
  spec.authors = ["Marvin Marcelo"]
10
10
  spec.email = ["mrclmrvn@gmail.com"]
11
11
  spec.description = %q{Wrap Google Form within your site}
@@ -7,13 +7,19 @@ require "tmpdir"
7
7
 
8
8
  class Gfrom
9
9
 
10
+ attr_accessor :fields, :form
11
+
10
12
  MATCHERS = '//input[@type="text"] | //input[@type="radio"] | //input[@type="checkbox"] | //input[@type="hidden"] | //textarea | //form'
11
13
 
12
14
  def initialize(url, regenerate_cache = false, lang = 'en')
13
15
  @form = Hash.new
14
16
  @fields = []
15
17
 
18
+ # url = Gfrom::locale_url(url, lang)
16
19
  uri = Addressable::URI.parse(url)
20
+ if uri.to_hash.select{|k,v| [:scheme, :host].include? k }.values.any?{|v| v.nil? || v.length == 0}
21
+ raise "Invalid URI"
22
+ end
17
23
  uri.query_values ||= Hash.new
18
24
  uri.query_values = uri.query_values.merge({"hl" => lang})
19
25
  url = uri.to_s
@@ -11,6 +11,22 @@ describe Gfrom do
11
11
  }.to raise_exception
12
12
  end
13
13
  end
14
+ context "attributes" do
15
+ stub_request(
16
+ :get,
17
+ "http://localhost.localdomain/foo.bar"
18
+ ).with(
19
+ :headers => {
20
+ 'Accept-Encoding' => 'gzip, deflate',
21
+ 'Accept-Language' => 'en-us',
22
+ 'User-Agent' => 'Ruby'
23
+ }
24
+ ).to_return(:status => 200, :body => "", :headers => {}
25
+ )
26
+ subject { Gfrom.new("http://localhost.localdomain/foo.bar") }
27
+ it { should.respond_to(:fields) }
28
+ it { should.respond_to(:form) }
29
+ end
14
30
  end
15
31
 
16
32
  describe "Gfrom::local_url" do
@@ -14,4 +14,5 @@ RSpec.configure do |config|
14
14
  # the seed, which is printed after each run.
15
15
  # --seed 1234
16
16
  config.order = 'random'
17
+ config.mock_with :rr
17
18
  end
@@ -1,4 +1,3 @@
1
-
2
1
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><link rel="shortcut icon" href="https://ssl.gstatic.com/docs/spreadsheets/forms/favicon_jfk2.png" type="image/x-icon">
3
2
  <meta http-equiv="Content-type" content="text/html; charset=utf-8">
4
3
  <meta http-equiv="X-UA-Compatible" content="IE=10; chrome=1;">
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gfrom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.01
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: