fog-xml 0.0.1.alpha → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12c27f44895e68fe9010f39286aa775b946fab8f
4
- data.tar.gz: 7453b55f621248e65516ed116f882307bd23708e
3
+ metadata.gz: ce8f9b8d09cf440bc8510dbf67d2cc23d4fcec4b
4
+ data.tar.gz: 529565cb7aa30250af6877f4fdaec10d6e9f043e
5
5
  SHA512:
6
- metadata.gz: c7f9342ec6794b11df1b570cd097b08c1e1a3a3619eb864b41e607ef2bea78e98f89873b2d15de2df8feb2aa952e7e9bf53bb602202996ac5f66a29587b00d39
7
- data.tar.gz: 649ac8df967444a144d7fbed2c24e1cbd41cf3d4cddfabfbfd60bf4d6eb86f06d61febba516b272c7ce9dfd5ac926ac59494492e693c195fab68d7fe79f2f5ea
6
+ metadata.gz: 4343f03be19f667da0a02a475976974f4ce0670908c45beb95dfd69a15a5df0dc12999e17e05e0ac1ab0552dd68c53a4776efb27921b877e4aabb696b6685660
7
+ data.tar.gz: 963c88b5c7326f967f9df6b8280ef8ad9d5e89e46b0ffd269a23a2518aa563c79e2b512a99b8e8cc3532721915ec33a65733e4d3bd590aeef8b0d2a9fb175909
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ gemfiles/*.lock
@@ -0,0 +1,20 @@
1
+ Metrics/LineLength:
2
+ Enabled: false
3
+
4
+ Style/EachWithObject:
5
+ Enabled: false
6
+
7
+ Style/Encoding:
8
+ EnforcedStyle: when_needed
9
+
10
+ Style/FormatString:
11
+ Enabled: false
12
+
13
+ Style/HashSyntax:
14
+ EnforcedStyle: hash_rockets
15
+
16
+ Style/SignalException:
17
+ EnforcedStyle: only_raise
18
+
19
+ Style/StringLiterals:
20
+ EnforcedStyle: double_quotes
@@ -0,0 +1,21 @@
1
+ matrix:
2
+ include:
3
+ - rvm: 1.8.7
4
+ gemfile: gemfiles/Gemfile.1.8.7
5
+ - rvm: 1.9.2
6
+ gemfile: gemfiles/Gemfile.1.9.2+
7
+ env: COVERAGE=true
8
+ - rvm: 1.9.3
9
+ gemfile: gemfiles/Gemfile.1.9.2+
10
+ env: COVERAGE=true
11
+ - rvm: 2.0.0
12
+ gemfile: gemfiles/Gemfile.1.9.2+
13
+ env: COVERAGE=true
14
+ - rvm: 2.1.1
15
+ gemfile: gemfiles/Gemfile.1.9.2+
16
+ env: COVERAGE=true
17
+ - rvm: ree
18
+ gemfile: gemfiles/Gemfile.1.8.7
19
+ - rvm: jruby
20
+ gemfile: gemfiles/Gemfile.1.9.2+
21
+ env: COVERAGE=true
@@ -5,14 +5,14 @@ New contributors are always welcome, when it doubt please ask questions. We stri
5
5
  ### Coding
6
6
 
7
7
  * Pick a task:
8
- * Offer feedback on open [pull requests](https://github.com/zertico/fog-xml/pulls).
9
- * Review open [issues](https://github.com/zertico/fog-xml/issues) for things to help on.
10
- * [Create an issue](https://github.com/zertico/fog-xml/issues/new) to start a discussion on additions or features.
8
+ * Offer feedback on open [pull requests](https://github.com/fog/fog-xml/pulls).
9
+ * Review open [issues](https://github.com/fog/fog-xml/issues) for things to help on.
10
+ * [Create an issue](https://github.com/fog/fog-xml/issues/new) to start a discussion on additions or features.
11
11
  * Fork the project, add your changes and tests to cover them in a topic branch.
12
- * Commit your changes and rebase against `zertico/fog-xml` to ensure everything is up to date.
13
- * [Submit a pull request](https://github.com/zertico/fog-xml/compare/)
12
+ * Commit your changes and rebase against `fog/fog-xml` to ensure everything is up to date.
13
+ * [Submit a pull request](https://github.com/fog/fog-xml/compare/)
14
14
 
15
15
  ### Non-Coding
16
16
 
17
- * Offer feedback on open [issues](https://github.com/zertico/fog-xml/issues).
17
+ * Offer feedback on open [issues](https://github.com/fog/fog-xml/issues).
18
18
  * Organize or volunteer at events.
@@ -1 +1,4 @@
1
- * Paulo Henrique Lopes Ribeiro <plribeiro@zertico.com>
1
+ * Michael Hale <mike@hales.ws>
2
+ * Paul Thornthwaite <tokengeek@gmail.com>
3
+ * Paulo Henrique Lopes Ribeiro <plribeiro3000@gmail.com>
4
+ * Wesley Beary <geemus@gmail.com>
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in fog-xml.gemspec
4
4
  gemspec
data/Rakefile CHANGED
@@ -1,2 +1,11 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rake/testtask"
2
3
 
4
+ Rake::TestTask.new do |t|
5
+ t.libs.push %w(spec)
6
+ t.test_files = FileList["spec/**/*_spec.rb"]
7
+ t.verbose = true
8
+ end
9
+
10
+ desc "Default Task"
11
+ task :default => [:test]
@@ -1,26 +1,30 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'fog/xml/version'
4
+ require "fog/xml/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "fog-xml"
8
8
  spec.version = Fog::Xml::VERSION
9
- spec.authors = %q(Paulo Henrique Lopes Ribeiro)
10
- spec.email = %q(plribeiro3000@gmail.com)
11
- spec.summary = %q{XML parsing for fog providers}
12
- spec.description = %q{Extraction of the XML parsing tools shared between a
13
- number of providers in the 'fog' gem}
14
- spec.homepage = 'https://github.com/zertico/fog-xml'
15
- spec.license = 'MIT'
9
+ spec.authors = ["Wesley Beary (geemus)", "Paul Thornthwaite (tokengeek)", "The fog team"]
10
+ spec.email = ["geemus@gmail.com", "tokengeek@gmail.com"]
11
+ spec.summary = "XML parsing for fog providers"
12
+ spec.description = "Extraction of the XML parsing tools shared between a
13
+ number of providers in the 'fog' gem"
14
+ spec.homepage = "https://github.com/fog/fog-xml"
15
+ spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0")
18
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
20
20
  spec.require_paths = %w(lib)
21
21
 
22
- spec.add_dependency 'fog-core'
23
- spec.add_dependency 'nokogiri', '~> 1.5', '>= 1.5.11'
24
- spec.add_development_dependency 'rake'
25
- spec.add_development_dependency 'rspec'
22
+ spec.add_dependency "fog-core"
23
+ spec.add_dependency "nokogiri", "~> 1.5", ">= 1.5.11"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "minitest"
26
+ spec.add_development_dependency "turn"
27
+ spec.add_development_dependency "pry"
28
+ spec.add_development_dependency "rubocop"
29
+ spec.add_development_dependency "coveralls" if RUBY_VERSION.to_f >= 1.9
26
30
  end
@@ -0,0 +1,8 @@
1
+ source :rubygems
2
+
3
+ gem 'mime-types', '< 2.0'
4
+ gem 'nokogiri', '< 1.6'
5
+ gem 'rest-client', '~> 1.6.8'
6
+ gem 'fog-core', :github => 'fog/fog-core'
7
+
8
+ gemspec :path => '../'
@@ -0,0 +1,7 @@
1
+ source :rubygems
2
+
3
+ gem 'activesupport', '>= 3.0', '< 4'
4
+ gem 'mime-types', '< 2.0'
5
+ gem 'fog-core', :github => 'fog/fog-core'
6
+
7
+ gemspec :path => '../'
@@ -0,0 +1,64 @@
1
+ module Fog
2
+ class ToHashDocument < Nokogiri::XML::SAX::Document
3
+ def initialize
4
+ @stack = []
5
+ end
6
+
7
+ def characters(string)
8
+ @value ||= ""
9
+ @value << string.strip
10
+ end
11
+
12
+ def end_element(name)
13
+ last = @stack.pop
14
+ if last.empty? && @value.empty?
15
+ @stack.last[name.to_sym] = ""
16
+ elsif last == { :i_nil => "true" }
17
+ @stack.last[name.to_sym] = nil
18
+ elsif !@value.empty?
19
+ @stack.last[name.to_sym] = @value
20
+ end
21
+ @value = ""
22
+ end
23
+
24
+ def body
25
+ @stack.first
26
+ end
27
+
28
+ def response
29
+ body
30
+ end
31
+
32
+ def start_element(name, attributes = [])
33
+ @value = ""
34
+ parsed_attributes = {}
35
+ until attributes.empty?
36
+ if attributes.first.is_a?(Array)
37
+ key, value = attributes.shift
38
+ else
39
+ key, value = attributes.shift, attributes.shift
40
+ end
41
+ parsed_attributes[key.gsub(":", "_").to_sym] = value
42
+ end
43
+ if @stack.last.is_a?(Array)
44
+ @stack.last << { name.to_sym => parsed_attributes }
45
+ else
46
+ data = if @stack.empty?
47
+ @stack.push(parsed_attributes)
48
+ parsed_attributes
49
+ elsif @stack.last[name.to_sym]
50
+ unless @stack.last[name.to_sym].is_a?(Array)
51
+ @stack.last[name.to_sym] = [@stack.last[name.to_sym]]
52
+ end
53
+ @stack.last[name.to_sym] << parsed_attributes
54
+ @stack.last[name.to_sym].last
55
+ else
56
+ @stack.last[name.to_sym] = {}
57
+ @stack.last[name.to_sym].merge!(parsed_attributes)
58
+ @stack.last[name.to_sym]
59
+ end
60
+ @stack.push(data)
61
+ end
62
+ end
63
+ end
64
+ end
@@ -1,9 +1,11 @@
1
- require 'fog/xml/version'
2
- require 'nokogiri'
1
+ require "fog/xml/version"
2
+ require "nokogiri"
3
3
 
4
4
  module Fog
5
- module Xml
6
- autoload :SAXParserConnection, 'fog/xml/sax_parser_connection'
7
- autoload :Connection, 'fog/xml/connection'
5
+ autoload :ToHashDocument, "fog/to_hash_document"
6
+
7
+ module XML
8
+ autoload :SAXParserConnection, "fog/xml/sax_parser_connection"
9
+ autoload :Connection, "fog/xml/connection"
8
10
  end
9
11
  end
@@ -1,8 +1,9 @@
1
1
  module Fog
2
- module Xml
2
+ module XML
3
3
  class Connection < SAXParserConnection
4
- def request(params, &block)
5
- if (parser = params.delete(:parser))
4
+ def request(params, &_block)
5
+ parser = params.delete(:parser)
6
+ if parser
6
7
  super(parser, params)
7
8
  else
8
9
  original_request(params)
@@ -10,4 +11,4 @@ module Fog
10
11
  end
11
12
  end
12
13
  end
13
- end
14
+ end
@@ -1,18 +1,18 @@
1
- require 'fog/core/connection'
1
+ require "fog/core/connection"
2
2
 
3
3
  module Fog
4
- module Xml
4
+ module XML
5
5
  class SAXParserConnection < ::Fog::Core::Connection
6
6
  # Makes a request using the connection using Excon
7
7
  #
8
8
  # @param [Hash] params
9
9
  # @option params [String] :body text to be sent over a socket
10
10
  # @option params [Hash<Symbol, String>] :headers The default headers to supply in a request
11
- # @option params [String] :host The destination host's reachable DNS name or IP, in the form of a String
12
- # @option params [String] :path appears after 'scheme://host:port/'
11
+ # @option params [String] :host The destination host"s reachable DNS name or IP, in the form of a String
12
+ # @option params [String] :path appears after "scheme://host:port/"
13
13
  # @option params [Fixnum] :port The port on which to connect, to the destination host
14
- # @option params [Hash] :query appended to the 'scheme://host:port/path/' in the form of '?key=value'
15
- # @option params [String] :scheme The protocol; 'https' causes OpenSSL to be used
14
+ # @option params [Hash] :query appended to the "scheme://host:port/path/" in the form of "?key=value"
15
+ # @option params [String] :scheme The protocol; "https" causes OpenSSL to be used
16
16
  # @option params [Proc] :response_block
17
17
  # @option params [Nokogiri::XML::SAX::Document] :parser
18
18
  #
@@ -28,14 +28,14 @@ module Fog
28
28
  # Prepare the SAX parser
29
29
  data_stream = Nokogiri::XML::SAX::PushParser.new(parser)
30
30
  response_string = ""
31
- params[:response_block] = lambda do |chunk, remaining, total|
32
- response_string << chunk if ENV['DEBUG_RESPONSE']
31
+ params[:response_block] = lambda do |chunk, _remaining, _total|
32
+ response_string << chunk if ENV["DEBUG_RESPONSE"]
33
33
  data_stream << chunk
34
34
  end
35
35
 
36
36
  # Make request which read chunks into parser
37
37
  response = @excon.request(params)
38
- Fog::Logger.debug "\n#{response_string}" if ENV['DEBUG_RESPONSE']
38
+ Fog::Logger.debug "\n#{response_string}" if ENV["DEBUG_RESPONSE"]
39
39
 
40
40
  # Cease parsing and override response.body with parsed data
41
41
  data_stream.finish
@@ -44,4 +44,4 @@ module Fog
44
44
  end
45
45
  end
46
46
  end
47
- end
47
+ end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Xml
3
- VERSION = "0.0.1.alpha"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -0,0 +1,32 @@
1
+ require "minitest_helper"
2
+
3
+ describe Fog::XML::Connection do
4
+ before do
5
+ @connection = Fog::XML::Connection.new("http://localhost")
6
+ end
7
+
8
+ after do
9
+ Excon.stubs.clear
10
+ end
11
+
12
+ it "responds to #request" do
13
+ assert_respond_to @connection, :request
14
+ end
15
+
16
+ describe "when request is passed a parser" do
17
+ it "returns the body after parsing" do
18
+ @parser = Fog::ToHashDocument.new
19
+ Excon.stub({}, { :status => 200, :body => "<xml></xml>" })
20
+ response = @connection.request(:parser => @parser, :mock => true)
21
+ assert_equal({ :xml => "" }, response.body)
22
+ end
23
+ end
24
+
25
+ describe "when request excludes a parser" do
26
+ it "returns the response body without change" do
27
+ Excon.stub({}, { :status => 200, :body => "<xml></xml>" })
28
+ response = @connection.request(:mock => true)
29
+ assert_equal("<xml></xml>", response.body)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ require "minitest/spec"
2
+ require "minitest/autorun"
3
+ require "turn"
4
+ require "excon"
5
+ require "fog/core"
6
+
7
+ Turn.config do |c|
8
+ # use one of output formats:
9
+ # :outline - turn's original case/test outline mode [default]
10
+ # :progress - indicates progress with progress bar
11
+ # :dotted - test/unit's traditional dot-progress mode
12
+ # :pretty - new pretty reporter
13
+ # :marshal - dump output as YAML (normal run mode only)
14
+ # :cue - interactive testing
15
+ # c.format = :outline
16
+ # turn on invoke/execute tracing, enable full backtrace
17
+ c.trace = 20
18
+ # use humanized test names (works only with :outline format)
19
+ c.natural = true
20
+ end
21
+
22
+ if ENV["COVERAGE"]
23
+ require "coveralls"
24
+ require "simplecov"
25
+
26
+ SimpleCov.start do
27
+ add_filter "/spec/"
28
+ end
29
+ end
30
+
31
+ require File.join(File.dirname(__FILE__), "../lib/fog/xml")
32
+
33
+ Coveralls.wear! if ENV["COVERAGE"]
metadata CHANGED
@@ -1,14 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Paulo Henrique Lopes Ribeiro
7
+ - Wesley Beary (geemus)
8
+ - Paul Thornthwaite (tokengeek)
9
+ - The fog team
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2014-06-11 00:00:00.000000000 Z
13
+ date: 2014-09-26 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
16
  name: fog-core
@@ -59,7 +61,63 @@ dependencies:
59
61
  - !ruby/object:Gem::Version
60
62
  version: '0'
61
63
  - !ruby/object:Gem::Dependency
62
- name: rspec
64
+ name: minitest
65
+ requirement: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ - !ruby/object:Gem::Dependency
78
+ name: turn
79
+ requirement: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ type: :development
85
+ prerelease: false
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ - !ruby/object:Gem::Dependency
92
+ name: pry
93
+ requirement: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ type: :development
99
+ prerelease: false
100
+ version_requirements: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ - !ruby/object:Gem::Dependency
106
+ name: rubocop
107
+ requirement: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ type: :development
113
+ prerelease: false
114
+ version_requirements: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ - !ruby/object:Gem::Dependency
120
+ name: coveralls
63
121
  requirement: !ruby/object:Gem::Requirement
64
122
  requirements:
65
123
  - - ">="
@@ -75,14 +133,18 @@ dependencies:
75
133
  description: |-
76
134
  Extraction of the XML parsing tools shared between a
77
135
  number of providers in the 'fog' gem
78
- email: plribeiro3000@gmail.com
136
+ email:
137
+ - geemus@gmail.com
138
+ - tokengeek@gmail.com
79
139
  executables: []
80
140
  extensions: []
81
141
  extra_rdoc_files: []
82
142
  files:
83
143
  - ".gitignore"
144
+ - ".rubocop.yml"
84
145
  - ".ruby-gemset"
85
146
  - ".ruby-version"
147
+ - ".travis.yml"
86
148
  - CONTRIBUTING.md
87
149
  - CONTRIBUTORS.md
88
150
  - Gemfile
@@ -90,11 +152,16 @@ files:
90
152
  - README.md
91
153
  - Rakefile
92
154
  - fog-xml.gemspec
155
+ - gemfiles/Gemfile.1.8.7
156
+ - gemfiles/Gemfile.1.9.2+
157
+ - lib/fog/to_hash_document.rb
93
158
  - lib/fog/xml.rb
94
159
  - lib/fog/xml/connection.rb
95
160
  - lib/fog/xml/sax_parser_connection.rb
96
161
  - lib/fog/xml/version.rb
97
- homepage: https://github.com/zertico/fog-xml
162
+ - spec/fog/xml/connection_spec.rb
163
+ - spec/minitest_helper.rb
164
+ homepage: https://github.com/fog/fog-xml
98
165
  licenses:
99
166
  - MIT
100
167
  metadata: {}
@@ -109,13 +176,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
176
  version: '0'
110
177
  required_rubygems_version: !ruby/object:Gem::Requirement
111
178
  requirements:
112
- - - ">"
179
+ - - ">="
113
180
  - !ruby/object:Gem::Version
114
- version: 1.3.1
181
+ version: '0'
115
182
  requirements: []
116
183
  rubyforge_project:
117
184
  rubygems_version: 2.2.2
118
185
  signing_key:
119
186
  specification_version: 4
120
187
  summary: XML parsing for fog providers
121
- test_files: []
188
+ test_files:
189
+ - spec/fog/xml/connection_spec.rb
190
+ - spec/minitest_helper.rb