web-connect-rails 0.1.1

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.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1 -0
  3. data/lib/generators/web_connect/install/install_generator.rb +13 -0
  4. data/lib/generators/web_connect/install/templates/initializer.rb +43 -0
  5. data/lib/netfira/web_connect/rails/configuration.rb +23 -0
  6. data/lib/netfira/web_connect/rails/initializer.rb +41 -0
  7. data/lib/netfira/web_connect/rails/railtie.rb +14 -0
  8. data/lib/netfira/web_connect/rails/request_trap.rb +19 -0
  9. data/lib/netfira/web_connect/rails/version.rb +7 -0
  10. data/lib/tasks/tasks.rake +20 -0
  11. data/lib/web_connect_rails.rb +13 -0
  12. data/spec/dummy/Gemfile +8 -0
  13. data/spec/dummy/Gemfile.lock +140 -0
  14. data/spec/dummy/README.rdoc +28 -0
  15. data/spec/dummy/Rakefile +6 -0
  16. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  17. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  18. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  19. data/spec/dummy/app/controllers/info_controller.rb +2 -0
  20. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  21. data/spec/dummy/app/views/info/view.html +1 -0
  22. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  23. data/spec/dummy/bin/bundle +3 -0
  24. data/spec/dummy/bin/rails +4 -0
  25. data/spec/dummy/bin/rake +4 -0
  26. data/spec/dummy/config.ru +4 -0
  27. data/spec/dummy/config/application.rb +29 -0
  28. data/spec/dummy/config/boot.rb +5 -0
  29. data/spec/dummy/config/database.yml +30 -0
  30. data/spec/dummy/config/environment.rb +5 -0
  31. data/spec/dummy/config/environments/development.rb +37 -0
  32. data/spec/dummy/config/environments/production.rb +83 -0
  33. data/spec/dummy/config/environments/test.rb +39 -0
  34. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  35. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  36. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  37. data/spec/dummy/config/initializers/inflections.rb +16 -0
  38. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  39. data/spec/dummy/config/initializers/session_store.rb +3 -0
  40. data/spec/dummy/config/initializers/web_connect.rb +43 -0
  41. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  42. data/spec/dummy/config/locales/en.yml +23 -0
  43. data/spec/dummy/config/routes.rb +62 -0
  44. data/spec/dummy/config/secrets.yml +22 -0
  45. data/spec/dummy/db/development.sqlite3 +0 -0
  46. data/spec/dummy/db/schema.rb +236 -0
  47. data/spec/dummy/db/test.sqlite3 +0 -0
  48. data/spec/dummy/db/wc_test.sqlite3 +0 -0
  49. data/spec/dummy/log/development.log +129 -0
  50. data/spec/dummy/log/test.log +457 -0
  51. data/spec/dummy/public/404.html +67 -0
  52. data/spec/dummy/public/422.html +67 -0
  53. data/spec/dummy/public/500.html +66 -0
  54. data/spec/dummy/public/favicon.ico +0 -0
  55. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  56. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  57. data/spec/dummy/tmp/cache/assets/test/sprockets/30fcdba934c852043bf90977fbe7cd41 +0 -0
  58. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  59. data/spec/dummy/tmp/cache/assets/test/sprockets/563c7c80a43c918ab182fbb055ca0d09 +0 -0
  60. data/spec/dummy/tmp/cache/assets/test/sprockets/595588477bd1d6985164b36ebf27d467 +0 -0
  61. data/spec/dummy/tmp/cache/assets/test/sprockets/7fe8ec92b30b7e2f688c3a91157c5eb3 +0 -0
  62. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  63. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  64. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  65. data/spec/features/passthru_spec.rb +14 -0
  66. data/spec/spec_helper.rb +28 -0
  67. metadata +234 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 73c737c4d369e6a8d3f964f9425675d7ce74c833
4
+ data.tar.gz: 064605e95ea9a6670569289ea225ba77d4df957a
5
+ SHA512:
6
+ metadata.gz: 823c22989f50c57104f200d72274773b027e1e95cdf061c1fb4a22f33a29801c1cd201ec709473aff91135d101a145c4d5224d95815d2c85f11e72744eedc09f
7
+ data.tar.gz: b9ac5a6ab31e072eeda124dab77f05d2a43aa86c60219bb44ab03cd897dfad1a255c2d9140f34369a83c4ddf4b2feb6f7a692ef77646ba854246f302b118e68a
data/README.md ADDED
@@ -0,0 +1 @@
1
+ This gem adds WebConnect support to existing Rails apps.
@@ -0,0 +1,13 @@
1
+ module WebConnect
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ def copy_initializer
8
+ template 'initializer.rb', 'config/initializers/web_connect.rb'
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,43 @@
1
+ Netfira::WebConnect::Rails.configure do |config|
2
+
3
+ # This will be WebConnect's URI namespace. All requests with this
4
+ # prefix will be routed to WebConnect, e.g. /webconnect/8/info
5
+ config.uri_namespace = 'webconnect'
6
+
7
+ # By default, WebConnect will use the host application's database.
8
+ # Uncomment this section if you want to use a different database.
9
+ # config.db = {
10
+ # adapter: 'sqlite3',
11
+ # database: "#{Rails.root}/db/wc_#{Rails.env}.sqlite3"
12
+ # }
13
+
14
+ # Tables created by WebConnect will be prefixed with this string.
15
+ # You can remove this option if WebConnect isn't sharing the host
16
+ # application's database.
17
+ config.db_table_prefix = 'wc_'
18
+
19
+ # WebConnect uses Paperclip for file storage. The hash below will
20
+ # be provided to Paperclip to determine where and how files are
21
+ # stored. If you remove the option completely, files will not be
22
+ # stored at all.
23
+ #
24
+ # WebConnect adds two additional interpolations for generating paths:
25
+ # :shop_id The ID of the shop that owns the file
26
+ # :model_type The type of file (plural), e.g. images, attachments
27
+ #
28
+ # See http://rdoc.info/gems/paperclip for specifics.
29
+ config.file_store = {
30
+ path: ':rails_root/public/system/uploaded_files/shop_:shop_id/:model_type/:filename'
31
+ }
32
+
33
+ # This callback will be used to authenticate incoming requests.
34
+ # Pass a block or proc that accepts two arguments (shop name and
35
+ # password), and returns true/false for success/fail.
36
+ #
37
+ # Your handler may also return a string that clients should use as
38
+ # a password in subsequent requests.
39
+ config.on_authenticate do |shop_name, password|
40
+ !shop_name.nil? && !password.nil?
41
+ end
42
+
43
+ end
@@ -0,0 +1,23 @@
1
+ require 'forwardable'
2
+
3
+ module Netfira::WebConnect::Rails
4
+
5
+ class Configuration
6
+ attr_accessor :uri_namespace
7
+
8
+ %i[db_table_prefix= db= file_store= on_authenticate].each do |property|
9
+ define_method property do |*args, &block|
10
+ Netfira::WebConnect.configure do |c|
11
+ c.__send__ property, *args, &block
12
+ end
13
+ end
14
+ end
15
+
16
+ end
17
+
18
+ class << self
19
+ extend Forwardable
20
+ delegate %i[uri_namespace] => :@config
21
+ end
22
+
23
+ end
@@ -0,0 +1,41 @@
1
+ module Netfira::WebConnect::Rails
2
+
3
+ def self.initialize!
4
+ @config = Configuration.new
5
+
6
+ # Read end-user configuration data, which may include database connection details
7
+ # This will fail if the end-user hasn't run rails generate web_connect:install
8
+ begin
9
+ require Rails.root + 'config/initializers/web_connect'
10
+ rescue LoadError
11
+ raise 'To complete installation of WebConnect, run: rails generate web_connect:install'
12
+ end
13
+
14
+ # Add additional configuration to the web-connect gem
15
+ Netfira::WebConnect.configure do |c|
16
+
17
+ # Use a blank string as the default table prefix
18
+ c.db_table_prefix ||= ''
19
+
20
+ # Sharing the host app's DB with no table prefix will cause collisions in the
21
+ # schema_migrations table, and possibly other tables.
22
+ raise 'WebConnect cannot share the host application database without a table prefix.' if !c.db && c.db_table_prefix.empty?
23
+
24
+ # Use the default rails logger
25
+ c.logger = Rails.logger
26
+
27
+ # Use the Rails database connection if none was specified by the end-user
28
+ c.db ||= Rails.configuration.database_configuration[Rails.env]
29
+ end
30
+
31
+ # Ensure database is properly migrated, except when running rake tasks
32
+ if File.basename($0) != 'rake' && Netfira::WebConnect.needs_migration?
33
+ raise 'WebConnect has pending database migrations. Please run rake wc:migrate'
34
+ end
35
+ end
36
+
37
+ def self.configure
38
+ yield @config
39
+ end
40
+
41
+ end
@@ -0,0 +1,14 @@
1
+ module Netfira::WebConnect::Rails
2
+ class Railtie < ::Rails::Railtie
3
+
4
+ initializer 'web_connect_rails.init' do |app|
5
+ app.middleware.insert_before ActionDispatch::Cookies, RequestTrap
6
+ Netfira::WebConnect::Rails.initialize!
7
+ end
8
+
9
+ rake_tasks do
10
+ load GEM_ROOT + 'tasks/tasks.rake'
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,19 @@
1
+ module Netfira::WebConnect::Rails
2
+ class RequestTrap
3
+
4
+ def initialize(app)
5
+ @rails = app
6
+ @wc = Netfira::WebConnect::RequestFilter.new Netfira::WebConnect::RackApp.new
7
+ end
8
+
9
+ def call(env)
10
+ uri_namespace = Netfira::WebConnect::Rails.uri_namespace
11
+ if uri_namespace && !env['PATH_INFO'][1..-1].start_with?(uri_namespace)
12
+ @rails.call env
13
+ else
14
+ @wc.call env
15
+ end
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ module Netfira
2
+ module WebConnect
3
+ module Rails
4
+ VERSION = '0.1.1'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ namespace :wc do
2
+
3
+ desc 'Migrate the WebConnect database'
4
+ task :migrate do
5
+ migration :migrate
6
+ end
7
+
8
+ desc 'Rollback the WebConnect database'
9
+ task :rollback do
10
+ migration :rollback
11
+ end
12
+
13
+ def migration(action)
14
+ Netfira::WebConnect::Rails.initialize!
15
+ require Rails.root + 'config/initializers/web_connect'
16
+ Netfira::WebConnect::Migration.log_to_stdout = true
17
+ Netfira::WebConnect.__send__ action
18
+ end
19
+
20
+ end
@@ -0,0 +1,13 @@
1
+ require 'web_connect'
2
+
3
+ module Netfira::WebConnect
4
+ module Rails
5
+ GEM_ROOT = Pathname(__FILE__).parent
6
+ end
7
+ end
8
+
9
+ require_relative 'netfira/web_connect/rails/version'
10
+ require_relative 'netfira/web_connect/rails/railtie'
11
+ require_relative 'netfira/web_connect/rails/request_trap'
12
+ require_relative 'netfira/web_connect/rails/configuration'
13
+ require_relative 'netfira/web_connect/rails/initializer'
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '~> 4.1'
4
+ gem 'rspec-rails', '3.0.0.beta2'
5
+ # gem 'web-connect', git: 'git@github.com:netfira/web-connect'
6
+ gem 'web-connect', path: File.expand_path('../../../../web-connect', __FILE__)
7
+ gem 'web-connect-rails', path: File.expand_path('../../..', __FILE__)
8
+ gem 'sqlite3'
@@ -0,0 +1,140 @@
1
+ PATH
2
+ remote: /Users/Neil/Documents/github.com/netfira/web-connect
3
+ specs:
4
+ web-connect (0.1.0)
5
+ activerecord (~> 4.1)
6
+ fastimage (~> 1.6)
7
+ locale (~> 2.1)
8
+ paperclip (~> 4.1)
9
+ rack (~> 1.5)
10
+
11
+ PATH
12
+ remote: /Users/Neil/Documents/github.com/netfira/web-connect-rails
13
+ specs:
14
+ web-connect-rails (0.1.1)
15
+ rails (~> 4.1.0.rc2)
16
+ web-connect
17
+
18
+ GEM
19
+ remote: https://rubygems.org/
20
+ specs:
21
+ actionmailer (4.1.1)
22
+ actionpack (= 4.1.1)
23
+ actionview (= 4.1.1)
24
+ mail (~> 2.5.4)
25
+ actionpack (4.1.1)
26
+ actionview (= 4.1.1)
27
+ activesupport (= 4.1.1)
28
+ rack (~> 1.5.2)
29
+ rack-test (~> 0.6.2)
30
+ actionview (4.1.1)
31
+ activesupport (= 4.1.1)
32
+ builder (~> 3.1)
33
+ erubis (~> 2.7.0)
34
+ activemodel (4.1.1)
35
+ activesupport (= 4.1.1)
36
+ builder (~> 3.1)
37
+ activerecord (4.1.1)
38
+ activemodel (= 4.1.1)
39
+ activesupport (= 4.1.1)
40
+ arel (~> 5.0.0)
41
+ activesupport (4.1.1)
42
+ i18n (~> 0.6, >= 0.6.9)
43
+ json (~> 1.7, >= 1.7.7)
44
+ minitest (~> 5.1)
45
+ thread_safe (~> 0.1)
46
+ tzinfo (~> 1.1)
47
+ addressable (2.3.6)
48
+ arel (5.0.1.20140414130214)
49
+ builder (3.2.2)
50
+ climate_control (0.0.3)
51
+ activesupport (>= 3.0)
52
+ cocaine (0.5.4)
53
+ climate_control (>= 0.0.3, < 1.0)
54
+ diff-lcs (1.2.5)
55
+ erubis (2.7.0)
56
+ fastimage (1.6.2)
57
+ addressable (~> 2.3, >= 2.3.5)
58
+ hike (1.2.3)
59
+ i18n (0.6.9)
60
+ json (1.8.1)
61
+ locale (2.1.0)
62
+ mail (2.5.4)
63
+ mime-types (~> 1.16)
64
+ treetop (~> 1.4.8)
65
+ mime-types (1.25.1)
66
+ minitest (5.3.4)
67
+ multi_json (1.10.1)
68
+ paperclip (4.1.1)
69
+ activemodel (>= 3.0.0)
70
+ activesupport (>= 3.0.0)
71
+ cocaine (~> 0.5.3)
72
+ mime-types
73
+ polyglot (0.3.5)
74
+ rack (1.5.2)
75
+ rack-test (0.6.2)
76
+ rack (>= 1.0)
77
+ rails (4.1.1)
78
+ actionmailer (= 4.1.1)
79
+ actionpack (= 4.1.1)
80
+ actionview (= 4.1.1)
81
+ activemodel (= 4.1.1)
82
+ activerecord (= 4.1.1)
83
+ activesupport (= 4.1.1)
84
+ bundler (>= 1.3.0, < 2.0)
85
+ railties (= 4.1.1)
86
+ sprockets-rails (~> 2.0)
87
+ railties (4.1.1)
88
+ actionpack (= 4.1.1)
89
+ activesupport (= 4.1.1)
90
+ rake (>= 0.8.7)
91
+ thor (>= 0.18.1, < 2.0)
92
+ rake (10.3.2)
93
+ rspec-collection_matchers (0.0.4)
94
+ rspec-expectations (>= 2.99.0.beta1)
95
+ rspec-core (3.0.0.beta2)
96
+ rspec-support (= 3.0.0.beta2)
97
+ rspec-expectations (3.0.0.beta2)
98
+ diff-lcs (>= 1.2.0, < 2.0)
99
+ rspec-support (= 3.0.0.beta2)
100
+ rspec-mocks (3.0.0.beta2)
101
+ rspec-support (= 3.0.0.beta2)
102
+ rspec-rails (3.0.0.beta2)
103
+ actionpack (>= 3.0)
104
+ activemodel (>= 3.0)
105
+ activesupport (>= 3.0)
106
+ railties (>= 3.0)
107
+ rspec-collection_matchers
108
+ rspec-core (= 3.0.0.beta2)
109
+ rspec-expectations (= 3.0.0.beta2)
110
+ rspec-mocks (= 3.0.0.beta2)
111
+ rspec-support (= 3.0.0.beta2)
112
+ rspec-support (3.0.0.beta2)
113
+ sprockets (2.12.1)
114
+ hike (~> 1.2)
115
+ multi_json (~> 1.0)
116
+ rack (~> 1.0)
117
+ tilt (~> 1.1, != 1.3.0)
118
+ sprockets-rails (2.1.3)
119
+ actionpack (>= 3.0)
120
+ activesupport (>= 3.0)
121
+ sprockets (~> 2.8)
122
+ sqlite3 (1.3.9)
123
+ thor (0.19.1)
124
+ thread_safe (0.3.4)
125
+ tilt (1.4.1)
126
+ treetop (1.4.15)
127
+ polyglot
128
+ polyglot (>= 0.3.1)
129
+ tzinfo (1.2.1)
130
+ thread_safe (~> 0.1)
131
+
132
+ PLATFORMS
133
+ ruby
134
+
135
+ DEPENDENCIES
136
+ rails (~> 4.1)
137
+ rspec-rails (= 3.0.0.beta2)
138
+ sqlite3
139
+ web-connect!
140
+ web-connect-rails!
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end