front_end_builds 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6fd868520d0d5a610455acb3c99d0840899fc90d
4
- data.tar.gz: 7440bdcf50f76bb1ea2b5d7fff954c6851cbbaf9
3
+ metadata.gz: ce1268253a64231fec485962a4a354ce6eb2ba19
4
+ data.tar.gz: 483d5a2c0dbcff38e9fbacd62432e770968143ac
5
5
  SHA512:
6
- metadata.gz: 61396b3ac76d1a6fcce0b06a07b92ffc1abe25bca323c8bd4332cd99dd6d27894e3887ffee7abd7dfcce960c767ffe02b8ffac508be8a5914c60f4b913ba4082
7
- data.tar.gz: 812c52f64e604aecaef6d1db4b89b891f69fa9a93a6a43ac08f1e84eab17947cf8b31ec7c80bdc61ed5226ac53c46f2ad68d3551b4dd358b317e0feadc866114
6
+ metadata.gz: 2001ef6a82057c6c7901b27f2a18b1dd2df29331aa510f1f226f2573a9cd02a36e0d7a15b7a9b21452ce52b7850b4f8a0261db9869afdbf03823e10331547b88
7
+ data.tar.gz: b83a54a65c9f1482b7e3fa928bf45034d04c45b016962ba17de4ec0caca85dbed2669c3fff5760d3264d36dc85a202d01bb5dda3cadd5f0e2569702943a6b5f0
data/Rakefile CHANGED
@@ -14,6 +14,23 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
14
  rdoc.rdoc_files.include('lib/**/*.rb')
15
15
  end
16
16
 
17
+ begin
18
+ require 'rspec/core/rake_task'
19
+ RSpec::Core::RakeTask.new(:spec)
20
+ task :default => :spec
21
+ rescue LoadError
22
+ # no rspec available
23
+ end
24
+
25
+ task :build_admin do
26
+ Dir.chdir('admin'){
27
+ cmd = 'ember build --output-path ../public --environment production'
28
+ system 'echo Running command: ' + cmd
29
+ system cmd
30
+ system 'rm ../public/index.html'
31
+ }
32
+ end
33
+
17
34
  APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
35
  load 'rails/tasks/engine.rake'
19
36
 
@@ -0,0 +1,17 @@
1
+ require_dependency "front_end_builds/application_controller"
2
+
3
+ module FrontEndBuilds
4
+ class AdminController < ApplicationController
5
+
6
+ def index
7
+ # We need to pass the url which the host app has mounted the
8
+ # engine to into index.html.erb, so the ember app's router
9
+ # will work appropriately.
10
+
11
+ # Trim leading/trailing slash marks...
12
+ @baseURL = request.fullpath[1..request.fullpath.length-2]
13
+ render :index, layout: false
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,91 @@
1
+ require_dependency "front_end_builds/application_controller"
2
+
3
+ module FrontEndBuilds
4
+ class AppsController < ApplicationController
5
+ before_filter :set_app , :only => [:show, :destroy]
6
+ respond_to :json
7
+
8
+ def index
9
+ apps = []
10
+ builds = []
11
+
12
+ FrontEndBuilds::App.all.each do |app|
13
+ apps.push serialize_app(app)
14
+ builds.concat serialize_builds(app)
15
+ end
16
+
17
+ respond_with({
18
+ apps: apps,
19
+ builds: builds
20
+ })
21
+ end
22
+
23
+ def show
24
+ respond_with({
25
+ app: serialize_app(@app),
26
+ builds: serialize_builds(@app)
27
+ })
28
+ end
29
+
30
+ def create
31
+ @app = FrontEndBuilds::App.new(app_create_params)
32
+
33
+ if @app.save!
34
+ hash = { app: @app }
35
+ respond_with hash, location: nil
36
+
37
+ else
38
+ respond_with(
39
+ {errors: @app.errors},
40
+ status: :unprocessable_entity
41
+ )
42
+ end
43
+ end
44
+
45
+ def destroy
46
+ if @app.destroy
47
+ hash = { app: @app }
48
+ respond_with hash, location: nil
49
+
50
+ else
51
+ respond_with(
52
+ {errors: @app.errors},
53
+ status: :unprocessable_entity
54
+ )
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ def set_app
61
+ @app = FrontEndBuilds::App.find params[:id]
62
+ end
63
+
64
+ def app_create_params
65
+ params.require(:app).permit(
66
+ :name
67
+ )
68
+ end
69
+
70
+ def serialize_app(app)
71
+ build_ids = app.builds.map {|build| build.id}
72
+
73
+ app.as_json.merge( {build_ids: build_ids} )
74
+ end
75
+
76
+ def serialize_builds(app)
77
+ builds = app.builds.as_json
78
+ best_build = app.find_best_build
79
+
80
+ if best_build
81
+ builds.each do |build|
82
+ if build["id"] === best_build.id
83
+ build["is_best"] = true
84
+ end
85
+ end
86
+ end
87
+
88
+ return builds
89
+ end
90
+ end
91
+ end
@@ -10,5 +10,11 @@ module FrontEndBuilds
10
10
  def ensure_api_key!
11
11
  self.api_key = SecureRandom.uuid if api_key.blank?
12
12
  end
13
+
14
+ def find_best_build
15
+ FrontEndBuilds::Build.find_best({
16
+ app: self
17
+ })
18
+ end
13
19
  end
14
20
  end
@@ -18,7 +18,7 @@ module FrontEndBuilds
18
18
  }
19
19
 
20
20
  if params[:app]
21
- query[:app] = params[:app]
21
+ query[:app_id] = params[:app].id
22
22
  end
23
23
 
24
24
  if params[:app_name]
@@ -51,6 +51,10 @@ module FrontEndBuilds
51
51
  .first
52
52
  end
53
53
 
54
+ def live?
55
+ self == app.find_best_build
56
+ end
57
+
54
58
  def fetch!
55
59
  return if fetched?
56
60
 
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <title>Admin</title>
7
+ <meta name="description" content="">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1">
9
+
10
+ <script>
11
+ window.RAILS_ENV = {
12
+ baseURL: '<%=@baseURL%>'
13
+ }
14
+ </script>
15
+ <base href="/<%=@baseURL%>">
16
+ <meta name="admin/config/environment" content="%7B%22modulePrefix%22%3A%22admin%22%2C%22environment%22%3A%22production%22%2C%22baseURL%22%3A%22/%22%2C%22locationType%22%3A%22auto%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%7D%2C%22APP%22%3A%7B%7D%2C%22contentSecurityPolicyHeader%22%3A%22Content-Security-Policy-Report-Only%22%2C%22contentSecurityPolicy%22%3A%7B%22default-src%22%3A%22%27none%27%22%2C%22script-src%22%3A%22%27self%27%22%2C%22font-src%22%3A%22%27self%27%22%2C%22connect-src%22%3A%22%27self%27%22%2C%22img-src%22%3A%22%27self%27%22%2C%22style-src%22%3A%22%27self%27%22%2C%22media-src%22%3A%22%27self%27%22%7D%2C%22exportApplicationGlobal%22%3Afalse%7D">
17
+
18
+
19
+ <link rel="stylesheet" href="/assets/vendor.css">
20
+ <link rel="stylesheet" href="/assets/admin.css">
21
+ </head>
22
+ <body>
23
+ <script src="/assets/vendor.js"></script>
24
+ <script src="/assets/admin.js"></script>
25
+ </body>
26
+ </html>
data/config/routes.rb CHANGED
@@ -1,2 +1,12 @@
1
+ # Front end
1
2
  FrontEndBuilds::Engine.routes.draw do
3
+ resources :apps, only: [:index, :show, :create, :edit, :destroy], path: '/api/apps'
4
+
5
+ get '/(*path)', to: 'admin#index'
6
+ end
7
+
8
+ Rails.application.routes.draw do
9
+ namespace :front_end_builds do
10
+ resources :builds, only: [:index, :create]
11
+ end
2
12
  end
@@ -8,5 +8,10 @@ module FrontEndBuilds
8
8
  g.assets false
9
9
  g.helper false
10
10
  end
11
+
12
+ # Initializer to combine this engines static assets with the static assets of the hosting site.
13
+ initializer "static assets" do |app|
14
+ app.middleware.insert_before(::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public")
15
+ end
11
16
  end
12
17
  end
@@ -5,14 +5,6 @@ module ActionDispatch::Routing
5
5
 
6
6
  # Create a front end in your rails router.
7
7
  def front_end(name, path = name, options = {})
8
-
9
- # Generic routes that have nothing to do with the app
10
- # name. Use this for testing or providing a non
11
- # app api endpoint.
12
- namespace :front_end_builds do
13
- resources :builds, only: [:index, :create]
14
- end
15
-
16
8
  # Create a new build for this app.
17
9
  post(
18
10
  "#{path}" => "front_end_builds/builds#create",
@@ -1,3 +1,3 @@
1
1
  module FrontEndBuilds
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: front_end_builds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Toronto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-05 00:00:00.000000000 Z
11
+ date: 2014-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rails
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 3.2.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: 3.2.0
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: sqlite3
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -42,44 +28,44 @@ dependencies:
42
28
  name: rspec-rails
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - "~>"
31
+ - - ">="
46
32
  - !ruby/object:Gem::Version
47
- version: 3.1.0
33
+ version: '0'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - "~>"
38
+ - - ">="
53
39
  - !ruby/object:Gem::Version
54
- version: 3.1.0
40
+ version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: factory_girl_rails
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - "~>"
45
+ - - ">="
60
46
  - !ruby/object:Gem::Version
61
- version: 4.4.1
47
+ version: '0'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - "~>"
52
+ - - ">="
67
53
  - !ruby/object:Gem::Version
68
- version: 4.4.1
54
+ version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: pry
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - "~>"
59
+ - - ">="
74
60
  - !ruby/object:Gem::Version
75
- version: 0.10.1
61
+ version: '0'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - "~>"
66
+ - - ">="
81
67
  - !ruby/object:Gem::Version
82
- version: 0.10.1
68
+ version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: pry-stack_explorer
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -98,30 +84,30 @@ dependencies:
98
84
  name: shoulda-matchers
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
- - - "~>"
87
+ - - ">="
102
88
  - !ruby/object:Gem::Version
103
- version: 2.7.0
89
+ version: '0'
104
90
  type: :development
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
- - - "~>"
94
+ - - ">="
109
95
  - !ruby/object:Gem::Version
110
- version: 2.7.0
96
+ version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: webmock
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
- - - "~>"
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
- version: 1.19.0
103
+ version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
- - - "~>"
108
+ - - ">="
123
109
  - !ruby/object:Gem::Version
124
- version: 1.19.0
110
+ version: '0'
125
111
  description: Description of FrontEndBuilds.
126
112
  email:
127
113
  - rt@ted.com
@@ -133,12 +119,14 @@ files:
133
119
  - Rakefile
134
120
  - app/assets/javascripts/front_end_builds/application.js
135
121
  - app/assets/stylesheets/front_end_builds/application.css
122
+ - app/controllers/front_end_builds/admin_controller.rb
136
123
  - app/controllers/front_end_builds/application_controller.rb
124
+ - app/controllers/front_end_builds/apps_controller.rb
137
125
  - app/controllers/front_end_builds/builds_controller.rb
138
126
  - app/helpers/front_end_builds/application_helper.rb
139
127
  - app/models/front_end_builds/app.rb
140
128
  - app/models/front_end_builds/build.rb
141
- - app/views/layouts/front_end_builds/application.html.erb
129
+ - app/views/front_end_builds/admin/index.html.erb
142
130
  - config/routes.rb
143
131
  - db/migrate/20141010162405_create_front_end_builds_builds.rb
144
132
  - db/migrate/20141010165726_create_front_end_builds_apps.rb
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>FrontEndBuilds</title>
5
- <%= stylesheet_link_tag "front_end_builds/application", media: "all" %>
6
- <%= javascript_include_tag "front_end_builds/application" %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>