conduit 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -21
  3. data/lib/conduit.rb +4 -6
  4. data/lib/conduit/configuration.rb +20 -31
  5. data/lib/conduit/core/action.rb +15 -2
  6. data/lib/conduit/core/connection.rb +3 -1
  7. data/lib/conduit/core/parser.rb +7 -3
  8. data/lib/conduit/storage.rb +2 -2
  9. data/lib/conduit/version.rb +1 -1
  10. data/lib/tmp/conduit/1/fusion/activate/request.xml +26 -0
  11. data/lib/tmp/conduit/1/fusion/change_device/request.xml +15 -0
  12. data/lib/tmp/conduit/1/fusion/change_number/request.xml +14 -0
  13. data/lib/tmp/conduit/1/fusion/deactivate/request.xml +14 -0
  14. data/lib/tmp/conduit/1/fusion/purchase/1-response.xml +1 -0
  15. data/lib/tmp/conduit/1/fusion/purchase/request.xml +15 -0
  16. data/lib/tmp/conduit/1/fusion/query_subscription/1-response.xml +1 -0
  17. data/lib/tmp/conduit/1/fusion/query_subscription/request.xml +15 -0
  18. data/lib/tmp/conduit/1/fusion/reset_voicemail/request.xml +14 -0
  19. data/lib/tmp/conduit/1/fusion/restore/request.xml +14 -0
  20. data/lib/tmp/conduit/1/fusion/suspend/request.xml +15 -0
  21. data/lib/tmp/conduit/2/fusion/purchase/request.xml +15 -0
  22. data/lib/tmp/conduit/3/fusion/activate/request.xml +26 -0
  23. data/lib/tmp/conduit/4/fusion/activate/request.xml +26 -0
  24. data/lib/tmp/conduit/5/fusion/activate/request.xml +26 -0
  25. data/lib/tmp/conduit/6/fusion/activate/request.xml +26 -0
  26. data/lib/tmp/conduit/7/fusion/activate/request.xml +26 -0
  27. data/lib/tmp/conduit/8/fusion/activate/request.xml +26 -0
  28. data/lib/tmp/conduit/9/fusion/activate/request.xml +26 -0
  29. data/spec/classes/core/action_spec.rb +11 -2
  30. data/spec/classes/core/parser_spec.rb +52 -0
  31. data/spec/spec_helper.rb +13 -17
  32. data/spec/{dummy/lib/conduit/drivers → support}/my_driver/actions/foo.rb +0 -0
  33. data/spec/{dummy/lib/conduit/drivers → support}/my_driver/driver.rb +0 -0
  34. data/spec/support/my_driver/parsers/foo.rb +75 -0
  35. data/spec/{dummy/lib/conduit/drivers → support}/my_driver/views/foo.erb +0 -0
  36. data/spec/{dummy/lib/conduit/drivers → support}/my_driver/views/layout.erb +0 -0
  37. data/spec/support/xml/xml_response.xml +3 -0
  38. metadata +45 -140
  39. data/app/controllers/conduit/responses_controller.rb +0 -14
  40. data/app/models/conduit/concerns/storage.rb +0 -41
  41. data/app/models/conduit/request.rb +0 -111
  42. data/app/models/conduit/response.rb +0 -50
  43. data/app/models/conduit/subscription.rb +0 -6
  44. data/config/routes.rb +0 -3
  45. data/db/migrate/20131209223122_create_conduit_requests.rb +0 -13
  46. data/db/migrate/20131209223734_create_conduit_responses.rb +0 -10
  47. data/db/migrate/20140305202729_create_conduit_subscriptions.rb +0 -12
  48. data/lib/conduit/acts_as_conduit_subscriber.rb +0 -41
  49. data/lib/conduit/engine.rb +0 -20
  50. data/lib/tasks/conduit_tasks.rake +0 -4
  51. data/spec/classes/acts_as_conduit_subscriber_spec.rb +0 -61
  52. data/spec/controllers/responses_controller_spec.rb +0 -29
  53. data/spec/dummy/README.rdoc +0 -28
  54. data/spec/dummy/Rakefile +0 -6
  55. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  56. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  57. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  58. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  59. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  60. data/spec/dummy/bin/bundle +0 -3
  61. data/spec/dummy/bin/rails +0 -4
  62. data/spec/dummy/bin/rake +0 -4
  63. data/spec/dummy/config.ru +0 -4
  64. data/spec/dummy/config/application.rb +0 -29
  65. data/spec/dummy/config/boot.rb +0 -5
  66. data/spec/dummy/config/database.yml +0 -12
  67. data/spec/dummy/config/environment.rb +0 -5
  68. data/spec/dummy/config/environments/development.rb +0 -29
  69. data/spec/dummy/config/environments/production.rb +0 -80
  70. data/spec/dummy/config/environments/test.rb +0 -36
  71. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  72. data/spec/dummy/config/initializers/conduit.rb +0 -5
  73. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  74. data/spec/dummy/config/initializers/inflections.rb +0 -16
  75. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  76. data/spec/dummy/config/initializers/secret_token.rb +0 -12
  77. data/spec/dummy/config/initializers/session_store.rb +0 -3
  78. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  79. data/spec/dummy/config/locales/en.yml +0 -23
  80. data/spec/dummy/config/routes.rb +0 -3
  81. data/spec/dummy/db/test.sqlite3 +0 -0
  82. data/spec/dummy/db/test.sqlite3-journal +0 -0
  83. data/spec/dummy/lib/conduit/drivers/my_driver/parsers/foo.rb +0 -13
  84. data/spec/dummy/log/test.log +0 -6
  85. data/spec/dummy/public/404.html +0 -58
  86. data/spec/dummy/public/422.html +0 -58
  87. data/spec/dummy/public/500.html +0 -57
  88. data/spec/models/conduit/request_spec.rb +0 -50
  89. data/spec/models/conduit/response_spec.rb +0 -52
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e34d56c273595e949bea0c5509651da47705ada
4
- data.tar.gz: 12f18151f2eb3d818daf4686490ec5e1e4c68916
3
+ metadata.gz: af1d024fb9a7e5f85f761488ce3383d52ccd8aa5
4
+ data.tar.gz: 260eacac8657722ecc0031cee7cd994b8ec35ba4
5
5
  SHA512:
6
- metadata.gz: b95ed2e1e6b02ec0b9978036a24c8207a39d23d2d4f9cd356970ae3ea274bf6ac1c8c1e965613c3b1bcb98355da9b02e3d497197b1f93a7831b94a571f265380
7
- data.tar.gz: 9a1d1e0f2c63d318a263356643391c90a9a49fdd0f9926a29c8cd079d952dc9ea1b4cb6f74001596650c1c4d154133318bffc0f8399874080872fe6e96cb0053
6
+ metadata.gz: 097c154b6dad1c386735896f4473cfea65cd3e8ebf75e0ef1151e51047c37db6e316427be0a4314d04da5e519978597f3c714fdb33c38cb22e8e07a430c27cca
7
+ data.tar.gz: 8c1cb2ed064f8c01aaaf2fae3d01b8857ba15b972b2ecefdf298e83c56d21e9bbcb4a787eb20ccc49f56a04037b60f7db104e30fa1decbb2230abeeaca161a9c
data/Rakefile CHANGED
@@ -1,22 +1,2 @@
1
- begin
2
- require 'bundler/setup'
3
- rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
- end
1
+ require "bundler/gem_tasks"
6
2
 
7
- require 'rdoc/task'
8
-
9
- RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'Foo'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.rdoc')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
15
- end
16
-
17
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
- load 'rails/tasks/engine.rake'
19
-
20
-
21
-
22
- Bundler::GemHelper.install_tasks
@@ -1,15 +1,13 @@
1
- require 'conduit/engine'
2
- require 'conduit/acts_as_conduit_subscriber'
1
+ $:.unshift File.dirname(__FILE__)
3
2
 
4
- module Conduit
3
+ require 'conduit/configuration'
5
4
 
6
- mattr_accessor :app_root
5
+ module Conduit
7
6
 
8
7
  # Autoload the Conduit base classes
9
8
  # NOTE: Autoloading should be
10
9
  # concurrency-safe
11
10
  #
12
- autoload :Configuration, 'conduit/configuration'
13
11
  autoload :Storage, 'conduit/storage'
14
12
  autoload :Util, 'conduit/util'
15
13
 
@@ -43,7 +41,7 @@ module Conduit
43
41
  # Load the drivers automatically, but only when they're needed
44
42
  #
45
43
  def load_drivers
46
- Conduit::Configuration.driver_paths.each do |dir|
44
+ Conduit.configuration.driver_paths.each do |dir|
47
45
  raise "Directory not found: #{dir}" unless File.exists?(dir)
48
46
  Dir["#{dir}/**/driver.rb"].each do |file|
49
47
  raise "File not found: #{file}" unless File.exists?(file)
@@ -4,40 +4,29 @@
4
4
  #
5
5
 
6
6
  module Conduit
7
- module Configuration
8
- class << self
7
+ class << self
8
+ attr_accessor :configuration
9
+ end
9
10
 
10
- #
11
- # Storage
12
- #
13
- # Define the storage configuration. This could
14
- # include anything from file paths, to
15
- # service credentials, and provider
16
- #
17
- mattr_accessor :storage_config
18
- self.storage_config = {
19
- provider: :file,
20
- file_path: Conduit.app_root.join('tmp', 'conduit')
21
- }
11
+ def self.configuration
12
+ @configuration ||= Configuration.new
13
+ end
22
14
 
23
- #
24
- # Drivers
25
- #
26
- # Define the driver load path
27
- # Define an array of drivers to load
28
- #
29
- mattr_accessor :driver_paths
30
- self.driver_paths = ["#{File.dirname(__FILE__)}/drivers"]
15
+ def self.configure(&block)
16
+ yield configuration
17
+ end
31
18
 
32
- #
33
- # Methods
34
- #
35
- # Read in the configuration
36
- #
37
- def configure(&block)
38
- yield self
39
- end
19
+ class Configuration
20
+ attr_accessor :storage_config, :driver_paths
21
+
22
+ def storage
23
+ path = File.join(__dir__, '../', 'tmp', 'conduit')
24
+ @storage_config ||= { provider: :file, file_path: path }
25
+ end
40
26
 
27
+ def driver_paths
28
+ default_path = "#{File.dirname(__FILE__)}/drivers"
29
+ @driver_paths ||= Array(default_path)
41
30
  end
42
31
  end
43
- end
32
+ end
@@ -12,6 +12,9 @@
12
12
  # => action.perform
13
13
  #
14
14
 
15
+ require 'active_support/inflector'
16
+ require 'forwardable'
17
+ require 'ostruct'
15
18
  require 'set'
16
19
 
17
20
  module Conduit
@@ -72,14 +75,24 @@ module Conduit
72
75
  end
73
76
 
74
77
  module InstanceMethods
75
-
76
- delegate :requirements, :attributes, to: :class
78
+ extend Forwardable
77
79
 
78
80
  def initialize(**options)
79
81
  @options = options
80
82
  validate!(options)
81
83
  end
82
84
 
85
+ def_delegator :'self.class', :requirements
86
+ def_delegator :'self.class', :attributes
87
+
88
+ # def requirements
89
+ # self.class.requirements
90
+ # end
91
+
92
+ # def attributes
93
+ # self.class.attributes
94
+ # end
95
+
83
96
  # Object used for passing data to the view
84
97
  # Only keys listed in attributes will be
85
98
  # used.
@@ -4,6 +4,7 @@
4
4
  #
5
5
 
6
6
  require 'conduit/version'
7
+ require 'forwardable'
7
8
  require 'excon'
8
9
 
9
10
  module Conduit
@@ -29,8 +30,9 @@ module Conduit
29
30
  end
30
31
 
31
32
  module InstanceMethods
33
+ extend Forwardable
32
34
 
33
- delegate :remote_url, to: :class
35
+ def_delegator :'self.class', :remote_url
34
36
 
35
37
  # Make a request
36
38
  #
@@ -3,9 +3,14 @@
3
3
  # and provide parsed attributes that can be
4
4
  # predictably consumed.
5
5
  #
6
+
7
+ require 'forwardable'
8
+ require 'set'
9
+
6
10
  module Conduit
7
11
  module Core
8
12
  class Parser
13
+ extend Forwardable
9
14
 
10
15
  class << self
11
16
 
@@ -20,12 +25,12 @@ module Conduit
20
25
  # Storage array for all attributes
21
26
  #
22
27
  def attributes
23
- @attributes ||= []
28
+ @attributes ||= Set.new
24
29
  end
25
30
 
26
31
  end
27
32
 
28
- delegate :attributes, to: :class
33
+ def_delegator :'self.class', :attributes
29
34
 
30
35
  # Returns a hash representation of each attribute
31
36
  # defined in a parser and its value.
@@ -49,7 +54,6 @@ module Conduit
49
54
  def response_errors
50
55
  raise NoMethodError, "Please define response_errors in your parser."
51
56
  end
52
-
53
57
  end
54
58
  end
55
59
  end
@@ -17,14 +17,14 @@ module Conduit
17
17
  # config/initializers/conduit.rb
18
18
  #
19
19
  def self.config
20
- Configuration.storage_config
20
+ Conduit.configuration.storage
21
21
  end
22
22
 
23
23
  # Get the name of the chosen provider
24
24
  # from the configuration
25
25
  #
26
26
  def self.provider
27
- Configuration.storage_config[:provider]
27
+ Conduit.configuration.storage[:provider]
28
28
  end
29
29
 
30
30
  # Load in the functionality for the storage provider
@@ -1,3 +1,3 @@
1
1
  module Conduit
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -0,0 +1,26 @@
1
+ <BeQuick product="OSS">
2
+ <session>
3
+ <clec>
4
+ <id>100</id>
5
+ <agentUser>
6
+ <username>foo</username>
7
+ <token>bar</token>
8
+ </agentUser>
9
+ </clec>
10
+ </session>
11
+ <request type="WirelessActivate">
12
+ <activity_type>NEW</activity_type>
13
+ <planId>1234</planId>
14
+ <esn>12345678935</esn>
15
+ <physicalAddress>
16
+ <firstName></firstName>
17
+ <lastName></lastName>
18
+ <address1></address1>
19
+ <address2></address2>
20
+ <city></city>
21
+ <state></state>
22
+ <zip>33410</zip>
23
+ </physicalAddress>
24
+ </request>
25
+
26
+ </BeQuick>
@@ -0,0 +1,15 @@
1
+ <BeQuick product="OSS">
2
+ <session>
3
+ <clec>
4
+ <id>100</id>
5
+ <agentUser>
6
+ <username>foo</username>
7
+ <token>bar</token>
8
+ </agentUser>
9
+ </clec>
10
+ </session>
11
+ <request type="SwapESN">
12
+ <mdn></mdn>
13
+ <newESN>12345678902</newESN>
14
+ </request>
15
+ </BeQuick>
@@ -0,0 +1,14 @@
1
+ <BeQuick product="OSS">
2
+ <session>
3
+ <clec>
4
+ <id>100</id>
5
+ <agentUser>
6
+ <username>foo</username>
7
+ <token>bar</token>
8
+ </agentUser>
9
+ </clec>
10
+ </session>
11
+ <request type="SwapMDN">
12
+ <mdn></mdn>
13
+ </request>
14
+ </BeQuick>
@@ -0,0 +1,14 @@
1
+ <BeQuick product="OSS">
2
+ <session>
3
+ <clec>
4
+ <id>100</id>
5
+ <agentUser>
6
+ <username>foo</username>
7
+ <token>bar</token>
8
+ </agentUser>
9
+ </clec>
10
+ </session>
11
+ <request type="WirelessDisconnect">
12
+ <mdn></mdn>
13
+ </request>
14
+ </BeQuick>
@@ -0,0 +1 @@
1
+ <BeQuick product="OSS"><response timestamp="20131121134653" status="success" type="WirelessPurchaseResponse" /><session><clec><overrides></overrides><id>227</id></clec><timestamp>20131121134637</timestamp><id></id></session></BeQuick>
@@ -0,0 +1,15 @@
1
+ <BeQuick product="OSS">
2
+ <session>
3
+ <clec>
4
+ <id>213</id>
5
+ <agentUser>
6
+ <username>apiuser</username>
7
+ <token>YSIZ8MRS2M6RSFY</token>
8
+ </agentUser>
9
+ </clec>
10
+ </session>
11
+ <request type="WirelessPurchase">
12
+ <mdn>8658248958</mdn>
13
+ <planId>1</planId>
14
+ </request>
15
+ </BeQuick>
@@ -0,0 +1 @@
1
+ #<File:0x007fe7aa225710>
@@ -0,0 +1,15 @@
1
+ <BeQuick product="OSS">
2
+ <session>
3
+ <clec>
4
+ <id>100</id>
5
+ <agentUser>
6
+ <username>foo</username>
7
+ <token>bar</token>
8
+ </agentUser>
9
+ </clec>
10
+ </session>
11
+ <request type="GetServiceInfo">
12
+ <mdn></mdn>
13
+ </request>
14
+
15
+ </BeQuick>
@@ -0,0 +1,14 @@
1
+ <BeQuick product="OSS">
2
+ <session>
3
+ <clec>
4
+ <id>100</id>
5
+ <agentUser>
6
+ <username>foo</username>
7
+ <token>bar</token>
8
+ </agentUser>
9
+ </clec>
10
+ </session>
11
+ <request type="WirelessVoiceMailRequest">
12
+ <mdn></mdn>
13
+ </request>
14
+ </BeQuick>
@@ -0,0 +1,14 @@
1
+ <BeQuick product="OSS">
2
+ <session>
3
+ <clec>
4
+ <id>100</id>
5
+ <agentUser>
6
+ <username>foo</username>
7
+ <token>bar</token>
8
+ </agentUser>
9
+ </clec>
10
+ </session>
11
+ <request type="WirelessRestore">
12
+ <mdn></mdn>
13
+ </request>
14
+ </BeQuick>
@@ -0,0 +1,15 @@
1
+ <BeQuick product="OSS">
2
+ <session>
3
+ <clec>
4
+ <id>100</id>
5
+ <agentUser>
6
+ <username>foo</username>
7
+ <token>bar</token>
8
+ </agentUser>
9
+ </clec>
10
+ </session>
11
+ <request type="WirelessSuspend">
12
+ <mdn></mdn>
13
+ </request>
14
+
15
+ </BeQuick>
@@ -0,0 +1,15 @@
1
+ <BeQuick product="OSS">
2
+ <session>
3
+ <clec>
4
+ <id>100</id>
5
+ <agentUser>
6
+ <username>foo</username>
7
+ <token>bar</token>
8
+ </agentUser>
9
+ </clec>
10
+ </session>
11
+ <request type="WirelessPurchase">
12
+ <mdn></mdn>
13
+ <planId>1234</planId>
14
+ </request>
15
+ </BeQuick>
@@ -0,0 +1,26 @@
1
+ <BeQuick product="OSS">
2
+ <session>
3
+ <clec>
4
+ <id>100</id>
5
+ <agentUser>
6
+ <username>foo</username>
7
+ <token>bar</token>
8
+ </agentUser>
9
+ </clec>
10
+ </session>
11
+ <request type="WirelessActivate">
12
+ <activity_type>NEW</activity_type>
13
+ <planId>1234</planId>
14
+ <esn>12345678937</esn>
15
+ <physicalAddress>
16
+ <firstName></firstName>
17
+ <lastName></lastName>
18
+ <address1></address1>
19
+ <address2></address2>
20
+ <city></city>
21
+ <state></state>
22
+ <zip>33410</zip>
23
+ </physicalAddress>
24
+ </request>
25
+
26
+ </BeQuick>