Use ENV.config instead of Travis.config

This commit is contained in:
Piotr Sarnacki 2015-01-30 17:15:13 +01:00
parent 6fb1bfaaaf
commit 165d072d79
12 changed files with 40 additions and 28 deletions

View File

@ -1,7 +1,7 @@
config = ENV.config
Adapter = DS.ActiveModelAdapter.extend
host: (->
Travis.config.api_endpoint
).property()
host: config.api_endpoint
ajaxOptions: (url, type, options) ->
hash = @_super(url, type, options)

View File

@ -86,7 +86,7 @@ App = Ember.Application.extend(Ember.Evented,
new Date()
onUserUpdate: (user) ->
if Travis.config.pro
if config.pro
@identifyCustomer(user)
@subscribePusher(user)
@setupCharm(user)

View File

@ -1,7 +1,8 @@
require 'models/model'
config = ENV.config
Model = Travis.Model
Repo = Travis.Repo
Hook = Model.extend
name: DS.attr()
@ -20,11 +21,11 @@ Hook = Model.extend
).property('ownerName', 'name')
urlGithub: (->
"#{Travis.config.source_endpoint}/#{@get('slug')}"
"#{config.source_endpoint}/#{@get('slug')}"
).property()
urlGithubAdmin: (->
"#{Travis.config.source_endpoint}/#{@get('slug')}/settings/hooks#travis_minibucket"
"#{config.source_endpoint}/#{@get('slug')}/settings/hooks#travis_minibucket"
).property()
toggle: ->

View File

@ -1,6 +1,7 @@
require 'utils/log-chunks'
Ajax = Travis.ajax
config = ENV.config
Request = Ember.Object.extend
HEADERS:
@ -13,7 +14,7 @@ Request = Ember.Object.extend
success: (body, status, xhr) => Ember.run(this, -> @handle(body, status, xhr))
handle: (body, status, xhr) ->
if Travis.config.pro
if config.pro
@log.set('token', xhr.getResponseHeader('X-Log-Access-Token'))
if xhr.status == 204
@ -58,7 +59,7 @@ Log = Ember.Object.extend
@append part
parts: (->
#if Travis.config.pusher_log_fallback
#if config.pusher_log_fallback
# Travis.LogChunks.create(content: [], missingPartsCallback: => @fetchMissingParts.apply(this, arguments))
#else
Ember.ArrayProxy.create(content: [])

View File

@ -4,6 +4,7 @@ require 'models/model'
Model = Travis.Model
Ajax = Travis.ajax
Account = Travis.Account
config = ENV.config
User = Model.extend
name: DS.attr()
@ -25,7 +26,7 @@ User = Model.extend
).observes('isSyncing')
urlGithub: (->
"#{Travis.config.source_endpoint}/#{@get('login')}"
"#{config.source_endpoint}/#{@get('login')}"
).property()
_rawPermissions: (->

View File

@ -13,7 +13,7 @@ Router = Ember.Router.extend
didTransition: ->
@_super.apply @, arguments
if Travis.config.ga_code
if config.ga_code
_gaq.push ['_trackPageview', location.pathname]
Router.map ->

View File

@ -1,3 +1,5 @@
config = ENV.config
Route = Ember.Route.extend
beforeModel: (transition) ->
@auth.autoSignIn() unless @signedIn()
@ -13,7 +15,7 @@ Route = Ember.Route.extend
needsAuth: (->
# on pro, we need to auth on every route
Travis.config.pro
config.pro
).property()
Travis.Route = Route

View File

@ -1,7 +1,7 @@
require 'config/emoij'
config_keys_map = Travis.CONFIG_KEYS_MAP
config = Travis.config
config = ENV.config
githubCommitUrl = Travis.Urls.githubCommit
timeago = $.timeago
intersect = $.intersect

View File

@ -1,43 +1,45 @@
config = ENV.config
plainTextLog = (id) ->
"#{Travis.config.api_endpoint}/jobs/#{id}/log.txt?deansi=true"
"#{config.api_endpoint}/jobs/#{id}/log.txt?deansi=true"
githubPullRequest = (slug, pullRequestNumber) ->
"#{Travis.config.source_endpoint}/#{slug}/pull/#{pullRequestNumber}"
"#{config.source_endpoint}/#{slug}/pull/#{pullRequestNumber}"
githubCommit = (slug, sha) ->
"#{Travis.config.source_endpoint}/#{slug}/commit/#{sha}"
"#{config.source_endpoint}/#{slug}/commit/#{sha}"
githubRepo = (slug) ->
"#{Travis.config.source_endpoint}/#{slug}"
"#{config.source_endpoint}/#{slug}"
githubWatchers = (slug) ->
"#{Travis.config.source_endpoint}/#{slug}/watchers"
"#{config.source_endpoint}/#{slug}/watchers"
githubNetwork = (slug) ->
"#{Travis.config.source_endpoint}/#{slug}/network"
"#{config.source_endpoint}/#{slug}/network"
githubAdmin = (slug) ->
"#{Travis.config.source_endpoint}/#{slug}/settings/hooks#travis_minibucket"
"#{config.source_endpoint}/#{slug}/settings/hooks#travis_minibucket"
statusImage = (slug, branch) ->
if Travis.config.pro
if config.pro
token = Travis.__container__.lookup('controller:currentUser').get('token')
"#{location.protocol}//#{location.host}/#{slug}.svg?token=#{token}" + if branch then "&branch=#{branch}" else ''
else
"#{location.protocol}//#{location.host}/#{slug}.svg" + if branch then "?branch=#{encodeURIComponent(branch)}" else ''
ccXml = (slug) ->
if Travis.config.pro
if config.pro
token = Travis.__container__.lookup('controller:currentUser').get('token')
"##{Travis.config.api_endpoint}/repos/#{slug}/cc.xml?token=#{token}"
"##{config.api_endpoint}/repos/#{slug}/cc.xml?token=#{token}"
else
"#{Travis.config.api_endpoint}/repos/#{slug}/cc.xml"
"#{config.api_endpoint}/repos/#{slug}/cc.xml"
email = (email) ->
"mailto:#{email}"
gravatarImage = (email, size) ->
"https://www.gravatar.com/avatar/#{md5(email)}?s=#{size}&d=#{encodeURIComponent(Travis.config.avatar_default_url)}"
"https://www.gravatar.com/avatar/#{md5(email)}?s=#{size}&d=#{encodeURIComponent(config.avatar_default_url)}"
Travis.Urls = {
plainTextLog: plainTextLog,

View File

@ -5,6 +5,8 @@ require 'utils/log-folder'
Log.DEBUG = false
Log.LIMIT = 10000
config = ENV.config
Travis.reopen
LogView: Travis.View.extend
templateName: 'jobs/log'
@ -106,7 +108,7 @@ Travis.reopen
plainTextLogUrl: (->
if id = @get('log.job.id')
url = Travis.Urls.plainTextLog(id)
if Travis.config.pro
if config.pro
url += "&access_token=#{@get('job.log.token')}"
url
).property('job.log.id', 'job.log.token')

View File

@ -1,3 +1,5 @@
config = ENV.config
View = Travis.View.extend
templateName: 'repos/show/actions'
@ -116,7 +118,7 @@ View = Travis.View.extend
plainTextLogUrl: (->
if id = @get('jobIdForLog')
url = Travis.Urls.plainTextLog(id)
if Travis.config.pro
if config.pro
token = @get('job.log.token') || @get('build.jobs.firstObject.log.token')
url += "&access_token=#{token}"
url

View File

@ -1,5 +1,6 @@
statusImage = Travis.Urls.statusImage
StatusImagesView = Travis.StatusImagesView
config = ENV.config
View = Travis.View.extend
reposBinding: 'controllers.repos'
@ -28,7 +29,7 @@ View = Travis.View.extend
ReposEmptyView: Travis.View.extend
template: (->
if Travis.config.pro
if config.pro
'pro/repos/show/empty'
else
''