Import command and naive server
Rodrigo Alvarez
committed Dec 14, 2012
commit 21f4a68ffcaa0eaa9b8faa46a78d3176cd938007
Showing 20
changed files with
608 additions
and 0 deletions
.gitignore
+18
-0
| @@ | @@ -0,0 +1,18 @@ |
| + | site |
| + | *.gem |
| + | *.rbc |
| + | .bundle |
| + | .config |
| + | .yardoc |
| + | Gemfile.lock |
| + | InstalledFiles |
| + | _yardoc |
| + | coverage |
| + | doc/ |
| + | lib/bundler/man |
| + | pkg |
| + | rdoc |
| + | spec/reports |
| + | test/tmp |
| + | test/version_tmp |
| + | tmp |
Gemfile
+5
-0
| @@ | @@ -0,0 +1,5 @@ |
| + | source 'https://rubygems.org' |
| + | |
| + | # Specify your gem's dependencies in steam.gemspec |
| + | gemspec |
| + | gem 'locomotivecms_mounter', path: '../mounter' |
| \ No newline at end of file | |
LICENSE.txt
+22
-0
| @@ | @@ -0,0 +1,22 @@ |
| + | Copyright (c) 2012 Rodrigo Alvarez |
| + | |
| + | MIT License |
| + | |
| + | Permission is hereby granted, free of charge, to any person obtaining |
| + | a copy of this software and associated documentation files (the |
| + | "Software"), to deal in the Software without restriction, including |
| + | without limitation the rights to use, copy, modify, merge, publish, |
| + | distribute, sublicense, and/or sell copies of the Software, and to |
| + | permit persons to whom the Software is furnished to do so, subject to |
| + | the following conditions: |
| + | |
| + | The above copyright notice and this permission notice shall be |
| + | included in all copies or substantial portions of the Software. |
| + | |
| + | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| + | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| + | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| + | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| + | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| + | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| + | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| \ No newline at end of file | |
README.md
+29
-0
| @@ | @@ -0,0 +1,29 @@ |
| + | # Steam |
| + | |
| + | TODO: Write a gem description |
| + | |
| + | ## Installation |
| + | |
| + | Add this line to your application's Gemfile: |
| + | |
| + | gem 'steam' |
| + | |
| + | And then execute: |
| + | |
| + | $ bundle |
| + | |
| + | Or install it yourself as: |
| + | |
| + | $ gem install steam |
| + | |
| + | ## Usage |
| + | |
| + | TODO: Write usage instructions here |
| + | |
| + | ## Contributing |
| + | |
| + | 1. Fork it |
| + | 2. Create your feature branch (`git checkout -b my-new-feature`) |
| + | 3. Commit your changes (`git commit -am 'Add some feature'`) |
| + | 4. Push to the branch (`git push origin my-new-feature`) |
| + | 5. Create new Pull Request |
Rakefile
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | require "bundler/gem_tasks" |
bin/steam
+5
-0
| @@ | @@ -0,0 +1,5 @@ |
| + | #!/usr/bin/env ruby |
| + | require "steam" |
| + | require "steam/cli" |
| + | |
| + | Steam::CLI.start |
| \ No newline at end of file | |
steam.rb b/lib/steam.rb
+11
-0
| @@ | @@ -0,0 +1,11 @@ |
| + | require "steam/version" |
| + | require "locomotive/mounter" |
| + | |
| + | module Steam |
| + | def self.import(name, site_url, email, password) |
| + | reader = Locomotive::Mounter::Reader::Api.instance |
| + | reader.run!(uri: "#{site_url.chomp('/')}/locomotive/api", email: email, password: password) |
| + | writer = Locomotive::Mounter::Writer::FileSystem.instance |
| + | writer.run!(mounting_point: reader.mounting_point, target_path: name) |
| + | end |
| + | end |
steam/cli.rb b/lib/steam/cli.rb
+21
-0
| @@ | @@ -0,0 +1,21 @@ |
| + | require "thor" |
| + | |
| + | module Steam |
| + | class CLI < Thor |
| + | |
| + | desc "import NAME SITE_URL EMAIL PASSWORD", "Import an existing locomotive site" |
| + | def import(name, site_url, email, password) |
| + | say("ERROR: \"#{name}\" directory already exists", :red) and return if File.exists?(name) |
| + | Steam.import(name, site_url, email, password) |
| + | end |
| + | |
| + | desc "server PATH [PORT]", "Serve an existing site from the file system" |
| + | def server(path, port = 3333) |
| + | require "thin" |
| + | require "steam/server" |
| + | reader = Locomotive::Mounter::Reader::FileSystem.instance |
| + | reader.run!(path: path) |
| + | Thin::Server.start('0.0.0.0', port, Steam::Server.new(reader)) |
| + | end |
| + | end |
| + | end |
| \ No newline at end of file | |
steam/server.rb b/lib/steam/server.rb
+21
-0
| @@ | @@ -0,0 +1,21 @@ |
| + | require "steam/server/middleware" |
| + | require "steam/server/index" |
| + | require "steam/server/not_found" |
| + | |
| + | module Steam |
| + | class Server |
| + | def initialize(reader) |
| + | @reader = reader |
| + | @app = Rack::Builder.new do |
| + | use Rack::Lint |
| + | use Index |
| + | run NotFound.new |
| + | end |
| + | end |
| + | |
| + | def call(env) |
| + | env["steam.mounting_point"] = @reader.mounting_point |
| + | @app.call(env) |
| + | end |
| + | end |
| + | end |
| \ No newline at end of file | |
steam/server/index.rb b/lib/steam/server/index.rb
+13
-0
| @@ | @@ -0,0 +1,13 @@ |
| + | module Steam |
| + | class Server |
| + | class Index < Middleware |
| + | def call(env) |
| + | if env['PATH_INFO'] == '/' |
| + | [404, {'Content-Type' => 'text/html'}, [env["steam.mounting_point"].pages["index"].source]] |
| + | else |
| + | super |
| + | end |
| + | end |
| + | end |
| + | end |
| + | end |
| \ No newline at end of file | |
steam/server/middleware.rb b/lib/steam/server/middleware.rb
+15
-0
| @@ | @@ -0,0 +1,15 @@ |
| + | module Steam |
| + | class Server |
| + | class Middleware |
| + | attr_accessor :app |
| + | |
| + | def initialize(app) |
| + | @app = app |
| + | end |
| + | |
| + | def call(env) |
| + | app.call(env) |
| + | end |
| + | end |
| + | end |
| + | end |
| \ No newline at end of file | |
steam/server/not_found.rb b/lib/steam/server/not_found.rb
+9
-0
| @@ | @@ -0,0 +1,9 @@ |
| + | module Steam |
| + | class Server |
| + | class NotFound |
| + | def call(env) |
| + | [404, {'Content-Type' => 'text/html'}, [env["steam.mounting_point"].pages["404"].source]] |
| + | end |
| + | end |
| + | end |
| + | end |
| \ No newline at end of file | |
steam/version.rb b/lib/steam/version.rb
+3
-0
| @@ | @@ -0,0 +1,3 @@ |
| + | module Steam |
| + | VERSION = "0.0.1" |
| + | end |
spec/integration/cassettes/import.yml
+331
-0
| @@ | @@ -0,0 +1,331 @@ |
| + | --- |
| + | http_interactions: |
| + | - request: |
| + | method: post |
| + | uri: http://locomotive.engine.dev:3000/locomotive/api/tokens.json |
| + | body: |
| + | encoding: US-ASCII |
| + | string: email=admin%40locomotivecms.com&password=locomotive |
| + | headers: {} |
| + | response: |
| + | status: |
| + | code: 200 |
| + | message: ! 'OK ' |
| + | headers: |
| + | Location: |
| + | - http://locomotive.engine.dev:3000/locomotive/ |
| + | Content-Type: |
| + | - application/json; charset=utf-8 |
| + | X-Ua-Compatible: |
| + | - IE=Edge |
| + | Etag: |
| + | - ! '"4f7e33d0d4bfa634c36913dd6b5c2881"' |
| + | Cache-Control: |
| + | - max-age=0, private, must-revalidate |
| + | X-Request-Id: |
| + | - beaa9b82d1d629d15de3811005e77336 |
| + | X-Runtime: |
| + | - '0.015989' |
| + | Content-Length: |
| + | - '32' |
| + | Server: |
| + | - WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10) |
| + | Date: |
| + | - Thu, 13 Dec 2012 12:53:25 GMT |
| + | Connection: |
| + | - Keep-Alive |
| + | Set-Cookie: |
| + | - _dummy_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWM3NmE5NGI2MjU0ZDFjMzRlZGIzZWMzMThhYzk5ZmVmBjsAVEkiCmZsYXNoBjsARm86JUFjdGlvbkRpc3BhdGNoOjpGbGFzaDo6Rmxhc2hIYXNoCToKQHVzZWRvOghTZXQGOgpAaGFzaHsAOgxAY2xvc2VkRjoNQGZsYXNoZXN7BjoLbm90aWNlSUM6HkFjdGl2ZVN1cHBvcnQ6OlNhZmVCdWZmZXIiI0hhc2ggd2FzIHN1Y2Nlc3NmdWxseSBjcmVhdGVkLgc7AFQ6D0BodG1sX3NhZmVUOglAbm93MA%3D%3D--988209950608fa27ccfa45c5edd3b38f28bd76a0; |
| + | domain=.engine.dev; path=/; HttpOnly |
| + | body: |
| + | encoding: US-ASCII |
| + | string: ! '{"token":"C3NNrE3RCZgGwiYoyJeQ"}' |
| + | http_version: |
| + | recorded_at: Thu, 13 Dec 2012 12:53:25 GMT |
| + | - request: |
| + | method: get |
| + | uri: http://locomotive.engine.dev:3000/locomotive/api/current_site.json?auth_token=C3NNrE3RCZgGwiYoyJeQ |
| + | body: |
| + | encoding: US-ASCII |
| + | string: '' |
| + | headers: {} |
| + | response: |
| + | status: |
| + | code: 200 |
| + | message: ! 'OK ' |
| + | headers: |
| + | Content-Type: |
| + | - application/json; charset=utf-8 |
| + | X-Ua-Compatible: |
| + | - IE=Edge |
| + | Etag: |
| + | - ! '"fce084a1bb09548212b111d21485000f"' |
| + | Cache-Control: |
| + | - max-age=0, private, must-revalidate |
| + | X-Request-Id: |
| + | - 43b08a978feb173070685bc3d7ba5fb1 |
| + | X-Runtime: |
| + | - '0.013959' |
| + | Content-Length: |
| + | - '678' |
| + | Server: |
| + | - WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10) |
| + | Date: |
| + | - Thu, 13 Dec 2012 12:53:25 GMT |
| + | Connection: |
| + | - Keep-Alive |
| + | Set-Cookie: |
| + | - _dummy_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTRhMGE1Yzk2MTJhYTI4MmNiYTBlZDY1ZDU5YmNjNWUyBjsAVEkiJ3dhcmRlbi51c2VyLmxvY29tb3RpdmVfYWNjb3VudC5rZXkGOwBUWwhJIhhMb2NvbW90aXZlOjpBY2NvdW50BjsARlsGbzoTQlNPTjo6T2JqZWN0SWQGOgpAZGF0YVsRaVVpAclpAZ1pfWkByGkxaQHRaQBpAdNpAGkAaQhJIhlDcWlUSzJLRE5iQnlXWnVoYWJpTAY7AFQ%3D--0a9a0199a84a99546b796bafa46771adab868c4e; |
| + | domain=.engine.dev; path=/; HttpOnly |
| + | body: |
| + | encoding: US-ASCII |
| + | string: ! '{"id":"50c99d81c82cd100d3000005","_id":"50c99d81c82cd100d3000005","created_at":"2012-12-13T10:18:57+01:00","updated_at":"2012-12-13T10:18:57+01:00","name":"locomotive","locales":["en"],"domain_name":"engine.dev","subdomain":"locomotive","domains":["locomotive.engine.dev"],"robots_txt":null,"seo_title":null,"meta_keywords":null,"meta_description":null,"domains_without_subdomain":[],"memberships":[{"id":"50c99d81c82cd100d3000006","_id":"50c99d81c82cd100d3000006","created_at":null,"updated_at":null,"account_id":"50c99d78c82cd100d3000003","name":"Locomotive","email":"admin@locomotivecms.com","role":"admin","role_name":"Administrator","can_update":false,"grant_admin":true}]}' |
| + | http_version: |
| + | recorded_at: Thu, 13 Dec 2012 12:53:25 GMT |
| + | - request: |
| + | method: get |
| + | uri: http://locomotive.engine.dev:3000/locomotive/api/snippets.json?auth_token=C3NNrE3RCZgGwiYoyJeQ |
| + | body: |
| + | encoding: US-ASCII |
| + | string: '' |
| + | headers: {} |
| + | response: |
| + | status: |
| + | code: 200 |
| + | message: ! 'OK ' |
| + | headers: |
| + | Content-Type: |
| + | - application/json; charset=utf-8 |
| + | X-Ua-Compatible: |
| + | - IE=Edge |
| + | Etag: |
| + | - ! '"d751713988987e9331980363e24189ce"' |
| + | Cache-Control: |
| + | - max-age=0, private, must-revalidate |
| + | X-Request-Id: |
| + | - 7cd2ac6df57168f9cf5dfcd2ce2fa7d8 |
| + | X-Runtime: |
| + | - '0.018109' |
| + | Content-Length: |
| + | - '2' |
| + | Server: |
| + | - WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10) |
| + | Date: |
| + | - Thu, 13 Dec 2012 12:53:25 GMT |
| + | Connection: |
| + | - Keep-Alive |
| + | Set-Cookie: |
| + | - _dummy_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTljZjFhNmJiZTc5MzQ0NzE0ZjVmYjZmN2ZhZmIzMmM4BjsAVEkiJ3dhcmRlbi51c2VyLmxvY29tb3RpdmVfYWNjb3VudC5rZXkGOwBUWwhJIhhMb2NvbW90aXZlOjpBY2NvdW50BjsARlsGbzoTQlNPTjo6T2JqZWN0SWQGOgpAZGF0YVsRaVVpAclpAZ1pfWkByGkxaQHRaQBpAdNpAGkAaQhJIhlDcWlUSzJLRE5iQnlXWnVoYWJpTAY7AFQ%3D--9b4bc7145449e302aee8e915ab145c1b68fb1749; |
| + | domain=.engine.dev; path=/; HttpOnly |
| + | body: |
| + | encoding: US-ASCII |
| + | string: ! '[]' |
| + | http_version: |
| + | recorded_at: Thu, 13 Dec 2012 12:53:25 GMT |
| + | - request: |
| + | method: get |
| + | uri: http://locomotive.engine.dev:3000/locomotive/api/content_types.json?auth_token=C3NNrE3RCZgGwiYoyJeQ |
| + | body: |
| + | encoding: US-ASCII |
| + | string: '' |
| + | headers: {} |
| + | response: |
| + | status: |
| + | code: 200 |
| + | message: ! 'OK ' |
| + | headers: |
| + | Content-Type: |
| + | - application/json; charset=utf-8 |
| + | X-Ua-Compatible: |
| + | - IE=Edge |
| + | Etag: |
| + | - ! '"d751713988987e9331980363e24189ce"' |
| + | Cache-Control: |
| + | - max-age=0, private, must-revalidate |
| + | X-Request-Id: |
| + | - c56341c0196eb389b412215f9820212b |
| + | X-Runtime: |
| + | - '0.020533' |
| + | Content-Length: |
| + | - '2' |
| + | Server: |
| + | - WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10) |
| + | Date: |
| + | - Thu, 13 Dec 2012 12:53:26 GMT |
| + | Connection: |
| + | - Keep-Alive |
| + | Set-Cookie: |
| + | - _dummy_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWZhZGIxZGRkM2U3NzU3ZTc2MTNjNTk3YWNkOWI0ZjJkBjsAVEkiJ3dhcmRlbi51c2VyLmxvY29tb3RpdmVfYWNjb3VudC5rZXkGOwBUWwhJIhhMb2NvbW90aXZlOjpBY2NvdW50BjsARlsGbzoTQlNPTjo6T2JqZWN0SWQGOgpAZGF0YVsRaVVpAclpAZ1pfWkByGkxaQHRaQBpAdNpAGkAaQhJIhlDcWlUSzJLRE5iQnlXWnVoYWJpTAY7AFQ%3D--22b273378229c2edcdc51ec777da024ef8519d44; |
| + | domain=.engine.dev; path=/; HttpOnly |
| + | body: |
| + | encoding: US-ASCII |
| + | string: ! '[]' |
| + | http_version: |
| + | recorded_at: Thu, 13 Dec 2012 12:53:26 GMT |
| + | - request: |
| + | method: get |
| + | uri: http://locomotive.engine.dev:3000/locomotive/api/content_assets.json?auth_token=C3NNrE3RCZgGwiYoyJeQ |
| + | body: |
| + | encoding: US-ASCII |
| + | string: '' |
| + | headers: {} |
| + | response: |
| + | status: |
| + | code: 200 |
| + | message: ! 'OK ' |
| + | headers: |
| + | Content-Type: |
| + | - application/json; charset=utf-8 |
| + | X-Ua-Compatible: |
| + | - IE=Edge |
| + | Etag: |
| + | - ! '"d751713988987e9331980363e24189ce"' |
| + | Cache-Control: |
| + | - max-age=0, private, must-revalidate |
| + | X-Request-Id: |
| + | - cea3fd2de247f129863cbcdfc37c8447 |
| + | X-Runtime: |
| + | - '0.022965' |
| + | Content-Length: |
| + | - '2' |
| + | Server: |
| + | - WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10) |
| + | Date: |
| + | - Thu, 13 Dec 2012 12:53:26 GMT |
| + | Connection: |
| + | - Keep-Alive |
| + | Set-Cookie: |
| + | - _dummy_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWU4NDU1NjBhZWU1NDZiZjM5MWUwM2NkMzYzYTg2MzNmBjsAVEkiJ3dhcmRlbi51c2VyLmxvY29tb3RpdmVfYWNjb3VudC5rZXkGOwBUWwhJIhhMb2NvbW90aXZlOjpBY2NvdW50BjsARlsGbzoTQlNPTjo6T2JqZWN0SWQGOgpAZGF0YVsRaVVpAclpAZ1pfWkByGkxaQHRaQBpAdNpAGkAaQhJIhlDcWlUSzJLRE5iQnlXWnVoYWJpTAY7AFQ%3D--e12338ab76b72d794ab2c1ac4cdd9325dfafe3ee; |
| + | domain=.engine.dev; path=/; HttpOnly |
| + | body: |
| + | encoding: US-ASCII |
| + | string: ! '[]' |
| + | http_version: |
| + | recorded_at: Thu, 13 Dec 2012 12:53:26 GMT |
| + | - request: |
| + | method: get |
| + | uri: http://locomotive.engine.dev:3000/locomotive/api/pages.json?auth_token=C3NNrE3RCZgGwiYoyJeQ |
| + | body: |
| + | encoding: US-ASCII |
| + | string: '' |
| + | headers: {} |
| + | response: |
| + | status: |
| + | code: 200 |
| + | message: ! 'OK ' |
| + | headers: |
| + | Content-Type: |
| + | - application/json; charset=utf-8 |
| + | X-Ua-Compatible: |
| + | - IE=Edge |
| + | Etag: |
| + | - ! '"6f9bd6c4bbc30d10a87403d1a83e9a6d"' |
| + | Cache-Control: |
| + | - max-age=0, private, must-revalidate |
| + | X-Request-Id: |
| + | - 92e948333a4d900322e35f66a00bc390 |
| + | X-Runtime: |
| + | - '0.025513' |
| + | Content-Length: |
| + | - '1146' |
| + | Server: |
| + | - WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10) |
| + | Date: |
| + | - Thu, 13 Dec 2012 12:53:26 GMT |
| + | Connection: |
| + | - Keep-Alive |
| + | Set-Cookie: |
| + | - _dummy_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWE4YzNhY2RiMjA2MjJjOGY1ZDdlMTQ4MTdkMzVjODU1BjsAVEkiJ3dhcmRlbi51c2VyLmxvY29tb3RpdmVfYWNjb3VudC5rZXkGOwBUWwhJIhhMb2NvbW90aXZlOjpBY2NvdW50BjsARlsGbzoTQlNPTjo6T2JqZWN0SWQGOgpAZGF0YVsRaVVpAclpAZ1pfWkByGkxaQHRaQBpAdNpAGkAaQhJIhlDcWlUSzJLRE5iQnlXWnVoYWJpTAY7AFQ%3D--78a0dc5781bf7be362cde68816e5ef530c461693; |
| + | domain=.engine.dev; path=/; HttpOnly |
| + | body: |
| + | encoding: US-ASCII |
| + | string: ! '[{"id":"50c99d81c82cd100d3000007","_id":"50c99d81c82cd100d3000007","created_at":"2012-12-13T10:18:58+01:00","updated_at":"2012-12-13T10:18:58+01:00","title":"Home |
| + | page","slug":"index","fullpath":"index","handle":null,"position":0,"raw_template":"Content |
| + | of the home page","published":true,"listed":true,"templatized":false,"templatized_from_parent":false,"target_klass_slug":null,"redirect":false,"redirect_url":null,"cache_strategy":"none","response_type":"text/html","template_changed":null,"editable_elements":[],"localized_fullpaths":{"en":""},"translated_in":["en"]},{"id":"50c99d82c82cd100d3000008","_id":"50c99d82c82cd100d3000008","created_at":"2012-12-13T10:18:58+01:00","updated_at":"2012-12-13T10:18:58+01:00","title":"Page |
| + | not found","slug":"404","fullpath":"404","handle":null,"position":1,"raw_template":"Content |
| + | of the 404 page","published":true,"listed":true,"templatized":false,"templatized_from_parent":false,"target_klass_slug":null,"redirect":false,"redirect_url":null,"cache_strategy":"none","response_type":"text/html","template_changed":null,"editable_elements":[],"localized_fullpaths":{"en":"404"},"translated_in":["en"]}]' |
| + | http_version: |
| + | recorded_at: Thu, 13 Dec 2012 12:53:26 GMT |
| + | - request: |
| + | method: get |
| + | uri: http://locomotive.engine.dev:3000/locomotive/api/theme_assets.json?auth_token=C3NNrE3RCZgGwiYoyJeQ |
| + | body: |
| + | encoding: US-ASCII |
| + | string: '' |
| + | headers: {} |
| + | response: |
| + | status: |
| + | code: 200 |
| + | message: ! 'OK ' |
| + | headers: |
| + | Content-Type: |
| + | - application/json; charset=utf-8 |
| + | X-Ua-Compatible: |
| + | - IE=Edge |
| + | Etag: |
| + | - ! '"d751713988987e9331980363e24189ce"' |
| + | Cache-Control: |
| + | - max-age=0, private, must-revalidate |
| + | X-Request-Id: |
| + | - 34b486c9978cf5f5450903810c132bc7 |
| + | X-Runtime: |
| + | - '0.023942' |
| + | Content-Length: |
| + | - '2' |
| + | Server: |
| + | - WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10) |
| + | Date: |
| + | - Thu, 13 Dec 2012 12:53:26 GMT |
| + | Connection: |
| + | - Keep-Alive |
| + | Set-Cookie: |
| + | - _dummy_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWQxOTQyYjk1YWE5YTliZDRiMWYzYzhkMDk3ZTUzMjZhBjsAVEkiJ3dhcmRlbi51c2VyLmxvY29tb3RpdmVfYWNjb3VudC5rZXkGOwBUWwhJIhhMb2NvbW90aXZlOjpBY2NvdW50BjsARlsGbzoTQlNPTjo6T2JqZWN0SWQGOgpAZGF0YVsRaVVpAclpAZ1pfWkByGkxaQHRaQBpAdNpAGkAaQhJIhlDcWlUSzJLRE5iQnlXWnVoYWJpTAY7AFQ%3D--1aa8aa75bf5957efb7103d8586dcc8bb9763b12e; |
| + | domain=.engine.dev; path=/; HttpOnly |
| + | body: |
| + | encoding: US-ASCII |
| + | string: ! '[]' |
| + | http_version: |
| + | recorded_at: Thu, 13 Dec 2012 12:53:26 GMT |
| + | - request: |
| + | method: post |
| + | uri: http://locomotive.engine.dev:3000/locomotive/api/tokens.json?auth_token=C3NNrE3RCZgGwiYoyJeQ |
| + | body: |
| + | encoding: US-ASCII |
| + | string: email=admin%40locomotivecms.com&password=locomotive |
| + | headers: {} |
| + | response: |
| + | status: |
| + | code: 200 |
| + | message: ! 'OK ' |
| + | headers: |
| + | location: |
| + | - http://locomotive.engine.dev:3000/locomotive/ |
| + | content-type: |
| + | - application/json; charset=utf-8 |
| + | x-ua-compatible: |
| + | - IE=Edge |
| + | etag: |
| + | - ! '"4f7e33d0d4bfa634c36913dd6b5c2881"' |
| + | cache-control: |
| + | - max-age=0, private, must-revalidate |
| + | x-request-id: |
| + | - 51c26dd05019c37ca3c2911bbc8454fc |
| + | x-runtime: |
| + | - '0.130599' |
| + | content-length: |
| + | - '32' |
| + | server: |
| + | - WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10) |
| + | date: |
| + | - Thu, 13 Dec 2012 17:49:07 GMT |
| + | connection: |
| + | - close |
| + | set-cookie: |
| + | - _dummy_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRkkiJTQwZTE3Y2QzNjYwZjVkNzE0MzM1YTY4ZDAzMTRlOGZmBjsAVEkiJ3dhcmRlbi51c2VyLmxvY29tb3RpdmVfYWNjb3VudC5rZXkGOwBUWwhJIhhMb2NvbW90aXZlOjpBY2NvdW50BjsARlsGbzoTQlNPTjo6T2JqZWN0SWQGOgpAZGF0YVsRaVVpAclpAZ1pfWkByGkxaQHRaQBpAdNpAGkAaQhJIhlDcWlUSzJLRE5iQnlXWnVoYWJpTAY7AFRJIgpmbGFzaAY7AEZvOiVBY3Rpb25EaXNwYXRjaDo6Rmxhc2g6OkZsYXNoSGFzaAk6CkB1c2VkbzoIU2V0BjoKQGhhc2h7ADoMQGNsb3NlZEY6DUBmbGFzaGVzewY6C25vdGljZUlDOh5BY3RpdmVTdXBwb3J0OjpTYWZlQnVmZmVyIiNIYXNoIHdhcyBzdWNjZXNzZnVsbHkgY3JlYXRlZC4HOwBUOg9AaHRtbF9zYWZlVDoJQG5vdzA%3D--9a091aee8f3e8944add26972c4c92b436680b266; |
| + | domain=.engine.dev; path=/; HttpOnly |
| + | body: |
| + | encoding: US-ASCII |
| + | string: ! '{"token":"C3NNrE3RCZgGwiYoyJeQ"}' |
| + | http_version: '1.1' |
| + | recorded_at: Thu, 13 Dec 2012 17:49:07 GMT |
| + | recorded_with: VCR 2.3.0 |
spec/integration/integration_helper.rb
+13
-0
| @@ | @@ -0,0 +1,13 @@ |
| + | require File.dirname(__FILE__) + '/../spec_helper' |
| + | require 'vcr' |
| + | |
| + | VCR.configure do |c| |
| + | c.ignore_localhost = false |
| + | c.cassette_library_dir = File.dirname(__FILE__) + '/cassettes' |
| + | c.hook_into :fakeweb |
| + | c.default_cassette_options = { record: :new_episodes } |
| + | end |
| + | |
| + | RSpec.configure do |c| |
| + | c.extend VCR::RSpec::Macros |
| + | end |
| \ No newline at end of file | |
spec/integration/server_spec.rb
+24
-0
| @@ | @@ -0,0 +1,24 @@ |
| + | require File.dirname(__FILE__) + "/integration_helper" |
| + | require "steam/server" |
| + | require "rack/test" |
| + | |
| + | describe Steam::Server do |
| + | include Rack::Test::Methods |
| + | |
| + | def app |
| + | import_site |
| + | reader = Locomotive::Mounter::Reader::FileSystem.instance |
| + | reader.run!(path: "site") |
| + | Steam::Server.new(reader) |
| + | end |
| + | |
| + | it "shows the index page" do |
| + | get '/' |
| + | last_response.body.should =~ /Content of the home page/ |
| + | end |
| + | |
| + | it "shows the 404 page" do |
| + | get '/void' |
| + | last_response.body.should =~ /Content of the 404 page/ |
| + | end |
| + | end |
| \ No newline at end of file | |
spec/integration/sites_spec.rb
+14
-0
| @@ | @@ -0,0 +1,14 @@ |
| + | require File.dirname(__FILE__) + "/integration_helper" |
| + | |
| + | describe Steam do |
| + | it "imports" do |
| + | File.exists?("site/config/site.yml").should be_false |
| + | import_site |
| + | YAML.load_file("site/config/site.yml").should == { |
| + | "name"=>"locomotive", |
| + | "locales"=>["en"], |
| + | "subdomain"=>"locomotive", |
| + | "domains"=>["locomotive.engine.dev"] |
| + | } |
| + | end |
| + | end |
| \ No newline at end of file | |
spec/spec_helper.rb
+12
-0
| @@ | @@ -0,0 +1,12 @@ |
| + | require "steam" |
| + | require "rspec" |
| + | |
| + | Dir["#{File.expand_path('../support', __FILE__)}/*.rb"].each do |file| |
| + | require file |
| + | end |
| + | |
| + | RSpec.configure do |c| |
| + | c.include Spec::Helpers |
| + | c.before { reset! } |
| + | c.after { reset! } |
| + | end |
| \ No newline at end of file | |
spec/support/helpers.rb
+13
-0
| @@ | @@ -0,0 +1,13 @@ |
| + | module Spec |
| + | module Helpers |
| + | def reset! |
| + | FileUtils.rm_rf(File.expand_path('../../../site', __FILE__)) |
| + | end |
| + | |
| + | def import_site |
| + | VCR.use_cassette('import') do |
| + | Steam.import("site", "http://locomotive.engine.dev:3000", "admin@locomotivecms.com", "locomotive") |
| + | end |
| + | end |
| + | end |
| + | end |
| \ No newline at end of file | |
steam.gemspec
+28
-0
| @@ | @@ -0,0 +1,28 @@ |
| + | # -*- encoding: utf-8 -*- |
| + | lib = File.expand_path('../lib', __FILE__) |
| + | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) |
| + | require 'steam/version' |
| + | |
| + | Gem::Specification.new do |gem| |
| + | gem.name = "steam" |
| + | gem.version = Steam::VERSION |
| + | gem.authors = ["Rodrigo Alvarez"] |
| + | gem.email = ["papipo@gmail.com"] |
| + | gem.description = %q{TODO: Write a gem description} |
| + | gem.summary = %q{TODO: Write a gem summary} |
| + | gem.homepage = "" |
| + | |
| + | gem.files = `git ls-files`.split($/) |
| + | gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } |
| + | gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) |
| + | gem.require_paths = ["lib"] |
| + | gem.executables = ["steam"] |
| + | |
| + | gem.add_dependency "thor" |
| + | gem.add_dependency "thin" |
| + | # gem.add_dependency "locomotivecms_mounter" # remove from Gemfile before adding it here |
| + | gem.add_development_dependency "rspec" |
| + | gem.add_development_dependency "vcr" |
| + | gem.add_development_dependency "fakeweb" |
| + | gem.add_development_dependency "rack-test" |
| + | end |