Introduction
Introduction Statistics Contact Development Disclaimer Help
Updating all files to Ruby 1.9 hash syntax - warvox - VoIP based wardialing too…
Log
Files
Refs
README
---
commit 7748223da0e7688d2db2ef51c03b835ad21e25ff
parent df11fd7842f74b579d73011c15cd87a3d27e4e4c
Author: Jay Scott <[email protected]>
Date: Mon, 5 Sep 2016 10:39:14 +0000
Updating all files to Ruby 1.9 hash syntax
Diffstat:
D Dockerfile | 27 ---------------------------
M app/controllers/analyze_controller… | 22 +++++++++++-----------
M app/controllers/application_contro… | 4 ++--
M app/controllers/home_controller.rb | 6 +++---
M app/controllers/jobs_controller.rb | 10 +++++-----
M app/controllers/projects_controlle… | 40 ++++++++++++++++-----------…
M app/controllers/providers_controll… | 18 +++++++++---------
M app/controllers/user_sessions_cont… | 6 +++---
M app/controllers/users_controller.rb | 8 ++++----
M app/helpers/application_helper.rb | 14 +++++++-------
M app/models/call.rb | 20 ++++++++++----------
M app/models/job.rb | 42 ++++++++++++++++-------------…
M app/models/line.rb | 4 ++--
M app/models/project.rb | 10 +++++-----
M app/models/provider.rb | 4 ++--
M app/models/user.rb | 4 ++--
M bin/adduser | 2 +-
M bin/export_audio.rb | 2 +-
M bin/export_list.rb | 2 +-
M bin/iaxrecord.rb | 2 +-
M bin/import_audio.rb | 24 ++++++++++++------------
M bin/resetpw | 2 +-
M bin/worker_manager.rb | 10 +++++-----
M config/routes.rb | 2 +-
M db/migrate/20121228171549_initial_… | 84 ++++++++++++++++-----------…
M db/migrate/20130113004653_create_r… | 24 ++++++++++++------------
M lib/warvox/audio/raw.rb | 2 +-
M lib/warvox/jobs/analysis.rb | 32 ++++++++++++++++-------------…
M lib/warvox/jobs/dialer.rb | 16 ++++++++--------
M lib/warvox/proto/iax2/client.rb | 8 ++++----
M spec/factories/settings.rb | 2 +-
31 files changed, 213 insertions(+), 240 deletions(-)
---
diff --git a/Dockerfile b/Dockerfile
@@ -1,27 +0,0 @@
-FROM ruby:slim
-MAINTAINER Jay Scott <[email protected]>
-
-RUN apt-get update && apt-get -y install \
- gnuplot \
- lame \
- build-essential \
- libssl-dev \
- libcurl4-openssl-dev \
- postgresql-contrib \
- git-core \
- curl \
- libpq-dev \
- sox \
- && rm -rf /var/lib/apt/lists/*
-
-ADD . /opt/warvox
-ADD setup.sh /
-
-WORKDIR /opt/warvox
-RUN ln -s /usr/bin/ruby2.1 /usr/bin/ruby \
- && bundle install \
- && make
-
-EXPOSE 7777
-
-CMD ["/setup.sh"]
diff --git a/app/controllers/analyze_controller.rb b/app/controllers/analyze_co…
@@ -2,8 +2,8 @@ class AnalyzeController < ApplicationController
def index
@jobs = Job.order('id DESC').paginate(
- :page => params[:page],
- :per_page => 30
+ page: params[:page],
+ per_page: 30
)
end
@@ -13,12 +13,12 @@ class AnalyzeController < ApplicationController
@shown = params[:show]
if request.format.html?
- ltypes = Call.select('DISTINCT line_type').where(:job_id => @job_id).map…
+ ltypes = Call.select('DISTINCT line_type').where(job_id: @job_id).map{|r…
res_types = {}
ltypes.each do |k|
next if not k
- res_types[k.capitalize.to_sym] = Call.where(:job_id => @job_id, :line_…
+ res_types[k.capitalize.to_sym] = Call.where(job_id: @job_id, line_type…
end
@lines_by_type = res_types
@@ -51,7 +51,7 @@ class AnalyzeController < ApplicationController
respond_to do |format|
format.html
format.json {
- render :content_type => 'application/json', :json => render_to_string(…
+ render content_type: 'application/json', json: render_to_string(partia…
}
end
@@ -60,9 +60,9 @@ class AnalyzeController < ApplicationController
def view_matches
@result = Call.find(params[:call_id])
@match_scopes = [
- { :scope => 'job', :label => 'This Job' },
- { :scope => 'project', :label => 'This Project' },
- { :scope => 'global', :label => 'All Projects' }
+ { scope: 'job', label: 'This Job' },
+ { scope: 'project', label: 'This Project' },
+ { scope: 'global', label: 'All Projects' }
]
@job_id = params[:job_id]
@@ -111,7 +111,7 @@ class AnalyzeController < ApplicationController
respond_to do |format|
format.html
format.json {
- render :content_type => 'application/json', :json => render_to_string(…
+ render content_type: 'application/json', json: render_to_string(partia…
}
end
@@ -122,7 +122,7 @@ class AnalyzeController < ApplicationController
cpath = nil
cdata = "File not found"
- res = CallMedium.where(:call_id => params[:result_id].to_i).first
+ res = CallMedium.where(call_id: params[:result_id].to_i).first
if res
case params[:rtype]
@@ -153,7 +153,7 @@ class AnalyzeController < ApplicationController
end
end
- send_data(cdata, :type => ctype, :disposition => 'inline')
+ send_data(cdata, type: ctype, disposition: 'inline')
end
#
diff --git a/app/controllers/application_controller.rb b/app/controllers/applic…
@@ -52,9 +52,9 @@ private
return true unless current_user
if params[:project_id]
- @project = Project.where(:id => params[:project_id].to_i).first
+ @project = Project.where(id: params[:project_id].to_i).first
elsif session[:project_id]
- @project = Project.where(:id => session[:project_id].to_i).first
+ @project = Project.where(id: session[:project_id].to_i).first
end
if @project and @project.id and not (session[:project_id] and session[:pro…
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controll…
@@ -18,9 +18,9 @@ class HomeController < ApplicationController
def check
@has_project = ( Project.count > 0 )
- @has_provider = ( Provider.where(:enabled => true).count > 0 )
- @has_job = ( Job.where(:task => 'dialer').count > 0 )
- @has_result = ( Call.where(:answered => true ).count > 0 )
+ @has_provider = ( Provider.where(enabled: true).count > 0 )
+ @has_job = ( Job.where(task: 'dialer').count > 0 )
+ @has_result = ( Call.where(answered: true ).count > 0 )
@has_analysis = ( Call.where('analysis_completed_at IS NOT NULL').count > …
end
diff --git a/app/controllers/jobs_controller.rb b/app/controllers/jobs_controll…
@@ -35,9 +35,9 @@ class JobsController < ApplicationController
@job = Job.find(params[:id])
@call_results = {
- :Timeout => @job.calls.where(:answered => false ).count,
- :Busy => @job.calls.where(:busy => true).count,
- :Answered => @job.calls.where(:answered => true).count,
+ Timeout: @job.calls.where(answered: false ).count,
+ Busy: @job.calls.where(busy: true).count,
+ Answered: @job.calls.where(answered: true).count,
}
@@ -145,8 +145,8 @@ class JobsController < ApplicationController
def purge_calls
unless params[:result_ids].blank?
- Call.delete_all(:id => params[:result_ids])
- CallMedium.delete_all(:call_id => params[:result_ids])
+ Call.delete_all(id: params[:result_ids])
+ CallMedium.delete_all(call_id: params[:result_ids])
flash[:notice] = "Purged #{params[:result_ids].length} calls"
end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_…
@@ -2,34 +2,34 @@ class ProjectsController < ApplicationController
def index
@projects = Project.order('id DESC').paginate(
- :page => params[:page],
- :per_page => 10
+ page: params[:page],
+ per_page: 10
)
@new_project = Project.new
respond_to do |format|
format.html
- format.xml { render :xml => @projects }
+ format.xml { render xml: @projects }
end
end
def show
@project = Project.find(params[:id])
- @active_jobs = @project.jobs.where(:status => 'running', :completed_at => …
+ @active_jobs = @project.jobs.where(status: 'running', completed_at: nil)
@inactive_jobs = @project.jobs.order('id DESC').where('status NOT IN (?)'…
- :page => params[:page],
- :per_page => 30
+ page: params[:page],
+ per_page: 30
)
@boxes = {
- :called => { :cnt => @project.calls.count },
- :answered => { :cnt => @project.calls.where(:answered => true).count },
- :analyzed => { :cnt => @project.calls.where('analysis_completed_at IS N…
- :voice => { :cnt => @project.lines.where(:line_type => 'voice').coun…
- :voicemail => { :cnt => @project.lines.where(:line_type => 'voicemail').…
- :fax => { :cnt => @project.lines.where(:line_type => 'fax').count …
- :modem => { :cnt => @project.lines.where(:line_type => 'modem').coun…
+ called: { cnt: @project.calls.count },
+ answered: { cnt: @project.calls.where(answered: true).count },
+ analyzed: { cnt: @project.calls.where('analysis_completed_at IS NOT NULL…
+ voice: { cnt: @project.lines.where(line_type: 'voice').count },
+ voicemail: { cnt: @project.lines.where(line_type: 'voicemail').count },
+ fax: { cnt: @project.lines.where(line_type: 'fax').count },
+ modem: { cnt: @project.lines.where(line_type: 'modem').count }
}
if @boxes[:called][:cnt] == 0
@@ -78,7 +78,7 @@ class ProjectsController < ApplicationController
respond_to do |format|
format.html
- format.xml { render :xml => @project }
+ format.xml { render xml: @project }
end
end
@@ -86,7 +86,7 @@ class ProjectsController < ApplicationController
@new_project = Project.new
respond_to do |format|
format.html
- format.xml { render :xml => @new_project }
+ format.xml { render xml: @new_project }
end
end
@@ -102,10 +102,10 @@ class ProjectsController < ApplicationController
respond_to do |format|
if @new_project.save
format.html { redirect_to(project_path(@new_project)) }
- format.xml { render :xml => @project, :status => :created, :location …
+ format.xml { render xml: @project, status: :created, location: @new_p…
else
- format.html { render :action => "new" }
- format.xml { render :xml => @new_project.errors, :status => :unproces…
+ format.html { render action: "new" }
+ format.xml { render xml: @new_project.errors, status: :unprocessable_…
end
end
end
@@ -118,8 +118,8 @@ class ProjectsController < ApplicationController
format.html { redirect_to projects_path }
format.xml { head :ok }
else
- format.html { render :action => "edit" }
- format.xml { render :xml => @project.errors, :status => :unprocessabl…
+ format.html { render action: "edit" }
+ format.xml { render xml: @project.errors, status: :unprocessable_enti…
end
end
end
diff --git a/app/controllers/providers_controller.rb b/app/controllers/provider…
@@ -3,8 +3,8 @@ class ProvidersController < ApplicationController
def index
@providers = Provider.order('id DESC').paginate(
- :page => params[:page],
- :per_page => 10
+ page: params[:page],
+ per_page: 10
)
@new_provider = Provider.new
@@ -12,7 +12,7 @@ class ProvidersController < ApplicationController
respond_to do |format|
format.html # index.html.erb
- format.xml { render :xml => @providers }
+ format.xml { render xml: @providers }
end
end
@@ -23,7 +23,7 @@ class ProvidersController < ApplicationController
respond_to do |format|
format.html # new.html.erb
- format.xml { render :xml => @provider }
+ format.xml { render xml: @provider }
end
end
@@ -40,10 +40,10 @@ class ProvidersController < ApplicationController
if @provider.save
flash[:notice] = 'Provider was successfully created.'
format.html { redirect_to providers_path }
- format.xml { render :xml => @provider, :status => :created, :location…
+ format.xml { render xml: @provider, status: :created, location: provi…
else
- format.html { render :action => "new" }
- format.xml { render :xml => @provider.errors, :status => :unprocessab…
+ format.html { render action: "new" }
+ format.xml { render xml: @provider.errors, status: :unprocessable_ent…
end
end
end
@@ -63,8 +63,8 @@ class ProvidersController < ApplicationController
format.html { redirect_to providers_path }
format.xml { head :ok }
else
- format.html { render :action => "edit" }
- format.xml { render :xml => @provider.errors, :status => :unprocessab…
+ format.html { render action: "edit" }
+ format.xml { render xml: @provider.errors, status: :unprocessable_ent…
end
end
end
diff --git a/app/controllers/user_sessions_controller.rb b/app/controllers/user…
@@ -1,6 +1,6 @@
class UserSessionsController < ApplicationController
- before_action :require_no_user, :only => [:new, :create]
- before_action :require_user, :only => :destroy
+ before_action :require_no_user, only: [:new, :create]
+ before_action :require_user, only: :destroy
layout 'login'
def new
@@ -12,7 +12,7 @@ class UserSessionsController < ApplicationController
if @user_session.save
redirect_back_or_default projects_path
else
- render :action => :new
+ render action: :new
end
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_contro…
@@ -1,6 +1,6 @@
class UsersController < ApplicationController
- before_action :require_no_user, :only => [:new, :create]
- before_action :require_user, :only => [:show, :edit, :update]
+ before_action :require_no_user, only: [:new, :create]
+ before_action :require_user, only: [:show, :edit, :update]
def new
@user = User.new
@@ -12,7 +12,7 @@ class UsersController < ApplicationController
flash[:notice] = "Account registered!"
redirect_back_or_default user_path(@user)
else
- render :action => :new
+ render action: :new
end
end
@@ -30,7 +30,7 @@ class UsersController < ApplicationController
flash[:notice] = "Account updated!"
redirect_to user_path(@user)
else
- render :action => :edit
+ render action: :edit
end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper…
@@ -2,7 +2,7 @@
module ApplicationHelper
def select_tag_for_filter(nvpairs, params)
- _url = ( url_for :overwrite_params => { }).split('?')[0]
+ _url = ( url_for overwrite_params: { }).split('?')[0]
_html = %{<span class="pull-left filter-label">Filter: </span> }
_html << %{<select name="show" class="filter-select" }
_html << %{onchange="window.location='#{_url}' + '?show=' + this.value"> }
@@ -19,7 +19,7 @@ module ApplicationHelper
end
def select_match_scope(nvpairs, params)
- _url = ( url_for :overwrite_params => { }).split('?')[0]
+ _url = ( url_for overwrite_params: { }).split('?')[0]
_html = %{<span class="pull-left filter-label">Matching Scope: </span> }
_html << %{<select name="match_scope" class="filter-select" }
_html << %{onchange="window.location='#{_url}' + '?match_scope=' + this.va…
@@ -45,8 +45,8 @@ module ApplicationHelper
ttip = raw("<div class='task_args_formatted'>")
info.each_pair do |k,v|
- ttip << raw("<div class='task_args_var'>") + h(truncate(k.to_s, :lengt…
- ttip << raw("<div class='task_args_val'>") + h(truncate((v.to_s), :len…
+ ttip << raw("<div class='task_args_var'>") + h(truncate(k.to_s, length…
+ ttip << raw("<div class='task_args_val'>") + h(truncate((v.to_s), leng…
end
ttip << raw("</div>\n")
outp = raw("<span class='xpopover' rel='popover' data-title=\"#{job.task…
@@ -120,9 +120,9 @@ module ApplicationHelper
def submit_checkboxes_to(name, path, html={})
if html[:confirm]
confirm = html.delete(:confirm)
- link_to(name, "#", html.merge({:onclick => "if(confirm('#{h confirm}')){…
+ link_to(name, "#", html.merge({onclick: "if(confirm('#{h confirm}')){ su…
else
- link_to(name, "#", html.merge({:onclick => "submit_checkboxes_to('#{path…
+ link_to(name, "#", html.merge({onclick: "submit_checkboxes_to('#{path}',…
end
end
@@ -143,7 +143,7 @@ module ApplicationHelper
# Generate the markup for the call's row checkbox.
# Returns the String markup html, escaped for json.
def call_checkbox_tag(call)
- check_box_tag("result_ids[]", call.id, false, :id => nil).to_json.html_safe
+ check_box_tag("result_ids[]", call.id, false, id: nil).to_json.html_safe
end
def call_number_html(call)
diff --git a/app/models/call.rb b/app/models/call.rb
@@ -26,20 +26,20 @@
class Call < ApplicationRecord
- reportable :hourly, :aggregation => :count, :grouping => :hour, :live_data =…
- reportable :daily, :aggregation => :count, :grouping => :day, :live_data => …
- reportable :weekly, :aggregation => :count, :grouping => :week, :live_data =…
- reportable :monthly, :aggregation => :count, :grouping => :month, :live_data…
+ reportable :hourly, aggregation: :count, grouping: :hour, live_data: true, c…
+ reportable :daily, aggregation: :count, grouping: :day, live_data: true, cac…
+ reportable :weekly, aggregation: :count, grouping: :week, live_data: true, c…
+ reportable :monthly, aggregation: :count, grouping: :month, live_data: true,…
- reportable :analyzed_hourly, :aggregation => :count, :grouping => :hour, :da…
- reportable :analyzed_daily, :aggregation => :count, :grouping => :day, :date…
- reportable :analyzed_weekly, :aggregation => :count, :grouping => :week, :da…
- reportable :analyzed_monthly, :aggregation => :count, :grouping => :month, :…
+ reportable :analyzed_hourly, aggregation: :count, grouping: :hour, date_colu…
+ reportable :analyzed_daily, aggregation: :count, grouping: :day, date_column…
+ reportable :analyzed_weekly, aggregation: :count, grouping: :week, date_colu…
+ reportable :analyzed_monthly, aggregation: :count, grouping: :month, date_co…
belongs_to :project
belongs_to :provider
belongs_to :job
- has_one :call_medium, :dependent => :delete
+ has_one :call_medium, dependent: :delete
def matches
# "AND (( icount(\'{#{fprint.map{|x| x.to_s}.join(",")}}\'::int[] & cal…
@@ -103,7 +103,7 @@ class Call < ApplicationRecord
args << min_match.to_f
query = [match_sql, *args]
- Call.paginate_by_sql(query, :page => page, :per_page => per_page)
+ Call.paginate_by_sql(query, page: page, per_page: per_page)
end
def media
diff --git a/app/models/job.rb b/app/models/job.rb
@@ -20,10 +20,10 @@
class Job < ApplicationRecord
- reportable :hourly, :aggregation => :count, :grouping => :hour, :date_column…
- reportable :daily, :aggregation => :count, :grouping => :day, :date_column =…
- reportable :weeky, :aggregation => :count, :grouping => :week, :date_column …
- reportable :monthly, :aggregation => :count, :grouping => :month, :date_colu…
+ reportable :hourly, aggregation: :count, grouping: :hour, date_column: :crea…
+ reportable :daily, aggregation: :count, grouping: :day, date_column: :create…
+ reportable :weeky, aggregation: :count, grouping: :week, date_column: :creat…
+ reportable :monthly, aggregation: :count, grouping: :month, date_column: :cr…
class JobValidator < ActiveModel::Validator
def validate(record)
@@ -54,10 +54,10 @@ class Job < ApplicationRecord
unless ['calls', 'job', 'project', 'global'].include?(record.scope)
record.errors[:scope] << "Scope must be calls, job, project, or glob…
end
- if record.scope == "job" and Job.where(:id => record.target_id.to_i, :…
+ if record.scope == "job" and Job.where(id: record.target_id.to_i, task…
record.errors[:job_id] << "The job_id is not valid"
end
- if record.scope == "project" and Project.where(:id => record.target_id…
+ if record.scope == "project" and Project.where(id: record.target_id.to…
record.errors[:project_id] << "The project_id is not valid"
end
if record.scope == "calls" and (record.target_ids.nil? or record.targe…
@@ -71,7 +71,7 @@ class Job < ApplicationRecord
end
# XXX: Purging a single job will be slow, but deleting the project is fast
- has_many :calls, :dependent => :destroy
+ has_many :calls, dependent: :destroy
belongs_to :project
@@ -97,9 +97,9 @@ class Job < ApplicationRecord
def update_progress(pct)
if pct >= 100
- self.class.where(id: self.id).update_all(:progress => pct, :completed_at…
+ self.class.where(id: self.id).update_all(progress: pct, completed_at: Ti…
else
- self.class.where(id: self.id).update_all(:progress => pct)
+ self.class.where(id: self.id).update_all(progress: pct)
end
end
@@ -112,10 +112,10 @@ class Job < ApplicationRecord
when 'dialer'
self.status = 'submitted'
self.args = Marshal.dump({
- :range => self.range,
- :lines => self.lines.to_i,
- :seconds => self.seconds.to_i,
- :cid_mask => self.cid_mask
+ range: self.range,
+ lines: self.lines.to_i,
+ seconds: self.seconds.to_i,
+ cid_mask: self.cid_mask
})
return self.save
@@ -123,18 +123,18 @@ class Job < ApplicationRecord
when 'analysis'
self.status = 'submitted'
d = {
- :scope => self.scope, # job / pr…
- :force => !!(self.force), # true / f…
- :target_id => self.target_id.to_i, # job_id o…
- :target_ids => (self.target_ids || []).map{|x|…
+ scope: self.scope, # job / project/ g…
+ force: !!(self.force), # true / false
+ target_id: self.target_id.to_i, # job_id or pr…
+ target_ids: (self.target_ids || []).map{|x| x.…
}
$stderr.puts d.inspect
self.args = Marshal.dump({
- :scope => self.scope, # job / project/ global
- :force => !!(self.force), # true / false
- :target_id => self.target_id.to_i, # job_id or project_id or nil
- :target_ids => (self.target_ids || []).map{|x| x.to_i }
+ scope: self.scope, # job / project/ global
+ force: !!(self.force), # true / false
+ target_id: self.target_id.to_i, # job_id or project_id or nil
+ target_ids: (self.target_ids || []).map{|x| x.to_i }
})
return self.save
else
diff --git a/app/models/line.rb b/app/models/line.rb
@@ -12,7 +12,7 @@
#
class Line < ApplicationRecord
- has_many :line_attributes, :dependent => :delete_all
+ has_many :line_attributes, dependent: :delete_all
belongs_to :project
def set_attribute(name, value, ctype='text/plain')
@@ -24,6 +24,6 @@ class Line < ApplicationRecord
end
def get_attribute(name)
- LineAttribute.where(:line_id => self[:id], :name => name).first
+ LineAttribute.where(line_id: self[:id], name: name).first
end
end
diff --git a/app/models/project.rb b/app/models/project.rb
@@ -18,9 +18,9 @@ class Project < ApplicationRecord
validates_uniqueness_of :name
# This is optimized for fast project deletion, even with thousands of calls/…
- has_many :lines, :dependent => :delete_all
- has_many :line_attributes, :dependent => :delete_all
- has_many :calls, :dependent => :delete_all
- has_many :call_media, :dependent => :delete_all
- has_many :jobs, :dependent => :delete_all
+ has_many :lines, dependent: :delete_all
+ has_many :line_attributes, dependent: :delete_all
+ has_many :calls, dependent: :delete_all
+ has_many :call_media, dependent: :delete_all
+ has_many :jobs, dependent: :delete_all
end
diff --git a/app/models/provider.rb b/app/models/provider.rb
@@ -18,6 +18,6 @@ class Provider < ApplicationRecord
has_many :dial_results
validates_presence_of :name, :host, :port, :user, :pass, :lines
- validates_numericality_of :port, :less_than => 65536, :greater_than => 0
- validates_numericality_of :lines, :less_than => 255, :greater_than => 0
+ validates_numericality_of :port, less_than: 65536, greater_than: 0
+ validates_numericality_of :lines, less_than: 255, greater_than: 0
end
diff --git a/app/models/user.rb b/app/models/user.rb
@@ -27,8 +27,8 @@ class User < ApplicationRecord
include RailsSettings::Extend
acts_as_authentic do |c|
c.validate_email_field = false
- c.merge_validates_length_of_password_field_options :minimum => 8
- c.merge_validates_length_of_password_confirmation_field_options :minimum =…
+ c.merge_validates_length_of_password_field_options minimum: 8
+ c.merge_validates_length_of_password_confirmation_field_options minimum: 8
c.logged_in_timeout = 1.day
end
end
diff --git a/bin/adduser b/bin/adduser
@@ -9,7 +9,7 @@ require 'bundler/setup'
# rails/all must be required explicitly to get the railties that pro/ui/config…
require 'rails/all'
# require all the gems in the current environment
-Bundler.require(*Rails.groups(:assets => %w(development test cucumber)))
+Bundler.require(*Rails.groups(assets: %w(development test cucumber)))
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
diff --git a/bin/export_audio.rb b/bin/export_audio.rb
@@ -49,7 +49,7 @@ end
FileUtils.mkdir_p(output)
begin
- cond = { :project_id => project_id.to_i, :answered => true, :busy => false }
+ cond = { project_id: project_id.to_i, answered: true, busy: false }
if line_type
cond[:line_type] = line_type.downcase
end
diff --git a/bin/export_list.rb b/bin/export_list.rb
@@ -51,7 +51,7 @@ end
fields = %W{ number line_type caller_id answered busy audio_length ring_length…
begin
$stdout.puts fields.to_csv
- cond = { :project_id => project_id.to_i }
+ cond = { project_id: project_id.to_i }
if line_type
cond[:line_type] = line_type.downcase
end
diff --git a/bin/iaxrecord.rb b/bin/iaxrecord.rb
@@ -16,7 +16,7 @@ require "optparse"
parser = OptionParser.new
opts = {
- :recording_time => 52
+ recording_time: 52
}
parser.banner = "Usage: #{$0} [options]"
diff --git a/bin/import_audio.rb b/bin/import_audio.rb
@@ -49,7 +49,7 @@ project = nil
provider = nil
if project_id
- project = Project.where(:id => project_id).first
+ project = Project.where(id: project_id).first
unless project
$stderr.puts "Error: Specified Project ID not found"
exit(1)
@@ -57,7 +57,7 @@ if project_id
end
if provider_id
- provider = Provider.where(:id => provider_id).first
+ provider = Provider.where(id: provider_id).first
unless provider
$stderr.puts "Error: Specified Provider ID not found"
exit(1)
@@ -66,21 +66,21 @@ end
unless project
project = Project.create(
- :name => "Import from #{dir} at #{Time.now.utc.to_s}",
- :created_by => "importer"
+ name: "Import from #{dir} at #{Time.now.utc.to_s}",
+ created_by: "importer"
)
end
provider = Provider.first
unless provider
provider = Provider.create(
- :name => 'Import Provider',
- :host => 'localhost',
- :port => 4369,
- :user => "null",
- :pass => "null",
- :lines => 1,
- :enabled => false
+ name: 'Import Provider',
+ host: 'localhost',
+ port: 4369,
+ user: "null",
+ pass: "null",
+ lines: 1,
+ enabled: false
)
end
@@ -92,7 +92,7 @@ job.locked_at = Time.now.utc
job.started_at = Time.now.utc
job.created_by = "importer"
job.task = "import"
-job.args = Marshal.dump({ :directory => dir, :project_id => project.id…
+job.args = Marshal.dump({ directory: dir, project_id: project.id, prov…
job.status = "running"
job.save!
diff --git a/bin/resetpw b/bin/resetpw
@@ -9,7 +9,7 @@ require 'bundler/setup'
# rails/all must be required explicitly to get the railties that pro/ui/config…
require 'rails/all'
# require all the gems in the current environment
-Bundler.require(*Rails.groups(:assets => %w(development test cucumber)))
+Bundler.require(*Rails.groups(assets: %w(development test cucumber)))
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
diff --git a/bin/worker_manager.rb b/bin/worker_manager.rb
@@ -32,7 +32,7 @@ def stop
end
# Update the database
- Job.update_all({ :status => "stopped", :completed_at => Time.now.utc}, { :id…
+ Job.update_all({ status: "stopped", completed_at: Time.now.utc}, { id: @jobs…
# Signal running jobs to shut down
@jobs.map{|j| Process.kill("TERM", j[:pid]) rescue nil }
@@ -55,8 +55,8 @@ end
def schedule_job(j)
WarVOX::Log.debug("Worker Manager is launching job #{j.id}")
@jobs << {
- :id => j.id,
- :pid => Process.fork { exec("#{@worker_path} #{j.id}") }
+ id: j.id,
+ pid: Process.fork { exec("#{@worker_path} #{j.id}") }
}
end
@@ -67,7 +67,7 @@ def stop_cancelled_jobs
end
return if jids.length == 0
- Job.where(:status => 'cancelled', :id => jids).find_each do |j|
+ Job.where(status: 'cancelled', id: jids).find_each do |j|
job = @jobs.select{ |o| o[:id] == j.id }.first
next unless job and job[:pid]
pid = job[:pid]
@@ -131,7 +131,7 @@ def clear_stale_jobs
# Mark these jobs as abandoned
if dead.length > 0
WarVOX::Log.debug("Worker Manager is marking #{dead.length} jobs as abando…
- Job.where(:id => dead).update_all({locked_by: nil, status: 'abandoned'})
+ Job.where(id: dead).update_all({locked_by: nil, status: 'abandoned'})
end
end
diff --git a/config/routes.rb b/config/routes.rb
@@ -50,5 +50,5 @@ Rails.application.routes.draw do
get '/help' => 'home#help', :as => :help
get '/check' => 'home#check', :as => :check
- root :to => "projects#index"
+ root to: "projects#index"
end
diff --git a/db/migrate/20121228171549_initial_schema.rb b/db/migrate/201212281…
@@ -5,27 +5,27 @@ class InitialSchema < ActiveRecord::Migration[5.0]
execute("CREATE EXTENSION IF NOT EXISTS intarray")
create_table :settings do |t|
- t.string :var, :null => false
- t.text :value, :null => true
- t.integer :thing_id, :null => true
- t.string :thing_type, :limit => 30, :null => true
+ t.string :var, null: false
+ t.text :value, null: true
+ t.integer :thing_id, null: true
+ t.string :thing_type, limit: 30, null: true
t.timestamps null: false
end
- add_index :settings, [ :thing_type, :thing_id, :var ], :unique => true
+ add_index :settings, [ :thing_type, :thing_id, :var ], unique: true
create_table 'users' do |t|
- t.string :login, :null => false # option…
- t.string :email, :null => true # option…
- t.string :crypted_password, :null => false # option…
- t.string :password_salt, :null => false # option…
- t.string :persistence_token, :null => false # requir…
- t.string :single_access_token, :null => false # option…
- t.string :perishable_token, :null => false # option…
+ t.string :login, null: false # optional,…
+ t.string :email, null: true # optional,…
+ t.string :crypted_password, null: false # optional,…
+ t.string :password_salt, null: false # optional,…
+ t.string :persistence_token, null: false # required
+ t.string :single_access_token, null: false # optional,…
+ t.string :perishable_token, null: false # optional,…
# Magic columns, just like ActiveRecord's created_at and updated_at. The…
- t.integer :login_count, :null => false, :default => 0 # option…
- t.integer :failed_login_count, :null => false, :default => 0 # option…
+ t.integer :login_count, null: false, default: 0 # optional, se…
+ t.integer :failed_login_count, null: false, default: 0 # optional, se…
t.datetime :last_request_at # option…
t.datetime :current_login_at # option…
t.datetime :last_login_at # option…
@@ -33,13 +33,13 @@ class InitialSchema < ActiveRecord::Migration[5.0]
t.string :last_login_ip # option…
t.timestamps null: false
- t.boolean "enabled", :default => true
- t.boolean "admin", :default => true
+ t.boolean "enabled", default: true
+ t.boolean "admin", default: true
end
create_table 'projects' do |t|
t.timestamps null: false
- t.text "name", :null => false
+ t.text "name", null: false
t.text "description"
t.text "included"
t.text "excluded"
@@ -48,43 +48,43 @@ class InitialSchema < ActiveRecord::Migration[5.0]
create_table "jobs" do |t|
t.timestamps null: false
- t.integer "project_id", :null => false
+ t.integer "project_id", null: false
t.string "locked_by"
t.timestamp "locked_at"
t.timestamp "started_at"
t.timestamp "completed_at"
t.string "created_by"
- t.string "task", :null => false
+ t.string "task", null: false
t.binary "args"
t.string "status"
t.text "error"
- t.integer "progress", :default => 0
+ t.integer "progress", default: 0
end
create_table "lines" do |t|
t.timestamps null: false
- t.text "number", :null => false
- t.integer "project_id", :null => false
+ t.text "number", null: false
+ t.integer "project_id", null: false
t.text "line_type"
t.text "notes"
end
create_table "line_attributes" do |t|
t.timestamps null: false
- t.integer "line_id", :null => false
- t.integer "project_id", :null => false
- t.text "name", :null => false
- t.binary "value", :null => false
- t.string "content_type", :default => "text"
+ t.integer "line_id", null: false
+ t.integer "project_id", null: false
+ t.text "name", null: false
+ t.binary "value", null: false
+ t.string "content_type", default: "text"
end
create_table "calls" do |t|
# Created by the dialer job
t.timestamps null: false
- t.text "number", :null => false
- t.integer "project_id", :null => false
- t.integer "job_id", :null => false
- t.integer "provider_id", :null => false
+ t.text "number", null: false
+ t.integer "project_id", null: false
+ t.integer "job_id", null: false
+ t.integer "provider_id", null: false
t.boolean "answered"
t.boolean "busy"
t.text "error"
@@ -99,12 +99,12 @@ class InitialSchema < ActiveRecord::Migration[5.0]
t.float "peak_freq"
t.text "peak_freq_data"
t.text "line_type"
- t.integer "fprint", :array => true
+ t.integer "fprint", array: true
end
create_table "call_media" do |t|
- t.integer "call_id", :null => false
- t.integer "project_id", :null => false
+ t.integer "call_id", null: false
+ t.integer "project_id", null: false
t.binary "audio"
t.binary "mp3"
t.binary "png_big"
@@ -116,7 +116,7 @@ class InitialSchema < ActiveRecord::Migration[5.0]
create_table "signatures" do |t|
t.timestamps null: false
- t.text "name", :null => false
+ t.text "name", null: false
t.string "source"
t.text "description"
t.string "category"
@@ -125,19 +125,19 @@ class InitialSchema < ActiveRecord::Migration[5.0]
end
create_table "signature_fp" do |t|
- t.integer "signature_id", :null => false
- t.integer "fprint", :array => true
+ t.integer "signature_id", null: false
+ t.integer "fprint", array: true
end
create_table "providers" do |t|
t.timestamps null: false
- t.text "name", :null => false
- t.text "host", :null => false
- t.integer "port", :null => false
+ t.text "name", null: false
+ t.text "host", null: false
+ t.integer "port", null: false
t.text "user"
t.text "pass"
- t.integer "lines", :null => false, :default => 1
- t.boolean "enabled", :default => true
+ t.integer "lines", null: false, default: 1
+ t.boolean "enabled", default: true
end
add_index :jobs, :project_id
diff --git a/db/migrate/20130113004653_create_reportable_cache.rb b/db/migrate/…
@@ -1,13 +1,13 @@
class CreateReportableCache < ActiveRecord::Migration[5.0]
def up
- create_table :reportable_cache, :force => true do |t|
- t.string :model_name, :null => false, :limit => 100
- t.string :report_name, :null => false, :limit => 100
- t.string :grouping, :null => false, :limit => 10
- t.string :aggregation, :null => false, :limit => 10
- t.string :conditions, :null => false, :limit => 100
- t.float :value, :null => false, :default =>…
- t.datetime :reporting_period, :null => false
+ create_table :reportable_cache, force: true do |t|
+ t.string :model_name, null: false, limit: 100
+ t.string :report_name, null: false, limit: 100
+ t.string :grouping, null: false, limit: 10
+ t.string :aggregation, null: false, limit: 10
+ t.string :conditions, null: false, limit: 100
+ t.float :value, null: false, default: 0
+ t.datetime :reporting_period, null: false
t.timestamps null: false
end
@@ -18,7 +18,7 @@ class CreateReportableCache < ActiveRecord::Migration[5.0]
:grouping,
:aggregation,
:conditions
- ], :name => :name_model_grouping_agregation
+ ], name: :name_model_grouping_agregation
add_index :reportable_cache, [
:model_name,
:report_name,
@@ -26,12 +26,12 @@ class CreateReportableCache < ActiveRecord::Migration[5.0]
:aggregation,
:conditions,
:reporting_period
- ], :unique => true, :name => :name_model_grouping_aggregation_period
+ ], unique: true, name: :name_model_grouping_aggregation_period
end
def self.down
- remove_index :reportable_cache, :name => :name_model_grouping_agregation
- remove_index :reportable_cache, :name => :name_model_grouping_aggregation_…
+ remove_index :reportable_cache, name: :name_model_grouping_agregation
+ remove_index :reportable_cache, name: :name_model_grouping_aggregation_per…
drop_table :reportable_cache
end
diff --git a/lib/warvox/audio/raw.rb b/lib/warvox/audio/raw.rb
@@ -88,7 +88,7 @@ class Raw
raise RuntimeError, "The sox binary could not be find, make sure it is i…
end
- o, s = Open3.capture2("#{sox} -t raw -b 16 -e signed-integer -r 8000 - -t …
+ o, s = Open3.capture2("#{sox} -t raw -b 16 -e signed-integer -r 8000 - -t …
o
end
diff --git a/lib/warvox/jobs/analysis.rb b/lib/warvox/jobs/analysis.rb
@@ -72,27 +72,27 @@ class Analysis < Base
case @conf[:scope]
when 'calls'
if @conf[:force]
- query = {:id => @conf[:target_ids], :answered => true, :busy => false}
+ query = {id: @conf[:target_ids], answered: true, busy: false}
else
- query = {:id => @conf[:target_ids], :answered => true, :busy => false,…
+ query = {id: @conf[:target_ids], answered: true, busy: false, analysis…
end
when 'job'
if @conf[:force]
- query = {:job_id => @conf[:target_id], :answered => true, :busy => fal…
+ query = {job_id: @conf[:target_id], answered: true, busy: false}
else
- query = {:job_id => @conf[:target_id], :answered => true, :busy => fal…
+ query = {job_id: @conf[:target_id], answered: true, busy: false, analy…
end
when 'project'
if @conf[:force]
- query = {:project_id => @conf[:target_id], :answered => true, :busy =>…
+ query = {project_id: @conf[:target_id], answered: true, busy: false}
else
- query = {:project_id => @conf[:target_id], :answered => true, :busy =>…
+ query = {project_id: @conf[:target_id], answered: true, busy: false, a…
end
when 'global'
if @conf[:force]
- query = {:answered => true, :busy => false}
+ query = {answered: true, busy: false}
else
- query = {:answered => true, :busy => false, :analysis_started_at => ni…
+ query = {answered: true, busy: false, analysis_started_at: nil}
end
else
# Bail if we don't have a valid scope
@@ -295,14 +295,14 @@ class Analysis < Base
sproc = Classifier.new
sproc.data =
{
- :raw => raw,
- :freq => freq,
- :fcnt => fcnt,
- :fft => fft,
- :pks => pks,
- :pkz => pkz,
- :maxf => maxf,
- :maxp => maxp
+ raw: raw,
+ freq: freq,
+ fcnt: fcnt,
+ fft: fft,
+ pks: pks,
+ pkz: pkz,
+ maxf: maxf,
+ maxp: maxp
}
WarVOX::Config.classifiers_load.each do |sigfile|
diff --git a/lib/warvox/jobs/dialer.rb b/lib/warvox/jobs/dialer.rb
@@ -48,15 +48,15 @@ class Dialer < Base
res = []
::ActiveRecord::Base.connection_pool.with_connection {
- ::Provider.where(:enabled => true).all.each do |prov|
+ ::Provider.where(enabled: true).all.each do |prov|
info = {
- :name => prov.name,
- :id => prov.id,
- :port => prov.port,
- :host => prov.host,
- :user => prov.user,
- :pass => prov.pass,
- :lines => prov.lines
+ name: prov.name,
+ id: prov.id,
+ port: prov.port,
+ host: prov.host,
+ user: prov.user,
+ pass: prov.pass,
+ lines: prov.lines
}
1.upto(prov.lines) {|i| res.push(info) }
end
diff --git a/lib/warvox/proto/iax2/client.rb b/lib/warvox/proto/iax2/client.rb
@@ -22,10 +22,10 @@ class Client
def initialize(uopts={})
opts = {
- :caller_number => '15555555555',
- :caller_name => '',
- :server_port => IAX2_DEFAULT_PORT,
- :context => { }
+ caller_number: '15555555555',
+ caller_name: '',
+ server_port: IAX2_DEFAULT_PORT,
+ context: { }
}.merge(uopts)
self.caller_name = opts[:caller_name]
diff --git a/spec/factories/settings.rb b/spec/factories/settings.rb
@@ -12,7 +12,7 @@
#
FactoryGirl.define do
- factory :setting, :class => 'Settings' do
+ factory :setting, class: 'Settings' do
var "CachedStuff"
end
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.