Ember CLI compat

This commit is contained in:
Piotr Sarnacki 2015-01-28 17:21:27 +01:00
parent 8f5c5022cb
commit 4871409032
15 changed files with 68 additions and 25 deletions

View File

@ -1,9 +1,13 @@
require 'travis/model'
Travis.Account = Travis.Model.extend
Model = Travis.Model
Account = Model.extend
name: DS.attr()
type: DS.attr()
reposCount: DS.attr('number')
subscribed: DS.attr('boolean')
education: DS.attr('boolean')
loginBinding: 'id'
Travis.Account = Account

View File

@ -1,6 +1,8 @@
require 'travis/model'
Travis.Annotation = Travis.Model.extend
Model = Travis.Model
Annotation = Model.extend
jobId: DS.attr('number')
description: DS.attr()
url: DS.attr()
@ -8,3 +10,5 @@ Travis.Annotation = Travis.Model.extend
providerName: DS.attr()
job: DS.belongsTo('job')
Travis.Annotation = Annotation

View File

@ -1,6 +1,8 @@
require 'travis/model'
Travis.Branch = Travis.Model.extend
Model = Travis.Model
Branch = Model.extend
repositoryId: DS.attr('number')
commitId: DS.attr('number')
state: DS.attr()
@ -22,6 +24,4 @@ Travis.Branch = Travis.Model.extend
@notifyPropertyChange 'started_at'
@notifyPropertyChange 'finished_at'
Travis.Branch.reopenClass
byRepoId: (id) ->
@find repository_id: id
Travis.Branch = Branch

View File

@ -1,6 +1,8 @@
require 'travis/model'
Broadcast = Travis.Model.extend
Model = Travis.Model
Broadcast = Model.extend
message: DS.attr()
toObject: ->

View File

@ -6,10 +6,11 @@ require 'travis/ajax'
compact = Travis.Helpers.compact
configKeys = Travis.Helpers.configKeys
Ajax = Travis.ajax
config_keys_map = Travis.CONFIG_KEYS_MAP
configKeysMap = Travis.CONFIG_KEYS_MAP
DurationCalculations = Travis.DurationCalculations
Model = Travis.Model
Travis.Build = Travis.Model.extend DurationCalculations,
Build = Model.extend DurationCalculations,
state: DS.attr()
number: DS.attr('number')
branch: DS.attr('string')
@ -89,7 +90,7 @@ Travis.Build = Travis.Model.extend DurationCalculations,
configKeys: (->
keys = @get('rawConfigKeys')
headers = ['Job', 'Duration', 'Finished']
$.map(headers.concat(keys), (key) -> if config_keys_map.hasOwnProperty(key) then config_keys_map[key] else key)
$.map(headers.concat(keys), (key) -> if configKeysMap.hasOwnProperty(key) then configKeysMap[key] else key)
).property('rawConfigKeys.length')
canCancel: (->
@ -107,3 +108,5 @@ Travis.Build = Travis.Model.extend DurationCalculations,
if finishedAt = @get('finishedAt')
moment(finishedAt).format('lll')
).property('finishedAt')
Travis.Build = Build

View File

@ -1,6 +1,8 @@
require 'travis/model'
@Travis.Commit = Travis.Model.extend
Model = Travis.Model
Commit = Model.extend
sha: DS.attr()
branch: DS.attr()
message: DS.attr()
@ -31,3 +33,5 @@ require 'travis/model'
@get('authorName') == @get('committerName') and
@get('authorEmail') == @get('committerEmail')
).property('authorName', 'authorEmail', 'committerName', 'committerEmail')
Travis.Commit = Commit

View File

@ -1,8 +1,12 @@
require 'travis/model'
Travis.EnvVar = Travis.Model.extend
Model = Travis.Model
EnvVar = Model.extend
name: DS.attr()
value: DS.attr()
public: DS.attr('boolean')
repo: DS.belongsTo('repo', async: true)
Travis.EnvVar = EnvVar

View File

@ -1,6 +1,8 @@
require 'travis/model'
@Travis.Event = Travis.Model.extend
Model = Travis.Model
Event = Model.extend
event: DS.attr()
repositoryId: DS.attr('number')
sourceId: DS.attr('number')
@ -23,6 +25,4 @@ require 'travis/model'
Travis[type].find(@get('sourceId')) if type = @get('sourceType')
).property('sourceType', 'sourceId')
@Travis.Event.reopenClass
byRepoId: (id) ->
@find repository_id: id
Travis.Event = Event

View File

@ -1,8 +1,9 @@
require 'travis/model'
Model = Travis.Model
Repo = Travis.Repo
@Travis.Hook = Travis.Model.extend
Hook = Model.extend
name: DS.attr()
ownerName: DS.attr()
description: DS.attr()
@ -30,3 +31,5 @@ Repo = Travis.Repo
return if @get('isSaving')
@set 'active', !@get('active')
@save()
Travis.Hook = Hook

View File

@ -3,12 +3,13 @@ require 'models/extensions'
require 'models/log'
require 'travis/ajax'
Model = Travis.Model
DurationCalculations = Travis.DurationCalculations
Log = Travis.Log
compact = Travis.Helpers.compact
Ajax = Travis.ajax
@Travis.Job = Travis.Model.extend DurationCalculations,
Job = Model.extend DurationCalculations,
logId: DS.attr()
queue: DS.attr()
@ -143,3 +144,5 @@ Ajax = Travis.ajax
slug: (->
"#{@get('repo.slug')} ##{@get('number')}"
).property()
Travis.Job = Job

View File

@ -2,7 +2,7 @@ require 'travis/log_chunks'
Ajax = Travis.ajax
Request = Em.Object.extend
Request = Ember.Object.extend
HEADERS:
accept: 'application/json; chunked=true; version=2, text/plain; version=2'
@ -34,7 +34,7 @@ Request = Em.Object.extend
type = xhr.getResponseHeader('Content-Type') || ''
type.indexOf('json') > -1
@Travis.Log = Em.Object.extend
Log = Ember.Object.extend
version: 0 # used to refresh log on requeue
isLoaded: false
length: 0
@ -96,3 +96,5 @@ Request = Em.Object.extend
console.log 'log model: load text' if Log.DEBUG
@append(number: 1, content: text, final: true)
@set('isLoaded', true)
Travis.Log = Log

View File

@ -2,6 +2,7 @@ require 'travis/expandable_record_array'
require 'travis/model'
require 'helpers/helpers'
Model = Travis.Model
ExpandableRecordArray = Travis.ExpandableRecordArray
EnvVar = Travis.EnvVar
Build = Travis.Build
@ -10,7 +11,7 @@ Event = Travis.Event
durationFrom = Travis.Helpers.durationFrom
Ajax = Travis.ajax
Travis.Repo = Travis.Model.extend
Repo = Model.extend
slug: DS.attr()
description: DS.attr()
private: DS.attr('boolean')
@ -138,7 +139,7 @@ Travis.Repo = Travis.Model.extend
saveSettings: (settings) ->
Ajax.ajax('/repos/' + @get('id') + '/settings', 'patch', data: { settings: settings })
Travis.Repo.reopenClass
Repo.reopenClass
recent: ->
@find()
@ -183,3 +184,5 @@ Travis.Repo.reopenClass
# buildURL: (slug) ->
# if slug then slug else 'repos'
Travis.Repo = Repo

View File

@ -1,6 +1,8 @@
require 'travis/model'
@Travis.Request = Travis.Model.extend
Model = Travis.Model
Request = Model.extend
created_at: DS.attr()
event_type: DS.attr()
result: DS.attr()
@ -27,3 +29,5 @@ require 'travis/model'
isPullRequest: (->
@get('event_type') == 'pull_request'
).property('event_type')
Travis.Request = Request

View File

@ -1,4 +1,8 @@
Travis.SshKey = Travis.Model.extend
Travis.Model = Model
SshKey = Model.extend
value: DS.attr()
description: DS.attr()
fingerprint: DS.attr()
Travis.SshKey = SshKey

View File

@ -1,11 +1,12 @@
require 'travis/ajax'
require 'travis/model'
Model = Travis.Model
Ajax = Travis.ajax
trigger = Travis.trigger
Account = Travis.Account
@Travis.User = Travis.Model.extend
User = Model.extend
name: DS.attr()
email: DS.attr()
login: DS.attr()
@ -86,3 +87,5 @@ Account = Travis.Account
user = JSON.parse(Travis.sessionStorage.getItem('travis.user'))
user[$.underscore(name)] = @get(name)
Travis.sessionStorage.setItem('travis.user', JSON.stringify(user))
Travis.User = User