CombinedText stringlengths 4 3.42M |
|---|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
Add some DB seeds
Configurations.create(name: 'default', audit_frequency: 24 * 60, github_token: '')
rules = [
{
name: 'strong_vuln_patterns',
rule_type_id: 7,
value: '(?i)(advisory|attack|\bCVE\b|exploit|\bPOC\b|proof.of.concept|victim|\bvuln|\bRCE\b|remote.code.execution|\bDOS\b|denial.of.service)',
description: 'Likely to indicate vulnerability'
},
{
name: 'markdown_file',
rule_type_id: 1,
value: '(?i)\.(md|markdown)\z',
description: 'Markdown file'
},
{
name: 'non_code_file',
rule_type_id: 1,
value: '(?i)\.(log|cfg|ini|text|config|md|markdown|txt|yml|yaml)\z',
description: 'Plaintext file types'
},
{
name: 'medium_vuln_patterns',
rule_type_id: 7,
value: '(?i)(insecure|\bsecure|\bsecurity|expose|exposing|RFC\d{4,5}|infinite loop|compliant|privelage|\bescalat|(de)?serializ)',
description: 'Keywords sometimes associated with vulns'
},
{
name: 'weak_vuln_patterns',
rule_type_id: 4,
value: '(?i)(\bweak|\bcrypto|escalate)',
description: 'Weakly associated with vulns'
},
{
name: 'high_profile',
rule_type_id: 6,
value: 'strong_vuln_patterns && !non_code_file',
description: 'Strong vuln pattern but not in a non code file'
},
]
rules.each { |r| Rules.create(r) }
RuleSets.create(name: 'global', rules: ['high_profile'].to_json, description: 'Global rule set')
Projects.create(name: 'srcclr/commit_watcher', rule_sets: ['global'].to_json)
|
# window.rb
module Ruby2D
class Window
attr_reader :title, :width, :height, :mouse_x, :mouse_y
def initialize(width: 640, height: 480, title: "Ruby 2D", fps: 60, vsync: true)
@width, @height, @title = width, height, title
@mouse_x = @mouse_y = 0
@fps_cap = fps
@fps = 60
@vsync = vsync
@objects = []
@keys = {}
@keys_down = {}
@controller = {}
@update_proc = Proc.new {}
end
def get(sym)
case sym
when :window
return self
when :title
return @title
when :width
return @width
when :height
return @height
when :fps
return @fps
when :mouse_x
return @mouse_x
when :mouse_y
return @mouse_y
end
end
def set(opts)
valid_keys = [:title, :width, :height]
valid_opts = opts.reject { |k| !valid_keys.include?(k) }
if !valid_opts.empty?
@title = valid_opts[:title]
@width = valid_opts[:width]
@height = valid_opts[:height]
return true
else
return false
end
end
def add(o)
case o
when nil
raise Error, "Cannot add '#{o.class}' to window!"
when Array
o.each { |x| add_object(x) }
else
add_object(o)
end
end
def remove(o)
if o == nil
raise Error, "Cannot remove '#{o.class}' from window!"
end
if i = @objects.index(o)
@objects.slice!(i)
true
else
false
end
end
def clear
@objects.clear
end
def update(&proc)
@update_proc = proc
true
end
def on(mouse: nil, key: nil, key_down: nil, controller: nil, &proc)
unless mouse.nil?
# reg_mouse(btn, &proc)
end
unless key.nil?
reg_key(key, &proc)
end
unless key_down.nil?
reg_key_down(key_down, &proc)
end
unless controller.nil?
reg_controller(controller, &proc)
end
end
def key_callback(key)
key.downcase!
if @keys.has_key? key
@keys[key].call
end
end
def key_down_callback(key)
key.downcase!
if @keys_down.has_key? key
@keys_down[key].call
end
end
def controller_callback(is_axis, axis, val, is_btn, btn)
# puts "is_axis: #{is_axis}, axis: #{axis}, val: #{val}, is_btn: #{is_btn}, btn: #{btn}"
if is_axis
if axis == 0 && val == -32768
event = 'left'
elsif axis == 0 && val == 32767
event = 'right'
elsif axis == 1 && val == -32768
event = 'up'
elsif axis == 1 && val == 32767
event = 'down'
end
elsif is_btn
event = btn
end
if @controller.has_key? event
@controller[event].call
end
end
def update_callback
@update_proc.call
end
private
def add_object(o)
if !@objects.include?(o)
@objects.push(o)
true
else
false
end
end
# Register key string with proc
def reg_key(key, &proc)
@keys[key] = proc
true
end
# Register key string with proc
def reg_key_down(key, &proc)
@keys_down[key] = proc
true
end
# Register controller string with proc
def reg_controller(event, &proc)
@controller[event] = proc
true
end
end
end
Fix failing DSL test
`set` must be able set a single window attribute without making others
nil
# window.rb
module Ruby2D
class Window
attr_reader :title, :width, :height, :mouse_x, :mouse_y
def initialize(width: 640, height: 480, title: "Ruby 2D", fps: 60, vsync: true)
@width, @height, @title = width, height, title
@mouse_x = @mouse_y = 0
@fps_cap = fps
@fps = 60
@vsync = vsync
@objects = []
@keys = {}
@keys_down = {}
@controller = {}
@update_proc = Proc.new {}
end
def get(sym)
case sym
when :window
return self
when :title
return @title
when :width
return @width
when :height
return @height
when :fps
return @fps
when :mouse_x
return @mouse_x
when :mouse_y
return @mouse_y
end
end
def set(opts)
# Store new window attributes, or ignore if nil
@title = opts[:title] || @title
@width = opts[:width] || @width
@height = opts[:height] || @height
end
def add(o)
case o
when nil
raise Error, "Cannot add '#{o.class}' to window!"
when Array
o.each { |x| add_object(x) }
else
add_object(o)
end
end
def remove(o)
if o == nil
raise Error, "Cannot remove '#{o.class}' from window!"
end
if i = @objects.index(o)
@objects.slice!(i)
true
else
false
end
end
def clear
@objects.clear
end
def update(&proc)
@update_proc = proc
true
end
def on(mouse: nil, key: nil, key_down: nil, controller: nil, &proc)
unless mouse.nil?
# reg_mouse(btn, &proc)
end
unless key.nil?
reg_key(key, &proc)
end
unless key_down.nil?
reg_key_down(key_down, &proc)
end
unless controller.nil?
reg_controller(controller, &proc)
end
end
def key_callback(key)
key.downcase!
if @keys.has_key? key
@keys[key].call
end
end
def key_down_callback(key)
key.downcase!
if @keys_down.has_key? key
@keys_down[key].call
end
end
def controller_callback(is_axis, axis, val, is_btn, btn)
# puts "is_axis: #{is_axis}, axis: #{axis}, val: #{val}, is_btn: #{is_btn}, btn: #{btn}"
if is_axis
if axis == 0 && val == -32768
event = 'left'
elsif axis == 0 && val == 32767
event = 'right'
elsif axis == 1 && val == -32768
event = 'up'
elsif axis == 1 && val == 32767
event = 'down'
end
elsif is_btn
event = btn
end
if @controller.has_key? event
@controller[event].call
end
end
def update_callback
@update_proc.call
end
private
def add_object(o)
if !@objects.include?(o)
@objects.push(o)
true
else
false
end
end
# Register key string with proc
def reg_key(key, &proc)
@keys[key] = proc
true
end
# Register key string with proc
def reg_key_down(key, &proc)
@keys_down[key] = proc
true
end
# Register controller string with proc
def reg_controller(event, &proc)
@controller[event] = proc
true
end
end
end
|
require 'RMagick'
require 'base64'
module ReallySimpleCaptcha::Captcha
module PlainCaptcha
DEFAULT_OPTIONS = {
width: 120,
height: 40,
wave_amplitude: 4.0,
wave_length: 60.0,
implode_amount: 0.3,
pointsize: 22,
text_fill: 'darkblue',
background_color: 'white'
}
include ActiveSupport::Configurable
config_accessor :field_name
config_accessor :width
config_accessor :height
config_accessor :implode_amount
config_accessor :wave_amplitude
config_accessor :wave_length
config_accessor :pointsize
config_accessor :fill
config_accessor :background_color
config_accessor :text_length
config.field_name = :plain_captcha
config.text_length = 6
def self.configure(&block)
yield config
end
module ViewHelpers
def plain_captcha_tag
session[PlainCaptcha.field_name] = ReallySimpleCaptcha::Util.random_string(PlainCaptcha.text_length)
image = PlainCaptcha.generate_image(session[:plain_captcha],
PlainCaptcha.config.select { |k,v| DEFAULT_OPTIONS.has_key?(k) })
content_tag :div, class: 'plain_captcha' do
html = image_tag "data:image/gif;base64,#{image}", alt: "Captcha"
html.concat text_field_tag PlainCaptcha.field_name, nil, required: 'required', autocomplete: 'off'
html
end
end
end
module ControllerHelpers
def plain_captcha_valid?
return true if Rails.env.test?
res = params[PlainCaptcha.field_name] == session[PlainCaptcha.field_name]
session[PlainCaptcha.field_name] = nil
res
end
end
def self.generate_image(captcha_text, args={})
options = DEFAULT_OPTIONS.merge(args)
image = ::Magick::Image.new(options[:width], options[:height]) do
self.background_color = options[:background_color]
end
text = ::Magick::Draw.new do
self.pointsize = options[:pointsize]
self.gravity = ::Magick::CenterGravity
self.fill = options[:text_fill]
end
text.annotate(image, 0, 0, 0, 0, captcha_text)
image = image.implode(options[:implode_amount]).wave(options[:wave_amplitude], options[:wave_length])
Base64.strict_encode64(image.to_blob { self.format = 'GIF' })
end
end
end
Require 'rmagick' instead of 'RMagick'
require 'rmagick'
require 'base64'
module ReallySimpleCaptcha::Captcha
module PlainCaptcha
DEFAULT_OPTIONS = {
width: 120,
height: 40,
wave_amplitude: 4.0,
wave_length: 60.0,
implode_amount: 0.3,
pointsize: 22,
text_fill: 'darkblue',
background_color: 'white'
}
include ActiveSupport::Configurable
config_accessor :field_name
config_accessor :width
config_accessor :height
config_accessor :implode_amount
config_accessor :wave_amplitude
config_accessor :wave_length
config_accessor :pointsize
config_accessor :fill
config_accessor :background_color
config_accessor :text_length
config.field_name = :plain_captcha
config.text_length = 6
def self.configure(&block)
yield config
end
module ViewHelpers
def plain_captcha_tag
session[PlainCaptcha.field_name] = ReallySimpleCaptcha::Util.random_string(PlainCaptcha.text_length)
image = PlainCaptcha.generate_image(session[:plain_captcha],
PlainCaptcha.config.select { |k,v| DEFAULT_OPTIONS.has_key?(k) })
content_tag :div, class: 'plain_captcha' do
html = image_tag "data:image/gif;base64,#{image}", alt: "Captcha"
html.concat text_field_tag PlainCaptcha.field_name, nil, required: 'required', autocomplete: 'off'
html
end
end
end
module ControllerHelpers
def plain_captcha_valid?
return true if Rails.env.test?
res = params[PlainCaptcha.field_name] == session[PlainCaptcha.field_name]
session[PlainCaptcha.field_name] = nil
res
end
end
def self.generate_image(captcha_text, args={})
options = DEFAULT_OPTIONS.merge(args)
image = ::Magick::Image.new(options[:width], options[:height]) do
self.background_color = options[:background_color]
end
text = ::Magick::Draw.new do
self.pointsize = options[:pointsize]
self.gravity = ::Magick::CenterGravity
self.fill = options[:text_fill]
end
text.annotate(image, 0, 0, 0, 0, captcha_text)
image = image.implode(options[:implode_amount]).wave(options[:wave_amplitude], options[:wave_length])
Base64.strict_encode64(image.to_blob { self.format = 'GIF' })
end
end
end
|
# encoding: utf-8
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Emanuel', :city => cities.first)
# clear old caches to start from scratch
Cache.clear
Setting.create_if_not_exists(
title: 'Application secret',
name: 'application_secret',
area: 'Core',
description: 'Defines the random application secret.',
options: {},
state: SecureRandom.hex(128),
preferences: {
permission: ['admin'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'System Init Done',
name: 'system_init_done',
area: 'Core',
description: 'Defines if application is in init mode.',
options: {},
state: false,
preferences: { online_service_disable: true },
frontend: true
)
Setting.create_if_not_exists(
title: 'App Version',
name: 'app_version',
area: 'Core::WebApp',
description: 'Only used internally to propagate current web app version to clients.',
options: {},
state: '',
preferences: { online_service_disable: true },
frontend: false
)
Setting.create_if_not_exists(
title: 'Maintenance Mode',
name: 'maintenance_mode',
area: 'Core::WebApp',
description: 'Enable or disable the maintenance mode of Zammad. If enabled, all non-administrators get logged out and only administrators can start a new session.',
options: {},
state: false,
preferences: {
permission: ['admin.maintenance'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Maintenance Login',
name: 'maintenance_login',
area: 'Core::WebApp',
description: 'Put a message on the login page. To change it, click on the text area below and change it inline.',
options: {},
state: false,
preferences: {
permission: ['admin.maintenance'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Maintenance Login',
name: 'maintenance_login_message',
area: 'Core::WebApp',
description: 'Message for login page.',
options: {},
state: 'Something about to share. Click here to change.',
preferences: {
permission: ['admin.maintenance'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Developer System',
name: 'developer_mode',
area: 'Core::Develop',
description: 'Defines if application is in developer mode (useful for developer, all users have the same password, password reset will work without email delivery).',
options: {},
state: false,
preferences: { online_service_disable: true },
frontend: true
)
Setting.create_if_not_exists(
title: 'Online Service',
name: 'system_online_service',
area: 'Core',
description: 'Defines if application is used as online service.',
options: {},
state: false,
preferences: { online_service_disable: true },
frontend: true
)
Setting.create_if_not_exists(
title: 'Product Name',
name: 'product_name',
area: 'System::Branding',
description: 'Defines the name of the application, shown in the web interface, tabs and title bar of the web browser.',
options: {
form: [
{
display: '',
null: false,
name: 'product_name',
tag: 'input',
},
],
},
preferences: {
render: true,
prio: 1,
placeholder: true,
permission: ['admin.branding'],
},
state: 'Zammad Helpdesk',
frontend: true
)
Setting.create_if_not_exists(
title: 'Logo',
name: 'product_logo',
area: 'System::Branding',
description: 'Defines the logo of the application, shown in the web interface.',
options: {
form: [
{
display: '',
null: false,
name: 'product_logo',
tag: 'input',
},
],
},
preferences: {
prio: 3,
controller: 'SettingsAreaLogo',
permission: ['admin.branding'],
},
state: 'logo.svg',
frontend: true
)
Setting.create_if_not_exists(
title: 'Organization',
name: 'organization',
area: 'System::Branding',
description: 'Will be shown in the app and is included in email footers.',
options: {
form: [
{
display: '',
null: false,
name: 'organization',
tag: 'input',
},
],
},
state: '',
preferences: {
prio: 2,
placeholder: true,
permission: ['admin.branding'],
},
frontend: true
)
options = {}
(10..99).each { |item|
options[item] = item
}
system_id = rand(10..99)
Setting.create_if_not_exists(
title: 'SystemID',
name: 'system_id',
area: 'System::Base',
description: 'Defines the system identifier. Every ticket number contains this ID. This ensures that only tickets which belong to your system will be processed as follow-ups (useful when communicating between two instances of Zammad).',
options: {
form: [
{
display: '',
null: true,
name: 'system_id',
tag: 'select',
options: options,
},
],
},
state: system_id,
preferences: {
online_service_disable: true,
placeholder: true,
authentication: true,
permission: ['admin.system'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Fully Qualified Domain Name',
name: 'fqdn',
area: 'System::Base',
description: 'Defines the fully qualified domain name of the system. This setting is used as a variable, #{setting.fqdn} which is found in all forms of messaging used by the application, to build links to the tickets within your system.',
options: {
form: [
{
display: '',
null: false,
name: 'fqdn',
tag: 'input',
},
],
},
state: 'zammad.example.com',
preferences: {
online_service_disable: true,
placeholder: true,
permission: ['admin.system'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Websocket port',
name: 'websocket_port',
area: 'System::WebSocket',
description: 'Defines the port of the websocket server.',
options: {
form: [
{
display: '',
null: false,
name: 'websocket_port',
tag: 'input',
},
],
},
state: '6042',
preferences: { online_service_disable: true },
frontend: true
)
Setting.create_if_not_exists(
title: 'HTTP type',
name: 'http_type',
area: 'System::Base',
description: 'Define the http protocol of your instance.',
options: {
form: [
{
display: '',
null: true,
name: 'http_type',
tag: 'select',
options: {
'https' => 'https',
'http' => 'http',
},
},
],
},
state: 'http',
preferences: {
online_service_disable: true,
placeholder: true,
permission: ['admin.system'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Storage Mechanism',
name: 'storage_provider',
area: 'System::Storage',
description: '"Database" stores all attachments in the database (not recommended for storing large amounts of data). "Filesystem" stores the data in the filesystem. You can switch between the modules even on a system that is already in production without any loss of data.',
options: {
form: [
{
display: '',
null: true,
name: 'storage_provider',
tag: 'select',
tranlate: true,
options: {
'DB' => 'Database',
'File' => 'Filesystem',
},
},
],
},
state: 'DB',
preferences: {
controller: 'SettingsAreaStorageProvider',
online_service_disable: true,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Image Service',
name: 'image_backend',
area: 'System::Services',
description: 'Defines the backend for user and organization image lookups.',
options: {
form: [
{
display: '',
null: true,
name: 'image_backend',
tag: 'select',
options: {
'' => '-',
'Service::Image::Zammad' => 'Zammad Image Service',
},
},
],
},
state: 'Service::Image::Zammad',
preferences: {
prio: 1,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Geo IP Service',
name: 'geo_ip_backend',
area: 'System::Services',
description: 'Defines the backend for geo IP lookups. Shows also location of an IP address if an IP address is shown.',
options: {
form: [
{
display: '',
null: true,
name: 'geo_ip_backend',
tag: 'select',
options: {
'' => '-',
'Service::GeoIp::Zammad' => 'Zammad GeoIP Service',
},
},
],
},
state: 'Service::GeoIp::Zammad',
preferences: {
prio: 2,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Geo Location Service',
name: 'geo_location_backend',
area: 'System::Services',
description: 'Defines the backend for geo location lookups to store geo locations for addresses.',
options: {
form: [
{
display: '',
null: true,
name: 'geo_location_backend',
tag: 'select',
options: {
'' => '-',
'Service::GeoLocation::Gmaps' => 'Google Maps',
},
},
],
},
state: 'Service::GeoLocation::Gmaps',
preferences: {
prio: 3,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Geo Calendar Service',
name: 'geo_calendar_backend',
area: 'System::Services',
description: 'Defines the backend for geo calendar lookups. Used for initial calendar succession.',
options: {
form: [
{
display: '',
null: true,
name: 'geo_calendar_backend',
tag: 'select',
options: {
'' => '-',
'Service::GeoCalendar::Zammad' => 'Zammad GeoCalendar Service',
},
},
],
},
state: 'Service::GeoCalendar::Zammad',
preferences: {
prio: 2,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Proxy Settings',
name: 'proxy',
area: 'System::Network',
description: 'Address of the proxy server for http and https resources.',
options: {
form: [
{
display: '',
null: false,
name: 'proxy',
tag: 'input',
placeholder: 'proxy.example.com:3128',
},
],
},
state: '',
preferences: {
online_service_disable: true,
controller: 'SettingsAreaProxy',
prio: 1,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Proxy User',
name: 'proxy_username',
area: 'System::Network',
description: 'Username for proxy connection.',
options: {
form: [
{
display: '',
null: false,
name: 'proxy_username',
tag: 'input',
},
],
},
state: '',
preferences: {
disabled: true,
online_service_disable: true,
prio: 2,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Proxy Password',
name: 'proxy_password',
area: 'System::Network',
description: 'Password for proxy connection.',
options: {
form: [
{
display: '',
null: false,
name: 'proxy_passowrd',
tag: 'input',
},
],
},
state: '',
preferences: {
disabled: true,
online_service_disable: true,
prio: 3,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Send client stats',
name: 'ui_send_client_stats',
area: 'System::UI',
description: 'Send client stats/error message to central server to improve the usability.',
options: {
form: [
{
display: '',
null: true,
name: 'ui_send_client_stats',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
prio: 1,
permission: ['admin.system'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Client storage',
name: 'ui_client_storage',
area: 'System::UI',
description: 'Use client storage to cache data to enhance performance of application.',
options: {
form: [
{
display: '',
null: true,
name: 'ui_client_storage',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
prio: 2,
permission: ['admin.system'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Define default visibility of new a new article',
name: 'ui_ticket_zoom_article_new_internal',
area: 'UI::TicketZoom',
description: 'Set default visibility of new a new article.',
options: {
form: [
{
display: '',
null: true,
name: 'ui_ticket_zoom_article_new_internal',
tag: 'boolean',
translate: true,
options: {
true => 'internal',
false => 'public',
},
},
],
},
state: true,
preferences: {
prio: 1,
permission: ['admin.ui'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'New User Accounts',
name: 'user_create_account',
area: 'Security::Base',
description: 'Enables users to create their own account via web interface.',
options: {
form: [
{
display: '',
null: true,
name: 'user_create_account',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: true,
preferences: {
permission: ['admin.security'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Lost Password',
name: 'user_lost_password',
area: 'Security::Base',
description: 'Activates lost password feature for users.',
options: {
form: [
{
display: '',
null: true,
name: 'user_lost_password',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: true,
preferences: {
permission: ['admin.security'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_ldap',
area: 'Security::Authentication',
description: 'Enables user authentication via %s.',
preferences: {
title_i18n: ['LDAP'],
description_i18n: ['LDAP'],
permission: ['admin.security'],
},
state: {
adapter: 'Auth::Ldap',
host: 'localhost',
port: 389,
bind_dn: 'cn=Manager,dc=example,dc=org',
bind_pw: 'example',
uid: 'mail',
base: 'dc=example,dc=org',
always_filter: '',
always_roles: %w(Admin Agent),
always_groups: ['Users'],
sync_params: {
firstname: 'sn',
lastname: 'givenName',
email: 'mail',
login: 'mail',
},
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_twitter',
area: 'Security::ThirdPartyAuthentication',
description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
options: {
form: [
{
display: '',
null: true,
name: 'auth_twitter',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
controller: 'SettingsAreaSwitch',
sub: ['auth_twitter_credentials'],
title_i18n: ['Twitter'],
description_i18n: ['Twitter', 'Twitter Developer Site', 'https://dev.twitter.com/apps'],
permission: ['admin.security'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Twitter App Credentials',
name: 'auth_twitter_credentials',
area: 'Security::ThirdPartyAuthentication::Twitter',
description: 'App credentials for Twitter.',
options: {
form: [
{
display: 'Twitter Key',
null: true,
name: 'key',
tag: 'input',
},
{
display: 'Twitter Secret',
null: true,
name: 'secret',
tag: 'input',
},
],
},
state: {},
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_facebook',
area: 'Security::ThirdPartyAuthentication',
description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
options: {
form: [
{
display: '',
null: true,
name: 'auth_facebook',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
controller: 'SettingsAreaSwitch',
sub: ['auth_facebook_credentials'],
title_i18n: ['Facebook'],
description_i18n: ['Facebook', 'Facebook Developer Site', 'https://developers.facebook.com/apps/'],
permission: ['admin.security'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Facebook App Credentials',
name: 'auth_facebook_credentials',
area: 'Security::ThirdPartyAuthentication::Facebook',
description: 'App credentials for Facebook.',
options: {
form: [
{
display: 'App ID',
null: true,
name: 'app_id',
tag: 'input',
},
{
display: 'App Secret',
null: true,
name: 'app_secret',
tag: 'input',
},
],
},
state: {},
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_google_oauth2',
area: 'Security::ThirdPartyAuthentication',
description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
options: {
form: [
{
display: '',
null: true,
name: 'auth_google_oauth2',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
controller: 'SettingsAreaSwitch',
sub: ['auth_google_oauth2_credentials'],
title_i18n: ['Google'],
description_i18n: ['Google', 'Google API Console Site', 'https://console.developers.google.com/apis/credentials'],
permission: ['admin.security'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Google App Credentials',
name: 'auth_google_oauth2_credentials',
area: 'Security::ThirdPartyAuthentication::Google',
description: 'Enables user authentication via Google.',
options: {
form: [
{
display: 'Client ID',
null: true,
name: 'client_id',
tag: 'input',
},
{
display: 'Client Secret',
null: true,
name: 'client_secret',
tag: 'input',
},
],
},
state: {},
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_linkedin',
area: 'Security::ThirdPartyAuthentication',
description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
options: {
form: [
{
display: '',
null: true,
name: 'auth_linkedin',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
controller: 'SettingsAreaSwitch',
sub: ['auth_linkedin_credentials'],
title_i18n: ['LinkedIn'],
description_i18n: ['LinkedIn', 'Linkedin Developer Site', 'https://www.linkedin.com/developer/apps'],
permission: ['admin.security'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'LinkedIn App Credentials',
name: 'auth_linkedin_credentials',
area: 'Security::ThirdPartyAuthentication::Linkedin',
description: 'Enables user authentication via LinkedIn.',
options: {
form: [
{
display: 'App ID',
null: true,
name: 'app_id',
tag: 'input',
},
{
display: 'App Secret',
null: true,
name: 'app_secret',
tag: 'input',
},
],
},
state: {},
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_github',
area: 'Security::ThirdPartyAuthentication',
description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
options: {
form: [
{
display: '',
null: true,
name: 'auth_github',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
controller: 'SettingsAreaSwitch',
sub: ['auth_github_credentials'],
title_i18n: ['Github'],
description_i18n: ['Github', 'Github OAuth Applications', 'https://github.com/settings/applications'],
permission: ['admin.security'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Github App Credentials',
name: 'auth_github_credentials',
area: 'Security::ThirdPartyAuthentication::Github',
description: 'Enables user authentication via Github.',
options: {
form: [
{
display: 'App ID',
null: true,
name: 'app_id',
tag: 'input',
},
{
display: 'App Secret',
null: true,
name: 'app_secret',
tag: 'input',
},
],
},
state: {},
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_gitlab',
area: 'Security::ThirdPartyAuthentication',
description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
options: {
form: [
{
display: '',
null: true,
name: 'auth_gitlab',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
controller: 'SettingsAreaSwitch',
sub: ['auth_gitlab_credentials'],
title_i18n: ['Gitlab'],
description_i18n: ['Gitlab', 'Gitlab Applications', 'https://your-gitlab-host/admin/applications'],
permission: ['admin.security'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Gitlab App Credentials',
name: 'auth_gitlab_credentials',
area: 'Security::ThirdPartyAuthentication::Gitlab',
description: 'Enables user authentication via Gitlab.',
options: {
form: [
{
display: 'App ID',
null: true,
name: 'app_id',
tag: 'input',
},
{
display: 'App Secret',
null: true,
name: 'app_secret',
tag: 'input',
},
{
display: 'Site',
null: true,
name: 'site',
tag: 'input',
placeholder: 'https://gitlab.YOURDOMAIN.com',
},
],
},
state: {},
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_oauth2',
area: 'Security::ThirdPartyAuthentication',
description: 'Enables user authentication via generic OAuth2. Register your app first.',
options: {
form: [
{
display: '',
null: true,
name: 'auth_oauth2',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
controller: 'SettingsAreaSwitch',
sub: ['auth_oauth2_credentials'],
title_i18n: ['Generic OAuth2'],
permission: ['admin.security'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Generic OAuth2 App Credentials',
name: 'auth_oauth2_credentials',
area: 'Security::ThirdPartyAuthentication::GenericOAuth',
description: 'Enables user authentication via generic OAuth2.',
options: {
form: [
{
display: 'Name',
null: true,
name: 'name',
tag: 'input',
placeholder: 'Some Provider Name',
},
{
display: 'App ID',
null: true,
name: 'app_id',
tag: 'input',
},
{
display: 'App Secret',
null: true,
name: 'app_secret',
tag: 'input',
},
{
display: 'Site',
null: true,
name: 'site',
tag: 'input',
placeholder: 'https://gitlab.YOURDOMAIN.com',
},
{
display: 'authorize_url',
null: true,
name: 'authorize_url',
tag: 'input',
placeholder: '/oauth/authorize',
},
{
display: 'token_url',
null: true,
name: 'token_url',
tag: 'input',
placeholder: '/oauth/token',
},
],
},
state: {},
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Minimum length',
name: 'password_min_size',
area: 'Security::Password',
description: 'Password needs to have at least a minimal number of characters.',
options: {
form: [
{
display: '',
null: true,
name: 'password_min_size',
tag: 'select',
options: {
4 => ' 4',
5 => ' 5',
6 => ' 6',
7 => ' 7',
8 => ' 8',
9 => ' 9',
10 => '10',
11 => '11',
12 => '12',
13 => '13',
14 => '14',
15 => '15',
16 => '16',
17 => '17',
18 => '18',
19 => '19',
20 => '20',
},
},
],
},
state: 6,
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: '2 lower and 2 upper characters',
name: 'password_min_2_lower_2_upper_characters',
area: 'Security::Password',
description: 'Password needs to contain 2 lower and 2 upper characters.',
options: {
form: [
{
display: '',
null: true,
name: 'password_min_2_lower_2_upper_characters',
tag: 'select',
options: {
1 => 'yes',
0 => 'no',
},
},
],
},
state: 0,
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Digit required',
name: 'password_need_digit',
area: 'Security::Password',
description: 'Password needs to contain at least one digit.',
options: {
form: [
{
display: 'Needed',
null: true,
name: 'password_need_digit',
tag: 'select',
options: {
1 => 'yes',
0 => 'no',
},
},
],
},
state: 1,
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Maximum failed logins',
name: 'password_max_login_failed',
area: 'Security::Password',
description: 'Number of failed logins after account will be deactivated.',
options: {
form: [
{
display: '',
null: true,
name: 'password_max_login_failed',
tag: 'select',
options: {
4 => ' 4',
5 => ' 5',
6 => ' 6',
7 => ' 7',
8 => ' 8',
9 => ' 9',
10 => '10',
11 => '11',
13 => '13',
14 => '14',
15 => '15',
16 => '16',
17 => '17',
18 => '18',
19 => '19',
20 => '20',
},
},
],
},
state: 10,
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Ticket Hook',
name: 'ticket_hook',
area: 'Ticket::Base',
description: 'The identifier for a ticket, e. g. Ticket#, Call#, MyTicket#. The default is Ticket#.',
options: {
form: [
{
display: '',
null: false,
name: 'ticket_hook',
tag: 'input',
},
],
},
preferences: {
render: true,
placeholder: true,
authentication: true,
permission: ['admin.ticket'],
},
state: 'Ticket#',
frontend: true
)
Setting.create_if_not_exists(
title: 'Ticket Hook Divider',
name: 'ticket_hook_divider',
area: 'Ticket::Base::Shadow',
description: 'The divider between TicketHook and ticket number. E. g. \': \'.',
options: {
form: [
{
display: '',
null: true,
name: 'ticket_hook_divider',
tag: 'input',
},
],
},
state: '',
preferences: {
permission: ['admin.ticket'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Ticket Hook Position',
name: 'ticket_hook_position',
area: 'Ticket::Base',
description: "The format of the subject.
* **Right** means **Some Subject [Ticket#12345]**
* **Left** means **[Ticket#12345] Some Subject**
* **None** means **Some Subject** (without ticket number). In the last case you should enable *postmaster_follow_up_search_in* to recognize follow-ups based on email headers and/or body.",
options: {
form: [
{
display: '',
null: true,
name: 'ticket_hook_position',
tag: 'select',
translate: true,
options: {
'left' => 'left',
'right' => 'right',
'none' => 'none',
},
},
],
},
state: 'right',
preferences: {
controller: 'SettingsAreaTicketHookPosition',
permission: ['admin.ticket'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Ticket Number Format',
name: 'ticket_number',
area: 'Ticket::Number',
description: "Selects the ticket number generator module.
* **Increment** increments the ticket number, the SystemID and the counter are used with SystemID.Counter format (e.g. 1010138, 1010139).
* With **Date** the ticket numbers will be generated by the current date, the SystemID and the counter. The format looks like Year.Month.Day.SystemID.counter (e.g. 201206231010138, 201206231010139).",
options: {
form: [
{
display: '',
null: true,
name: 'ticket_number',
tag: 'select',
translate: true,
options: {
'Ticket::Number::Increment' => 'Increment (SystemID.Counter)',
'Ticket::Number::Date' => 'Date (Year.Month.Day.SystemID.Counter)',
},
},
],
},
state: 'Ticket::Number::Increment',
preferences: {
settings_included: %w(ticket_number_increment ticket_number_date),
controller: 'SettingsAreaTicketNumber',
permission: ['admin.ticket'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Ticket Number Increment',
name: 'ticket_number_increment',
area: 'Ticket::Number',
description: '-',
options: {
form: [
{
display: 'Checksum',
null: true,
name: 'checksum',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
{
display: 'Min. size of number',
null: true,
name: 'min_size',
tag: 'select',
options: {
1 => ' 1',
2 => ' 2',
3 => ' 3',
4 => ' 4',
5 => ' 5',
6 => ' 6',
7 => ' 7',
8 => ' 8',
9 => ' 9',
10 => '10',
11 => '11',
12 => '12',
13 => '13',
14 => '14',
15 => '15',
16 => '16',
17 => '17',
18 => '18',
19 => '19',
20 => '20',
},
},
],
},
state: {
checksum: false,
min_size: 5,
},
preferences: {
permission: ['admin.ticket'],
hidden: true,
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Ticket Number Increment Date',
name: 'ticket_number_date',
area: 'Ticket::Number',
description: '-',
options: {
form: [
{
display: 'Checksum',
null: true,
name: 'checksum',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: {
checksum: false
},
preferences: {
permission: ['admin.ticket'],
hidden: true,
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Enable Ticket creation',
name: 'customer_ticket_create',
area: 'CustomerWeb::Base',
description: 'Defines if a customer can create tickets via the web interface.',
options: {
form: [
{
display: '',
null: true,
name: 'customer_ticket_create',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: true,
preferences: {
authentication: true,
permission: ['admin.channel_web'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Group selection for Ticket creation',
name: 'customer_ticket_create_group_ids',
area: 'CustomerWeb::Base',
description: 'Defines groups for which a customer can create tickets via web interface. "-" means all groups are available.',
options: {
form: [
{
display: '',
null: true,
name: 'group_ids',
tag: 'select',
multiple: true,
nulloption: true,
relation: 'Group',
},
],
},
state: '',
preferences: {
authentication: true,
permission: ['admin.channel_web'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Enable Ticket creation',
name: 'form_ticket_create',
area: 'Form::Base',
description: 'Defines if tickets can be created via web form.',
options: {
form: [
{
display: '',
null: true,
name: 'form_ticket_create',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
permission: ['admin.channel_formular'],
},
frontend: false,
)
Setting.create_if_not_exists(
title: 'Ticket Subject Size',
name: 'ticket_subject_size',
area: 'Email::Base',
description: 'Max. length of the subject in an email reply.',
options: {
form: [
{
display: '',
null: false,
name: 'ticket_subject_size',
tag: 'input',
},
],
},
state: '110',
preferences: {
permission: ['admin.channel_email'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Ticket Subject Reply',
name: 'ticket_subject_re',
area: 'Email::Base',
description: 'The text at the beginning of the subject in an email reply, e. g. RE, AW, or AS.',
options: {
form: [
{
display: '',
null: true,
name: 'ticket_subject_re',
tag: 'input',
},
],
},
state: 'RE',
preferences: {
permission: ['admin.channel_email'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Sender Format',
name: 'ticket_define_email_from',
area: 'Email::Base',
description: 'Defines how the From field of emails (sent from answers and email tickets) should look like.',
options: {
form: [
{
display: '',
null: true,
name: 'ticket_define_email_from',
tag: 'select',
options: {
SystemAddressName: 'System Address Display Name',
AgentNameSystemAddressName: 'Agent Name + FromSeparator + System Address Display Name',
},
},
],
},
state: 'AgentNameSystemAddressName',
preferences: {
permission: ['admin.channel_email'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Sender Format Separator',
name: 'ticket_define_email_from_separator',
area: 'Email::Base',
description: 'Defines the separator between the agent\'s real name and the given group email address.',
options: {
form: [
{
display: '',
null: false,
name: 'ticket_define_email_from_separator',
tag: 'input',
},
],
},
state: 'via',
preferences: {
permission: ['admin.channel_email'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Maximum Email Size',
name: 'postmaster_max_size',
area: 'Email::Base',
description: 'Maximum size in MB of emails.',
options: {
form: [
{
display: '',
null: true,
name: 'postmaster_max_size',
tag: 'select',
options: {
1 => ' 1',
2 => ' 2',
3 => ' 3',
4 => ' 4',
5 => ' 5',
6 => ' 6',
7 => ' 7',
8 => ' 8',
9 => ' 9',
10 => ' 10',
15 => ' 15',
20 => ' 20',
25 => ' 25',
30 => ' 30',
35 => ' 35',
40 => ' 40',
45 => ' 45',
50 => ' 50',
60 => ' 60',
70 => ' 70',
80 => ' 80',
90 => ' 90',
100 => '100',
125 => '125',
150 => '150',
},
},
],
},
state: 10,
preferences: {
online_service_disable: true,
permission: ['admin.channel_email'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Additional follow-up detection',
name: 'postmaster_follow_up_search_in',
area: 'Email::Base',
description: 'By default the follow-up check is done via the subject of an email. With this setting you can add more fields for which the follow-up check will be executed.',
options: {
form: [
{
display: '',
null: true,
name: 'postmaster_follow_up_search_in',
tag: 'checkbox',
options: {
'references' => 'References - Search for follow up also in In-Reply-To or References headers.',
'body' => 'Body - Search for follow up also in mail body.',
'attachment' => 'Attachment - Search for follow up also in attachments.',
},
},
],
},
state: [],
preferences: {
permission: ['admin.channel_email'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Notification Sender',
name: 'notification_sender',
area: 'Email::Base',
description: 'Defines the sender of email notifications.',
options: {
form: [
{
display: '',
null: false,
name: 'notification_sender',
tag: 'input',
},
],
},
state: 'Notification Master <noreply@#{config.fqdn}>',
preferences: {
online_service_disable: true,
permission: ['admin.channel_email'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Block Notifications',
name: 'send_no_auto_response_reg_exp',
area: 'Email::Base',
description: 'If this regex matches, no notification will be sent by the sender.',
options: {
form: [
{
display: '',
null: false,
name: 'send_no_auto_response_reg_exp',
tag: 'input',
},
],
},
state: '(mailer-daemon|postmaster|abuse|root|noreply|noreply.+?|no-reply|no-reply.+?)@.+?\..+?',
preferences: {
online_service_disable: true,
permission: ['admin.channel_email'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'API Token Access',
name: 'api_token_access',
area: 'API::Base',
description: 'Enable REST API using tokens (not username/email address and password). Each user needs to create its own access tokens in user profile.',
options: {
form: [
{
display: '',
null: true,
name: 'api_token_access',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: true,
preferences: {
permission: ['admin.api'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'API Password Access',
name: 'api_password_access',
area: 'API::Base',
description: 'Enable REST API access using the username/email address and password for the authentication user.',
options: {
form: [
{
display: '',
null: true,
name: 'api_password_access',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: true,
preferences: {
permission: ['admin.api'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Monitoring Token',
name: 'monitoring_token',
area: 'HealthCheck::Base',
description: 'Token for monitoring.',
options: {
form: [
{
display: '',
null: false,
name: 'monitoring_token',
tag: 'input',
},
],
},
state: SecureRandom.urlsafe_base64(40),
preferences: {
permission: ['admin.monitoring'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Enable Chat',
name: 'chat',
area: 'Chat::Base',
description: 'Enable/disable online chat.',
options: {
form: [
{
display: '',
null: true,
name: 'chat',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
trigger: ['menu:render', 'chat:rerender'],
permission: ['admin.channel_chat'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Agent idle timeout',
name: 'chat_agent_idle_timeout',
area: 'Chat::Extended',
description: 'Idle timeout in seconds until agent is set offline automatically.',
options: {
form: [
{
display: '',
null: false,
name: 'chat_agent_idle_timeout',
tag: 'input',
},
],
},
state: '120',
preferences: {
permission: ['admin.channel_chat'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Defines searchable models.',
name: 'models_searchable',
area: 'Models::Base',
description: 'Defines the searchable models.',
options: {},
state: [],
preferences: {
authentication: true,
},
frontend: true,
)
Setting.create_if_not_exists(
title: 'Default Screen',
name: 'default_controller',
area: 'Core',
description: 'Defines the default screen.',
options: {},
state: '#dashboard',
frontend: true
)
Setting.create_if_not_exists(
title: 'Elasticsearch Endpoint URL',
name: 'es_url',
area: 'SearchIndex::Elasticsearch',
description: 'Defines endpoint of Elasticsearch.',
state: '',
preferences: { online_service_disable: true },
frontend: false
)
Setting.create_if_not_exists(
title: 'Elasticsearch Endpoint User',
name: 'es_user',
area: 'SearchIndex::Elasticsearch',
description: 'Defines HTTP basic auth user of Elasticsearch.',
state: '',
preferences: { online_service_disable: true },
frontend: false
)
Setting.create_if_not_exists(
title: 'Elasticsearch Endpoint Password',
name: 'es_password',
area: 'SearchIndex::Elasticsearch',
description: 'Defines HTTP basic auth password of Elasticsearch.',
state: '',
preferences: { online_service_disable: true },
frontend: false
)
Setting.create_if_not_exists(
title: 'Elasticsearch Endpoint Index',
name: 'es_index',
area: 'SearchIndex::Elasticsearch',
description: 'Defines Elasticsearch index name.',
state: 'zammad',
preferences: { online_service_disable: true },
frontend: false
)
Setting.create_if_not_exists(
title: 'Elasticsearch Attachment Extensions',
name: 'es_attachment_ignore',
area: 'SearchIndex::Elasticsearch',
description: 'Defines attachment extensions which will be ignored by Elasticsearch.',
state: [ '.png', '.jpg', '.jpeg', '.mpeg', '.mpg', '.mov', '.bin', '.exe', '.box', '.mbox' ],
preferences: { online_service_disable: true },
frontend: false
)
Setting.create_if_not_exists(
title: 'Elasticsearch Attachment Size',
name: 'es_attachment_max_size_in_mb',
area: 'SearchIndex::Elasticsearch',
description: 'Define max. attachment size for Elasticsearch.',
state: 50,
preferences: { online_service_disable: true },
frontend: false
)
Setting.create_if_not_exists(
title: 'Import Mode',
name: 'import_mode',
area: 'Import::Base',
description: 'Puts Zammad into import mode (disables some triggers).',
options: {
form: [
{
display: '',
null: true,
name: 'import_mode',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Import Backend',
name: 'import_backend',
area: 'Import::Base::Internal',
description: 'Set backend which is being used for import.',
options: {},
state: '',
frontend: true
)
Setting.create_if_not_exists(
title: 'Ignore Escalation/SLA Information',
name: 'import_ignore_sla',
area: 'Import::Base',
description: 'Ignore escalation/SLA information for import.',
options: {
form: [
{
display: '',
null: true,
name: 'import_ignore_sla',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
frontend: false
)
Setting.create_if_not_exists(
title: 'Import Endpoint',
name: 'import_otrs_endpoint',
area: 'Import::OTRS',
description: 'Defines OTRS endpoint to import users, tickets, states and articles.',
options: {
form: [
{
display: '',
null: false,
name: 'import_otrs_endpoint',
tag: 'input',
},
],
},
state: 'http://otrs_host/otrs',
frontend: false
)
Setting.create_if_not_exists(
title: 'Import Key',
name: 'import_otrs_endpoint_key',
area: 'Import::OTRS',
description: 'Defines OTRS endpoint authentication key.',
options: {
form: [
{
display: '',
null: false,
name: 'import_otrs_endpoint_key',
tag: 'input',
},
],
},
state: '',
frontend: false
)
Setting.create_if_not_exists(
title: 'Import User for HTTP basic authentication',
name: 'import_otrs_user',
area: 'Import::OTRS',
description: 'Defines HTTP basic authentication user (only if OTRS is protected via HTTP basic auth).',
options: {
form: [
{
display: '',
null: true,
name: 'import_otrs_user',
tag: 'input',
},
],
},
state: '',
frontend: false
)
Setting.create_if_not_exists(
title: 'Import Password for http basic authentication',
name: 'import_otrs_password',
area: 'Import::OTRS',
description: 'Defines http basic authentication password (only if OTRS is protected via http basic auth).',
options: {
form: [
{
display: '',
null: true,
name: 'import_otrs_password',
tag: 'input',
},
],
},
state: '',
frontend: false
)
Setting.create_if_not_exists(
title: 'Import Endpoint',
name: 'import_zendesk_endpoint',
area: 'Import::Zendesk',
description: 'Defines Zendesk endpoint to import users, ticket, states and articles.',
options: {
form: [
{
display: '',
null: false,
name: 'import_zendesk_endpoint',
tag: 'input',
},
],
},
state: 'https://yours.zendesk.com/api/v2',
frontend: false
)
Setting.create_if_not_exists(
title: 'Import Key for requesting the Zendesk API',
name: 'import_zendesk_endpoint_key',
area: 'Import::Zendesk',
description: 'Defines Zendesk endpoint authentication key.',
options: {
form: [
{
display: '',
null: false,
name: 'import_zendesk_endpoint_key',
tag: 'input',
},
],
},
state: '',
frontend: false
)
Setting.create_if_not_exists(
title: 'Import User for requesting the Zendesk API',
name: 'import_zendesk_endpoint_username',
area: 'Import::Zendesk',
description: 'Defines Zendesk endpoint authentication user.',
options: {
form: [
{
display: '',
null: true,
name: 'import_zendesk_endpoint_username',
tag: 'input',
},
],
},
state: '',
frontend: false
)
Setting.create_if_not_exists(
title: 'Time Accounting',
name: 'time_accounting',
area: 'Web::Base',
description: 'Enable time accounting.',
options: {
form: [
{
display: '',
null: true,
name: 'time_accounting',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
authentication: true,
permission: ['admin.time_accounting'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Time Accounting Selector',
name: 'time_accounting_selector',
area: 'Web::Base',
description: 'Enable time accounting for these tickets.',
options: {
form: [
{},
],
},
preferences: {
authentication: true,
permission: ['admin.time_accounting'],
},
state: {},
frontend: true
)
Setting.create_if_not_exists(
title: 'New Tags',
name: 'tag_new',
area: 'Web::Base',
description: 'Allow users to create new tags.',
options: {
form: [
{
display: '',
null: true,
name: 'tag_new',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
authentication: true,
permission: ['admin.tag'],
},
state: true,
frontend: true
)
Setting.create_if_not_exists(
title: 'Default calendar tickets subscriptions',
name: 'defaults_calendar_subscriptions_tickets',
area: 'Defaults::CalendarSubscriptions',
description: 'Defines the default calendar tickets subscription settings.',
options: {},
state: {
escalation: {
own: true,
not_assigned: false,
},
new_open: {
own: true,
not_assigned: false,
},
pending: {
own: true,
not_assigned: false,
}
},
preferences: {
authentication: true,
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Defines translator identifier.',
name: 'translator_key',
area: 'i18n::translator_key',
description: 'Defines the translator identifier for contributions.',
options: {},
state: '',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0010_postmaster_filter_trusted',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to remove X-Zammad headers from not trusted sources.',
options: {},
state: 'Channel::Filter::Trusted',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0012_postmaster_filter_sender_is_system_address',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to check if email has been created by Zammad itself and will set the article sender.',
options: {},
state: 'Channel::Filter::SenderIsSystemAddress',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0014_postmaster_filter_own_notification_loop_detection',
area: 'Postmaster::PreFilter',
description: 'Define postmaster filter to check if email is a own created notification email, then ignore it to prevent email loops.',
options: {},
state: 'Channel::Filter::OwnNotificationLoopDetection',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0015_postmaster_filter_identify_sender',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to identify sender user.',
options: {},
state: 'Channel::Filter::IdentifySender',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0020_postmaster_filter_auto_response_check',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to identify auto responses to prevent auto replies from Zammad.',
options: {},
state: 'Channel::Filter::AutoResponseCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0030_postmaster_filter_out_of_office_check',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to identify out-of-office emails for follow-up detection and keeping current ticket state.',
options: {},
state: 'Channel::Filter::OutOfOfficeCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0100_postmaster_filter_follow_up_check',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to identify follow-ups (based on admin settings).',
options: {},
state: 'Channel::Filter::FollowUpCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0200_postmaster_filter_follow_up_possible_check',
area: 'Postmaster::PreFilter',
description: 'Define postmaster filter to check if follow ups get created (based on admin settings).',
options: {},
state: 'Channel::Filter::FollowUpPossibleCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0900_postmaster_filter_bounce_check',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to identify postmaster bounced - to handle it as follow-up of the original ticket.',
options: {},
state: 'Channel::Filter::BounceCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '1000_postmaster_filter_database_check',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter for filters managed via admin interface.',
options: {},
state: 'Channel::Filter::Database',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '5000_postmaster_filter_icinga',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to manage Icinga (http://www.icinga.org) emails.',
options: {},
state: 'Channel::Filter::Icinga',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '5100_postmaster_filter_nagios',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to manage Nagios (http://www.nagios.org) emails.',
options: {},
state: 'Channel::Filter::Nagios',
frontend: false
)
Setting.create_if_not_exists(
title: 'Icinga integration',
name: 'icinga_integration',
area: 'Integration::Switch',
description: 'Defines if Icinga (http://www.icinga.org) is enabled or not.',
options: {
form: [
{
display: '',
null: true,
name: 'icinga_integration',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
prio: 1,
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Sender',
name: 'icinga_sender',
area: 'Integration::Icinga',
description: 'Defines the sender email address of Icinga emails.',
options: {
form: [
{
display: '',
null: false,
name: 'icinga_sender',
tag: 'input',
placeholder: 'icinga@monitoring.example.com',
},
],
},
state: 'icinga@monitoring.example.com',
preferences: {
prio: 2,
permission: ['admin.integration'],
},
frontend: false,
)
Setting.create_if_not_exists(
title: 'Auto close',
name: 'icinga_auto_close',
area: 'Integration::Icinga',
description: 'Defines if tickets should be closed if service is recovered.',
options: {
form: [
{
display: '',
null: true,
name: 'icinga_auto_close',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: true,
preferences: {
prio: 3,
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Auto close state',
name: 'icinga_auto_close_state_id',
area: 'Integration::Icinga',
description: 'Defines the state of auto closed tickets.',
options: {
form: [
{
display: '',
null: false,
name: 'icinga_auto_close_state_id',
tag: 'select',
relation: 'TicketState',
},
],
},
state: 4,
preferences: {
prio: 4,
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Nagios integration',
name: 'nagios_integration',
area: 'Integration::Switch',
description: 'Defines if Nagios (http://www.nagios.org) is enabled or not.',
options: {
form: [
{
display: '',
null: true,
name: 'nagios_integration',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
prio: 1,
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Sender',
name: 'nagios_sender',
area: 'Integration::Nagios',
description: 'Defines the sender email address of Nagios emails.',
options: {
form: [
{
display: '',
null: false,
name: 'nagios_sender',
tag: 'input',
placeholder: 'nagios@monitoring.example.com',
},
],
},
state: 'nagios@monitoring.example.com',
preferences: {
prio: 2,
permission: ['admin.integration'],
},
frontend: false,
)
Setting.create_if_not_exists(
title: 'Auto close',
name: 'nagios_auto_close',
area: 'Integration::Nagios',
description: 'Defines if tickets should be closed if service is recovered.',
options: {
form: [
{
display: '',
null: true,
name: 'nagios_auto_close',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: true,
preferences: {
prio: 3,
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Auto close state',
name: 'nagios_auto_close_state_id',
area: 'Integration::Nagios',
description: 'Defines the state of auto closed tickets.',
options: {
form: [
{
display: '',
null: false,
name: 'nagios_auto_close_state_id',
tag: 'select',
relation: 'TicketState',
},
],
},
state: 4,
preferences: {
prio: 4,
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines sync transaction backend.',
name: '0100_trigger',
area: 'Transaction::Backend::Sync',
description: 'Defines the transaction backend to execute triggers.',
options: {},
state: 'Transaction::Trigger',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines transaction backend.',
name: '0100_notification',
area: 'Transaction::Backend::Async',
description: 'Defines the transaction backend to send agent notifications.',
options: {},
state: 'Transaction::Notification',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines transaction backend.',
name: '1000_signature_detection',
area: 'Transaction::Backend::Async',
description: 'Defines the transaction backend to detect customer signatures in emails.',
options: {},
state: 'Transaction::SignatureDetection',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines transaction backend.',
name: '6000_slack_webhook',
area: 'Transaction::Backend::Async',
description: 'Defines the transaction backend which posts messages to Slack (http://www.slack.com).',
options: {},
state: 'Transaction::Slack',
frontend: false
)
Setting.create_if_not_exists(
title: 'Slack integration',
name: 'slack_integration',
area: 'Integration::Switch',
description: 'Defines if Slack (http://www.slack.org) is enabled or not.',
options: {
form: [
{
display: '',
null: true,
name: 'slack_integration',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
prio: 1,
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Slack config',
name: 'slack_config',
area: 'Integration::Slack',
description: 'Defines the slack config.',
options: {},
state: {
items: []
},
preferences: {
prio: 2,
permission: ['admin.integration'],
},
frontend: false,
)
Setting.create_if_not_exists(
title: 'sipgate.io integration',
name: 'sipgate_integration',
area: 'Integration::Switch',
description: 'Defines if sipgate.io (http://www.sipgate.io) is enabled or not.',
options: {
form: [
{
display: '',
null: true,
name: 'sipgate_integration',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
prio: 1,
trigger: ['menu:render', 'cti:reload'],
authentication: true,
permission: ['admin.integration'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'sipgate.io config',
name: 'sipgate_config',
area: 'Integration::Sipgate',
description: 'Defines the sipgate.io config.',
options: {},
state: {},
preferences: {
prio: 2,
permission: ['admin.integration'],
},
frontend: false,
)
Setting.create_if_not_exists(
title: 'Clearbit integration',
name: 'clearbit_integration',
area: 'Integration::Switch',
description: 'Defines if Clearbit (http://www.clearbit.com) is enabled or not.',
options: {
form: [
{
display: '',
null: true,
name: 'clearbit_integration',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
prio: 1,
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Clearbit config',
name: 'clearbit_config',
area: 'Integration::Clearbit',
description: 'Defines the Clearbit config.',
options: {},
state: {},
frontend: false,
preferences: {
prio: 2,
permission: ['admin.integration'],
},
)
Setting.create_if_not_exists(
title: 'Defines transaction backend.',
name: '9000_clearbit_enrichment',
area: 'Transaction::Backend::Async',
description: 'Defines the transaction backend which will enrich customer and organization information from Clearbit (http://www.clearbit.com).',
options: {},
state: 'Transaction::ClearbitEnrichment',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines transaction backend.',
name: '9100_cti_caller_id_detection',
area: 'Transaction::Backend::Async',
description: 'Defines the transaction backend which detects caller IDs in objects and store them for CTI lookups.',
options: {},
state: 'Transaction::CtiCallerIdDetection',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines transaction backend.',
name: '9200_karma',
area: 'Transaction::Backend::Async',
description: 'Defines the transaction backend which creates the karma score.',
options: {},
state: 'Transaction::Karma',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines karma levels.',
name: 'karma_levels',
area: 'Core::Karma',
description: 'Defines the karma levels.',
options: {},
state: [
{
name: 'Beginner',
start: 0,
end: 499,
},
{
name: 'Newbie',
start: 500,
end: 1999,
},
{
name: 'Intermediate',
start: 2000,
end: 4999,
},
{
name: 'Professional',
start: 5000,
end: 6999,
},
{
name: 'Expert',
start: 7000,
end: 8999,
},
{
name: 'Master',
start: 9000,
end: 18_999,
},
{
name: 'Evangelist',
start: 19_000,
end: 45_999,
},
{
name: 'Hero',
start: 50_000,
end: nil,
},
],
frontend: false
)
Setting.create_if_not_exists(
title: 'Set limit of agents',
name: 'system_agent_limit',
area: 'Core::Online',
description: 'Defines the limit of the agents.',
options: {},
state: false,
preferences: { online_service_disable: true },
frontend: false
)
signature = Signature.create_if_not_exists(
id: 1,
name: 'default',
body: '
#{user.firstname} #{user.lastname}
--
Super Support - Waterford Business Park
5201 Blue Lagoon Drive - 8th Floor & 9th Floor - Miami, 33126 USA
Email: hot@example.com - Web: http://www.example.com/
--'.text2html,
updated_by_id: 1,
created_by_id: 1
)
Role.create_if_not_exists(
id: 1,
name: 'Admin',
note: 'To configure your system.',
preferences: {
not: ['Customer'],
},
default_at_signup: false,
updated_by_id: 1,
created_by_id: 1
)
Role.create_if_not_exists(
id: 2,
name: 'Agent',
note: 'To work on Tickets.',
default_at_signup: false,
preferences: {
not: ['Customer'],
},
updated_by_id: 1,
created_by_id: 1
)
Role.create_if_not_exists(
id: 3,
name: 'Customer',
note: 'People who create Tickets ask for help.',
preferences: {
not: %w(Agent Admin),
},
default_at_signup: true,
updated_by_id: 1,
created_by_id: 1
)
Permission.create_if_not_exists(
name: 'admin',
note: 'Admin Interface',
preferences: {},
)
Permission.create_if_not_exists(
name: 'admin.user',
note: 'Manage %s',
preferences: {
translations: ['Users']
},
)
Permission.create_if_not_exists(
name: 'admin.group',
note: 'Manage %s',
preferences: {
translations: ['Groups']
},
)
Permission.create_if_not_exists(
name: 'admin.role',
note: 'Manage %s',
preferences: {
translations: ['Roles']
},
)
Permission.create_if_not_exists(
name: 'admin.organization',
note: 'Manage %s',
preferences: {
translations: ['Organizations']
},
)
Permission.create_if_not_exists(
name: 'admin.overview',
note: 'Manage %s',
preferences: {
translations: ['Overviews']
},
)
Permission.create_if_not_exists(
name: 'admin.text_module',
note: 'Manage %s',
preferences: {
translations: ['Text Modules']
},
)
Permission.create_if_not_exists(
name: 'admin.macro',
note: 'Manage %s',
preferences: {
translations: ['Macros']
},
)
Permission.create_if_not_exists(
name: 'admin.tag',
note: 'Manage %s',
preferences: {
translations: ['Tags']
},
)
Permission.create_if_not_exists(
name: 'admin.calendar',
note: 'Manage %s',
preferences: {
translations: ['Calendar']
},
)
Permission.create_if_not_exists(
name: 'admin.sla',
note: 'Manage %s',
preferences: {
translations: ['SLA']
},
)
Permission.create_if_not_exists(
name: 'admin.scheduler',
note: 'Manage %s',
preferences: {
translations: ['Scheduler']
},
)
Permission.create_if_not_exists(
name: 'admin.report_profile',
note: 'Manage %s',
preferences: {
translations: ['Report Profiles']
},
)
Permission.create_if_not_exists(
name: 'admin.channel_web',
note: 'Manage %s',
preferences: {
translations: ['Channel - Web']
},
)
Permission.create_if_not_exists(
name: 'admin.channel_formular',
note: 'Manage %s',
preferences: {
translations: ['Channel - Formular']
},
)
Permission.create_if_not_exists(
name: 'admin.channel_email',
note: 'Manage %s',
preferences: {
translations: ['Channel - Email']
},
)
Permission.create_if_not_exists(
name: 'admin.channel_twitter',
note: 'Manage %s',
preferences: {
translations: ['Channel - Twitter']
},
)
Permission.create_if_not_exists(
name: 'admin.channel_facebook',
note: 'Manage %s',
preferences: {
translations: ['Channel - Facebook']
},
)
Permission.create_if_not_exists(
name: 'admin.channel_telegram',
note: 'Manage %s',
preferences: {
translations: ['Channel - Telegram']
},
)
Permission.create_if_not_exists(
name: 'admin.channel_chat',
note: 'Manage %s',
preferences: {
translations: ['Channel - Chat']
},
)
Permission.create_if_not_exists(
name: 'admin.branding',
note: 'Manage %s',
preferences: {
translations: ['Branding']
},
)
Permission.create_if_not_exists(
name: 'admin.setting_system',
note: 'Manage %s Settings',
preferences: {
translations: ['System']
},
)
Permission.create_if_not_exists(
name: 'admin.security',
note: 'Manage %s Settings',
preferences: {
translations: ['Security']
},
)
Permission.create_if_not_exists(
name: 'admin.ticket',
note: 'Manage %s Settings',
preferences: {
translations: ['Ticket']
},
)
Permission.create_if_not_exists(
name: 'admin.package',
note: 'Manage %s',
preferences: {
translations: ['Packages']
},
)
Permission.create_if_not_exists(
name: 'admin.integration',
note: 'Manage %s',
preferences: {
translations: ['Integrations']
},
)
Permission.create_if_not_exists(
name: 'admin.api',
note: 'Manage %s',
preferences: {
translations: ['API']
},
)
Permission.create_if_not_exists(
name: 'admin.object',
note: 'Manage %s',
preferences: {
translations: ['Objects']
},
)
Permission.create_if_not_exists(
name: 'admin.translation',
note: 'Manage %s',
preferences: {
translations: ['Translations']
},
)
Permission.create_if_not_exists(
name: 'admin.monitoring',
note: 'Manage %s',
preferences: {
translations: ['Monitoring']
},
)
Permission.create_if_not_exists(
name: 'admin.maintenance',
note: 'Manage %s',
preferences: {
translations: ['Maintenance']
},
)
Permission.create_if_not_exists(
name: 'admin.session',
note: 'Manage %s',
preferences: {
translations: ['Sessions']
},
)
Permission.create_if_not_exists(
name: 'user_preferences',
note: 'User Preferences',
preferences: {},
)
Permission.create_if_not_exists(
name: 'user_preferences.password',
note: 'Change %s',
preferences: {
translations: ['Password']
},
)
Permission.create_if_not_exists(
name: 'user_preferences.notifications',
note: 'Manage %s',
preferences: {
translations: ['Notifications'],
required: ['ticket.agent'],
},
)
Permission.create_if_not_exists(
name: 'user_preferences.access_token',
note: 'Manage %s',
preferences: {
translations: ['Token Access']
},
)
Permission.create_if_not_exists(
name: 'user_preferences.language',
note: 'Change %s',
preferences: {
translations: ['Language']
},
)
Permission.create_if_not_exists(
name: 'user_preferences.linked_accounts',
note: 'Manage %s',
preferences: {
translations: ['Linked Accounts']
},
)
Permission.create_if_not_exists(
name: 'user_preferences.device',
note: 'Manage %s',
preferences: {
translations: ['Devices']
},
)
Permission.create_if_not_exists(
name: 'user_preferences.avatar',
note: 'Manage %s',
preferences: {
translations: ['Avatar']
},
)
Permission.create_if_not_exists(
name: 'user_preferences.calendar',
note: 'Access to %s',
preferences: {
translations: ['Calendars'],
required: ['ticket.agent'],
},
)
Permission.create_if_not_exists(
name: 'report',
note: 'Report Interface',
preferences: {},
)
Permission.create_if_not_exists(
name: 'ticket',
note: 'Ticket Interface',
preferences: {
disabled: true
},
)
Permission.create_if_not_exists(
name: 'ticket.agent',
note: 'Access to Agent Tickets based on Group Access',
preferences: {
not: ['ticket.customer'],
plugin: ['groups']
},
)
Permission.create_if_not_exists(
name: 'ticket.customer',
note: 'Access to Customer Tickets based on current_user.id and current_user.organization_id',
preferences: {
not: ['ticket.agent'],
},
)
Permission.create_if_not_exists(
name: 'chat',
note: 'Access to %s',
preferences: {
translations: ['Chat']
},
)
Permission.create_if_not_exists(
name: 'chat.agent',
note: 'Access to %s',
preferences: {
translations: ['Chat'],
not: ['chat.customer'],
},
)
Permission.create_if_not_exists(
name: 'cti',
note: 'CTI',
preferences: {
disabled: true
},
)
Permission.create_if_not_exists(
name: 'cti.agent',
note: 'Access to %s',
preferences: {
translations: ['CTI'],
not: ['cti.customer'],
},
)
admin = Role.find_by(name: 'Admin')
admin.permission_grant('user_preferences')
admin.permission_grant('admin')
admin.permission_grant('report')
agent = Role.find_by(name: 'Agent')
agent.permission_grant('user_preferences')
agent.permission_grant('ticket.agent')
agent.permission_grant('chat.agent')
agent.permission_grant('cti.agent')
customer = Role.find_by(name: 'Customer')
customer.permission_grant('user_preferences.password')
customer.permission_grant('user_preferences.language')
customer.permission_grant('user_preferences.linked_accounts')
customer.permission_grant('user_preferences.avatar')
customer.permission_grant('ticket.customer')
Group.create_if_not_exists(
id: 1,
name: 'Users',
signature_id: signature.id,
note: 'Standard Group/Pool for Tickets.',
updated_by_id: 1,
created_by_id: 1
)
user = User.create_if_not_exists(
id: 1,
login: '-',
firstname: '-',
lastname: '',
email: '',
active: false,
updated_by_id: 1,
created_by_id: 1
)
UserInfo.current_user_id = 1
roles = Role.find_by(name: 'Customer')
organizations = Organization.all
groups = Group.all
org_community = Organization.create_if_not_exists(
id: 1,
name: 'Zammad Foundation',
)
user_community = User.create_or_update(
id: 2,
login: 'nicole.braun@zammad.org',
firstname: 'Nicole',
lastname: 'Braun',
email: 'nicole.braun@zammad.org',
password: '',
active: true,
roles: [roles],
organization_id: org_community.id,
)
Link::Type.create_if_not_exists(id: 1, name: 'normal')
Link::Object.create_if_not_exists(id: 1, name: 'Ticket')
Link::Object.create_if_not_exists(id: 2, name: 'Announcement')
Link::Object.create_if_not_exists(id: 3, name: 'Question/Answer')
Link::Object.create_if_not_exists(id: 4, name: 'Idea')
Link::Object.create_if_not_exists(id: 5, name: 'Bug')
Ticket::StateType.create_if_not_exists(id: 1, name: 'new')
Ticket::StateType.create_if_not_exists(id: 2, name: 'open')
Ticket::StateType.create_if_not_exists(id: 3, name: 'pending reminder')
Ticket::StateType.create_if_not_exists(id: 4, name: 'pending action')
Ticket::StateType.create_if_not_exists(id: 5, name: 'closed')
Ticket::StateType.create_if_not_exists(id: 6, name: 'merged')
Ticket::StateType.create_if_not_exists(id: 7, name: 'removed')
Ticket::State.create_if_not_exists(
id: 1,
name: 'new',
state_type_id: Ticket::StateType.find_by(name: 'new').id,
default_create: true,
)
Ticket::State.create_if_not_exists(
id: 2,
name: 'open',
state_type_id: Ticket::StateType.find_by(name: 'open').id,
default_follow_up: true,
)
Ticket::State.create_if_not_exists(
id: 3,
name: 'pending reminder',
state_type_id: Ticket::StateType.find_by(name: 'pending reminder').id,
ignore_escalation: true,
)
Ticket::State.create_if_not_exists(
id: 4,
name: 'closed',
state_type_id: Ticket::StateType.find_by(name: 'closed').id,
ignore_escalation: true,
)
Ticket::State.create_if_not_exists(
id: 5,
name: 'merged',
state_type_id: Ticket::StateType.find_by(name: 'merged').id,
ignore_escalation: true,
)
Ticket::State.create_if_not_exists(
id: 6,
name: 'removed',
state_type_id: Ticket::StateType.find_by(name: 'removed').id,
active: false,
ignore_escalation: true,
)
Ticket::State.create_if_not_exists(
id: 7,
name: 'pending close',
state_type_id: Ticket::StateType.find_by(name: 'pending action').id,
next_state_id: Ticket::State.find_by(name: 'closed').id,
ignore_escalation: true,
)
Ticket::Priority.create_if_not_exists(id: 1, name: '1 low')
Ticket::Priority.create_if_not_exists(id: 2, name: '2 normal', default_create: true)
Ticket::Priority.create_if_not_exists(id: 3, name: '3 high')
Ticket::Article::Type.create_if_not_exists(id: 1, name: 'email', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 2, name: 'sms', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 3, name: 'chat', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 4, name: 'fax', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 5, name: 'phone', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 6, name: 'twitter status', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 7, name: 'twitter direct-message', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 8, name: 'facebook feed post', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 9, name: 'facebook feed comment', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 10, name: 'note', communication: false)
Ticket::Article::Type.create_if_not_exists(id: 11, name: 'web', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 12, name: 'telegram personal-message', communication: true)
Ticket::Article::Sender.create_if_not_exists(id: 1, name: 'Agent')
Ticket::Article::Sender.create_if_not_exists(id: 2, name: 'Customer')
Ticket::Article::Sender.create_if_not_exists(id: 3, name: 'System')
Macro.create_if_not_exists(
name: 'Close & Tag as Spam',
perform: {
'ticket.state_id' => {
value: Ticket::State.find_by(name: 'closed').id,
},
'ticket.tags' => {
operator: 'add',
value: 'spam',
},
'ticket.owner_id' => {
pre_condition: 'current_user.id',
value: '',
},
},
note: 'example macro',
active: true,
)
UserInfo.current_user_id = user_community.id
ticket = Ticket.create(
group_id: Group.find_by(name: 'Users').id,
customer_id: User.find_by(login: 'nicole.braun@zammad.org').id,
title: 'Welcome to Zammad!',
state_id: Ticket::State.find_by(name: 'new').id,
priority_id: Ticket::Priority.find_by(name: '2 normal').id,
)
Ticket::Article.create(
ticket_id: ticket.id,
type_id: Ticket::Article::Type.find_by(name: 'phone').id,
sender_id: Ticket::Article::Sender.find_by(name: 'Customer').id,
from: 'Zammad Feedback <feedback@zammad.org>',
body: 'Welcome!
Thank you for choosing Zammad.
You will find updates and patches at https://zammad.org/. Online
documentation is available at https://zammad.org/documentation. Get
involved (discussions, contributing, ...) at https://zammad.org/participate.
Regards,
Your Zammad Team
',
internal: false,
)
UserInfo.current_user_id = 1
overview_role = Role.find_by(name: 'Agent')
Overview.create_if_not_exists(
name: 'My assigned Tickets',
link: 'my_assigned',
prio: 1000,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: Ticket::State.by_category(:open).pluck(:id),
},
'ticket.owner_id' => {
operator: 'is',
pre_condition: 'current_user.id',
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group created_at),
s: %w(title customer group created_at),
m: %w(number title customer group created_at),
view_mode_default: 's',
},
)
Overview.create_if_not_exists(
name: 'Unassigned & Open',
link: 'all_unassigned',
prio: 1010,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: Ticket::State.by_category(:work_on_all).pluck(:id),
},
'ticket.owner_id' => {
operator: 'is',
pre_condition: 'not_set',
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group created_at),
s: %w(title customer group created_at),
m: %w(number title customer group created_at),
view_mode_default: 's',
},
)
Overview.create_if_not_exists(
name: 'My pending reached Tickets',
link: 'my_pending_reached',
prio: 1020,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: Ticket::State.by_category(:pending_reminder).pluck(:id),
},
'ticket.owner_id' => {
operator: 'is',
pre_condition: 'current_user.id',
},
'ticket.pending_time' => {
operator: 'within next (relative)',
value: 0,
range: 'minute',
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group created_at),
s: %w(title customer group created_at),
m: %w(number title customer group created_at),
view_mode_default: 's',
},
)
Overview.create_if_not_exists(
name: 'Open',
link: 'all_open',
prio: 1030,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: Ticket::State.by_category(:work_on_all).pluck(:id),
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group state owner created_at),
s: %w(title customer group state owner created_at),
m: %w(number title customer group state owner created_at),
view_mode_default: 's',
},
)
Overview.create_if_not_exists(
name: 'Pending reached',
link: 'all_pending_reached',
prio: 1040,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: Ticket::State.by_category(:pending_reminder).pluck(:id),
},
'ticket.pending_time' => {
operator: 'within next (relative)',
value: 0,
range: 'minute',
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group owner created_at),
s: %w(title customer group owner created_at),
m: %w(number title customer group owner created_at),
view_mode_default: 's',
},
)
Overview.create_if_not_exists(
name: 'Escalated',
link: 'all_escalated',
prio: 1050,
role_id: overview_role.id,
condition: {
'ticket.escalation_at' => {
operator: 'within next (relative)',
value: '10',
range: 'minute',
},
},
order: {
by: 'escalation_at',
direction: 'ASC',
},
view: {
d: %w(title customer group owner escalation_at),
s: %w(title customer group owner escalation_at),
m: %w(number title customer group owner escalation_at),
view_mode_default: 's',
},
)
overview_role = Role.find_by(name: 'Customer')
Overview.create_if_not_exists(
name: 'My Tickets',
link: 'my_tickets',
prio: 1100,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: Ticket::State.by_category(:viewable).pluck(:id),
},
'ticket.customer_id' => {
operator: 'is',
pre_condition: 'current_user.id',
},
},
order: {
by: 'created_at',
direction: 'DESC',
},
view: {
d: %w(title customer state created_at),
s: %w(number title state created_at),
m: %w(number title state created_at),
view_mode_default: 's',
},
)
Overview.create_if_not_exists(
name: 'My Organization Tickets',
link: 'my_organization_tickets',
prio: 1200,
role_id: overview_role.id,
organization_shared: true,
condition: {
'ticket.state_id' => {
operator: 'is',
value: Ticket::State.by_category(:viewable).pluck(:id),
},
'ticket.organization_id' => {
operator: 'is',
pre_condition: 'current_user.organization_id',
},
},
order: {
by: 'created_at',
direction: 'DESC',
},
view: {
d: %w(title customer state created_at),
s: %w(number title customer state created_at),
m: %w(number title customer state created_at),
view_mode_default: 's',
},
)
Channel.create_if_not_exists(
area: 'Email::Notification',
options: {
outbound: {
adapter: 'smtp',
options: {
host: 'host.example.com',
user: '',
password: '',
ssl: true,
},
},
},
group_id: 1,
preferences: { online_service_disable: true },
active: false,
)
Channel.create_if_not_exists(
area: 'Email::Notification',
options: {
outbound: {
adapter: 'sendmail',
},
},
preferences: { online_service_disable: true },
active: true,
)
Report::Profile.create_if_not_exists(
name: '-all-',
condition: {},
active: true,
updated_by_id: 1,
created_by_id: 1,
)
chat = Chat.create_if_not_exists(
name: 'default',
max_queue: 5,
note: '',
active: true,
updated_by_id: 1,
created_by_id: 1,
)
network = Network.create_if_not_exists(
id: 1,
name: 'base',
)
Network::Category::Type.create_if_not_exists(
id: 1,
name: 'Announcement',
)
Network::Category::Type.create_if_not_exists(
id: 2,
name: 'Idea',
)
Network::Category::Type.create_if_not_exists(
id: 3,
name: 'Question',
)
Network::Category::Type.create_if_not_exists(
id: 4,
name: 'Bug Report',
)
Network::Privacy.create_if_not_exists(
id: 1,
name: 'logged in',
key: 'loggedIn',
)
Network::Privacy.create_if_not_exists(
id: 2,
name: 'logged in and moderator',
key: 'loggedInModerator',
)
Network::Category.create_if_not_exists(
id: 1,
name: 'Announcements',
network_id: network.id,
network_category_type_id: Network::Category::Type.find_by(name: 'Announcement').id,
network_privacy_id: Network::Privacy.find_by(name: 'logged in and moderator').id,
allow_comments: true,
)
Network::Category.create_if_not_exists(
id: 2,
name: 'Questions',
network_id: network.id,
allow_comments: true,
network_category_type_id: Network::Category::Type.find_by(name: 'Question').id,
network_privacy_id: Network::Privacy.find_by(name: 'logged in').id,
)
Network::Category.create_if_not_exists(
id: 3,
name: 'Ideas',
network_id: network.id,
network_category_type_id: Network::Category::Type.find_by(name: 'Idea').id,
network_privacy_id: Network::Privacy.find_by(name: 'logged in').id,
allow_comments: true,
)
Network::Category.create_if_not_exists(
id: 4,
name: 'Bug Reports',
network_id: network.id,
network_category_type_id: Network::Category::Type.find_by(name: 'Bug Report').id,
network_privacy_id: Network::Privacy.find_by(name: 'logged in').id,
allow_comments: true,
)
item = Network::Item.create(
title: 'Example Announcement',
body: 'Some announcement....',
network_category_id: Network::Category.find_by(name: 'Announcements').id,
)
Network::Item::Comment.create(
network_item_id: item.id,
body: 'Some comment....',
)
item = Network::Item.create(
title: 'Example Question?',
body: 'Some questions....',
network_category_id: Network::Category.find_by(name: 'Questions').id,
)
Network::Item::Comment.create(
network_item_id: item.id,
body: 'Some comment....',
)
item = Network::Item.create(
title: 'Example Idea',
body: 'Some idea....',
network_category_id: Network::Category.find_by(name: 'Ideas').id,
)
Network::Item::Comment.create(
network_item_id: item.id,
body: 'Some comment....',
)
item = Network::Item.create(
title: 'Example Bug Report',
body: 'Some bug....',
network_category_id: Network::Category.find_by(name: 'Bug Reports').id,
)
Network::Item::Comment.create(
network_item_id: item.id,
body: 'Some comment....',
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'title',
display: 'Title',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 200,
null: false,
translate: false,
},
editable: false,
active: true,
screens: {
create_top: {
'-all-' => {
null: false,
},
},
edit: {},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 15,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'customer_id',
display: 'Customer',
data_type: 'user_autocompletion',
data_option: {
relation: 'User',
autocapitalize: false,
multiple: false,
guess: true,
null: false,
limit: 200,
placeholder: 'Enter Person or Organization/Company',
minLengt: 2,
translate: false,
permission: ['ticket.agent'],
},
editable: false,
active: true,
screens: {
create_top: {
'-all-' => {
null: false,
},
},
edit: {},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 10,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'type',
display: 'Type',
data_type: 'select',
data_option: {
default: '',
options: {
'Incident' => 'Incident',
'Problem' => 'Problem',
'Request for Change' => 'Request for Change',
},
nulloption: true,
multiple: false,
null: true,
translate: true,
},
editable: true,
active: false,
screens: {
create_middle: {
'-all-' => {
null: false,
item_class: 'column',
},
},
edit: {
'ticket.agent' => {
null: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 20,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'group_id',
display: 'Group',
data_type: 'select',
data_option: {
default: '',
relation: 'Group',
relation_condition: { access: 'rw' },
nulloption: true,
multiple: false,
null: false,
translate: false,
only_shown_if_selectable: true,
permission: ['ticket.agent', 'ticket.customer'],
},
editable: false,
active: true,
screens: {
create_middle: {
'-all-' => {
null: false,
item_class: 'column',
},
},
edit: {
'ticket.agent' => {
null: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 25,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'owner_id',
display: 'Owner',
data_type: 'select',
data_option: {
default: '',
relation: 'User',
relation_condition: { roles: 'Agent' },
nulloption: true,
multiple: false,
null: true,
translate: false,
permission: ['ticket.agent'],
},
editable: false,
active: true,
screens: {
create_middle: {
'-all-' => {
null: true,
item_class: 'column',
},
},
edit: {
'-all-' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 30,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'state_id',
display: 'State',
data_type: 'select',
data_option: {
relation: 'TicketState',
nulloption: true,
multiple: false,
null: false,
default: Ticket::State.find_by(name: 'open').id,
translate: true,
filter: Ticket::State.by_category(:viewable).pluck(:id),
},
editable: false,
active: true,
screens: {
create_middle: {
'ticket.agent' => {
null: false,
item_class: 'column',
filter: Ticket::State.by_category(:viewable_agent_new).pluck(:id),
},
'ticket.customer' => {
item_class: 'column',
nulloption: false,
null: true,
filter: Ticket::State.by_category(:viewable_customer_new).pluck(:id),
default: Ticket::State.find_by(name: 'new').id,
},
},
edit: {
'ticket.agent' => {
nulloption: false,
null: false,
filter: Ticket::State.by_category(:viewable_agent_edit).pluck(:id),
},
'ticket.customer' => {
nulloption: false,
null: true,
filter: Ticket::State.by_category(:viewable_customer_edit).pluck(:id),
default: Ticket::State.find_by(name: 'open').id,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 40,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'pending_time',
display: 'Pending till',
data_type: 'datetime',
data_option: {
future: true,
past: false,
diff: 24,
null: true,
translate: true,
required_if: {
state_id: Ticket::State.by_category(:pending).pluck(:id),
},
shown_if: {
state_id: Ticket::State.by_category(:pending).pluck(:id),
},
},
editable: false,
active: true,
screens: {
create_middle: {
'-all-' => {
null: false,
item_class: 'column',
},
},
edit: {
'-all-' => {
null: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 41,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'priority_id',
display: 'Priority',
data_type: 'select',
data_option: {
relation: 'TicketPriority',
nulloption: false,
multiple: false,
null: false,
default: Ticket::Priority.find_by(name: '2 normal').id,
translate: true,
},
editable: false,
active: true,
screens: {
create_middle: {
'ticket.agent' => {
null: false,
item_class: 'column',
},
},
edit: {
'ticket.agent' => {
null: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 80,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'tags',
display: 'Tags',
data_type: 'tag',
data_option: {
type: 'text',
null: true,
translate: false,
},
editable: false,
active: true,
screens: {
create_bottom: {
'ticket.agent' => {
null: true,
},
},
edit: {},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 900,
)
ObjectManager::Attribute.add(
force: true,
object: 'TicketArticle',
name: 'type_id',
display: 'Type',
data_type: 'select',
data_option: {
relation: 'TicketArticleType',
nulloption: false,
multiple: false,
null: false,
default: Ticket::Article::Type.lookup(name: 'note').id,
translate: true,
},
editable: false,
active: true,
screens: {
create_middle: {},
edit: {
'ticket.agent' => {
null: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 100,
)
ObjectManager::Attribute.add(
force: true,
object: 'TicketArticle',
name: 'internal',
display: 'Visibility',
data_type: 'select',
data_option: {
options: { true: 'internal', false: 'public' },
nulloption: false,
multiple: false,
null: true,
default: false,
translate: true,
},
editable: false,
active: true,
screens: {
create_middle: {},
edit: {
'ticket.agent' => {
null: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 200,
)
ObjectManager::Attribute.add(
force: true,
object: 'TicketArticle',
name: 'to',
display: 'To',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 1000,
null: true,
},
editable: false,
active: true,
screens: {
create_middle: {},
edit: {
'ticket.agent' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 300,
)
ObjectManager::Attribute.add(
force: true,
object: 'TicketArticle',
name: 'cc',
display: 'Cc',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 1000,
null: true,
},
editable: false,
active: true,
screens: {
create_top: {},
create_middle: {},
edit: {
'ticket.agent' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 400,
)
ObjectManager::Attribute.add(
force: true,
object: 'TicketArticle',
name: 'body',
display: 'Text',
data_type: 'richtext',
data_option: {
type: 'richtext',
maxlength: 20_000,
upload: true,
rows: 8,
null: true,
},
editable: false,
active: true,
screens: {
create_top: {
'-all-' => {
null: false,
},
},
edit: {
'-all-' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 600,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'login',
display: 'Login',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 100,
null: true,
autocapitalize: false,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {},
view: {
'-all-' => {
shown: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 100,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'firstname',
display: 'Firstname',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 150,
null: false,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {
'-all-' => {
null: false,
},
},
invite_agent: {
'-all-' => {
null: false,
},
},
invite_customer: {
'-all-' => {
null: false,
},
},
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 200,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'lastname',
display: 'Lastname',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 150,
null: false,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {
'-all-' => {
null: false,
},
},
invite_agent: {
'-all-' => {
null: false,
},
},
invite_customer: {
'-all-' => {
null: false,
},
},
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 300,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'email',
display: 'Email',
data_type: 'input',
data_option: {
type: 'email',
maxlength: 150,
null: false,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {
'-all-' => {
null: false,
},
},
invite_agent: {
'-all-' => {
null: false,
},
},
invite_customer: {
'-all-' => {
null: false,
},
},
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 400,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'web',
display: 'Web',
data_type: 'input',
data_option: {
type: 'url',
maxlength: 250,
null: true,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 500,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'phone',
display: 'Phone',
data_type: 'input',
data_option: {
type: 'tel',
maxlength: 100,
null: true,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 600,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'mobile',
display: 'Mobile',
data_type: 'input',
data_option: {
type: 'tel',
maxlength: 100,
null: true,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 700,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'fax',
display: 'Fax',
data_type: 'input',
data_option: {
type: 'tel',
maxlength: 100,
null: true,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 800,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'organization_id',
display: 'Organization',
data_type: 'autocompletion_ajax',
data_option: {
multiple: false,
nulloption: true,
null: true,
relation: 'Organization',
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {
'-all-' => {
null: true,
},
},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 900,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'department',
display: 'Department',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 200,
null: true,
item_class: 'formGroup--halfSize',
},
editable: true,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1000,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'street',
display: 'Street',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 100,
null: true,
},
editable: true,
active: false,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1100,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'zip',
display: 'Zip',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 100,
null: true,
item_class: 'formGroup--halfSize',
},
editable: true,
active: false,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1200,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'city',
display: 'City',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 100,
null: true,
item_class: 'formGroup--halfSize',
},
editable: true,
active: false,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1300,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'address',
display: 'Address',
data_type: 'textarea',
data_option: {
type: 'text',
maxlength: 500,
null: true,
item_class: 'formGroup--halfSize',
},
editable: true,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1350,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'password',
display: 'Password',
data_type: 'input',
data_option: {
type: 'password',
maxlength: 100,
null: true,
autocomplete: 'off',
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {
'-all-' => {
null: false,
},
},
invite_agent: {},
invite_customer: {},
edit: {
'admin.user' => {
null: true,
},
},
view: {}
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1400,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'vip',
display: 'VIP',
data_type: 'boolean',
data_option: {
null: true,
default: false,
item_class: 'formGroup--halfSize',
options: {
false: 'no',
true: 'yes',
},
translate: true,
permission: ['admin.user', 'ticket.agent'],
},
editable: false,
active: true,
screens: {
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1490,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'note',
display: 'Note',
data_type: 'richtext',
data_option: {
type: 'text',
maxlength: 250,
null: true,
note: 'Notes are visible to agents only, never to customers.',
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {
'-all-' => {
null: true,
},
},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1500,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'role_ids',
display: 'Permissions',
data_type: 'user_permission',
data_option: {
null: false,
item_class: 'checkbox',
permission: ['admin.user'],
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {
'-all-' => {
null: false,
default: [Role.lookup(name: 'Agent').id],
},
},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1600,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'active',
display: 'Active',
data_type: 'active',
data_option: {
null: true,
default: true,
permission: ['admin.user', 'ticket.agent'],
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1800,
)
ObjectManager::Attribute.add(
force: true,
object: 'Organization',
name: 'name',
display: 'Name',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 150,
null: false,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 200,
)
ObjectManager::Attribute.add(
force: true,
object: 'Organization',
name: 'shared',
display: 'Shared organization',
data_type: 'boolean',
data_option: {
null: true,
default: true,
note: 'Customers in the organization can view each other items.',
item_class: 'formGroup--halfSize',
options: {
true: 'yes',
false: 'no',
},
translate: true,
permission: ['admin.organization'],
},
editable: false,
active: true,
screens: {
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1400,
)
ObjectManager::Attribute.add(
force: true,
object: 'Organization',
name: 'domain_assignment',
display: 'Domain based assignment',
data_type: 'boolean',
data_option: {
null: true,
default: false,
note: 'Assign Users based on users domain.',
item_class: 'formGroup--halfSize',
options: {
true: 'yes',
false: 'no',
},
translate: true,
permission: ['admin.organization'],
},
editable: false,
active: true,
screens: {
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1410,
)
ObjectManager::Attribute.add(
force: true,
object: 'Organization',
name: 'domain',
display: 'Domain',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 150,
null: true,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1420,
)
ObjectManager::Attribute.add(
force: true,
object: 'Organization',
name: 'note',
display: 'Note',
data_type: 'richtext',
data_option: {
type: 'text',
maxlength: 250,
null: true,
note: 'Notes are visible to agents only, never to customers.',
},
editable: false,
active: true,
screens: {
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1500,
)
ObjectManager::Attribute.add(
force: true,
object: 'Organization',
name: 'active',
display: 'Active',
data_type: 'active',
data_option: {
null: true,
default: true,
permission: ['admin.organization'],
},
editable: false,
active: true,
screens: {
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1800,
)
ObjectManager::Attribute.add(
force: true,
object: 'Group',
name: 'name',
display: 'Name',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 150,
null: false,
},
editable: false,
active: true,
screens: {
create: {
'-all-' => {
null: false,
},
},
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 200,
)
ObjectManager::Attribute.add(
force: true,
object: 'Group',
name: 'assignment_timeout',
display: 'Assignment Timeout',
data_type: 'integer',
data_option: {
maxlength: 150,
null: true,
note: 'Assignment timeout in minutes if assigned agent is not working on it. Ticket will be shown as unassigend.',
min: 0,
max: 999_999,
},
editable: false,
active: true,
screens: {
create: {
'-all-' => {
null: true,
},
},
edit: {
'-all-' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 300,
)
ObjectManager::Attribute.add(
force: true,
object: 'Group',
name: 'follow_up_possible',
display: 'Follow up possible',
data_type: 'select',
data_option: {
default: 'yes',
options: {
yes: 'yes',
new_ticket: 'do not reopen Ticket but create new Ticket'
},
null: false,
note: 'Follow up for closed ticket possible or not.',
translate: true
},
editable: false,
active: true,
screens: {
create: {
'-all-' => {
null: true,
},
},
edit: {
'-all-' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 400,
)
ObjectManager::Attribute.add(
force: true,
object: 'Group',
name: 'follow_up_assignment',
display: 'Assign Follow Ups',
data_type: 'select',
data_option: {
default: 'yes',
options: {
true: 'yes',
false: 'no',
},
null: false,
note: 'Assign follow up to latest agent again.',
translate: true
},
editable: false,
active: true,
screens: {
create: {
'-all-' => {
null: true,
},
},
edit: {
'-all-' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 500,
)
ObjectManager::Attribute.add(
force: true,
object: 'Group',
name: 'email_address_id',
display: 'Email',
data_type: 'select',
data_option: {
default: '',
multiple: false,
null: true,
relation: 'EmailAddress',
nulloption: true,
do_not_log: true,
},
editable: false,
active: true,
screens: {
create: {
'-all-' => {
null: true,
},
},
edit: {
'-all-' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 600,
)
ObjectManager::Attribute.add(
force: true,
object: 'Group',
name: 'signature_id',
display: 'Signature',
data_type: 'select',
data_option: {
default: '',
multiple: false,
null: true,
relation: 'Signature',
nulloption: true,
do_not_log: true,
},
editable: false,
active: true,
screens: {
create: {
'-all-' => {
null: true,
},
},
edit: {
'-all-' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 600,
)
ObjectManager::Attribute.add(
force: true,
object: 'Group',
name: 'note',
display: 'Note',
data_type: 'richtext',
data_option: {
type: 'text',
maxlength: 250,
null: true,
note: 'Notes are visible to agents only, never to customers.',
},
editable: false,
active: true,
screens: {
create: {
'-all-' => {
null: true,
},
},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1500,
)
ObjectManager::Attribute.add(
force: true,
object: 'Group',
name: 'active',
display: 'Active',
data_type: 'active',
data_option: {
null: true,
default: true,
permission: ['admin.group'],
},
editable: false,
active: true,
screens: {
create: {
'-all-' => {
null: true,
},
},
edit: {
'-all-': {
null: false,
},
},
view: {
'-all-' => {
shown: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1800,
)
Scheduler.create_if_not_exists(
name: 'Process pending tickets',
method: 'Ticket.process_pending',
period: 60 * 15,
prio: 1,
active: true,
)
Scheduler.create_if_not_exists(
name: 'Process escalation tickets',
method: 'Ticket.process_escalation',
period: 60 * 5,
prio: 1,
active: true,
)
Scheduler.create_if_not_exists(
name: 'Import OTRS diff load',
method: 'Import::OTRS.diff_worker',
period: 60 * 3,
prio: 1,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Check Channels',
method: 'Channel.fetch',
period: 30,
prio: 1,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Check streams for Channel',
method: 'Channel.stream',
period: 60,
prio: 1,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Generate Session data',
method: 'Sessions.jobs',
period: 60,
prio: 1,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Execute jobs',
method: 'Job.run',
period: 5 * 60,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Cleanup expired sessions',
method: 'SessionHelper.cleanup_expired',
period: 60 * 60 * 12,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Delete old activity stream entries.',
method: 'ActivityStream.cleanup',
period: 1.day,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Delete old entries.',
method: 'RecentView.cleanup',
period: 1.day,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_or_update(
name: 'Delete old online notification entries.',
method: 'OnlineNotification.cleanup',
period: 2.hours,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_or_update(
name: 'Delete old token entries.',
method: 'Token.cleanup',
period: 30.days,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_or_update(
name: 'Closed chat sessions where participients are offline.',
method: 'Chat.cleanup_close',
period: 60 * 15,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_or_update(
name: 'Cleanup closed sessions.',
method: 'Chat.cleanup',
period: 5.days,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_or_update(
name: 'Sync calendars with ical feeds.',
method: 'Calendar.sync',
period: 1.day,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_or_update(
name: 'Generate user based stats.',
method: 'Stats.generate',
period: 11.minutes,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_or_update(
name: 'Delete old stats store entries.',
method: 'StatsStore.cleanup',
period: 31.days,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Cleanup HttpLog',
method: 'HttpLog.cleanup',
period: 24 * 60 * 60,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Trigger.create_or_update(
name: 'auto reply (on new tickets)',
condition: {
'ticket.action' => {
'operator' => 'is',
'value' => 'create',
},
'ticket.state_id' => {
'operator' => 'is not',
'value' => Ticket::State.lookup(name: 'closed').id,
},
'article.type_id' => {
'operator' => 'is',
'value' => [
Ticket::Article::Type.lookup(name: 'email').id,
Ticket::Article::Type.lookup(name: 'phone').id,
Ticket::Article::Type.lookup(name: 'web').id,
],
},
'article.sender_id' => {
'operator' => 'is',
'value' => Ticket::Article::Sender.lookup(name: 'Customer').id,
},
},
perform: {
'notification.email' => {
'body' => '<div>Your request <b>(#{config.ticket_hook}#{ticket.number})</b> has been received and will be reviewed by our support staff.</div>
<br/>
<div>To provide additional information, please reply to this email or click on the following link (for initial login, please request a new password):
<a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
</div>
<br/>
<div>Your #{config.product_name} Team</div>
<br/>
<div><i><a href="https://zammad.com">Zammad</a>, your customer support system</i></div>',
'recipient' => 'ticket_customer',
'subject' => 'Thanks for your inquiry (#{ticket.title})',
},
},
active: true,
created_by_id: 1,
updated_by_id: 1,
)
Trigger.create_or_update(
name: 'auto reply (on follow up of tickets)',
condition: {
'ticket.action' => {
'operator' => 'is',
'value' => 'update',
},
'article.sender_id' => {
'operator' => 'is',
'value' => Ticket::Article::Sender.lookup(name: 'Customer').id,
},
'article.type_id' => {
'operator' => 'is',
'value' => [
Ticket::Article::Type.lookup(name: 'email').id,
Ticket::Article::Type.lookup(name: 'phone').id,
Ticket::Article::Type.lookup(name: 'web').id,
],
},
},
perform: {
'notification.email' => {
'body' => '<div>Your follow up for <b>(#{config.ticket_hook}#{ticket.number})</b> has been received and will be reviewed by our support staff.</div>
<br/>
<div>To provide additional information, please reply to this email or click on the following link:
<a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
</div>
<br/>
<div>Your #{config.product_name} Team</div>
<br/>
<div><i><a href="https://zammad.com">Zammad</a>, your customer support system</i></div>',
'recipient' => 'ticket_customer',
'subject' => 'Thanks for your follow up (#{ticket.title})',
},
},
active: false,
created_by_id: 1,
updated_by_id: 1,
)
Trigger.create_or_update(
name: 'customer notification (on owner change)',
condition: {
'ticket.owner_id' => {
'operator' => 'has changed',
'pre_condition' => 'current_user.id',
'value' => '',
'value_completion' => '',
}
},
perform: {
'notification.email' => {
'body' => '<p>The owner of ticket (Ticket##{ticket.number}) has changed and is now "#{ticket.owner.firstname} #{ticket.owner.lastname}".<p>
<br/>
<p>To provide additional information, please reply to this email or click on the following link:
<a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
</p>
<br/>
<p><i><a href="https://zammad.com">Zammad</a>, your customer support system</i></p>',
'recipient' => 'ticket_customer',
'subject' => 'Owner has changed (#{ticket.title})',
},
},
active: false,
created_by_id: 1,
updated_by_id: 1,
)
Karma::Activity.create_or_update(
name: 'ticket create',
description: 'You have created a ticket',
score: 10,
once_ttl: 60,
)
Karma::Activity.create_or_update(
name: 'ticket close',
description: 'You have closed a ticket',
score: 5,
once_ttl: 60,
)
Karma::Activity.create_or_update(
name: 'ticket answer 1h',
description: 'You have answered a ticket within 1h',
score: 25,
once_ttl: 60,
)
Karma::Activity.create_or_update(
name: 'ticket answer 2h',
description: 'You have answered a ticket within 2h',
score: 20,
once_ttl: 60,
)
Karma::Activity.create_or_update(
name: 'ticket answer 12h',
description: 'You have answered a ticket within 12h',
score: 10,
once_ttl: 60,
)
Karma::Activity.create_or_update(
name: 'ticket answer 24h',
description: 'You have answered a ticket within 24h',
score: 5,
once_ttl: 60,
)
Karma::Activity.create_or_update(
name: 'ticket pending state',
description: 'Usage of advanced features',
score: 2,
once_ttl: 60,
)
Karma::Activity.create_or_update(
name: 'ticket escalated',
description: 'You have escalated tickets',
score: -5,
once_ttl: 60 * 60 * 24,
)
Karma::Activity.create_or_update(
name: 'ticket reminder overdue (+2 days)',
description: 'You have tickets that are over 2 days overdue',
score: -5,
once_ttl: 60 * 60 * 24,
)
Karma::Activity.create_or_update(
name: 'text module',
description: 'Usage of advanced features',
score: 4,
once_ttl: 60 * 30,
)
Karma::Activity.create_or_update(
name: 'tagging',
description: 'Usage of advanced features',
score: 4,
once_ttl: 60 * 60 * 4,
)
# reset primary key sequences
DbHelper.import_post
# install locales and translations
Locale.create_if_not_exists(
locale: 'en-us',
alias: 'en',
name: 'English (United States)',
)
Locale.sync
Translation.sync
Calendar.init_setup
# install all packages in auto_install
Package.auto_install
Set password field to autocomplete=“new-password”.
# encoding: utf-8
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Emanuel', :city => cities.first)
# clear old caches to start from scratch
Cache.clear
Setting.create_if_not_exists(
title: 'Application secret',
name: 'application_secret',
area: 'Core',
description: 'Defines the random application secret.',
options: {},
state: SecureRandom.hex(128),
preferences: {
permission: ['admin'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'System Init Done',
name: 'system_init_done',
area: 'Core',
description: 'Defines if application is in init mode.',
options: {},
state: false,
preferences: { online_service_disable: true },
frontend: true
)
Setting.create_if_not_exists(
title: 'App Version',
name: 'app_version',
area: 'Core::WebApp',
description: 'Only used internally to propagate current web app version to clients.',
options: {},
state: '',
preferences: { online_service_disable: true },
frontend: false
)
Setting.create_if_not_exists(
title: 'Maintenance Mode',
name: 'maintenance_mode',
area: 'Core::WebApp',
description: 'Enable or disable the maintenance mode of Zammad. If enabled, all non-administrators get logged out and only administrators can start a new session.',
options: {},
state: false,
preferences: {
permission: ['admin.maintenance'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Maintenance Login',
name: 'maintenance_login',
area: 'Core::WebApp',
description: 'Put a message on the login page. To change it, click on the text area below and change it inline.',
options: {},
state: false,
preferences: {
permission: ['admin.maintenance'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Maintenance Login',
name: 'maintenance_login_message',
area: 'Core::WebApp',
description: 'Message for login page.',
options: {},
state: 'Something about to share. Click here to change.',
preferences: {
permission: ['admin.maintenance'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Developer System',
name: 'developer_mode',
area: 'Core::Develop',
description: 'Defines if application is in developer mode (useful for developer, all users have the same password, password reset will work without email delivery).',
options: {},
state: false,
preferences: { online_service_disable: true },
frontend: true
)
Setting.create_if_not_exists(
title: 'Online Service',
name: 'system_online_service',
area: 'Core',
description: 'Defines if application is used as online service.',
options: {},
state: false,
preferences: { online_service_disable: true },
frontend: true
)
Setting.create_if_not_exists(
title: 'Product Name',
name: 'product_name',
area: 'System::Branding',
description: 'Defines the name of the application, shown in the web interface, tabs and title bar of the web browser.',
options: {
form: [
{
display: '',
null: false,
name: 'product_name',
tag: 'input',
},
],
},
preferences: {
render: true,
prio: 1,
placeholder: true,
permission: ['admin.branding'],
},
state: 'Zammad Helpdesk',
frontend: true
)
Setting.create_if_not_exists(
title: 'Logo',
name: 'product_logo',
area: 'System::Branding',
description: 'Defines the logo of the application, shown in the web interface.',
options: {
form: [
{
display: '',
null: false,
name: 'product_logo',
tag: 'input',
},
],
},
preferences: {
prio: 3,
controller: 'SettingsAreaLogo',
permission: ['admin.branding'],
},
state: 'logo.svg',
frontend: true
)
Setting.create_if_not_exists(
title: 'Organization',
name: 'organization',
area: 'System::Branding',
description: 'Will be shown in the app and is included in email footers.',
options: {
form: [
{
display: '',
null: false,
name: 'organization',
tag: 'input',
},
],
},
state: '',
preferences: {
prio: 2,
placeholder: true,
permission: ['admin.branding'],
},
frontend: true
)
options = {}
(10..99).each { |item|
options[item] = item
}
system_id = rand(10..99)
Setting.create_if_not_exists(
title: 'SystemID',
name: 'system_id',
area: 'System::Base',
description: 'Defines the system identifier. Every ticket number contains this ID. This ensures that only tickets which belong to your system will be processed as follow-ups (useful when communicating between two instances of Zammad).',
options: {
form: [
{
display: '',
null: true,
name: 'system_id',
tag: 'select',
options: options,
},
],
},
state: system_id,
preferences: {
online_service_disable: true,
placeholder: true,
authentication: true,
permission: ['admin.system'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Fully Qualified Domain Name',
name: 'fqdn',
area: 'System::Base',
description: 'Defines the fully qualified domain name of the system. This setting is used as a variable, #{setting.fqdn} which is found in all forms of messaging used by the application, to build links to the tickets within your system.',
options: {
form: [
{
display: '',
null: false,
name: 'fqdn',
tag: 'input',
},
],
},
state: 'zammad.example.com',
preferences: {
online_service_disable: true,
placeholder: true,
permission: ['admin.system'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Websocket port',
name: 'websocket_port',
area: 'System::WebSocket',
description: 'Defines the port of the websocket server.',
options: {
form: [
{
display: '',
null: false,
name: 'websocket_port',
tag: 'input',
},
],
},
state: '6042',
preferences: { online_service_disable: true },
frontend: true
)
Setting.create_if_not_exists(
title: 'HTTP type',
name: 'http_type',
area: 'System::Base',
description: 'Define the http protocol of your instance.',
options: {
form: [
{
display: '',
null: true,
name: 'http_type',
tag: 'select',
options: {
'https' => 'https',
'http' => 'http',
},
},
],
},
state: 'http',
preferences: {
online_service_disable: true,
placeholder: true,
permission: ['admin.system'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Storage Mechanism',
name: 'storage_provider',
area: 'System::Storage',
description: '"Database" stores all attachments in the database (not recommended for storing large amounts of data). "Filesystem" stores the data in the filesystem. You can switch between the modules even on a system that is already in production without any loss of data.',
options: {
form: [
{
display: '',
null: true,
name: 'storage_provider',
tag: 'select',
tranlate: true,
options: {
'DB' => 'Database',
'File' => 'Filesystem',
},
},
],
},
state: 'DB',
preferences: {
controller: 'SettingsAreaStorageProvider',
online_service_disable: true,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Image Service',
name: 'image_backend',
area: 'System::Services',
description: 'Defines the backend for user and organization image lookups.',
options: {
form: [
{
display: '',
null: true,
name: 'image_backend',
tag: 'select',
options: {
'' => '-',
'Service::Image::Zammad' => 'Zammad Image Service',
},
},
],
},
state: 'Service::Image::Zammad',
preferences: {
prio: 1,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Geo IP Service',
name: 'geo_ip_backend',
area: 'System::Services',
description: 'Defines the backend for geo IP lookups. Shows also location of an IP address if an IP address is shown.',
options: {
form: [
{
display: '',
null: true,
name: 'geo_ip_backend',
tag: 'select',
options: {
'' => '-',
'Service::GeoIp::Zammad' => 'Zammad GeoIP Service',
},
},
],
},
state: 'Service::GeoIp::Zammad',
preferences: {
prio: 2,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Geo Location Service',
name: 'geo_location_backend',
area: 'System::Services',
description: 'Defines the backend for geo location lookups to store geo locations for addresses.',
options: {
form: [
{
display: '',
null: true,
name: 'geo_location_backend',
tag: 'select',
options: {
'' => '-',
'Service::GeoLocation::Gmaps' => 'Google Maps',
},
},
],
},
state: 'Service::GeoLocation::Gmaps',
preferences: {
prio: 3,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Geo Calendar Service',
name: 'geo_calendar_backend',
area: 'System::Services',
description: 'Defines the backend for geo calendar lookups. Used for initial calendar succession.',
options: {
form: [
{
display: '',
null: true,
name: 'geo_calendar_backend',
tag: 'select',
options: {
'' => '-',
'Service::GeoCalendar::Zammad' => 'Zammad GeoCalendar Service',
},
},
],
},
state: 'Service::GeoCalendar::Zammad',
preferences: {
prio: 2,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Proxy Settings',
name: 'proxy',
area: 'System::Network',
description: 'Address of the proxy server for http and https resources.',
options: {
form: [
{
display: '',
null: false,
name: 'proxy',
tag: 'input',
placeholder: 'proxy.example.com:3128',
},
],
},
state: '',
preferences: {
online_service_disable: true,
controller: 'SettingsAreaProxy',
prio: 1,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Proxy User',
name: 'proxy_username',
area: 'System::Network',
description: 'Username for proxy connection.',
options: {
form: [
{
display: '',
null: false,
name: 'proxy_username',
tag: 'input',
},
],
},
state: '',
preferences: {
disabled: true,
online_service_disable: true,
prio: 2,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Proxy Password',
name: 'proxy_password',
area: 'System::Network',
description: 'Password for proxy connection.',
options: {
form: [
{
display: '',
null: false,
name: 'proxy_passowrd',
tag: 'input',
},
],
},
state: '',
preferences: {
disabled: true,
online_service_disable: true,
prio: 3,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Send client stats',
name: 'ui_send_client_stats',
area: 'System::UI',
description: 'Send client stats/error message to central server to improve the usability.',
options: {
form: [
{
display: '',
null: true,
name: 'ui_send_client_stats',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
prio: 1,
permission: ['admin.system'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Client storage',
name: 'ui_client_storage',
area: 'System::UI',
description: 'Use client storage to cache data to enhance performance of application.',
options: {
form: [
{
display: '',
null: true,
name: 'ui_client_storage',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
prio: 2,
permission: ['admin.system'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Define default visibility of new a new article',
name: 'ui_ticket_zoom_article_new_internal',
area: 'UI::TicketZoom',
description: 'Set default visibility of new a new article.',
options: {
form: [
{
display: '',
null: true,
name: 'ui_ticket_zoom_article_new_internal',
tag: 'boolean',
translate: true,
options: {
true => 'internal',
false => 'public',
},
},
],
},
state: true,
preferences: {
prio: 1,
permission: ['admin.ui'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'New User Accounts',
name: 'user_create_account',
area: 'Security::Base',
description: 'Enables users to create their own account via web interface.',
options: {
form: [
{
display: '',
null: true,
name: 'user_create_account',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: true,
preferences: {
permission: ['admin.security'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Lost Password',
name: 'user_lost_password',
area: 'Security::Base',
description: 'Activates lost password feature for users.',
options: {
form: [
{
display: '',
null: true,
name: 'user_lost_password',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: true,
preferences: {
permission: ['admin.security'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_ldap',
area: 'Security::Authentication',
description: 'Enables user authentication via %s.',
preferences: {
title_i18n: ['LDAP'],
description_i18n: ['LDAP'],
permission: ['admin.security'],
},
state: {
adapter: 'Auth::Ldap',
host: 'localhost',
port: 389,
bind_dn: 'cn=Manager,dc=example,dc=org',
bind_pw: 'example',
uid: 'mail',
base: 'dc=example,dc=org',
always_filter: '',
always_roles: %w(Admin Agent),
always_groups: ['Users'],
sync_params: {
firstname: 'sn',
lastname: 'givenName',
email: 'mail',
login: 'mail',
},
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_twitter',
area: 'Security::ThirdPartyAuthentication',
description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
options: {
form: [
{
display: '',
null: true,
name: 'auth_twitter',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
controller: 'SettingsAreaSwitch',
sub: ['auth_twitter_credentials'],
title_i18n: ['Twitter'],
description_i18n: ['Twitter', 'Twitter Developer Site', 'https://dev.twitter.com/apps'],
permission: ['admin.security'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Twitter App Credentials',
name: 'auth_twitter_credentials',
area: 'Security::ThirdPartyAuthentication::Twitter',
description: 'App credentials for Twitter.',
options: {
form: [
{
display: 'Twitter Key',
null: true,
name: 'key',
tag: 'input',
},
{
display: 'Twitter Secret',
null: true,
name: 'secret',
tag: 'input',
},
],
},
state: {},
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_facebook',
area: 'Security::ThirdPartyAuthentication',
description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
options: {
form: [
{
display: '',
null: true,
name: 'auth_facebook',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
controller: 'SettingsAreaSwitch',
sub: ['auth_facebook_credentials'],
title_i18n: ['Facebook'],
description_i18n: ['Facebook', 'Facebook Developer Site', 'https://developers.facebook.com/apps/'],
permission: ['admin.security'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Facebook App Credentials',
name: 'auth_facebook_credentials',
area: 'Security::ThirdPartyAuthentication::Facebook',
description: 'App credentials for Facebook.',
options: {
form: [
{
display: 'App ID',
null: true,
name: 'app_id',
tag: 'input',
},
{
display: 'App Secret',
null: true,
name: 'app_secret',
tag: 'input',
},
],
},
state: {},
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_google_oauth2',
area: 'Security::ThirdPartyAuthentication',
description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
options: {
form: [
{
display: '',
null: true,
name: 'auth_google_oauth2',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
controller: 'SettingsAreaSwitch',
sub: ['auth_google_oauth2_credentials'],
title_i18n: ['Google'],
description_i18n: ['Google', 'Google API Console Site', 'https://console.developers.google.com/apis/credentials'],
permission: ['admin.security'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Google App Credentials',
name: 'auth_google_oauth2_credentials',
area: 'Security::ThirdPartyAuthentication::Google',
description: 'Enables user authentication via Google.',
options: {
form: [
{
display: 'Client ID',
null: true,
name: 'client_id',
tag: 'input',
},
{
display: 'Client Secret',
null: true,
name: 'client_secret',
tag: 'input',
},
],
},
state: {},
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_linkedin',
area: 'Security::ThirdPartyAuthentication',
description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
options: {
form: [
{
display: '',
null: true,
name: 'auth_linkedin',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
controller: 'SettingsAreaSwitch',
sub: ['auth_linkedin_credentials'],
title_i18n: ['LinkedIn'],
description_i18n: ['LinkedIn', 'Linkedin Developer Site', 'https://www.linkedin.com/developer/apps'],
permission: ['admin.security'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'LinkedIn App Credentials',
name: 'auth_linkedin_credentials',
area: 'Security::ThirdPartyAuthentication::Linkedin',
description: 'Enables user authentication via LinkedIn.',
options: {
form: [
{
display: 'App ID',
null: true,
name: 'app_id',
tag: 'input',
},
{
display: 'App Secret',
null: true,
name: 'app_secret',
tag: 'input',
},
],
},
state: {},
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_github',
area: 'Security::ThirdPartyAuthentication',
description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
options: {
form: [
{
display: '',
null: true,
name: 'auth_github',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
controller: 'SettingsAreaSwitch',
sub: ['auth_github_credentials'],
title_i18n: ['Github'],
description_i18n: ['Github', 'Github OAuth Applications', 'https://github.com/settings/applications'],
permission: ['admin.security'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Github App Credentials',
name: 'auth_github_credentials',
area: 'Security::ThirdPartyAuthentication::Github',
description: 'Enables user authentication via Github.',
options: {
form: [
{
display: 'App ID',
null: true,
name: 'app_id',
tag: 'input',
},
{
display: 'App Secret',
null: true,
name: 'app_secret',
tag: 'input',
},
],
},
state: {},
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_gitlab',
area: 'Security::ThirdPartyAuthentication',
description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
options: {
form: [
{
display: '',
null: true,
name: 'auth_gitlab',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
controller: 'SettingsAreaSwitch',
sub: ['auth_gitlab_credentials'],
title_i18n: ['Gitlab'],
description_i18n: ['Gitlab', 'Gitlab Applications', 'https://your-gitlab-host/admin/applications'],
permission: ['admin.security'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Gitlab App Credentials',
name: 'auth_gitlab_credentials',
area: 'Security::ThirdPartyAuthentication::Gitlab',
description: 'Enables user authentication via Gitlab.',
options: {
form: [
{
display: 'App ID',
null: true,
name: 'app_id',
tag: 'input',
},
{
display: 'App Secret',
null: true,
name: 'app_secret',
tag: 'input',
},
{
display: 'Site',
null: true,
name: 'site',
tag: 'input',
placeholder: 'https://gitlab.YOURDOMAIN.com',
},
],
},
state: {},
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Authentication via %s',
name: 'auth_oauth2',
area: 'Security::ThirdPartyAuthentication',
description: 'Enables user authentication via generic OAuth2. Register your app first.',
options: {
form: [
{
display: '',
null: true,
name: 'auth_oauth2',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
controller: 'SettingsAreaSwitch',
sub: ['auth_oauth2_credentials'],
title_i18n: ['Generic OAuth2'],
permission: ['admin.security'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Generic OAuth2 App Credentials',
name: 'auth_oauth2_credentials',
area: 'Security::ThirdPartyAuthentication::GenericOAuth',
description: 'Enables user authentication via generic OAuth2.',
options: {
form: [
{
display: 'Name',
null: true,
name: 'name',
tag: 'input',
placeholder: 'Some Provider Name',
},
{
display: 'App ID',
null: true,
name: 'app_id',
tag: 'input',
},
{
display: 'App Secret',
null: true,
name: 'app_secret',
tag: 'input',
},
{
display: 'Site',
null: true,
name: 'site',
tag: 'input',
placeholder: 'https://gitlab.YOURDOMAIN.com',
},
{
display: 'authorize_url',
null: true,
name: 'authorize_url',
tag: 'input',
placeholder: '/oauth/authorize',
},
{
display: 'token_url',
null: true,
name: 'token_url',
tag: 'input',
placeholder: '/oauth/token',
},
],
},
state: {},
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Minimum length',
name: 'password_min_size',
area: 'Security::Password',
description: 'Password needs to have at least a minimal number of characters.',
options: {
form: [
{
display: '',
null: true,
name: 'password_min_size',
tag: 'select',
options: {
4 => ' 4',
5 => ' 5',
6 => ' 6',
7 => ' 7',
8 => ' 8',
9 => ' 9',
10 => '10',
11 => '11',
12 => '12',
13 => '13',
14 => '14',
15 => '15',
16 => '16',
17 => '17',
18 => '18',
19 => '19',
20 => '20',
},
},
],
},
state: 6,
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: '2 lower and 2 upper characters',
name: 'password_min_2_lower_2_upper_characters',
area: 'Security::Password',
description: 'Password needs to contain 2 lower and 2 upper characters.',
options: {
form: [
{
display: '',
null: true,
name: 'password_min_2_lower_2_upper_characters',
tag: 'select',
options: {
1 => 'yes',
0 => 'no',
},
},
],
},
state: 0,
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Digit required',
name: 'password_need_digit',
area: 'Security::Password',
description: 'Password needs to contain at least one digit.',
options: {
form: [
{
display: 'Needed',
null: true,
name: 'password_need_digit',
tag: 'select',
options: {
1 => 'yes',
0 => 'no',
},
},
],
},
state: 1,
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Maximum failed logins',
name: 'password_max_login_failed',
area: 'Security::Password',
description: 'Number of failed logins after account will be deactivated.',
options: {
form: [
{
display: '',
null: true,
name: 'password_max_login_failed',
tag: 'select',
options: {
4 => ' 4',
5 => ' 5',
6 => ' 6',
7 => ' 7',
8 => ' 8',
9 => ' 9',
10 => '10',
11 => '11',
13 => '13',
14 => '14',
15 => '15',
16 => '16',
17 => '17',
18 => '18',
19 => '19',
20 => '20',
},
},
],
},
state: 10,
preferences: {
permission: ['admin.security'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Ticket Hook',
name: 'ticket_hook',
area: 'Ticket::Base',
description: 'The identifier for a ticket, e. g. Ticket#, Call#, MyTicket#. The default is Ticket#.',
options: {
form: [
{
display: '',
null: false,
name: 'ticket_hook',
tag: 'input',
},
],
},
preferences: {
render: true,
placeholder: true,
authentication: true,
permission: ['admin.ticket'],
},
state: 'Ticket#',
frontend: true
)
Setting.create_if_not_exists(
title: 'Ticket Hook Divider',
name: 'ticket_hook_divider',
area: 'Ticket::Base::Shadow',
description: 'The divider between TicketHook and ticket number. E. g. \': \'.',
options: {
form: [
{
display: '',
null: true,
name: 'ticket_hook_divider',
tag: 'input',
},
],
},
state: '',
preferences: {
permission: ['admin.ticket'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Ticket Hook Position',
name: 'ticket_hook_position',
area: 'Ticket::Base',
description: "The format of the subject.
* **Right** means **Some Subject [Ticket#12345]**
* **Left** means **[Ticket#12345] Some Subject**
* **None** means **Some Subject** (without ticket number). In the last case you should enable *postmaster_follow_up_search_in* to recognize follow-ups based on email headers and/or body.",
options: {
form: [
{
display: '',
null: true,
name: 'ticket_hook_position',
tag: 'select',
translate: true,
options: {
'left' => 'left',
'right' => 'right',
'none' => 'none',
},
},
],
},
state: 'right',
preferences: {
controller: 'SettingsAreaTicketHookPosition',
permission: ['admin.ticket'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Ticket Number Format',
name: 'ticket_number',
area: 'Ticket::Number',
description: "Selects the ticket number generator module.
* **Increment** increments the ticket number, the SystemID and the counter are used with SystemID.Counter format (e.g. 1010138, 1010139).
* With **Date** the ticket numbers will be generated by the current date, the SystemID and the counter. The format looks like Year.Month.Day.SystemID.counter (e.g. 201206231010138, 201206231010139).",
options: {
form: [
{
display: '',
null: true,
name: 'ticket_number',
tag: 'select',
translate: true,
options: {
'Ticket::Number::Increment' => 'Increment (SystemID.Counter)',
'Ticket::Number::Date' => 'Date (Year.Month.Day.SystemID.Counter)',
},
},
],
},
state: 'Ticket::Number::Increment',
preferences: {
settings_included: %w(ticket_number_increment ticket_number_date),
controller: 'SettingsAreaTicketNumber',
permission: ['admin.ticket'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Ticket Number Increment',
name: 'ticket_number_increment',
area: 'Ticket::Number',
description: '-',
options: {
form: [
{
display: 'Checksum',
null: true,
name: 'checksum',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
{
display: 'Min. size of number',
null: true,
name: 'min_size',
tag: 'select',
options: {
1 => ' 1',
2 => ' 2',
3 => ' 3',
4 => ' 4',
5 => ' 5',
6 => ' 6',
7 => ' 7',
8 => ' 8',
9 => ' 9',
10 => '10',
11 => '11',
12 => '12',
13 => '13',
14 => '14',
15 => '15',
16 => '16',
17 => '17',
18 => '18',
19 => '19',
20 => '20',
},
},
],
},
state: {
checksum: false,
min_size: 5,
},
preferences: {
permission: ['admin.ticket'],
hidden: true,
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Ticket Number Increment Date',
name: 'ticket_number_date',
area: 'Ticket::Number',
description: '-',
options: {
form: [
{
display: 'Checksum',
null: true,
name: 'checksum',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: {
checksum: false
},
preferences: {
permission: ['admin.ticket'],
hidden: true,
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Enable Ticket creation',
name: 'customer_ticket_create',
area: 'CustomerWeb::Base',
description: 'Defines if a customer can create tickets via the web interface.',
options: {
form: [
{
display: '',
null: true,
name: 'customer_ticket_create',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: true,
preferences: {
authentication: true,
permission: ['admin.channel_web'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Group selection for Ticket creation',
name: 'customer_ticket_create_group_ids',
area: 'CustomerWeb::Base',
description: 'Defines groups for which a customer can create tickets via web interface. "-" means all groups are available.',
options: {
form: [
{
display: '',
null: true,
name: 'group_ids',
tag: 'select',
multiple: true,
nulloption: true,
relation: 'Group',
},
],
},
state: '',
preferences: {
authentication: true,
permission: ['admin.channel_web'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Enable Ticket creation',
name: 'form_ticket_create',
area: 'Form::Base',
description: 'Defines if tickets can be created via web form.',
options: {
form: [
{
display: '',
null: true,
name: 'form_ticket_create',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
permission: ['admin.channel_formular'],
},
frontend: false,
)
Setting.create_if_not_exists(
title: 'Ticket Subject Size',
name: 'ticket_subject_size',
area: 'Email::Base',
description: 'Max. length of the subject in an email reply.',
options: {
form: [
{
display: '',
null: false,
name: 'ticket_subject_size',
tag: 'input',
},
],
},
state: '110',
preferences: {
permission: ['admin.channel_email'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Ticket Subject Reply',
name: 'ticket_subject_re',
area: 'Email::Base',
description: 'The text at the beginning of the subject in an email reply, e. g. RE, AW, or AS.',
options: {
form: [
{
display: '',
null: true,
name: 'ticket_subject_re',
tag: 'input',
},
],
},
state: 'RE',
preferences: {
permission: ['admin.channel_email'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Sender Format',
name: 'ticket_define_email_from',
area: 'Email::Base',
description: 'Defines how the From field of emails (sent from answers and email tickets) should look like.',
options: {
form: [
{
display: '',
null: true,
name: 'ticket_define_email_from',
tag: 'select',
options: {
SystemAddressName: 'System Address Display Name',
AgentNameSystemAddressName: 'Agent Name + FromSeparator + System Address Display Name',
},
},
],
},
state: 'AgentNameSystemAddressName',
preferences: {
permission: ['admin.channel_email'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Sender Format Separator',
name: 'ticket_define_email_from_separator',
area: 'Email::Base',
description: 'Defines the separator between the agent\'s real name and the given group email address.',
options: {
form: [
{
display: '',
null: false,
name: 'ticket_define_email_from_separator',
tag: 'input',
},
],
},
state: 'via',
preferences: {
permission: ['admin.channel_email'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Maximum Email Size',
name: 'postmaster_max_size',
area: 'Email::Base',
description: 'Maximum size in MB of emails.',
options: {
form: [
{
display: '',
null: true,
name: 'postmaster_max_size',
tag: 'select',
options: {
1 => ' 1',
2 => ' 2',
3 => ' 3',
4 => ' 4',
5 => ' 5',
6 => ' 6',
7 => ' 7',
8 => ' 8',
9 => ' 9',
10 => ' 10',
15 => ' 15',
20 => ' 20',
25 => ' 25',
30 => ' 30',
35 => ' 35',
40 => ' 40',
45 => ' 45',
50 => ' 50',
60 => ' 60',
70 => ' 70',
80 => ' 80',
90 => ' 90',
100 => '100',
125 => '125',
150 => '150',
},
},
],
},
state: 10,
preferences: {
online_service_disable: true,
permission: ['admin.channel_email'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Additional follow-up detection',
name: 'postmaster_follow_up_search_in',
area: 'Email::Base',
description: 'By default the follow-up check is done via the subject of an email. With this setting you can add more fields for which the follow-up check will be executed.',
options: {
form: [
{
display: '',
null: true,
name: 'postmaster_follow_up_search_in',
tag: 'checkbox',
options: {
'references' => 'References - Search for follow up also in In-Reply-To or References headers.',
'body' => 'Body - Search for follow up also in mail body.',
'attachment' => 'Attachment - Search for follow up also in attachments.',
},
},
],
},
state: [],
preferences: {
permission: ['admin.channel_email'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Notification Sender',
name: 'notification_sender',
area: 'Email::Base',
description: 'Defines the sender of email notifications.',
options: {
form: [
{
display: '',
null: false,
name: 'notification_sender',
tag: 'input',
},
],
},
state: 'Notification Master <noreply@#{config.fqdn}>',
preferences: {
online_service_disable: true,
permission: ['admin.channel_email'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Block Notifications',
name: 'send_no_auto_response_reg_exp',
area: 'Email::Base',
description: 'If this regex matches, no notification will be sent by the sender.',
options: {
form: [
{
display: '',
null: false,
name: 'send_no_auto_response_reg_exp',
tag: 'input',
},
],
},
state: '(mailer-daemon|postmaster|abuse|root|noreply|noreply.+?|no-reply|no-reply.+?)@.+?\..+?',
preferences: {
online_service_disable: true,
permission: ['admin.channel_email'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'API Token Access',
name: 'api_token_access',
area: 'API::Base',
description: 'Enable REST API using tokens (not username/email address and password). Each user needs to create its own access tokens in user profile.',
options: {
form: [
{
display: '',
null: true,
name: 'api_token_access',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: true,
preferences: {
permission: ['admin.api'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'API Password Access',
name: 'api_password_access',
area: 'API::Base',
description: 'Enable REST API access using the username/email address and password for the authentication user.',
options: {
form: [
{
display: '',
null: true,
name: 'api_password_access',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: true,
preferences: {
permission: ['admin.api'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Monitoring Token',
name: 'monitoring_token',
area: 'HealthCheck::Base',
description: 'Token for monitoring.',
options: {
form: [
{
display: '',
null: false,
name: 'monitoring_token',
tag: 'input',
},
],
},
state: SecureRandom.urlsafe_base64(40),
preferences: {
permission: ['admin.monitoring'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Enable Chat',
name: 'chat',
area: 'Chat::Base',
description: 'Enable/disable online chat.',
options: {
form: [
{
display: '',
null: true,
name: 'chat',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
trigger: ['menu:render', 'chat:rerender'],
permission: ['admin.channel_chat'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Agent idle timeout',
name: 'chat_agent_idle_timeout',
area: 'Chat::Extended',
description: 'Idle timeout in seconds until agent is set offline automatically.',
options: {
form: [
{
display: '',
null: false,
name: 'chat_agent_idle_timeout',
tag: 'input',
},
],
},
state: '120',
preferences: {
permission: ['admin.channel_chat'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Defines searchable models.',
name: 'models_searchable',
area: 'Models::Base',
description: 'Defines the searchable models.',
options: {},
state: [],
preferences: {
authentication: true,
},
frontend: true,
)
Setting.create_if_not_exists(
title: 'Default Screen',
name: 'default_controller',
area: 'Core',
description: 'Defines the default screen.',
options: {},
state: '#dashboard',
frontend: true
)
Setting.create_if_not_exists(
title: 'Elasticsearch Endpoint URL',
name: 'es_url',
area: 'SearchIndex::Elasticsearch',
description: 'Defines endpoint of Elasticsearch.',
state: '',
preferences: { online_service_disable: true },
frontend: false
)
Setting.create_if_not_exists(
title: 'Elasticsearch Endpoint User',
name: 'es_user',
area: 'SearchIndex::Elasticsearch',
description: 'Defines HTTP basic auth user of Elasticsearch.',
state: '',
preferences: { online_service_disable: true },
frontend: false
)
Setting.create_if_not_exists(
title: 'Elasticsearch Endpoint Password',
name: 'es_password',
area: 'SearchIndex::Elasticsearch',
description: 'Defines HTTP basic auth password of Elasticsearch.',
state: '',
preferences: { online_service_disable: true },
frontend: false
)
Setting.create_if_not_exists(
title: 'Elasticsearch Endpoint Index',
name: 'es_index',
area: 'SearchIndex::Elasticsearch',
description: 'Defines Elasticsearch index name.',
state: 'zammad',
preferences: { online_service_disable: true },
frontend: false
)
Setting.create_if_not_exists(
title: 'Elasticsearch Attachment Extensions',
name: 'es_attachment_ignore',
area: 'SearchIndex::Elasticsearch',
description: 'Defines attachment extensions which will be ignored by Elasticsearch.',
state: [ '.png', '.jpg', '.jpeg', '.mpeg', '.mpg', '.mov', '.bin', '.exe', '.box', '.mbox' ],
preferences: { online_service_disable: true },
frontend: false
)
Setting.create_if_not_exists(
title: 'Elasticsearch Attachment Size',
name: 'es_attachment_max_size_in_mb',
area: 'SearchIndex::Elasticsearch',
description: 'Define max. attachment size for Elasticsearch.',
state: 50,
preferences: { online_service_disable: true },
frontend: false
)
Setting.create_if_not_exists(
title: 'Import Mode',
name: 'import_mode',
area: 'Import::Base',
description: 'Puts Zammad into import mode (disables some triggers).',
options: {
form: [
{
display: '',
null: true,
name: 'import_mode',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Import Backend',
name: 'import_backend',
area: 'Import::Base::Internal',
description: 'Set backend which is being used for import.',
options: {},
state: '',
frontend: true
)
Setting.create_if_not_exists(
title: 'Ignore Escalation/SLA Information',
name: 'import_ignore_sla',
area: 'Import::Base',
description: 'Ignore escalation/SLA information for import.',
options: {
form: [
{
display: '',
null: true,
name: 'import_ignore_sla',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
frontend: false
)
Setting.create_if_not_exists(
title: 'Import Endpoint',
name: 'import_otrs_endpoint',
area: 'Import::OTRS',
description: 'Defines OTRS endpoint to import users, tickets, states and articles.',
options: {
form: [
{
display: '',
null: false,
name: 'import_otrs_endpoint',
tag: 'input',
},
],
},
state: 'http://otrs_host/otrs',
frontend: false
)
Setting.create_if_not_exists(
title: 'Import Key',
name: 'import_otrs_endpoint_key',
area: 'Import::OTRS',
description: 'Defines OTRS endpoint authentication key.',
options: {
form: [
{
display: '',
null: false,
name: 'import_otrs_endpoint_key',
tag: 'input',
},
],
},
state: '',
frontend: false
)
Setting.create_if_not_exists(
title: 'Import User for HTTP basic authentication',
name: 'import_otrs_user',
area: 'Import::OTRS',
description: 'Defines HTTP basic authentication user (only if OTRS is protected via HTTP basic auth).',
options: {
form: [
{
display: '',
null: true,
name: 'import_otrs_user',
tag: 'input',
},
],
},
state: '',
frontend: false
)
Setting.create_if_not_exists(
title: 'Import Password for http basic authentication',
name: 'import_otrs_password',
area: 'Import::OTRS',
description: 'Defines http basic authentication password (only if OTRS is protected via http basic auth).',
options: {
form: [
{
display: '',
null: true,
name: 'import_otrs_password',
tag: 'input',
},
],
},
state: '',
frontend: false
)
Setting.create_if_not_exists(
title: 'Import Endpoint',
name: 'import_zendesk_endpoint',
area: 'Import::Zendesk',
description: 'Defines Zendesk endpoint to import users, ticket, states and articles.',
options: {
form: [
{
display: '',
null: false,
name: 'import_zendesk_endpoint',
tag: 'input',
},
],
},
state: 'https://yours.zendesk.com/api/v2',
frontend: false
)
Setting.create_if_not_exists(
title: 'Import Key for requesting the Zendesk API',
name: 'import_zendesk_endpoint_key',
area: 'Import::Zendesk',
description: 'Defines Zendesk endpoint authentication key.',
options: {
form: [
{
display: '',
null: false,
name: 'import_zendesk_endpoint_key',
tag: 'input',
},
],
},
state: '',
frontend: false
)
Setting.create_if_not_exists(
title: 'Import User for requesting the Zendesk API',
name: 'import_zendesk_endpoint_username',
area: 'Import::Zendesk',
description: 'Defines Zendesk endpoint authentication user.',
options: {
form: [
{
display: '',
null: true,
name: 'import_zendesk_endpoint_username',
tag: 'input',
},
],
},
state: '',
frontend: false
)
Setting.create_if_not_exists(
title: 'Time Accounting',
name: 'time_accounting',
area: 'Web::Base',
description: 'Enable time accounting.',
options: {
form: [
{
display: '',
null: true,
name: 'time_accounting',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
authentication: true,
permission: ['admin.time_accounting'],
},
state: false,
frontend: true
)
Setting.create_if_not_exists(
title: 'Time Accounting Selector',
name: 'time_accounting_selector',
area: 'Web::Base',
description: 'Enable time accounting for these tickets.',
options: {
form: [
{},
],
},
preferences: {
authentication: true,
permission: ['admin.time_accounting'],
},
state: {},
frontend: true
)
Setting.create_if_not_exists(
title: 'New Tags',
name: 'tag_new',
area: 'Web::Base',
description: 'Allow users to create new tags.',
options: {
form: [
{
display: '',
null: true,
name: 'tag_new',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
preferences: {
authentication: true,
permission: ['admin.tag'],
},
state: true,
frontend: true
)
Setting.create_if_not_exists(
title: 'Default calendar tickets subscriptions',
name: 'defaults_calendar_subscriptions_tickets',
area: 'Defaults::CalendarSubscriptions',
description: 'Defines the default calendar tickets subscription settings.',
options: {},
state: {
escalation: {
own: true,
not_assigned: false,
},
new_open: {
own: true,
not_assigned: false,
},
pending: {
own: true,
not_assigned: false,
}
},
preferences: {
authentication: true,
},
frontend: true
)
Setting.create_if_not_exists(
title: 'Defines translator identifier.',
name: 'translator_key',
area: 'i18n::translator_key',
description: 'Defines the translator identifier for contributions.',
options: {},
state: '',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0010_postmaster_filter_trusted',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to remove X-Zammad headers from not trusted sources.',
options: {},
state: 'Channel::Filter::Trusted',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0012_postmaster_filter_sender_is_system_address',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to check if email has been created by Zammad itself and will set the article sender.',
options: {},
state: 'Channel::Filter::SenderIsSystemAddress',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0014_postmaster_filter_own_notification_loop_detection',
area: 'Postmaster::PreFilter',
description: 'Define postmaster filter to check if email is a own created notification email, then ignore it to prevent email loops.',
options: {},
state: 'Channel::Filter::OwnNotificationLoopDetection',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0015_postmaster_filter_identify_sender',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to identify sender user.',
options: {},
state: 'Channel::Filter::IdentifySender',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0020_postmaster_filter_auto_response_check',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to identify auto responses to prevent auto replies from Zammad.',
options: {},
state: 'Channel::Filter::AutoResponseCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0030_postmaster_filter_out_of_office_check',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to identify out-of-office emails for follow-up detection and keeping current ticket state.',
options: {},
state: 'Channel::Filter::OutOfOfficeCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0100_postmaster_filter_follow_up_check',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to identify follow-ups (based on admin settings).',
options: {},
state: 'Channel::Filter::FollowUpCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0200_postmaster_filter_follow_up_possible_check',
area: 'Postmaster::PreFilter',
description: 'Define postmaster filter to check if follow ups get created (based on admin settings).',
options: {},
state: 'Channel::Filter::FollowUpPossibleCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '0900_postmaster_filter_bounce_check',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to identify postmaster bounced - to handle it as follow-up of the original ticket.',
options: {},
state: 'Channel::Filter::BounceCheck',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '1000_postmaster_filter_database_check',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter for filters managed via admin interface.',
options: {},
state: 'Channel::Filter::Database',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '5000_postmaster_filter_icinga',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to manage Icinga (http://www.icinga.org) emails.',
options: {},
state: 'Channel::Filter::Icinga',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines postmaster filter.',
name: '5100_postmaster_filter_nagios',
area: 'Postmaster::PreFilter',
description: 'Defines postmaster filter to manage Nagios (http://www.nagios.org) emails.',
options: {},
state: 'Channel::Filter::Nagios',
frontend: false
)
Setting.create_if_not_exists(
title: 'Icinga integration',
name: 'icinga_integration',
area: 'Integration::Switch',
description: 'Defines if Icinga (http://www.icinga.org) is enabled or not.',
options: {
form: [
{
display: '',
null: true,
name: 'icinga_integration',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
prio: 1,
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Sender',
name: 'icinga_sender',
area: 'Integration::Icinga',
description: 'Defines the sender email address of Icinga emails.',
options: {
form: [
{
display: '',
null: false,
name: 'icinga_sender',
tag: 'input',
placeholder: 'icinga@monitoring.example.com',
},
],
},
state: 'icinga@monitoring.example.com',
preferences: {
prio: 2,
permission: ['admin.integration'],
},
frontend: false,
)
Setting.create_if_not_exists(
title: 'Auto close',
name: 'icinga_auto_close',
area: 'Integration::Icinga',
description: 'Defines if tickets should be closed if service is recovered.',
options: {
form: [
{
display: '',
null: true,
name: 'icinga_auto_close',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: true,
preferences: {
prio: 3,
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Auto close state',
name: 'icinga_auto_close_state_id',
area: 'Integration::Icinga',
description: 'Defines the state of auto closed tickets.',
options: {
form: [
{
display: '',
null: false,
name: 'icinga_auto_close_state_id',
tag: 'select',
relation: 'TicketState',
},
],
},
state: 4,
preferences: {
prio: 4,
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Nagios integration',
name: 'nagios_integration',
area: 'Integration::Switch',
description: 'Defines if Nagios (http://www.nagios.org) is enabled or not.',
options: {
form: [
{
display: '',
null: true,
name: 'nagios_integration',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
prio: 1,
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Sender',
name: 'nagios_sender',
area: 'Integration::Nagios',
description: 'Defines the sender email address of Nagios emails.',
options: {
form: [
{
display: '',
null: false,
name: 'nagios_sender',
tag: 'input',
placeholder: 'nagios@monitoring.example.com',
},
],
},
state: 'nagios@monitoring.example.com',
preferences: {
prio: 2,
permission: ['admin.integration'],
},
frontend: false,
)
Setting.create_if_not_exists(
title: 'Auto close',
name: 'nagios_auto_close',
area: 'Integration::Nagios',
description: 'Defines if tickets should be closed if service is recovered.',
options: {
form: [
{
display: '',
null: true,
name: 'nagios_auto_close',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: true,
preferences: {
prio: 3,
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Auto close state',
name: 'nagios_auto_close_state_id',
area: 'Integration::Nagios',
description: 'Defines the state of auto closed tickets.',
options: {
form: [
{
display: '',
null: false,
name: 'nagios_auto_close_state_id',
tag: 'select',
relation: 'TicketState',
},
],
},
state: 4,
preferences: {
prio: 4,
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines sync transaction backend.',
name: '0100_trigger',
area: 'Transaction::Backend::Sync',
description: 'Defines the transaction backend to execute triggers.',
options: {},
state: 'Transaction::Trigger',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines transaction backend.',
name: '0100_notification',
area: 'Transaction::Backend::Async',
description: 'Defines the transaction backend to send agent notifications.',
options: {},
state: 'Transaction::Notification',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines transaction backend.',
name: '1000_signature_detection',
area: 'Transaction::Backend::Async',
description: 'Defines the transaction backend to detect customer signatures in emails.',
options: {},
state: 'Transaction::SignatureDetection',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines transaction backend.',
name: '6000_slack_webhook',
area: 'Transaction::Backend::Async',
description: 'Defines the transaction backend which posts messages to Slack (http://www.slack.com).',
options: {},
state: 'Transaction::Slack',
frontend: false
)
Setting.create_if_not_exists(
title: 'Slack integration',
name: 'slack_integration',
area: 'Integration::Switch',
description: 'Defines if Slack (http://www.slack.org) is enabled or not.',
options: {
form: [
{
display: '',
null: true,
name: 'slack_integration',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
prio: 1,
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Slack config',
name: 'slack_config',
area: 'Integration::Slack',
description: 'Defines the slack config.',
options: {},
state: {
items: []
},
preferences: {
prio: 2,
permission: ['admin.integration'],
},
frontend: false,
)
Setting.create_if_not_exists(
title: 'sipgate.io integration',
name: 'sipgate_integration',
area: 'Integration::Switch',
description: 'Defines if sipgate.io (http://www.sipgate.io) is enabled or not.',
options: {
form: [
{
display: '',
null: true,
name: 'sipgate_integration',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
prio: 1,
trigger: ['menu:render', 'cti:reload'],
authentication: true,
permission: ['admin.integration'],
},
frontend: true
)
Setting.create_if_not_exists(
title: 'sipgate.io config',
name: 'sipgate_config',
area: 'Integration::Sipgate',
description: 'Defines the sipgate.io config.',
options: {},
state: {},
preferences: {
prio: 2,
permission: ['admin.integration'],
},
frontend: false,
)
Setting.create_if_not_exists(
title: 'Clearbit integration',
name: 'clearbit_integration',
area: 'Integration::Switch',
description: 'Defines if Clearbit (http://www.clearbit.com) is enabled or not.',
options: {
form: [
{
display: '',
null: true,
name: 'clearbit_integration',
tag: 'boolean',
options: {
true => 'yes',
false => 'no',
},
},
],
},
state: false,
preferences: {
prio: 1,
permission: ['admin.integration'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Clearbit config',
name: 'clearbit_config',
area: 'Integration::Clearbit',
description: 'Defines the Clearbit config.',
options: {},
state: {},
frontend: false,
preferences: {
prio: 2,
permission: ['admin.integration'],
},
)
Setting.create_if_not_exists(
title: 'Defines transaction backend.',
name: '9000_clearbit_enrichment',
area: 'Transaction::Backend::Async',
description: 'Defines the transaction backend which will enrich customer and organization information from Clearbit (http://www.clearbit.com).',
options: {},
state: 'Transaction::ClearbitEnrichment',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines transaction backend.',
name: '9100_cti_caller_id_detection',
area: 'Transaction::Backend::Async',
description: 'Defines the transaction backend which detects caller IDs in objects and store them for CTI lookups.',
options: {},
state: 'Transaction::CtiCallerIdDetection',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines transaction backend.',
name: '9200_karma',
area: 'Transaction::Backend::Async',
description: 'Defines the transaction backend which creates the karma score.',
options: {},
state: 'Transaction::Karma',
frontend: false
)
Setting.create_if_not_exists(
title: 'Defines karma levels.',
name: 'karma_levels',
area: 'Core::Karma',
description: 'Defines the karma levels.',
options: {},
state: [
{
name: 'Beginner',
start: 0,
end: 499,
},
{
name: 'Newbie',
start: 500,
end: 1999,
},
{
name: 'Intermediate',
start: 2000,
end: 4999,
},
{
name: 'Professional',
start: 5000,
end: 6999,
},
{
name: 'Expert',
start: 7000,
end: 8999,
},
{
name: 'Master',
start: 9000,
end: 18_999,
},
{
name: 'Evangelist',
start: 19_000,
end: 45_999,
},
{
name: 'Hero',
start: 50_000,
end: nil,
},
],
frontend: false
)
Setting.create_if_not_exists(
title: 'Set limit of agents',
name: 'system_agent_limit',
area: 'Core::Online',
description: 'Defines the limit of the agents.',
options: {},
state: false,
preferences: { online_service_disable: true },
frontend: false
)
signature = Signature.create_if_not_exists(
id: 1,
name: 'default',
body: '
#{user.firstname} #{user.lastname}
--
Super Support - Waterford Business Park
5201 Blue Lagoon Drive - 8th Floor & 9th Floor - Miami, 33126 USA
Email: hot@example.com - Web: http://www.example.com/
--'.text2html,
updated_by_id: 1,
created_by_id: 1
)
Role.create_if_not_exists(
id: 1,
name: 'Admin',
note: 'To configure your system.',
preferences: {
not: ['Customer'],
},
default_at_signup: false,
updated_by_id: 1,
created_by_id: 1
)
Role.create_if_not_exists(
id: 2,
name: 'Agent',
note: 'To work on Tickets.',
default_at_signup: false,
preferences: {
not: ['Customer'],
},
updated_by_id: 1,
created_by_id: 1
)
Role.create_if_not_exists(
id: 3,
name: 'Customer',
note: 'People who create Tickets ask for help.',
preferences: {
not: %w(Agent Admin),
},
default_at_signup: true,
updated_by_id: 1,
created_by_id: 1
)
Permission.create_if_not_exists(
name: 'admin',
note: 'Admin Interface',
preferences: {},
)
Permission.create_if_not_exists(
name: 'admin.user',
note: 'Manage %s',
preferences: {
translations: ['Users']
},
)
Permission.create_if_not_exists(
name: 'admin.group',
note: 'Manage %s',
preferences: {
translations: ['Groups']
},
)
Permission.create_if_not_exists(
name: 'admin.role',
note: 'Manage %s',
preferences: {
translations: ['Roles']
},
)
Permission.create_if_not_exists(
name: 'admin.organization',
note: 'Manage %s',
preferences: {
translations: ['Organizations']
},
)
Permission.create_if_not_exists(
name: 'admin.overview',
note: 'Manage %s',
preferences: {
translations: ['Overviews']
},
)
Permission.create_if_not_exists(
name: 'admin.text_module',
note: 'Manage %s',
preferences: {
translations: ['Text Modules']
},
)
Permission.create_if_not_exists(
name: 'admin.macro',
note: 'Manage %s',
preferences: {
translations: ['Macros']
},
)
Permission.create_if_not_exists(
name: 'admin.tag',
note: 'Manage %s',
preferences: {
translations: ['Tags']
},
)
Permission.create_if_not_exists(
name: 'admin.calendar',
note: 'Manage %s',
preferences: {
translations: ['Calendar']
},
)
Permission.create_if_not_exists(
name: 'admin.sla',
note: 'Manage %s',
preferences: {
translations: ['SLA']
},
)
Permission.create_if_not_exists(
name: 'admin.scheduler',
note: 'Manage %s',
preferences: {
translations: ['Scheduler']
},
)
Permission.create_if_not_exists(
name: 'admin.report_profile',
note: 'Manage %s',
preferences: {
translations: ['Report Profiles']
},
)
Permission.create_if_not_exists(
name: 'admin.channel_web',
note: 'Manage %s',
preferences: {
translations: ['Channel - Web']
},
)
Permission.create_if_not_exists(
name: 'admin.channel_formular',
note: 'Manage %s',
preferences: {
translations: ['Channel - Formular']
},
)
Permission.create_if_not_exists(
name: 'admin.channel_email',
note: 'Manage %s',
preferences: {
translations: ['Channel - Email']
},
)
Permission.create_if_not_exists(
name: 'admin.channel_twitter',
note: 'Manage %s',
preferences: {
translations: ['Channel - Twitter']
},
)
Permission.create_if_not_exists(
name: 'admin.channel_facebook',
note: 'Manage %s',
preferences: {
translations: ['Channel - Facebook']
},
)
Permission.create_if_not_exists(
name: 'admin.channel_telegram',
note: 'Manage %s',
preferences: {
translations: ['Channel - Telegram']
},
)
Permission.create_if_not_exists(
name: 'admin.channel_chat',
note: 'Manage %s',
preferences: {
translations: ['Channel - Chat']
},
)
Permission.create_if_not_exists(
name: 'admin.branding',
note: 'Manage %s',
preferences: {
translations: ['Branding']
},
)
Permission.create_if_not_exists(
name: 'admin.setting_system',
note: 'Manage %s Settings',
preferences: {
translations: ['System']
},
)
Permission.create_if_not_exists(
name: 'admin.security',
note: 'Manage %s Settings',
preferences: {
translations: ['Security']
},
)
Permission.create_if_not_exists(
name: 'admin.ticket',
note: 'Manage %s Settings',
preferences: {
translations: ['Ticket']
},
)
Permission.create_if_not_exists(
name: 'admin.package',
note: 'Manage %s',
preferences: {
translations: ['Packages']
},
)
Permission.create_if_not_exists(
name: 'admin.integration',
note: 'Manage %s',
preferences: {
translations: ['Integrations']
},
)
Permission.create_if_not_exists(
name: 'admin.api',
note: 'Manage %s',
preferences: {
translations: ['API']
},
)
Permission.create_if_not_exists(
name: 'admin.object',
note: 'Manage %s',
preferences: {
translations: ['Objects']
},
)
Permission.create_if_not_exists(
name: 'admin.translation',
note: 'Manage %s',
preferences: {
translations: ['Translations']
},
)
Permission.create_if_not_exists(
name: 'admin.monitoring',
note: 'Manage %s',
preferences: {
translations: ['Monitoring']
},
)
Permission.create_if_not_exists(
name: 'admin.maintenance',
note: 'Manage %s',
preferences: {
translations: ['Maintenance']
},
)
Permission.create_if_not_exists(
name: 'admin.session',
note: 'Manage %s',
preferences: {
translations: ['Sessions']
},
)
Permission.create_if_not_exists(
name: 'user_preferences',
note: 'User Preferences',
preferences: {},
)
Permission.create_if_not_exists(
name: 'user_preferences.password',
note: 'Change %s',
preferences: {
translations: ['Password']
},
)
Permission.create_if_not_exists(
name: 'user_preferences.notifications',
note: 'Manage %s',
preferences: {
translations: ['Notifications'],
required: ['ticket.agent'],
},
)
Permission.create_if_not_exists(
name: 'user_preferences.access_token',
note: 'Manage %s',
preferences: {
translations: ['Token Access']
},
)
Permission.create_if_not_exists(
name: 'user_preferences.language',
note: 'Change %s',
preferences: {
translations: ['Language']
},
)
Permission.create_if_not_exists(
name: 'user_preferences.linked_accounts',
note: 'Manage %s',
preferences: {
translations: ['Linked Accounts']
},
)
Permission.create_if_not_exists(
name: 'user_preferences.device',
note: 'Manage %s',
preferences: {
translations: ['Devices']
},
)
Permission.create_if_not_exists(
name: 'user_preferences.avatar',
note: 'Manage %s',
preferences: {
translations: ['Avatar']
},
)
Permission.create_if_not_exists(
name: 'user_preferences.calendar',
note: 'Access to %s',
preferences: {
translations: ['Calendars'],
required: ['ticket.agent'],
},
)
Permission.create_if_not_exists(
name: 'report',
note: 'Report Interface',
preferences: {},
)
Permission.create_if_not_exists(
name: 'ticket',
note: 'Ticket Interface',
preferences: {
disabled: true
},
)
Permission.create_if_not_exists(
name: 'ticket.agent',
note: 'Access to Agent Tickets based on Group Access',
preferences: {
not: ['ticket.customer'],
plugin: ['groups']
},
)
Permission.create_if_not_exists(
name: 'ticket.customer',
note: 'Access to Customer Tickets based on current_user.id and current_user.organization_id',
preferences: {
not: ['ticket.agent'],
},
)
Permission.create_if_not_exists(
name: 'chat',
note: 'Access to %s',
preferences: {
translations: ['Chat']
},
)
Permission.create_if_not_exists(
name: 'chat.agent',
note: 'Access to %s',
preferences: {
translations: ['Chat'],
not: ['chat.customer'],
},
)
Permission.create_if_not_exists(
name: 'cti',
note: 'CTI',
preferences: {
disabled: true
},
)
Permission.create_if_not_exists(
name: 'cti.agent',
note: 'Access to %s',
preferences: {
translations: ['CTI'],
not: ['cti.customer'],
},
)
admin = Role.find_by(name: 'Admin')
admin.permission_grant('user_preferences')
admin.permission_grant('admin')
admin.permission_grant('report')
agent = Role.find_by(name: 'Agent')
agent.permission_grant('user_preferences')
agent.permission_grant('ticket.agent')
agent.permission_grant('chat.agent')
agent.permission_grant('cti.agent')
customer = Role.find_by(name: 'Customer')
customer.permission_grant('user_preferences.password')
customer.permission_grant('user_preferences.language')
customer.permission_grant('user_preferences.linked_accounts')
customer.permission_grant('user_preferences.avatar')
customer.permission_grant('ticket.customer')
Group.create_if_not_exists(
id: 1,
name: 'Users',
signature_id: signature.id,
note: 'Standard Group/Pool for Tickets.',
updated_by_id: 1,
created_by_id: 1
)
user = User.create_if_not_exists(
id: 1,
login: '-',
firstname: '-',
lastname: '',
email: '',
active: false,
updated_by_id: 1,
created_by_id: 1
)
UserInfo.current_user_id = 1
roles = Role.find_by(name: 'Customer')
organizations = Organization.all
groups = Group.all
org_community = Organization.create_if_not_exists(
id: 1,
name: 'Zammad Foundation',
)
user_community = User.create_or_update(
id: 2,
login: 'nicole.braun@zammad.org',
firstname: 'Nicole',
lastname: 'Braun',
email: 'nicole.braun@zammad.org',
password: '',
active: true,
roles: [roles],
organization_id: org_community.id,
)
Link::Type.create_if_not_exists(id: 1, name: 'normal')
Link::Object.create_if_not_exists(id: 1, name: 'Ticket')
Link::Object.create_if_not_exists(id: 2, name: 'Announcement')
Link::Object.create_if_not_exists(id: 3, name: 'Question/Answer')
Link::Object.create_if_not_exists(id: 4, name: 'Idea')
Link::Object.create_if_not_exists(id: 5, name: 'Bug')
Ticket::StateType.create_if_not_exists(id: 1, name: 'new')
Ticket::StateType.create_if_not_exists(id: 2, name: 'open')
Ticket::StateType.create_if_not_exists(id: 3, name: 'pending reminder')
Ticket::StateType.create_if_not_exists(id: 4, name: 'pending action')
Ticket::StateType.create_if_not_exists(id: 5, name: 'closed')
Ticket::StateType.create_if_not_exists(id: 6, name: 'merged')
Ticket::StateType.create_if_not_exists(id: 7, name: 'removed')
Ticket::State.create_if_not_exists(
id: 1,
name: 'new',
state_type_id: Ticket::StateType.find_by(name: 'new').id,
default_create: true,
)
Ticket::State.create_if_not_exists(
id: 2,
name: 'open',
state_type_id: Ticket::StateType.find_by(name: 'open').id,
default_follow_up: true,
)
Ticket::State.create_if_not_exists(
id: 3,
name: 'pending reminder',
state_type_id: Ticket::StateType.find_by(name: 'pending reminder').id,
ignore_escalation: true,
)
Ticket::State.create_if_not_exists(
id: 4,
name: 'closed',
state_type_id: Ticket::StateType.find_by(name: 'closed').id,
ignore_escalation: true,
)
Ticket::State.create_if_not_exists(
id: 5,
name: 'merged',
state_type_id: Ticket::StateType.find_by(name: 'merged').id,
ignore_escalation: true,
)
Ticket::State.create_if_not_exists(
id: 6,
name: 'removed',
state_type_id: Ticket::StateType.find_by(name: 'removed').id,
active: false,
ignore_escalation: true,
)
Ticket::State.create_if_not_exists(
id: 7,
name: 'pending close',
state_type_id: Ticket::StateType.find_by(name: 'pending action').id,
next_state_id: Ticket::State.find_by(name: 'closed').id,
ignore_escalation: true,
)
Ticket::Priority.create_if_not_exists(id: 1, name: '1 low')
Ticket::Priority.create_if_not_exists(id: 2, name: '2 normal', default_create: true)
Ticket::Priority.create_if_not_exists(id: 3, name: '3 high')
Ticket::Article::Type.create_if_not_exists(id: 1, name: 'email', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 2, name: 'sms', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 3, name: 'chat', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 4, name: 'fax', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 5, name: 'phone', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 6, name: 'twitter status', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 7, name: 'twitter direct-message', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 8, name: 'facebook feed post', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 9, name: 'facebook feed comment', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 10, name: 'note', communication: false)
Ticket::Article::Type.create_if_not_exists(id: 11, name: 'web', communication: true)
Ticket::Article::Type.create_if_not_exists(id: 12, name: 'telegram personal-message', communication: true)
Ticket::Article::Sender.create_if_not_exists(id: 1, name: 'Agent')
Ticket::Article::Sender.create_if_not_exists(id: 2, name: 'Customer')
Ticket::Article::Sender.create_if_not_exists(id: 3, name: 'System')
Macro.create_if_not_exists(
name: 'Close & Tag as Spam',
perform: {
'ticket.state_id' => {
value: Ticket::State.find_by(name: 'closed').id,
},
'ticket.tags' => {
operator: 'add',
value: 'spam',
},
'ticket.owner_id' => {
pre_condition: 'current_user.id',
value: '',
},
},
note: 'example macro',
active: true,
)
UserInfo.current_user_id = user_community.id
ticket = Ticket.create(
group_id: Group.find_by(name: 'Users').id,
customer_id: User.find_by(login: 'nicole.braun@zammad.org').id,
title: 'Welcome to Zammad!',
state_id: Ticket::State.find_by(name: 'new').id,
priority_id: Ticket::Priority.find_by(name: '2 normal').id,
)
Ticket::Article.create(
ticket_id: ticket.id,
type_id: Ticket::Article::Type.find_by(name: 'phone').id,
sender_id: Ticket::Article::Sender.find_by(name: 'Customer').id,
from: 'Zammad Feedback <feedback@zammad.org>',
body: 'Welcome!
Thank you for choosing Zammad.
You will find updates and patches at https://zammad.org/. Online
documentation is available at https://zammad.org/documentation. Get
involved (discussions, contributing, ...) at https://zammad.org/participate.
Regards,
Your Zammad Team
',
internal: false,
)
UserInfo.current_user_id = 1
overview_role = Role.find_by(name: 'Agent')
Overview.create_if_not_exists(
name: 'My assigned Tickets',
link: 'my_assigned',
prio: 1000,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: Ticket::State.by_category(:open).pluck(:id),
},
'ticket.owner_id' => {
operator: 'is',
pre_condition: 'current_user.id',
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group created_at),
s: %w(title customer group created_at),
m: %w(number title customer group created_at),
view_mode_default: 's',
},
)
Overview.create_if_not_exists(
name: 'Unassigned & Open',
link: 'all_unassigned',
prio: 1010,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: Ticket::State.by_category(:work_on_all).pluck(:id),
},
'ticket.owner_id' => {
operator: 'is',
pre_condition: 'not_set',
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group created_at),
s: %w(title customer group created_at),
m: %w(number title customer group created_at),
view_mode_default: 's',
},
)
Overview.create_if_not_exists(
name: 'My pending reached Tickets',
link: 'my_pending_reached',
prio: 1020,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: Ticket::State.by_category(:pending_reminder).pluck(:id),
},
'ticket.owner_id' => {
operator: 'is',
pre_condition: 'current_user.id',
},
'ticket.pending_time' => {
operator: 'within next (relative)',
value: 0,
range: 'minute',
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group created_at),
s: %w(title customer group created_at),
m: %w(number title customer group created_at),
view_mode_default: 's',
},
)
Overview.create_if_not_exists(
name: 'Open',
link: 'all_open',
prio: 1030,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: Ticket::State.by_category(:work_on_all).pluck(:id),
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group state owner created_at),
s: %w(title customer group state owner created_at),
m: %w(number title customer group state owner created_at),
view_mode_default: 's',
},
)
Overview.create_if_not_exists(
name: 'Pending reached',
link: 'all_pending_reached',
prio: 1040,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: Ticket::State.by_category(:pending_reminder).pluck(:id),
},
'ticket.pending_time' => {
operator: 'within next (relative)',
value: 0,
range: 'minute',
},
},
order: {
by: 'created_at',
direction: 'ASC',
},
view: {
d: %w(title customer group owner created_at),
s: %w(title customer group owner created_at),
m: %w(number title customer group owner created_at),
view_mode_default: 's',
},
)
Overview.create_if_not_exists(
name: 'Escalated',
link: 'all_escalated',
prio: 1050,
role_id: overview_role.id,
condition: {
'ticket.escalation_at' => {
operator: 'within next (relative)',
value: '10',
range: 'minute',
},
},
order: {
by: 'escalation_at',
direction: 'ASC',
},
view: {
d: %w(title customer group owner escalation_at),
s: %w(title customer group owner escalation_at),
m: %w(number title customer group owner escalation_at),
view_mode_default: 's',
},
)
overview_role = Role.find_by(name: 'Customer')
Overview.create_if_not_exists(
name: 'My Tickets',
link: 'my_tickets',
prio: 1100,
role_id: overview_role.id,
condition: {
'ticket.state_id' => {
operator: 'is',
value: Ticket::State.by_category(:viewable).pluck(:id),
},
'ticket.customer_id' => {
operator: 'is',
pre_condition: 'current_user.id',
},
},
order: {
by: 'created_at',
direction: 'DESC',
},
view: {
d: %w(title customer state created_at),
s: %w(number title state created_at),
m: %w(number title state created_at),
view_mode_default: 's',
},
)
Overview.create_if_not_exists(
name: 'My Organization Tickets',
link: 'my_organization_tickets',
prio: 1200,
role_id: overview_role.id,
organization_shared: true,
condition: {
'ticket.state_id' => {
operator: 'is',
value: Ticket::State.by_category(:viewable).pluck(:id),
},
'ticket.organization_id' => {
operator: 'is',
pre_condition: 'current_user.organization_id',
},
},
order: {
by: 'created_at',
direction: 'DESC',
},
view: {
d: %w(title customer state created_at),
s: %w(number title customer state created_at),
m: %w(number title customer state created_at),
view_mode_default: 's',
},
)
Channel.create_if_not_exists(
area: 'Email::Notification',
options: {
outbound: {
adapter: 'smtp',
options: {
host: 'host.example.com',
user: '',
password: '',
ssl: true,
},
},
},
group_id: 1,
preferences: { online_service_disable: true },
active: false,
)
Channel.create_if_not_exists(
area: 'Email::Notification',
options: {
outbound: {
adapter: 'sendmail',
},
},
preferences: { online_service_disable: true },
active: true,
)
Report::Profile.create_if_not_exists(
name: '-all-',
condition: {},
active: true,
updated_by_id: 1,
created_by_id: 1,
)
chat = Chat.create_if_not_exists(
name: 'default',
max_queue: 5,
note: '',
active: true,
updated_by_id: 1,
created_by_id: 1,
)
network = Network.create_if_not_exists(
id: 1,
name: 'base',
)
Network::Category::Type.create_if_not_exists(
id: 1,
name: 'Announcement',
)
Network::Category::Type.create_if_not_exists(
id: 2,
name: 'Idea',
)
Network::Category::Type.create_if_not_exists(
id: 3,
name: 'Question',
)
Network::Category::Type.create_if_not_exists(
id: 4,
name: 'Bug Report',
)
Network::Privacy.create_if_not_exists(
id: 1,
name: 'logged in',
key: 'loggedIn',
)
Network::Privacy.create_if_not_exists(
id: 2,
name: 'logged in and moderator',
key: 'loggedInModerator',
)
Network::Category.create_if_not_exists(
id: 1,
name: 'Announcements',
network_id: network.id,
network_category_type_id: Network::Category::Type.find_by(name: 'Announcement').id,
network_privacy_id: Network::Privacy.find_by(name: 'logged in and moderator').id,
allow_comments: true,
)
Network::Category.create_if_not_exists(
id: 2,
name: 'Questions',
network_id: network.id,
allow_comments: true,
network_category_type_id: Network::Category::Type.find_by(name: 'Question').id,
network_privacy_id: Network::Privacy.find_by(name: 'logged in').id,
)
Network::Category.create_if_not_exists(
id: 3,
name: 'Ideas',
network_id: network.id,
network_category_type_id: Network::Category::Type.find_by(name: 'Idea').id,
network_privacy_id: Network::Privacy.find_by(name: 'logged in').id,
allow_comments: true,
)
Network::Category.create_if_not_exists(
id: 4,
name: 'Bug Reports',
network_id: network.id,
network_category_type_id: Network::Category::Type.find_by(name: 'Bug Report').id,
network_privacy_id: Network::Privacy.find_by(name: 'logged in').id,
allow_comments: true,
)
item = Network::Item.create(
title: 'Example Announcement',
body: 'Some announcement....',
network_category_id: Network::Category.find_by(name: 'Announcements').id,
)
Network::Item::Comment.create(
network_item_id: item.id,
body: 'Some comment....',
)
item = Network::Item.create(
title: 'Example Question?',
body: 'Some questions....',
network_category_id: Network::Category.find_by(name: 'Questions').id,
)
Network::Item::Comment.create(
network_item_id: item.id,
body: 'Some comment....',
)
item = Network::Item.create(
title: 'Example Idea',
body: 'Some idea....',
network_category_id: Network::Category.find_by(name: 'Ideas').id,
)
Network::Item::Comment.create(
network_item_id: item.id,
body: 'Some comment....',
)
item = Network::Item.create(
title: 'Example Bug Report',
body: 'Some bug....',
network_category_id: Network::Category.find_by(name: 'Bug Reports').id,
)
Network::Item::Comment.create(
network_item_id: item.id,
body: 'Some comment....',
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'title',
display: 'Title',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 200,
null: false,
translate: false,
},
editable: false,
active: true,
screens: {
create_top: {
'-all-' => {
null: false,
},
},
edit: {},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 15,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'customer_id',
display: 'Customer',
data_type: 'user_autocompletion',
data_option: {
relation: 'User',
autocapitalize: false,
multiple: false,
guess: true,
null: false,
limit: 200,
placeholder: 'Enter Person or Organization/Company',
minLengt: 2,
translate: false,
permission: ['ticket.agent'],
},
editable: false,
active: true,
screens: {
create_top: {
'-all-' => {
null: false,
},
},
edit: {},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 10,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'type',
display: 'Type',
data_type: 'select',
data_option: {
default: '',
options: {
'Incident' => 'Incident',
'Problem' => 'Problem',
'Request for Change' => 'Request for Change',
},
nulloption: true,
multiple: false,
null: true,
translate: true,
},
editable: true,
active: false,
screens: {
create_middle: {
'-all-' => {
null: false,
item_class: 'column',
},
},
edit: {
'ticket.agent' => {
null: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 20,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'group_id',
display: 'Group',
data_type: 'select',
data_option: {
default: '',
relation: 'Group',
relation_condition: { access: 'rw' },
nulloption: true,
multiple: false,
null: false,
translate: false,
only_shown_if_selectable: true,
permission: ['ticket.agent', 'ticket.customer'],
},
editable: false,
active: true,
screens: {
create_middle: {
'-all-' => {
null: false,
item_class: 'column',
},
},
edit: {
'ticket.agent' => {
null: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 25,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'owner_id',
display: 'Owner',
data_type: 'select',
data_option: {
default: '',
relation: 'User',
relation_condition: { roles: 'Agent' },
nulloption: true,
multiple: false,
null: true,
translate: false,
permission: ['ticket.agent'],
},
editable: false,
active: true,
screens: {
create_middle: {
'-all-' => {
null: true,
item_class: 'column',
},
},
edit: {
'-all-' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 30,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'state_id',
display: 'State',
data_type: 'select',
data_option: {
relation: 'TicketState',
nulloption: true,
multiple: false,
null: false,
default: Ticket::State.find_by(name: 'open').id,
translate: true,
filter: Ticket::State.by_category(:viewable).pluck(:id),
},
editable: false,
active: true,
screens: {
create_middle: {
'ticket.agent' => {
null: false,
item_class: 'column',
filter: Ticket::State.by_category(:viewable_agent_new).pluck(:id),
},
'ticket.customer' => {
item_class: 'column',
nulloption: false,
null: true,
filter: Ticket::State.by_category(:viewable_customer_new).pluck(:id),
default: Ticket::State.find_by(name: 'new').id,
},
},
edit: {
'ticket.agent' => {
nulloption: false,
null: false,
filter: Ticket::State.by_category(:viewable_agent_edit).pluck(:id),
},
'ticket.customer' => {
nulloption: false,
null: true,
filter: Ticket::State.by_category(:viewable_customer_edit).pluck(:id),
default: Ticket::State.find_by(name: 'open').id,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 40,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'pending_time',
display: 'Pending till',
data_type: 'datetime',
data_option: {
future: true,
past: false,
diff: 24,
null: true,
translate: true,
required_if: {
state_id: Ticket::State.by_category(:pending).pluck(:id),
},
shown_if: {
state_id: Ticket::State.by_category(:pending).pluck(:id),
},
},
editable: false,
active: true,
screens: {
create_middle: {
'-all-' => {
null: false,
item_class: 'column',
},
},
edit: {
'-all-' => {
null: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 41,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'priority_id',
display: 'Priority',
data_type: 'select',
data_option: {
relation: 'TicketPriority',
nulloption: false,
multiple: false,
null: false,
default: Ticket::Priority.find_by(name: '2 normal').id,
translate: true,
},
editable: false,
active: true,
screens: {
create_middle: {
'ticket.agent' => {
null: false,
item_class: 'column',
},
},
edit: {
'ticket.agent' => {
null: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 80,
)
ObjectManager::Attribute.add(
force: true,
object: 'Ticket',
name: 'tags',
display: 'Tags',
data_type: 'tag',
data_option: {
type: 'text',
null: true,
translate: false,
},
editable: false,
active: true,
screens: {
create_bottom: {
'ticket.agent' => {
null: true,
},
},
edit: {},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 900,
)
ObjectManager::Attribute.add(
force: true,
object: 'TicketArticle',
name: 'type_id',
display: 'Type',
data_type: 'select',
data_option: {
relation: 'TicketArticleType',
nulloption: false,
multiple: false,
null: false,
default: Ticket::Article::Type.lookup(name: 'note').id,
translate: true,
},
editable: false,
active: true,
screens: {
create_middle: {},
edit: {
'ticket.agent' => {
null: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 100,
)
ObjectManager::Attribute.add(
force: true,
object: 'TicketArticle',
name: 'internal',
display: 'Visibility',
data_type: 'select',
data_option: {
options: { true: 'internal', false: 'public' },
nulloption: false,
multiple: false,
null: true,
default: false,
translate: true,
},
editable: false,
active: true,
screens: {
create_middle: {},
edit: {
'ticket.agent' => {
null: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 200,
)
ObjectManager::Attribute.add(
force: true,
object: 'TicketArticle',
name: 'to',
display: 'To',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 1000,
null: true,
},
editable: false,
active: true,
screens: {
create_middle: {},
edit: {
'ticket.agent' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 300,
)
ObjectManager::Attribute.add(
force: true,
object: 'TicketArticle',
name: 'cc',
display: 'Cc',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 1000,
null: true,
},
editable: false,
active: true,
screens: {
create_top: {},
create_middle: {},
edit: {
'ticket.agent' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 400,
)
ObjectManager::Attribute.add(
force: true,
object: 'TicketArticle',
name: 'body',
display: 'Text',
data_type: 'richtext',
data_option: {
type: 'richtext',
maxlength: 20_000,
upload: true,
rows: 8,
null: true,
},
editable: false,
active: true,
screens: {
create_top: {
'-all-' => {
null: false,
},
},
edit: {
'-all-' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 600,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'login',
display: 'Login',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 100,
null: true,
autocapitalize: false,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {},
view: {
'-all-' => {
shown: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 100,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'firstname',
display: 'Firstname',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 150,
null: false,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {
'-all-' => {
null: false,
},
},
invite_agent: {
'-all-' => {
null: false,
},
},
invite_customer: {
'-all-' => {
null: false,
},
},
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 200,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'lastname',
display: 'Lastname',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 150,
null: false,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {
'-all-' => {
null: false,
},
},
invite_agent: {
'-all-' => {
null: false,
},
},
invite_customer: {
'-all-' => {
null: false,
},
},
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 300,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'email',
display: 'Email',
data_type: 'input',
data_option: {
type: 'email',
maxlength: 150,
null: false,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {
'-all-' => {
null: false,
},
},
invite_agent: {
'-all-' => {
null: false,
},
},
invite_customer: {
'-all-' => {
null: false,
},
},
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 400,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'web',
display: 'Web',
data_type: 'input',
data_option: {
type: 'url',
maxlength: 250,
null: true,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 500,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'phone',
display: 'Phone',
data_type: 'input',
data_option: {
type: 'tel',
maxlength: 100,
null: true,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 600,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'mobile',
display: 'Mobile',
data_type: 'input',
data_option: {
type: 'tel',
maxlength: 100,
null: true,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 700,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'fax',
display: 'Fax',
data_type: 'input',
data_option: {
type: 'tel',
maxlength: 100,
null: true,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 800,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'organization_id',
display: 'Organization',
data_type: 'autocompletion_ajax',
data_option: {
multiple: false,
nulloption: true,
null: true,
relation: 'Organization',
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {
'-all-' => {
null: true,
},
},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 900,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'department',
display: 'Department',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 200,
null: true,
item_class: 'formGroup--halfSize',
},
editable: true,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1000,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'street',
display: 'Street',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 100,
null: true,
},
editable: true,
active: false,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1100,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'zip',
display: 'Zip',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 100,
null: true,
item_class: 'formGroup--halfSize',
},
editable: true,
active: false,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1200,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'city',
display: 'City',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 100,
null: true,
item_class: 'formGroup--halfSize',
},
editable: true,
active: false,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1300,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'address',
display: 'Address',
data_type: 'textarea',
data_option: {
type: 'text',
maxlength: 500,
null: true,
item_class: 'formGroup--halfSize',
},
editable: true,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1350,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'password',
display: 'Password',
data_type: 'input',
data_option: {
type: 'password',
maxlength: 100,
null: true,
autocomplete: 'new-password',
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
signup: {
'-all-' => {
null: false,
},
},
invite_agent: {},
invite_customer: {},
edit: {
'admin.user' => {
null: true,
},
},
view: {}
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1400,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'vip',
display: 'VIP',
data_type: 'boolean',
data_option: {
null: true,
default: false,
item_class: 'formGroup--halfSize',
options: {
false: 'no',
true: 'yes',
},
translate: true,
permission: ['admin.user', 'ticket.agent'],
},
editable: false,
active: true,
screens: {
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1490,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'note',
display: 'Note',
data_type: 'richtext',
data_option: {
type: 'text',
maxlength: 250,
null: true,
note: 'Notes are visible to agents only, never to customers.',
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {
'-all-' => {
null: true,
},
},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1500,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'role_ids',
display: 'Permissions',
data_type: 'user_permission',
data_option: {
null: false,
item_class: 'checkbox',
permission: ['admin.user'],
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {
'-all-' => {
null: false,
default: [Role.lookup(name: 'Agent').id],
},
},
invite_customer: {},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1600,
)
ObjectManager::Attribute.add(
force: true,
object: 'User',
name: 'active',
display: 'Active',
data_type: 'active',
data_option: {
null: true,
default: true,
permission: ['admin.user', 'ticket.agent'],
},
editable: false,
active: true,
screens: {
signup: {},
invite_agent: {},
invite_customer: {},
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1800,
)
ObjectManager::Attribute.add(
force: true,
object: 'Organization',
name: 'name',
display: 'Name',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 150,
null: false,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 200,
)
ObjectManager::Attribute.add(
force: true,
object: 'Organization',
name: 'shared',
display: 'Shared organization',
data_type: 'boolean',
data_option: {
null: true,
default: true,
note: 'Customers in the organization can view each other items.',
item_class: 'formGroup--halfSize',
options: {
true: 'yes',
false: 'no',
},
translate: true,
permission: ['admin.organization'],
},
editable: false,
active: true,
screens: {
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1400,
)
ObjectManager::Attribute.add(
force: true,
object: 'Organization',
name: 'domain_assignment',
display: 'Domain based assignment',
data_type: 'boolean',
data_option: {
null: true,
default: false,
note: 'Assign Users based on users domain.',
item_class: 'formGroup--halfSize',
options: {
true: 'yes',
false: 'no',
},
translate: true,
permission: ['admin.organization'],
},
editable: false,
active: true,
screens: {
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1410,
)
ObjectManager::Attribute.add(
force: true,
object: 'Organization',
name: 'domain',
display: 'Domain',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 150,
null: true,
item_class: 'formGroup--halfSize',
},
editable: false,
active: true,
screens: {
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1420,
)
ObjectManager::Attribute.add(
force: true,
object: 'Organization',
name: 'note',
display: 'Note',
data_type: 'richtext',
data_option: {
type: 'text',
maxlength: 250,
null: true,
note: 'Notes are visible to agents only, never to customers.',
},
editable: false,
active: true,
screens: {
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1500,
)
ObjectManager::Attribute.add(
force: true,
object: 'Organization',
name: 'active',
display: 'Active',
data_type: 'active',
data_option: {
null: true,
default: true,
permission: ['admin.organization'],
},
editable: false,
active: true,
screens: {
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1800,
)
ObjectManager::Attribute.add(
force: true,
object: 'Group',
name: 'name',
display: 'Name',
data_type: 'input',
data_option: {
type: 'text',
maxlength: 150,
null: false,
},
editable: false,
active: true,
screens: {
create: {
'-all-' => {
null: false,
},
},
edit: {
'-all-' => {
null: false,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 200,
)
ObjectManager::Attribute.add(
force: true,
object: 'Group',
name: 'assignment_timeout',
display: 'Assignment Timeout',
data_type: 'integer',
data_option: {
maxlength: 150,
null: true,
note: 'Assignment timeout in minutes if assigned agent is not working on it. Ticket will be shown as unassigend.',
min: 0,
max: 999_999,
},
editable: false,
active: true,
screens: {
create: {
'-all-' => {
null: true,
},
},
edit: {
'-all-' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 300,
)
ObjectManager::Attribute.add(
force: true,
object: 'Group',
name: 'follow_up_possible',
display: 'Follow up possible',
data_type: 'select',
data_option: {
default: 'yes',
options: {
yes: 'yes',
new_ticket: 'do not reopen Ticket but create new Ticket'
},
null: false,
note: 'Follow up for closed ticket possible or not.',
translate: true
},
editable: false,
active: true,
screens: {
create: {
'-all-' => {
null: true,
},
},
edit: {
'-all-' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 400,
)
ObjectManager::Attribute.add(
force: true,
object: 'Group',
name: 'follow_up_assignment',
display: 'Assign Follow Ups',
data_type: 'select',
data_option: {
default: 'yes',
options: {
true: 'yes',
false: 'no',
},
null: false,
note: 'Assign follow up to latest agent again.',
translate: true
},
editable: false,
active: true,
screens: {
create: {
'-all-' => {
null: true,
},
},
edit: {
'-all-' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 500,
)
ObjectManager::Attribute.add(
force: true,
object: 'Group',
name: 'email_address_id',
display: 'Email',
data_type: 'select',
data_option: {
default: '',
multiple: false,
null: true,
relation: 'EmailAddress',
nulloption: true,
do_not_log: true,
},
editable: false,
active: true,
screens: {
create: {
'-all-' => {
null: true,
},
},
edit: {
'-all-' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 600,
)
ObjectManager::Attribute.add(
force: true,
object: 'Group',
name: 'signature_id',
display: 'Signature',
data_type: 'select',
data_option: {
default: '',
multiple: false,
null: true,
relation: 'Signature',
nulloption: true,
do_not_log: true,
},
editable: false,
active: true,
screens: {
create: {
'-all-' => {
null: true,
},
},
edit: {
'-all-' => {
null: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 600,
)
ObjectManager::Attribute.add(
force: true,
object: 'Group',
name: 'note',
display: 'Note',
data_type: 'richtext',
data_option: {
type: 'text',
maxlength: 250,
null: true,
note: 'Notes are visible to agents only, never to customers.',
},
editable: false,
active: true,
screens: {
create: {
'-all-' => {
null: true,
},
},
edit: {
'-all-' => {
null: true,
},
},
view: {
'-all-' => {
shown: true,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1500,
)
ObjectManager::Attribute.add(
force: true,
object: 'Group',
name: 'active',
display: 'Active',
data_type: 'active',
data_option: {
null: true,
default: true,
permission: ['admin.group'],
},
editable: false,
active: true,
screens: {
create: {
'-all-' => {
null: true,
},
},
edit: {
'-all-': {
null: false,
},
},
view: {
'-all-' => {
shown: false,
},
},
},
to_create: false,
to_migrate: false,
to_delete: false,
position: 1800,
)
Scheduler.create_if_not_exists(
name: 'Process pending tickets',
method: 'Ticket.process_pending',
period: 60 * 15,
prio: 1,
active: true,
)
Scheduler.create_if_not_exists(
name: 'Process escalation tickets',
method: 'Ticket.process_escalation',
period: 60 * 5,
prio: 1,
active: true,
)
Scheduler.create_if_not_exists(
name: 'Import OTRS diff load',
method: 'Import::OTRS.diff_worker',
period: 60 * 3,
prio: 1,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Check Channels',
method: 'Channel.fetch',
period: 30,
prio: 1,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Check streams for Channel',
method: 'Channel.stream',
period: 60,
prio: 1,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Generate Session data',
method: 'Sessions.jobs',
period: 60,
prio: 1,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Execute jobs',
method: 'Job.run',
period: 5 * 60,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Cleanup expired sessions',
method: 'SessionHelper.cleanup_expired',
period: 60 * 60 * 12,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Delete old activity stream entries.',
method: 'ActivityStream.cleanup',
period: 1.day,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Delete old entries.',
method: 'RecentView.cleanup',
period: 1.day,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_or_update(
name: 'Delete old online notification entries.',
method: 'OnlineNotification.cleanup',
period: 2.hours,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_or_update(
name: 'Delete old token entries.',
method: 'Token.cleanup',
period: 30.days,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_or_update(
name: 'Closed chat sessions where participients are offline.',
method: 'Chat.cleanup_close',
period: 60 * 15,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_or_update(
name: 'Cleanup closed sessions.',
method: 'Chat.cleanup',
period: 5.days,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_or_update(
name: 'Sync calendars with ical feeds.',
method: 'Calendar.sync',
period: 1.day,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_or_update(
name: 'Generate user based stats.',
method: 'Stats.generate',
period: 11.minutes,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_or_update(
name: 'Delete old stats store entries.',
method: 'StatsStore.cleanup',
period: 31.days,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Cleanup HttpLog',
method: 'HttpLog.cleanup',
period: 24 * 60 * 60,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Trigger.create_or_update(
name: 'auto reply (on new tickets)',
condition: {
'ticket.action' => {
'operator' => 'is',
'value' => 'create',
},
'ticket.state_id' => {
'operator' => 'is not',
'value' => Ticket::State.lookup(name: 'closed').id,
},
'article.type_id' => {
'operator' => 'is',
'value' => [
Ticket::Article::Type.lookup(name: 'email').id,
Ticket::Article::Type.lookup(name: 'phone').id,
Ticket::Article::Type.lookup(name: 'web').id,
],
},
'article.sender_id' => {
'operator' => 'is',
'value' => Ticket::Article::Sender.lookup(name: 'Customer').id,
},
},
perform: {
'notification.email' => {
'body' => '<div>Your request <b>(#{config.ticket_hook}#{ticket.number})</b> has been received and will be reviewed by our support staff.</div>
<br/>
<div>To provide additional information, please reply to this email or click on the following link (for initial login, please request a new password):
<a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
</div>
<br/>
<div>Your #{config.product_name} Team</div>
<br/>
<div><i><a href="https://zammad.com">Zammad</a>, your customer support system</i></div>',
'recipient' => 'ticket_customer',
'subject' => 'Thanks for your inquiry (#{ticket.title})',
},
},
active: true,
created_by_id: 1,
updated_by_id: 1,
)
Trigger.create_or_update(
name: 'auto reply (on follow up of tickets)',
condition: {
'ticket.action' => {
'operator' => 'is',
'value' => 'update',
},
'article.sender_id' => {
'operator' => 'is',
'value' => Ticket::Article::Sender.lookup(name: 'Customer').id,
},
'article.type_id' => {
'operator' => 'is',
'value' => [
Ticket::Article::Type.lookup(name: 'email').id,
Ticket::Article::Type.lookup(name: 'phone').id,
Ticket::Article::Type.lookup(name: 'web').id,
],
},
},
perform: {
'notification.email' => {
'body' => '<div>Your follow up for <b>(#{config.ticket_hook}#{ticket.number})</b> has been received and will be reviewed by our support staff.</div>
<br/>
<div>To provide additional information, please reply to this email or click on the following link:
<a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
</div>
<br/>
<div>Your #{config.product_name} Team</div>
<br/>
<div><i><a href="https://zammad.com">Zammad</a>, your customer support system</i></div>',
'recipient' => 'ticket_customer',
'subject' => 'Thanks for your follow up (#{ticket.title})',
},
},
active: false,
created_by_id: 1,
updated_by_id: 1,
)
Trigger.create_or_update(
name: 'customer notification (on owner change)',
condition: {
'ticket.owner_id' => {
'operator' => 'has changed',
'pre_condition' => 'current_user.id',
'value' => '',
'value_completion' => '',
}
},
perform: {
'notification.email' => {
'body' => '<p>The owner of ticket (Ticket##{ticket.number}) has changed and is now "#{ticket.owner.firstname} #{ticket.owner.lastname}".<p>
<br/>
<p>To provide additional information, please reply to this email or click on the following link:
<a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
</p>
<br/>
<p><i><a href="https://zammad.com">Zammad</a>, your customer support system</i></p>',
'recipient' => 'ticket_customer',
'subject' => 'Owner has changed (#{ticket.title})',
},
},
active: false,
created_by_id: 1,
updated_by_id: 1,
)
Karma::Activity.create_or_update(
name: 'ticket create',
description: 'You have created a ticket',
score: 10,
once_ttl: 60,
)
Karma::Activity.create_or_update(
name: 'ticket close',
description: 'You have closed a ticket',
score: 5,
once_ttl: 60,
)
Karma::Activity.create_or_update(
name: 'ticket answer 1h',
description: 'You have answered a ticket within 1h',
score: 25,
once_ttl: 60,
)
Karma::Activity.create_or_update(
name: 'ticket answer 2h',
description: 'You have answered a ticket within 2h',
score: 20,
once_ttl: 60,
)
Karma::Activity.create_or_update(
name: 'ticket answer 12h',
description: 'You have answered a ticket within 12h',
score: 10,
once_ttl: 60,
)
Karma::Activity.create_or_update(
name: 'ticket answer 24h',
description: 'You have answered a ticket within 24h',
score: 5,
once_ttl: 60,
)
Karma::Activity.create_or_update(
name: 'ticket pending state',
description: 'Usage of advanced features',
score: 2,
once_ttl: 60,
)
Karma::Activity.create_or_update(
name: 'ticket escalated',
description: 'You have escalated tickets',
score: -5,
once_ttl: 60 * 60 * 24,
)
Karma::Activity.create_or_update(
name: 'ticket reminder overdue (+2 days)',
description: 'You have tickets that are over 2 days overdue',
score: -5,
once_ttl: 60 * 60 * 24,
)
Karma::Activity.create_or_update(
name: 'text module',
description: 'Usage of advanced features',
score: 4,
once_ttl: 60 * 30,
)
Karma::Activity.create_or_update(
name: 'tagging',
description: 'Usage of advanced features',
score: 4,
once_ttl: 60 * 60 * 4,
)
# reset primary key sequences
DbHelper.import_post
# install locales and translations
Locale.create_if_not_exists(
locale: 'en-us',
alias: 'en',
name: 'English (United States)',
)
Locale.sync
Translation.sync
Calendar.init_setup
# install all packages in auto_install
Package.auto_install
|
module Rugged
class Commit
def self.prettify_message(msg, strip_comments = true)
Rugged::prettify_message(msg, strip_comments)
end
def inspect
"#<Rugged::Commit:#{object_id} {message: #{message.inspect}, tree: #{tree.inspect}, parents: #{parent_oids}>"
end
# Return a diff between this commit and it's parent or another commit or tree.
#
# See `Rugged::Tree#diff` for more details.
def diff(*args)
self.tree.diff(*args)
end
# Return a diff between this commit and the workdir.
#
# See `Rugged::Tree#workdir_diff` for more details.
def workdir_diff(*args)
self.tree.workdir_diff(*args)
end
# The time when this commit was made effective. This is the same value
# as the +:time+ attribute for +commit.committer+.
#
# Returns a Time object
def time
@time ||= Time.at(self.epoch_time)
end
def to_hash
{
:message => message,
:committer => committer,
:author => author,
:tree => tree,
:parents => parents,
}
end
def modify(new_args, update_ref=nil)
args = self.to_hash.merge(new_args)
Commit.create(args, update_ref)
end
end
end
Make Rugged::Commit#diff return a diff against its parent by default.
module Rugged
class Commit
def self.prettify_message(msg, strip_comments = true)
Rugged::prettify_message(msg, strip_comments)
end
def inspect
"#<Rugged::Commit:#{object_id} {message: #{message.inspect}, tree: #{tree.inspect}, parents: #{parent_oids}>"
end
# Return a diff between this commit and its first parent or another commit or tree.
#
# See `Rugged::Tree#diff` for more details.
def diff(other = parents.first, options = {})
self.tree.diff(other, options)
end
# Return a diff between this commit and the workdir.
#
# See `Rugged::Tree#workdir_diff` for more details.
def workdir_diff(options = {})
self.tree.workdir_diff(options)
end
# The time when this commit was made effective. This is the same value
# as the +:time+ attribute for +commit.committer+.
#
# Returns a Time object
def time
@time ||= Time.at(self.epoch_time)
end
def to_hash
{
:message => message,
:committer => committer,
:author => author,
:tree => tree,
:parents => parents,
}
end
def modify(new_args, update_ref=nil)
args = self.to_hash.merge(new_args)
Commit.create(args, update_ref)
end
end
end
|
Added real player post processing
# Copyright (c) 2010-2016 Arxopia LLC.
#
# 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 NON INFRINGEMENT. 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.
module Risu
module Parsers
module Nessus
module PostProcess
class RealPlayerPatchRollup < Risu::Base::PostProcessBase
#
def initialize
@info =
{
:description => "RealPlayer Patch Rollup",
:plugin_id => -99957,
:plugin_name => "Update to the latest RealPlayer",
:item_name => "Update to the latest RealPlayer",
:plugin_ids => [
57863,
59173,
62065,
63289,
65630,
69472,
71772,
76458,
]
}
end
end
end
end
end
end
|
module VMC
module Cli
# This version number is used as the RubyGem release version.
# The internal VMC version number is VMC::VERSION.
VERSION = '0.3.14.beta.4'
end
end
bump gem version to 0.3.14.beta1
Change-Id: I642900d79e54be7f0cbd81ec1c8fdb1a909df9fd
module VMC
module Cli
# This version number is used as the RubyGem release version.
# The internal VMC version number is VMC::VERSION.
VERSION = '0.3.15.beta.1'
end
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
foods = [{:name => "100% Juice Concentrate/Boxes", :needPriority => 0},
{:name => "Canned Beans", :needPriority => 0},
{:name => "Boxed Potatoes", :needPriority => 0},
{:name => "Fresh Produce", :needPriority => 0},
{:name => "Canned Beans", :needPriority => 0},
{:name => "Boxed Potatoes", :needPriority => 0},
{:name => "Frozen Foods", :needPriority => 0},
{:name => "Canned Fruits", :needPriority => 0},
{:name => "Granola Bars", :needPriority => 0},
{:name => "Jelly", :needPriority => 0},
{:name => "Mac 'n Cheese", :needPriority => 0},
{:name => "Canned Meat", :needPriority => 0},
{:name => "Miscellaneous Food Items", :needPriority => 0},
{:name => "Oatmeal", :needPriority => 0},
{:name => "Pancake Mix", :needPriority => 0},
{:name => "Pasta & Pasta Sauce", :needPriority => 0},
{:name => "Peanut Butter", :needPriority => 0},
{:name => "Ramen", :needPriority => 0},
{:name => "Refrigerated Food", :needPriority => 0},
{:name => "Rice", :needPriority => 0},
{:name => "Skillet Dinners", :needPriority => 0},
{:name => "Canned Soup", :needPriority => 0},
{:name => "Syrup", :needPriority => 0},
{:name => "Canned Tuna", :needPriority => 0},
{:name => "Canned Vegetables", :needPriority => 0},
{:name => "Baby Food", :needPriority => 0},
{:name => "Baby Wipes", :needPriority => 0},
{:name => "Baby Wash", :needPriority => 0},
{:name => "Children's Book", :needPriority => 0},
{:name => "Deodorant", :needPriority => 0},
{:name => "Diapers", :needPriority => 0},
{:name => "Dishwashing Liquid", :needPriority => 0},
{:name => "Floss", :needPriority => 0},
{:name => "Infant Formula", :needPriority => 0},
{:name => "Laundry Detergent", :needPriority => 0},
{:name => "Paper Towels", :needPriority => 0},
{:name => "Razers & Shaving Cream", :needPriority => 0},
{:name => "Shampoo & Conditioner", :needPriority => 0},
{:name => "Soap", :needPriority => 0},
{:name => "Tampons", :needPriority => 0},
{:name => "Tissues", :needPriority => 0},
{:name => "Toilet Paper", :needPriority => 0},
{:name => "Toothbrushes", :needPriority => 0},
]
foods.each do |fud|
FoodItem.create!(fud)
end
contacts = [{:hours => "8AM-5PM", :email => "info@micaonline.org", :street_location => "611 4th St", :state_location => "Grinnell, IA 50112", :phone_number => "641-236-3923", :holiday_hours => "Closed on holidays"},
]
contacts.each do |con|
ContactInfo.create!(con)
end
abouts = [{:statement => "In all our endeavors, we are guided by five values: family, helping others, partnership, achieving results and innovation. These values direct the way we provide services and the way that we structure our organization. They constitute the core of MICA's philosophy and, together with our strategic plan, serve as guideposts for our staff. Our core values echo the mission of community action around the country but also highlight MICA's focus on providing excellent services to families."},
]
abouts.each do |ab|
About.create!(ab)
end
updated seeds with new column name
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
foods = [{:name => "100% Juice Concentrate/Boxes", :needpriority => 0},
{:name => "Canned Beans", :needpriority => 0},
{:name => "Boxed Potatoes", :needpriority => 0},
{:name => "Fresh Produce", :needpriority => 0},
{:name => "Canned Beans", :needpriority => 0},
{:name => "Boxed Potatoes", :needpriority => 0},
{:name => "Frozen Foods", :needpriority => 0},
{:name => "Canned Fruits", :needpriority => 0},
{:name => "Granola Bars", :needpriority => 0},
{:name => "Jelly", :needpriority => 0},
{:name => "Mac 'n Cheese", :needpriority => 0},
{:name => "Canned Meat", :needpriority => 0},
{:name => "Miscellaneous Food Items", :needpriority => 0},
{:name => "Oatmeal", :needpriority => 0},
{:name => "Pancake Mix", :needpriority => 0},
{:name => "Pasta & Pasta Sauce", :needpriority => 0},
{:name => "Peanut Butter", :needpriority => 0},
{:name => "Ramen", :needpriority => 0},
{:name => "Refrigerated Food", :needpriority => 0},
{:name => "Rice", :needpriority => 0},
{:name => "Skillet Dinners", :needpriority => 0},
{:name => "Canned Soup", :needpriority => 0},
{:name => "Syrup", :needpriority => 0},
{:name => "Canned Tuna", :needpriority => 0},
{:name => "Canned Vegetables", :needpriority => 0},
{:name => "Baby Food", :needpriority => 0},
{:name => "Baby Wipes", :needpriority => 0},
{:name => "Baby Wash", :needpriority => 0},
{:name => "Children's Book", :needpriority => 0},
{:name => "Deodorant", :needpriority => 0},
{:name => "Diapers", :needpriority => 0},
{:name => "Dishwashing Liquid", :needpriority => 0},
{:name => "Floss", :needpriority => 0},
{:name => "Infant Formula", :needpriority => 0},
{:name => "Laundry Detergent", :needpriority => 0},
{:name => "Paper Towels", :needpriority => 0},
{:name => "Razers & Shaving Cream", :needpriority => 0},
{:name => "Shampoo & Conditioner", :needpriority => 0},
{:name => "Soap", :needpriority => 0},
{:name => "Tampons", :needpriority => 0},
{:name => "Tissues", :needpriority => 0},
{:name => "Toilet Paper", :needpriority => 0},
{:name => "Toothbrushes", :needpriority => 0},
]
foods.each do |fud|
FoodItem.create!(fud)
end
contacts = [{:hours => "8AM-5PM", :email => "info@micaonline.org", :street_location => "611 4th St", :state_location => "Grinnell, IA 50112", :phone_number => "641-236-3923", :holiday_hours => "Closed on holidays"},
]
contacts.each do |con|
ContactInfo.create!(con)
end
abouts = [{:statement => "In all our endeavors, we are guided by five values: family, helping others, partnership, achieving results and innovation. These values direct the way we provide services and the way that we structure our organization. They constitute the core of MICA's philosophy and, together with our strategic plan, serve as guideposts for our staff. Our core values echo the mission of community action around the country but also highlight MICA's focus on providing excellent services to families."},
]
abouts.each do |ab|
About.create!(ab)
end
|
module PublicApiBuilder
def last_build_params
SystemStatus.last_build_params
end
def last_build_log
return "none" unless File.exists?(SystemConfig.BuildOutputFile)
File.read(SystemConfig.BuildOutputFile)
end
def build_status
SystemStatus.build_status
end
def current_build_params
SystemStatus.current_build_params
end
#writes stream from build.out to out
#returns 'OK' of FalseClass (latter BuilderApiError
def follow_build(out)
build_log_file = File.new(SystemConfig.BuildOutputFile, 'r')
while
begin
bytes = build_log_file.read_nonblock(100)
rescue IO::WaitReadable
retry
rescue EOFError
out.write(bytes.force_encoding(Encoding::UTF_8))
return 'OK'
build_log_file.close
rescue => e
out.write(bytes)
build_log_file.close
return 'Maybe ' + e.to_s
end
out.write(bytes)
end
end
end
.force_encoding(Encoding::UTF_8)
module PublicApiBuilder
def last_build_params
SystemStatus.last_build_params
end
def last_build_log
return "none" unless File.exists?(SystemConfig.BuildOutputFile)
File.read(SystemConfig.BuildOutputFile)
end
def build_status
SystemStatus.build_status
end
def current_build_params
SystemStatus.current_build_params
end
#writes stream from build.out to out
#returns 'OK' of FalseClass (latter BuilderApiError
def follow_build(out)
build_log_file = File.new(SystemConfig.BuildOutputFile, 'r')
while
begin
bytes = build_log_file.read_nonblock(100)
rescue IO::WaitReadable
retry
rescue EOFError
out.write(bytes.force_encoding(Encoding::UTF_8))
return 'OK'
build_log_file.close
rescue => e
out.write(bytes)
build_log_file.close
return 'Maybe ' + e.to_s
end
out.write(bytes.force_encoding(Encoding::UTF_8))
end
end
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Daley', city: cities.first)
Add seed for initial user
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Daley', city: cities.first)
User.create!(login: "admin", email: "admin@example.com", password: "password") |
module Certificates
def upload_ssl_certificate(params)
cert_file = File.new('/home/app/tmp/' + params[:domain_name] + '.cert','w+')
cert_file.write(params[:certificate])
cert_file.close
key_file = File.new('/home/app/tmp/' + params[:domain_name] + '.key','w+')
key_file.write(params[:key])
key_file.close
flag = ''
flag = ' -d' if params[:set_as_default] == true
res = SystemUtils.execute_command('/opt/engines/bin/install_cert.sh ' + flag + params[:domain_name] )
return true if res[:result] == 0
@last_error = res[:stderr]
return false
end
def remove_cert(domain)
res = SystemUtils.execute_command('/opt/engines/bin/rm_cert.sh ' + params[:domain_name] )
return true if res[:result] == 0
@last_error = res[:stderr]
return false
end
def list_certs
certs = []
p :certs_from
p SystemConfig.CertificatesDir
Dir.glob( SystemConfig.CertificatesDir + '/*.crt').each do |cert_file|
p :cert
p cert_file
certs.push(cert_file)
end
certs
rescue StandardError =>e
log_exception(e)
end
def get_cert(domain)
File.read(SystemConfig.CertificatesDir + '/' + domain.to_s + '.crt')
rescue StandardError =>e
log_exception(e)
end
end
correct param
module Certificates
def upload_ssl_certificate(params)
cert_file = File.new('/home/app/tmp/' + params[:domain_name] + '.cert','w+')
cert_file.write(params[:certificate])
cert_file.close
key_file = File.new('/home/app/tmp/' + params[:domain_name] + '.key','w+')
key_file.write(params[:key])
key_file.close
flag = ''
flag = ' -d' if params[:set_as_default] == true
res = SystemUtils.execute_command('/opt/engines/bin/install_cert.sh ' + flag + params[:domain_name] )
return true if res[:result] == 0
@last_error = res[:stderr]
return false
end
def remove_cert(domain)
res = SystemUtils.execute_command('/opt/engines/bin/rm_cert.sh ' + domain )
return true if res[:result] == 0
@last_error = res[:stderr]
return false
end
def list_certs
certs = []
p :certs_from
p SystemConfig.CertificatesDir
Dir.glob( SystemConfig.CertificatesDir + '/*.crt').each do |cert_file|
p :cert
p cert_file
certs.push(cert_file)
end
certs
rescue StandardError =>e
log_exception(e)
end
def get_cert(domain)
File.read(SystemConfig.CertificatesDir + '/' + domain.to_s + '.crt')
rescue StandardError =>e
log_exception(e)
end
end |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
admin = User.create({
username: "admin",
password: "password",
password_confirmation: "password",
about: "About the Admin",
admin: true
})
user = User.create({
username: "user",
password: "password",
password_confirmation: "password",
about: "About the Basic user",
})
[
{content: "I have never been to Cuba and would like to visit, would I like it?", title: "How is Cuba?"},
{content: "What kind of cars do everyday Cubans Drive?", title: "What cars do you drive?"},
{content: "I play basketball", title: "What do you do for fun?"},
{title: "I just ran out of titles", content: "Imagine a great title and text here."},
].each do |item|
admin.items.create(item)
user.items.create(item)
end
[admin, user, disabled_user].each do |u|
puts "created user: #{u.attributes.inspect}"
end
fixed seed file
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
admin = User.create({
username: "admin",
password: "password",
password_confirmation: "password",
about: "About the Admin",
admin: true
})
user = User.create({
username: "user",
password: "password",
password_confirmation: "password",
about: "About the Basic user",
})
[
{content: "I have never been to Cuba and would like to visit, would I like it?", title: "How is Cuba?"},
{content: "What kind of cars do everyday Cubans Drive?", title: "What cars do you drive?"},
{content: "I play basketball", title: "What do you do for fun?"},
{title: "I just ran out of titles", content: "Imagine a great title and text here."},
].each do |item|
admin.items.create(item)
user.items.create(item)
end
[admin, user,].each do |u|
puts "created user: #{u.attributes.inspect}"
end
|
case ARGV[3]
when 'restart'
when 'update'
when 'shtudown'
end
base commands
case ARGV[3]
when 'restart'
@route += '/' + ARGV[3]
when 'update'
@route += '/' + ARGV[3]
when 'shtudown'
@route += '/' + ARGV[3]
end
perform_get |
# Encoding: Utf-8
module Ts3r
class Application
module Dispatch
def dispatch action = (@opts[:dispatch] || :help)
load_configuration!
case action
when :version, :info then dispatch_info
else
if respond_to?("dispatch_#{action}")
send("dispatch_#{action}")
else
abort("unknown action #{action}", 1)
end
end
end
def dispatch_help
logger.log_without_timestr do
@optparse.to_s.split("\n").each(&method(:log))
end
end
def dispatch_info
logger.log_without_timestr do
log ""
log " Your version: #{your_version = Gem::Version.new(Ts3r::VERSION)}"
# get current version
logger.log_with_print do
log " Current version: "
if @opts[:check_for_updates]
require "net/http"
log c("checking...", :blue)
begin
current_version = Gem::Version.new Net::HTTP.get_response(URI.parse(Ts3r::UPDATE_URL)).body.strip
if current_version > your_version
status = c("#{current_version} (consider update)", :red)
elsif current_version < your_version
status = c("#{current_version} (ahead, beta)", :green)
else
status = c("#{current_version} (up2date)", :green)
end
rescue
status = c("failed (#{$!.message})", :red)
end
logger.raw "#{"\b" * 11}#{" " * 11}#{"\b" * 11}", :print # reset cursor
log status
else
log c("check disabled", :red)
end
end
# more info
log ""
log " Ts3r is brought to you by #{c "bmonkeys.net", :green}"
log " Contribute @ #{c "github.com/2called-chaos/ts3r", :cyan}"
log " Eat bananas every day!"
log ""
end
end
def dispatch_console
establish_connection!
async = []
begin
Console.new("console") do
help
pry(quiet: true)
end.invoke(self, async)
rescue Errno::EPIPE
warn "reconnect and retry task (#{$!.message})"
reconnect!
retry
end
async.each(&:join)
end
def dispatch_index
tasks = @config.get("ts3r.tasks") || {}
if tasks.empty?
binding.pry
abort "No tasks defined, we would do nothing!"
else
establish_connection!
log "Starting loop..."
loop do
async = []
tasks.each do |name, task|
logger.ensure_prefix c("[#{name}]\t", :magenta) do
begin
task.invoke(self, async)
rescue Errno::EPIPE
warn "reconnect and retry task (#{$!.message})"
reconnect!
retry
rescue
warn $!.inspect
warn "in #{$!.backtrace.detect{|l| l.include?(Ts3r::ROOT.to_s) }.to_s.gsub(Ts3r::ROOT.to_s, "%ROOT%")}"
end
end
end
async.each(&:join)
sleep @config.get("ts3r.tick_sleep")
end
end
end
end
end
end
Slowdown
# Encoding: Utf-8
module Ts3r
class Application
module Dispatch
def dispatch action = (@opts[:dispatch] || :help)
load_configuration!
case action
when :version, :info then dispatch_info
else
if respond_to?("dispatch_#{action}")
send("dispatch_#{action}")
else
abort("unknown action #{action}", 1)
end
end
end
def dispatch_help
logger.log_without_timestr do
@optparse.to_s.split("\n").each(&method(:log))
end
end
def dispatch_info
logger.log_without_timestr do
log ""
log " Your version: #{your_version = Gem::Version.new(Ts3r::VERSION)}"
# get current version
logger.log_with_print do
log " Current version: "
if @opts[:check_for_updates]
require "net/http"
log c("checking...", :blue)
begin
current_version = Gem::Version.new Net::HTTP.get_response(URI.parse(Ts3r::UPDATE_URL)).body.strip
if current_version > your_version
status = c("#{current_version} (consider update)", :red)
elsif current_version < your_version
status = c("#{current_version} (ahead, beta)", :green)
else
status = c("#{current_version} (up2date)", :green)
end
rescue
status = c("failed (#{$!.message})", :red)
end
logger.raw "#{"\b" * 11}#{" " * 11}#{"\b" * 11}", :print # reset cursor
log status
else
log c("check disabled", :red)
end
end
# more info
log ""
log " Ts3r is brought to you by #{c "bmonkeys.net", :green}"
log " Contribute @ #{c "github.com/2called-chaos/ts3r", :cyan}"
log " Eat bananas every day!"
log ""
end
end
def dispatch_console
establish_connection!
async = []
begin
Console.new("console") do
help
pry(quiet: true)
end.invoke(self, async)
rescue Errno::EPIPE
sleep 3
warn "reconnect and retry task (#{$!.message})"
reconnect!
retry
end
async.each(&:join)
end
def dispatch_index
tasks = @config.get("ts3r.tasks") || {}
if tasks.empty?
binding.pry
abort "No tasks defined, we would do nothing!"
else
establish_connection!
log "Starting loop..."
loop do
async = []
tasks.each do |name, task|
logger.ensure_prefix c("[#{name}]\t", :magenta) do
begin
task.invoke(self, async)
rescue Errno::EPIPE
warn "reconnect and retry task (#{$!.message})"
sleep 3
reconnect!
retry
rescue
warn $!.inspect
warn "in #{$!.backtrace.detect{|l| l.include?(Ts3r::ROOT.to_s) }.to_s.gsub(Ts3r::ROOT.to_s, "%ROOT%")}"
end
end
end
async.each(&:join)
sleep @config.get("ts3r.tick_sleep")
end
end
end
end
end
end
|
# The Movietheater is the movie complex.
# Movietheater.create(name: "Chicago Movie Theater")
# Auditoriums are the individual theaters with the movietheater complex.
# Auditorium.create(movietheater_id: 1)
# Seats belong to an auditorium
Auditorium.create(movietheater_id: 1)
CategoryProduct.create!([
{category_id: 1, product_id: 2},
{category_id: 1, product_id: 4},
{category_id: 1, product_id: 7},
{category_id: 2, product_id: 1},
{category_id: 2, product_id: 2},
{category_id: 2, product_id: 4},
{category_id: 2, product_id: 7},
{category_id: 3, product_id: 5},
{category_id: 3, product_id: 6},
{category_id: 1, product_id: 3},
{category_id: 1, product_id: 5},
{category_id: 2, product_id: 5},
{category_id: 2, product_id: 6}
200.times do
Address.create(
address_1: Faker::Address.street_address,
address_2: Faker::Address.secondary_address,
city: Faker::Address.city,
state: Faker::Address.state,
zip: Faker::Address.zip,
employee_id: Employee.all.sample.id
)
end
Add seed data for seats for each auditorium.
# The Movietheater is the movie complex.
# Movietheater.create(name: "Chicago Movie Theater")
# Auditoriums are the individual theaters with the movietheater complex.
# Auditorium.create(movietheater_id: 1)
# Seats belong to an auditorium
# 10.times do
# Seat.create(
# auditorium_id: 1,
# )
# end
# 20.times do
# Seat.create(
# auditorium_id: 2,
# )
# end
# 30.times do
# Seat.create(
# auditorium_id: 3,
# )
# end |
def setup_build_dir
setup_default_files
ConfigFileWriter.compile_base_docker_files(@templater, basedir)
unless @blueprint_reader.web_port.nil?
@web_port = @blueprint_reader.web_port
else
read_web_port
end
read_web_user
@build_params[:mapped_ports] = @blueprint_reader.mapped_ports
SystemDebug.debug(SystemDebug.builder, :ports, @build_params[:mapped_ports])
SystemDebug.debug(SystemDebug.builder, :attached_services, @build_params[:attached_services])
@service_builder.required_services_are_running?
@service_builder.create_persistent_services(@blueprint_reader.services, @blueprint_reader.environments, @build_params[:attached_services]).is_a?(EnginesError)
apply_templates_to_environments
create_engines_config_files
index = 0
unless @blueprint_reader.sed_strings.nil? || @blueprint_reader.sed_strings[:sed_str].nil?
@blueprint_reader.sed_strings[:sed_str].each do |sed_string|
sed_string = @templater.process_templated_string(sed_string)
@blueprint_reader.sed_strings[:sed_str][index] = sed_string
index += 1
end
end
@build_params[:app_is_persistent] = @service_builder.app_is_persistent
dockerfile_builder = DockerFileBuilder.new(@blueprint_reader, @build_params, @web_port, self)
dockerfile_builder.write_files_for_docker
write_env_file
setup_framework_logging
rescue StandardError => e
#log_exception(e)
log_build_errors('Engine Build Aborted Due to:' + e.to_s)
post_failed_build_clean_up
raise e
end
def create_build_dir
FileUtils.mkdir_p(basedir)
end
def create_engines_config_files
create_template_files
create_php_ini
create_apache_config
create_scripts
end
def create_template_files
if @blueprint_reader.template_files
@blueprint_reader.template_files.each do |template_hash|
template_hash[:path].sub!(/^\/home/,'')
write_software_file('/home/engines/templates/' + template_hash[:path], template_hash[:content])
end
end
end
def create_httaccess
if @blueprint_reader.apache_htaccess_files
@blueprint_reader.apache_htaccess_files.each do |htaccess_hash|
STDERR.puts(' apache_htaccess_files ' + SystemConfig.htaccessSourceDir + htaccess_hash[:directory].to_s + ' ' + htaccess_hash[:content].to_s)
write_software_file(SystemConfig.htaccessSourceDir + htaccess_hash[:directory] + '/.htaccess', htaccess_hash[:content])
end
end
end
def create_php_ini
FileUtils.mkdir_p(basedir + File.dirname(SystemConfig.CustomPHPiniFile))
if @blueprint_reader.custom_php_inis
contents = ''
@blueprint_reader.custom_php_inis.each do |php_ini_hash|
content = php_ini_hash[:content].gsub(/\r/, '')
contents = contents + "\n" + content
end
write_software_file(SystemConfig.CustomPHPiniFile, contents)
end
end
def create_apache_config
if @blueprint_reader.apache_httpd_configurations
FileUtils.mkdir_p(basedir + File.dirname(SystemConfig.CustomApacheConfFile))
contents = ''
@blueprint_reader.apache_httpd_configurations.each do |httpd_configuration|
contents = contents + httpd_configuration[:content] + "\n"
end
write_software_file(SystemConfig.CustomApacheConfFile, contents)
end
end
def write_env_file
log_build_output('Setting up Environments')
env_file = File.new(basedir + '/home/app.env', 'a')
env_file.puts('')
@blueprint_reader.environments.each do |env|
env_file.puts(env.name) unless env.build_time_only
end
@set_environments.each do |env|
env_file.puts(env[0])
end
env_file.close
end
def write_software_file(filename, content)
ConfigFileWriter.write_templated_file(@templater, basedir + '/' + filename, content)
end
def create_templater
builder_public = BuilderPublic.new(self)
@templater = Templater.new(@core_api.system_value_access, builder_public)
end
def read_web_user
if @blueprint_reader.framework == 'docker'
@web_user = @blueprint_reader.cont_user
# STDERR.puts("Set web user to:" + @web_user.to_s)
return @web_user
end
log_build_output('Read Web User')
stef = File.open(basedir + '/home/stack.env', 'r')
while line = stef.gets do
if line.include?('USER')
i = line.split('=')
@web_user = i[1].strip
end
end
stef.close
end
def apply_templates_to_environments
@blueprint_reader.environments.each do |env|
env.value = @templater.process_templated_string(env.value) if env.value.is_a?(String)
end
end
def read_web_port
log_build_output('Setting Web port')
stef = File.open(basedir + '/home/stack.env', 'r')
while line = stef.gets do
if line.include?('PORT')
i = line.split('=')
@web_port = i[1].strip
SystemDebug.debug(SystemDebug.builder, :web_port_line, line)
end
end
stef.close
# throw BuildStandardError.new(e,'setting web port')
end
def setup_default_files
log_build_output('Setup Default Files ')
log_error_mesg('Failed to setup Global Defaults', self) unless setup_global_defaults
setup_framework_defaults
end
def setup_global_defaults
log_build_output('Setup global defaults')
cmd = 'cp -r ' + SystemConfig.DeploymentTemplates + '/global/* ' + basedir
system cmd
end
def setup_framework_defaults
log_build_output('Copy in default templates')
cmd = 'cp -r ' + SystemConfig.DeploymentTemplates + '/' + @blueprint_reader.framework + '/* ' + basedir
r = system cmd
if @blueprint_reader.framework == 'docker'
df = File.read(basedir + '/_Dockerfile.tmpl')
df = 'FROM ' + @blueprint_reader.base_image + "\n" + 'ENV ContUser ' + @blueprint_reader.cont_user + "\n" + df
fw = File.new(basedir + '/Dockerfile.tmpl','w+')
fw.write(df)
fw.close
return true
end
r
end
def setup_framework_logging
log_build_output('Seting up logging')
rmt_log_dir_var_fname = basedir + '/home/LOG_DIR'
if File.exist?(rmt_log_dir_var_fname)
rmt_log_dir_varfile = File.open(rmt_log_dir_var_fname)
rmt_log_dir = rmt_log_dir_varfile.read
else
rmt_log_dir = '/var/log'
end
local_log_dir = SystemConfig.SystemLogRoot + '/containers/' + @build_params[:engine_name]
Dir.mkdir(local_log_dir) unless Dir.exist?(local_log_dir)
rmt_log_dir_varfile.close
' -v ' + local_log_dir + ':' + rmt_log_dir + ':rw '
end
create htaccess
def setup_build_dir
setup_default_files
ConfigFileWriter.compile_base_docker_files(@templater, basedir)
unless @blueprint_reader.web_port.nil?
@web_port = @blueprint_reader.web_port
else
read_web_port
end
read_web_user
@build_params[:mapped_ports] = @blueprint_reader.mapped_ports
SystemDebug.debug(SystemDebug.builder, :ports, @build_params[:mapped_ports])
SystemDebug.debug(SystemDebug.builder, :attached_services, @build_params[:attached_services])
@service_builder.required_services_are_running?
@service_builder.create_persistent_services(@blueprint_reader.services, @blueprint_reader.environments, @build_params[:attached_services]).is_a?(EnginesError)
apply_templates_to_environments
create_engines_config_files
index = 0
unless @blueprint_reader.sed_strings.nil? || @blueprint_reader.sed_strings[:sed_str].nil?
@blueprint_reader.sed_strings[:sed_str].each do |sed_string|
sed_string = @templater.process_templated_string(sed_string)
@blueprint_reader.sed_strings[:sed_str][index] = sed_string
index += 1
end
end
@build_params[:app_is_persistent] = @service_builder.app_is_persistent
dockerfile_builder = DockerFileBuilder.new(@blueprint_reader, @build_params, @web_port, self)
dockerfile_builder.write_files_for_docker
write_env_file
setup_framework_logging
rescue StandardError => e
#log_exception(e)
log_build_errors('Engine Build Aborted Due to:' + e.to_s)
post_failed_build_clean_up
raise e
end
def create_build_dir
FileUtils.mkdir_p(basedir)
end
def create_engines_config_files
create_template_files
create_php_ini
create_httaccess
create_apache_config
create_scripts
end
def create_template_files
if @blueprint_reader.template_files
@blueprint_reader.template_files.each do |template_hash|
template_hash[:path].sub!(/^\/home/,'')
write_software_file('/home/engines/templates/' + template_hash[:path], template_hash[:content])
end
end
end
def create_httaccess
if @blueprint_reader.apache_htaccess_files
@blueprint_reader.apache_htaccess_files.each do |htaccess_hash|
STDERR.puts(' HTTACCES FILE ' + SystemConfig.htaccessSourceDir + htaccess_hash[:directory].to_s + ' ' + htaccess_hash[:content].to_s)
write_software_file(SystemConfig.htaccessSourceDir + htaccess_hash[:directory] + '/.htaccess', htaccess_hash[:content])
end
end
end
def create_php_ini
FileUtils.mkdir_p(basedir + File.dirname(SystemConfig.CustomPHPiniFile))
if @blueprint_reader.custom_php_inis
contents = ''
@blueprint_reader.custom_php_inis.each do |php_ini_hash|
content = php_ini_hash[:content].gsub(/\r/, '')
contents = contents + "\n" + content
end
write_software_file(SystemConfig.CustomPHPiniFile, contents)
end
end
def create_apache_config
if @blueprint_reader.apache_httpd_configurations
FileUtils.mkdir_p(basedir + File.dirname(SystemConfig.CustomApacheConfFile))
contents = ''
@blueprint_reader.apache_httpd_configurations.each do |httpd_configuration|
contents = contents + httpd_configuration[:content] + "\n"
end
write_software_file(SystemConfig.CustomApacheConfFile, contents)
end
end
def write_env_file
log_build_output('Setting up Environments')
env_file = File.new(basedir + '/home/app.env', 'a')
env_file.puts('')
@blueprint_reader.environments.each do |env|
env_file.puts(env.name) unless env.build_time_only
end
@set_environments.each do |env|
env_file.puts(env[0])
end
env_file.close
end
def write_software_file(filename, content)
ConfigFileWriter.write_templated_file(@templater, basedir + '/' + filename, content)
end
def create_templater
builder_public = BuilderPublic.new(self)
@templater = Templater.new(@core_api.system_value_access, builder_public)
end
def read_web_user
if @blueprint_reader.framework == 'docker'
@web_user = @blueprint_reader.cont_user
# STDERR.puts("Set web user to:" + @web_user.to_s)
return @web_user
end
log_build_output('Read Web User')
stef = File.open(basedir + '/home/stack.env', 'r')
while line = stef.gets do
if line.include?('USER')
i = line.split('=')
@web_user = i[1].strip
end
end
stef.close
end
def apply_templates_to_environments
@blueprint_reader.environments.each do |env|
env.value = @templater.process_templated_string(env.value) if env.value.is_a?(String)
end
end
def read_web_port
log_build_output('Setting Web port')
stef = File.open(basedir + '/home/stack.env', 'r')
while line = stef.gets do
if line.include?('PORT')
i = line.split('=')
@web_port = i[1].strip
SystemDebug.debug(SystemDebug.builder, :web_port_line, line)
end
end
stef.close
# throw BuildStandardError.new(e,'setting web port')
end
def setup_default_files
log_build_output('Setup Default Files ')
log_error_mesg('Failed to setup Global Defaults', self) unless setup_global_defaults
setup_framework_defaults
end
def setup_global_defaults
log_build_output('Setup global defaults')
cmd = 'cp -r ' + SystemConfig.DeploymentTemplates + '/global/* ' + basedir
system cmd
end
def setup_framework_defaults
log_build_output('Copy in default templates')
cmd = 'cp -r ' + SystemConfig.DeploymentTemplates + '/' + @blueprint_reader.framework + '/* ' + basedir
r = system cmd
if @blueprint_reader.framework == 'docker'
df = File.read(basedir + '/_Dockerfile.tmpl')
df = 'FROM ' + @blueprint_reader.base_image + "\n" + 'ENV ContUser ' + @blueprint_reader.cont_user + "\n" + df
fw = File.new(basedir + '/Dockerfile.tmpl','w+')
fw.write(df)
fw.close
return true
end
r
end
def setup_framework_logging
log_build_output('Seting up logging')
rmt_log_dir_var_fname = basedir + '/home/LOG_DIR'
if File.exist?(rmt_log_dir_var_fname)
rmt_log_dir_varfile = File.open(rmt_log_dir_var_fname)
rmt_log_dir = rmt_log_dir_varfile.read
else
rmt_log_dir = '/var/log'
end
local_log_dir = SystemConfig.SystemLogRoot + '/containers/' + @build_params[:engine_name]
Dir.mkdir(local_log_dir) unless Dir.exist?(local_log_dir)
rmt_log_dir_varfile.close
' -v ' + local_log_dir + ':' + rmt_log_dir + ':rw '
end
|
# frozen_string_literal: true
module TuneSpec
module Instances
# Abstract class for Group, Step and Page
class Tuner
class << self
def instance_method_name(name)
"#{name}_#{type}".downcase
end
# A hook to define rules by subclasses
def rules_passed?(_instance, _opts = {})
raise "Implement a #rules_passed? method for #{self}"
end
def format_opts(opts, instance_klass)
default_opts = fetch_default_opts
pre_format_opts(opts).tap do |hash|
default_opts.each do |key, value|
hash[key] = value if argument_required?(key, instance_klass)
end
end
end
def call_object(file_name)
ensure_required(file_name)
const_name = file_name.split('_').each(&:capitalize!).join('')
const_get(const_name)
end
def object_type
:common
end
private
def type
@type ||= itself.to_s.split('::').last.downcase
end
def fetch_default_opts
TuneSpec.__send__("#{type}_opts".downcase)
end
def argument_required?(arg, klass)
klass.instance_method(:initialize).parameters.flatten.include?(arg)
end
def ensure_required(name)
path = project_files.detect { |f| f.include?("/#{name}.rb") }
path ? require("./#{path}") : raise("Unable to find #{name}.rb")
end
def project_files
@project_files ||= Dir.glob("#{file_directory}/**/*")
end
# A hook to implement folder name by subclass
def file_directory
raise "Implement a #folder_name method for #{self}"
end
def pre_format_opts(opts)
opts
end
end
end
end
end
Better error message when file not found
# frozen_string_literal: true
module TuneSpec
module Instances
# Abstract class for Group, Step and Page
class Tuner
class << self
def instance_method_name(name)
"#{name}_#{type}".downcase
end
# A hook to define rules by subclasses
def rules_passed?(_instance, _opts = {})
raise "Implement a #rules_passed? method for #{self}"
end
def format_opts(opts, instance_klass)
default_opts = fetch_default_opts
pre_format_opts(opts).tap do |hash|
default_opts.each do |key, value|
hash[key] = value if argument_required?(key, instance_klass)
end
end
end
def call_object(file_name)
ensure_required(file_name)
const_name = file_name.split('_').each(&:capitalize!).join('')
const_get(const_name)
end
def object_type
:common
end
private
def type
@type ||= itself.to_s.split('::').last.downcase
end
def fetch_default_opts
TuneSpec.__send__("#{type}_opts".downcase)
end
def argument_required?(arg, klass)
klass.instance_method(:initialize).parameters.flatten.include?(arg)
end
def ensure_required(name)
path = project_files.detect { |f| f.include?("/#{name}.rb") }
return require("./#{path}") if path
raise("Unable to find #{name}.rb in /#{TuneSpec.directory} directory")
end
def project_files
@project_files ||= Dir.glob("#{file_directory}/**/*")
end
# A hook to implement folder name by subclass
def file_directory
raise "Implement a #folder_name method for #{self}"
end
def pre_format_opts(opts)
opts
end
end
end
end
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
administrator = User.new(email: 'admin', password: 'admin', password_confirmation: 'admin')
administrator.save
Cleaner db:seeds
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
FactoryGirl.create(:administrator, email: 'admin', password: 'admin', password_confirmation: 'admin')
|
def setup_build_dir
return post_failed_build_clean_up unless setup_default_files
return post_failed_build_clean_up unless ConfigFileWriter.compile_base_docker_files(@templater, basedir)
unless @blueprint_reader.web_port.nil?
@web_port = @blueprint_reader.web_port
else
read_web_port
end
read_web_user
@build_params[:mapped_ports] = @blueprint_reader.mapped_ports
SystemDebug.debug(SystemDebug.builder, :ports, @build_params[:mapped_ports])
SystemDebug.debug(SystemDebug.builder, :attached_services, @build_params[:attached_services])
return build_failed(@service_builder.last_error) unless @service_builder.required_services_are_running?
return build_failed(@service_builder.last_error) if @service_builder.create_persistent_services(@blueprint_reader.services, @blueprint_reader.environments,@build_params[:attached_services]).is_a?(EnginesError)
apply_templates_to_environments
create_engines_config_files
index = 0
unless @blueprint_reader.sed_strings.nil? || @blueprint_reader.sed_strings[:sed_str].nil?
@blueprint_reader.sed_strings[:sed_str].each do |sed_string|
sed_string = @templater.process_templated_string(sed_string)
@blueprint_reader.sed_strings[:sed_str][index] = sed_string
index += 1
end
end
@build_params[:app_is_persistent] = @service_builder.app_is_persistent
dockerfile_builder = DockerFileBuilder.new(@blueprint_reader, @build_params, @web_port, self)
return post_failed_build_clean_up unless dockerfile_builder.write_files_for_docker
write_env_file
setup_framework_logging
return true
end
def create_build_dir
FileUtils.mkdir_p(basedir)
rescue StandardError => e
log_exception(e)
end
def create_engines_config_files
create_template_files
create_php_ini
create_apache_config
create_scripts
end
def create_template_files
if @blueprint[:software].key?(:template_files) && @blueprint[:software][:template_files].nil? == false
@blueprint[:software][:template_files].each do |template_hash|
template_hash[:path].sub!(/^\/home/,'')
write_software_file('/home/engines/templates/' + template_hash[:path], template_hash[:content])
end
end
end
def create_httaccess
if @blueprint[:software].key?(:apache_htaccess_files) && @blueprint[:software][:apache_htaccess_files].nil? == false
@blueprint[:software][:apache_htaccess_files].each do |htaccess_hash|
write_software_file('/home/engines/htaccess_files' + htaccess_hash[:directory] + '/.htaccess', htaccess_hash[:htaccess_content])
end
end
end
def create_php_ini
FileUtils.mkdir_p(basedir + File.dirname(SystemConfig.CustomPHPiniFile))
if @blueprint[:software].key?(:custom_php_inis) \
&& @blueprint[:software][:custom_php_inis].nil? == false \
&& @blueprint[:software][:custom_php_inis].length > 0
contents = ''
@blueprint[:software][:custom_php_inis].each do |php_ini_hash|
content = php_ini_hash[:content].gsub(/\r/, '')
contents = contents + "\n" + content
end
write_software_file(SystemConfig.CustomPHPiniFile, contents)
end
end
def create_apache_config
if @blueprint[:software].key?(:apache_httpd_configurations) \
&& @blueprint[:software][:apache_httpd_configurations].nil? == false \
&& @blueprint[:software][:apache_httpd_configurations].length > 0
FileUtils.mkdir_p(basedir + File.dirname(SystemConfig.CustomApacheConfFile))
# @ if @blueprint[:software].key?(:apache_httpd_configurations) && @blueprint[:software][:apache_httpd_configurations] != nil
contents = ''
@blueprint[:software][:apache_httpd_configurations].each do |httpd_configuration|
contents = contents + httpd_configuration[:httpd_configuration] + "\n"
end
write_software_file(SystemConfig.CustomApacheConfFile, contents)
end
end
def write_env_file
log_build_output('Setting up Environments')
env_file = File.new(basedir + '/home/app.env', 'a')
env_file.puts('')
@blueprint_reader.environments.each do |env|
env_file.puts(env.name) unless env.build_time_only
end
@set_environments.each do |env|
env_file.puts(env[0])
end
env_file.close
end
def write_software_file(filename, content)
ConfigFileWriter.write_templated_file(@templater, basedir + '/' + filename, content)
end
def create_templater
builder_public = BuilderPublic.new(self)
@templater = Templater.new(@core_api.system_value_access, builder_public)
rescue StandardError => e
log_exception(e)
end
def read_web_user
log_build_output('Read Web User')
stef = File.open(basedir + '/home/stack.env', 'r')
while line = stef.gets do
if line.include?('USER')
i = line.split('=')
@web_user = i[1].strip
end
end
stef.close
rescue StandardError => e
log_exception(e)
end
def apply_templates_to_environments
@blueprint_reader.environments.each do |env|
env.value = @templater.process_templated_string(env.value)
end
end
def read_web_port
log_build_output('Setting Web port')
stef = File.open(basedir + '/home/stack.env', 'r')
while line = stef.gets do
if line.include?('PORT')
i = line.split('=')
@web_port = i[1].strip
SystemDebug.debug(SystemDebug.builder, :web_port_line, line)
end
end
stef.close
rescue StandardError => e
log_exception(e)
# throw BuildStandardError.new(e,'setting web port')
end
def setup_default_files
log_build_output('Setup Default Files')
log_error_mesg('Failed to setup Global Defaults', self) unless setup_global_defaults
return setup_framework_defaults
end
def setup_global_defaults
log_build_output('Setup global defaults')
cmd = 'cp -r ' + SystemConfig.DeploymentTemplates + '/global/* ' + basedir
system cmd
rescue StandardError => e
log_exception(e)
end
def setup_framework_defaults
log_build_output('Copy in default templates')
cmd = 'cp -r ' + SystemConfig.DeploymentTemplates + '/' + @blueprint_reader.framework + '/* ' + basedir
system cmd
if @blueprint_reader.framework == 'docker'
df = File.read(SystemConfig.DeploymentTemplates + '/' + @blueprint_reader.framework + '/_Dockerfile.tmpl')
df = 'FROM: ' + @blueprint_reader.base_image + "\n" + df
fw = File.new(basedir + '/Dockerfile.tmpl','w+')
fw.write(df)
fw.close
end
rescue StandardError => e
log_exception(e)
end
def setup_framework_logging
log_build_output('Seting up logging')
rmt_log_dir_var_fname = basedir + '/home/LOG_DIR'
if File.exist?(rmt_log_dir_var_fname)
rmt_log_dir_varfile = File.open(rmt_log_dir_var_fname)
rmt_log_dir = rmt_log_dir_varfile.read
else
rmt_log_dir = '/var/log'
end
local_log_dir = SystemConfig.SystemLogRoot + '/containers/' + @build_params[:engine_name]
Dir.mkdir(local_log_dir) unless Dir.exist?(local_log_dir)
rmt_log_dir_varfile.close
return ' -v ' + local_log_dir + ':' + rmt_log_dir + ':rw '
rescue StandardError => e
log_exception(e)
end
correct ret val
def setup_build_dir
return post_failed_build_clean_up unless setup_default_files
return post_failed_build_clean_up unless ConfigFileWriter.compile_base_docker_files(@templater, basedir)
unless @blueprint_reader.web_port.nil?
@web_port = @blueprint_reader.web_port
else
read_web_port
end
read_web_user
@build_params[:mapped_ports] = @blueprint_reader.mapped_ports
SystemDebug.debug(SystemDebug.builder, :ports, @build_params[:mapped_ports])
SystemDebug.debug(SystemDebug.builder, :attached_services, @build_params[:attached_services])
return build_failed(@service_builder.last_error) unless @service_builder.required_services_are_running?
return build_failed(@service_builder.last_error) if @service_builder.create_persistent_services(@blueprint_reader.services, @blueprint_reader.environments,@build_params[:attached_services]).is_a?(EnginesError)
apply_templates_to_environments
create_engines_config_files
index = 0
unless @blueprint_reader.sed_strings.nil? || @blueprint_reader.sed_strings[:sed_str].nil?
@blueprint_reader.sed_strings[:sed_str].each do |sed_string|
sed_string = @templater.process_templated_string(sed_string)
@blueprint_reader.sed_strings[:sed_str][index] = sed_string
index += 1
end
end
@build_params[:app_is_persistent] = @service_builder.app_is_persistent
dockerfile_builder = DockerFileBuilder.new(@blueprint_reader, @build_params, @web_port, self)
return post_failed_build_clean_up unless dockerfile_builder.write_files_for_docker
write_env_file
setup_framework_logging
return true
end
def create_build_dir
FileUtils.mkdir_p(basedir)
rescue StandardError => e
log_exception(e)
end
def create_engines_config_files
create_template_files
create_php_ini
create_apache_config
create_scripts
end
def create_template_files
if @blueprint[:software].key?(:template_files) && @blueprint[:software][:template_files].nil? == false
@blueprint[:software][:template_files].each do |template_hash|
template_hash[:path].sub!(/^\/home/,'')
write_software_file('/home/engines/templates/' + template_hash[:path], template_hash[:content])
end
end
end
def create_httaccess
if @blueprint[:software].key?(:apache_htaccess_files) && @blueprint[:software][:apache_htaccess_files].nil? == false
@blueprint[:software][:apache_htaccess_files].each do |htaccess_hash|
write_software_file('/home/engines/htaccess_files' + htaccess_hash[:directory] + '/.htaccess', htaccess_hash[:htaccess_content])
end
end
end
def create_php_ini
FileUtils.mkdir_p(basedir + File.dirname(SystemConfig.CustomPHPiniFile))
if @blueprint[:software].key?(:custom_php_inis) \
&& @blueprint[:software][:custom_php_inis].nil? == false \
&& @blueprint[:software][:custom_php_inis].length > 0
contents = ''
@blueprint[:software][:custom_php_inis].each do |php_ini_hash|
content = php_ini_hash[:content].gsub(/\r/, '')
contents = contents + "\n" + content
end
write_software_file(SystemConfig.CustomPHPiniFile, contents)
end
end
def create_apache_config
if @blueprint[:software].key?(:apache_httpd_configurations) \
&& @blueprint[:software][:apache_httpd_configurations].nil? == false \
&& @blueprint[:software][:apache_httpd_configurations].length > 0
FileUtils.mkdir_p(basedir + File.dirname(SystemConfig.CustomApacheConfFile))
# @ if @blueprint[:software].key?(:apache_httpd_configurations) && @blueprint[:software][:apache_httpd_configurations] != nil
contents = ''
@blueprint[:software][:apache_httpd_configurations].each do |httpd_configuration|
contents = contents + httpd_configuration[:httpd_configuration] + "\n"
end
write_software_file(SystemConfig.CustomApacheConfFile, contents)
end
end
def write_env_file
log_build_output('Setting up Environments')
env_file = File.new(basedir + '/home/app.env', 'a')
env_file.puts('')
@blueprint_reader.environments.each do |env|
env_file.puts(env.name) unless env.build_time_only
end
@set_environments.each do |env|
env_file.puts(env[0])
end
env_file.close
end
def write_software_file(filename, content)
ConfigFileWriter.write_templated_file(@templater, basedir + '/' + filename, content)
end
def create_templater
builder_public = BuilderPublic.new(self)
@templater = Templater.new(@core_api.system_value_access, builder_public)
rescue StandardError => e
log_exception(e)
end
def read_web_user
log_build_output('Read Web User')
stef = File.open(basedir + '/home/stack.env', 'r')
while line = stef.gets do
if line.include?('USER')
i = line.split('=')
@web_user = i[1].strip
end
end
stef.close
rescue StandardError => e
log_exception(e)
end
def apply_templates_to_environments
@blueprint_reader.environments.each do |env|
env.value = @templater.process_templated_string(env.value)
end
end
def read_web_port
log_build_output('Setting Web port')
stef = File.open(basedir + '/home/stack.env', 'r')
while line = stef.gets do
if line.include?('PORT')
i = line.split('=')
@web_port = i[1].strip
SystemDebug.debug(SystemDebug.builder, :web_port_line, line)
end
end
stef.close
rescue StandardError => e
log_exception(e)
# throw BuildStandardError.new(e,'setting web port')
end
def setup_default_files
log_build_output('Setup Default Files')
log_error_mesg('Failed to setup Global Defaults', self) unless setup_global_defaults
return setup_framework_defaults
end
def setup_global_defaults
log_build_output('Setup global defaults')
cmd = 'cp -r ' + SystemConfig.DeploymentTemplates + '/global/* ' + basedir
system cmd
rescue StandardError => e
log_exception(e)
end
def setup_framework_defaults
log_build_output('Copy in default templates')
cmd = 'cp -r ' + SystemConfig.DeploymentTemplates + '/' + @blueprint_reader.framework + '/* ' + basedir
system cmd
if @blueprint_reader.framework == 'docker'
df = File.read(SystemConfig.DeploymentTemplates + '/' + @blueprint_reader.framework + '/_Dockerfile.tmpl')
df = 'FROM: ' + @blueprint_reader.base_image + "\n" + df
fw = File.new(basedir + '/Dockerfile.tmpl','w+')
fw.write(df)
fw.close
return true
end
rescue StandardError => e
log_exception(e)
end
def setup_framework_logging
log_build_output('Seting up logging')
rmt_log_dir_var_fname = basedir + '/home/LOG_DIR'
if File.exist?(rmt_log_dir_var_fname)
rmt_log_dir_varfile = File.open(rmt_log_dir_var_fname)
rmt_log_dir = rmt_log_dir_varfile.read
else
rmt_log_dir = '/var/log'
end
local_log_dir = SystemConfig.SystemLogRoot + '/containers/' + @build_params[:engine_name]
Dir.mkdir(local_log_dir) unless Dir.exist?(local_log_dir)
rmt_log_dir_varfile.close
return ' -v ' + local_log_dir + ':' + rmt_log_dir + ':rw '
rescue StandardError => e
log_exception(e)
end
|
module VagrantPlugins
module SyncedFolderNFSGuest
VERSION = "0.1.1"
end
end
[BUMP] version
module VagrantPlugins
module SyncedFolderNFSGuest
VERSION = "0.1.2"
end
end
|
# ruby encoding: utf-8
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
#
# Copyable Item: ['', ''],
# Repos
repo_list = [
['rails/rails', 'web application framework'],
['sinatra/sinatra', 'web application framework'],
['zurb/foundation', 'design framework'],
['twitter/bootstrap', 'design framework'],
['37signals/pow', 'development server'],
['rodreegez/powder', 'development server'],
['mbleigh/acts-as-taggable-on', 'tagging'],
['bradphelan/rocket_tag', 'tagging'],
['chrome/markable', 'tagging'],
['mperham/sidekiq', 'background jobs'],
['mperham/girl_friday', 'background jobs'],
['defunkt/resque', 'background jobs'],
['collectiveidea/delayed_job', 'background jobs'],
['ryandotsmith/queue_classic', 'background jobs'],
['NoamB/sorcery', 'user management: authentication'],
['plataformatec/devise', 'user management: authentication'],
['thoughtbot/clearance', 'user management: authentication'],
['intridea/omniauth', 'user management: authentication'],
['ryanb/cancan', 'user management: authorization'],
['stffn/declarative_authorization', 'user management: authorization'],
['kristianmandrup/cantango', 'user management: authorization'],
['nathanl/authority', 'user management: authorization'],
['james2m/canard', 'user management: authorization'],
['mcrowe/roleable', 'user management: authorization'],
['37signals/mail_view', 'email: preview emails'],
['sj26/mailcatcher', 'email: preview emails'],
['ryanb/letter_opener', 'email: preview emails'],
['jeriko/app_drone', 'rails: project generators and templates'],
['RailsApps/rails_apps_composer', 'rails: project generators and templates'],
['RailsApps/rails3-application-templates', 'rails: project generators and templates']
]
repo_list.each do |repo|
Repo.create(full_name: repo[0], category_list: repo[1])
end
# Categories
category_list = [
['web application framework', 'Build web applications with style.'],
['user management: authentication', 'User Authentication Plugins, that let you manage your users and handle signing in via Oauth Services (Twitter, Facebook, Github & more). There\'s a good railscasts that shows how an authentication solution can work.'],
['user management: authorization', 'Manage User Rights, User Roles & Abilities.'],
['design framework', 'Good foundation for your website styling.'],
['development server', 'Local Development Server with automatic reload capabilites. Speeds up your development.'],
['tagging', 'Tagging functionality for your ActiveRecord Models.'],
['background jobs', 'Message queuing helps you allocating workload to seperate worker processes in the background. Used as synonyms: Background processing, message queues.'],
['email: preview emails', 'Preview emails in development, e.g. in the browser, instead of sending them.'],
['rails: project generators and templates', 'Get projects started. Helps getting up and running quickly, automating configuration.']
]
category_list.each do |category|
Category.create(name: category[0], description: category[1])
end
# Run Jobs
Repo.update_all_repos_from_github
Category.update
Seeds.rb: Change way how category descriptions are injected
# ruby encoding: utf-8
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
#
# Copyable Item: ['', ''],
# Repos
repo_list = [
['rails/rails', 'web application framework'],
['sinatra/sinatra', 'web application framework'],
['zurb/foundation', 'design framework'],
['twitter/bootstrap', 'design framework'],
['37signals/pow', 'development server'],
['rodreegez/powder', 'development server'],
['mbleigh/acts-as-taggable-on', 'tagging'],
['bradphelan/rocket_tag', 'tagging'],
['chrome/markable', 'tagging'],
['mperham/sidekiq', 'background jobs'],
['mperham/girl_friday', 'background jobs'],
['defunkt/resque', 'background jobs'],
['collectiveidea/delayed_job', 'background jobs'],
['ryandotsmith/queue_classic', 'background jobs'],
['NoamB/sorcery', 'user management: authentication'],
['plataformatec/devise', 'user management: authentication'],
['thoughtbot/clearance', 'user management: authentication'],
['intridea/omniauth', 'user management: authentication'],
['ryanb/cancan', 'user management: authorization'],
['stffn/declarative_authorization', 'user management: authorization'],
['kristianmandrup/cantango', 'user management: authorization'],
['nathanl/authority', 'user management: authorization'],
['james2m/canard', 'user management: authorization'],
['mcrowe/roleable', 'user management: authorization'],
['37signals/mail_view', 'email: preview emails'],
['sj26/mailcatcher', 'email: preview emails'],
['ryanb/letter_opener', 'email: preview emails'],
['jeriko/app_drone', 'rails: project generators and templates'],
['RailsApps/rails_apps_composer', 'rails: project generators and templates'],
['RailsApps/rails3-application-templates', 'rails: project generators and templates']
]
repo_list.each do |repo|
Repo.create(full_name: repo[0], category_list: repo[1])
end
# Categories
category_list = [
['web application framework', 'Build web applications with style.'],
['user management: authentication', 'User Authentication Plugins, that let you manage your users and handle signing in via Oauth Services (Twitter, Facebook, Github & more). There\'s a good railscasts that shows how an authentication solution can work.'],
['user management: authorization', 'Manage User Rights, User Roles & Abilities.'],
['design framework', 'Good foundation for your website styling.'],
['development server', 'Local Development Server with automatic reload capabilites. Speeds up your development.'],
['tagging', 'Tagging functionality for your ActiveRecord Models.'],
['background jobs', 'Message queuing helps you allocating workload to seperate worker processes in the background. Used as synonyms: Background processing, message queues.'],
['email: preview emails', 'Preview emails in development, e.g. in the browser, instead of sending them.'],
['rails: project generators and templates', 'Get projects started. Helps getting up and running quickly, automating configuration.']
]
# Run Jobs
# Update Repos
Repo.update_all_repos_from_github
# Insert Category Descriptions
category_list.each do |category|
category = Category.find_or_initialize_by_name(name: category[0])
category[:description] = category[1]
end
# Update Category Attributes
Category.update
|
module VagrantPlugins
module Parallels
VERSION = "1.1.0"
end
end
Version bumped to v1.2.0
module VagrantPlugins
module Parallels
VERSION = "1.2.0"
end
end
|
# encoding: utf-8
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Daley', :city => cities.first)
PublicActivity.enabled = false
# access roles
Role.create!(:note => 'Просмотр информации по исполняемым ролям, участию в процессах, комментирование документов процесса', :name => 'user', :description => 'Исполнитель')
Role.create!(:note => 'Ведение документов, ролей, приложений, рабочих мест процесса, назначение исполнителей на роли', :name => 'owner', :description => 'Владелец процесса')
Role.create!(:note => 'Ведение списка процессов, документов, ролей, рабочих мест, приложений', :name => 'analitic', :description => 'Бизнес-аналитик')
Role.create!(:note => 'Ведение списков рабочих мест и приложений, настройка системы', :name => 'admin', :description => 'Администратор')
Role.create!(:note => 'Ведение документов и директив, удаление своих документов', :name => 'author', :description => 'Писатель')
Role.create!(:note => 'Отвечает за хранение бумажных оригиналов, изменяет место хранения документа', :name => 'keeper', :description => 'Хранитель')
Role.create!(:note => 'Ведение прав пользователей, настройка системы', :name => 'security', :description => 'Администратор доступа')
puts "access roles created"
Role.pluck(:name)
# users
user1 = User.create(:displayname => 'Иванов И.И.', :username => 'ivanov', :email => 'ivanov@example.com', :password => 'ivanov')
user1.roles << Role.find_by_name(:author)
user1.roles << Role.find_by_name(:owner)
user2 = User.create(:displayname => 'Петров П.П.', :username => 'petrov', :email => 'petrov@example.com', :password => 'petrov')
user2.roles << Role.find_by_name(:author)
user3 = User.create(:displayname => 'Администратор', :username => 'admin1', :email => 'admin1@example.com', :password => 'admin1')
user3.roles << Role.find_by_name(:admin)
user3.roles << Role.find_by_name(:security)
user4 = User.create(:displayname => 'Сидоров С.С.', :username => 'sidorov', :email => 'sidorov@example.com', :password => 'sidoriv')
user4.roles << Role.find_by_name(:author)
user5 = User.create(:displayname => 'Путин В.В.', :username => 'putin', :email => 'putin@example.com', :password => 'sidoriv')
user5.roles << Role.find_by_name(:keeper)
user5.roles << Role.find_by_name(:user)
puts "users created"
# applications
['Office', 'Notepad', "Excel", 'Word', 'Powerpoint'].each do |name |
Bapp.create(:name => name,
:description => 'Microsoft ' + name + ' 2003',
:apptype => 'офис',
:purpose => 'редактирование ' + name)
end
ap1 = Bapp.create(:name => '1С:Бухгалтерия', :description => '1С:Бухгалтерия. Учет основных средств', :apptype => 'бух')
puts "applications created"
# workplaces
wp1 = Workplace.create(:name => 'РМ УИТ Начальник', :description => "начальник УИТ", :designation => 'РМУИТНачальник', :location => '100')
wp2 = Workplace.create(:name => 'Главный бухгалтер', :description => "Главный бухгалтер", :designation => 'РМГлБухгалтер', :location => '200')
["Кассир", "Бухгалтер", "Контролер", "Юрист", "Экономист"].each do |name|
3.times do |n|
n += 1
Workplace.create(:name => 'РМ ' + name + n.to_s,
:description => 'рабочее место' + name + n.to_s,
:designation => name + n.to_s,
:location => n.to_s + '01')
end
end
puts "workplaces created"
# terms
term1 = Term.create(:name => 'электронная подпись', :shortname => 'ЭП', :description => 'электронная подпись')
puts 'terms created'
PublicActivity.enabled = true
заполнение БД демо-данными - процессы
# encoding: utf-8
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Daley', :city => cities.first)
PublicActivity.enabled = false
# access roles
Role.create!(:note => 'Просмотр информации по исполняемым ролям, участию в процессах, комментирование документов процесса', :name => 'user', :description => 'Исполнитель')
Role.create!(:note => 'Ведение документов, ролей, приложений, рабочих мест процесса, назначение исполнителей на роли', :name => 'owner', :description => 'Владелец процесса')
Role.create!(:note => 'Ведение списка процессов, документов, ролей, рабочих мест, приложений', :name => 'analitic', :description => 'Бизнес-аналитик')
Role.create!(:note => 'Ведение списков рабочих мест и приложений, настройка системы', :name => 'admin', :description => 'Администратор')
Role.create!(:note => 'Ведение документов и директив, удаление своих документов', :name => 'author', :description => 'Писатель')
Role.create!(:note => 'Отвечает за хранение бумажных оригиналов, изменяет место хранения документа', :name => 'keeper', :description => 'Хранитель')
Role.create!(:note => 'Ведение прав пользователей, настройка системы', :name => 'security', :description => 'Администратор доступа')
puts "access roles created"
Role.pluck(:name)
# users
user1 = User.create(:displayname => 'Иванов И.И.', :username => 'ivanov', :email => 'ivanov@example.com', :password => 'ivanov')
user1.roles << Role.find_by_name(:author)
user1.roles << Role.find_by_name(:analitic)
user1.roles << Role.find_by_name(:owner)
user2 = User.create(:displayname => 'Петров П.П.', :username => 'petrov', :email => 'petrov@example.com', :password => 'petrov')
user2.roles << Role.find_by_name(:author)
user3 = User.create(:displayname => 'Администратор', :username => 'admin1', :email => 'admin1@example.com', :password => 'admin1')
user3.roles << Role.find_by_name(:admin)
user3.roles << Role.find_by_name(:security)
user4 = User.create(:displayname => 'Сидоров С.С.', :username => 'sidorov', :email => 'sidorov@example.com', :password => 'sidorov')
user4.roles << Role.find_by_name(:author)
user5 = User.create(:displayname => 'Путин В.В.', :username => 'putin', :email => 'putin@example.com', :password => 'putin')
user5.roles << Role.find_by_name(:keeper)
user5.roles << Role.find_by_name(:user)
user6 = User.create(:displayname => 'Кудрин А.В.', :username => 'kudrin', :email => 'kudrin@example.com', :password => 'kudrin')
user6.roles << Role.find_by_name(:author)
user6.roles << Role.find_by_name(:owner)
user6.roles << Role.find_by_name(:analitic)
user6.roles << Role.find_by_name(:security)
puts "users created"
# applications
['Office', 'Notepad', "Excel", 'Word', 'Powerpoint'].each do |name |
Bapp.create(:name => name,
:description => 'Microsoft ' + name + ' 2003',
:apptype => 'офис',
:purpose => 'редактирование ' + name)
end
ap1 = Bapp.create(:name => '1С:Бухгалтерия', :description => '1С:Бухгалтерия. Учет основных средств', :apptype => 'бух')
puts "applications created"
# workplaces
wp1 = Workplace.create(:name => 'РМ УИТ Начальник', :description => "начальник УИТ", :designation => 'РМУИТНачальник', :location => '100')
wp2 = Workplace.create(:name => 'Главный бухгалтер', :description => "Главный бухгалтер", :designation => 'РМГлБухгалтер', :location => '200')
["Кассир", "Бухгалтер", "Контролер", "Юрист", "Экономист"].each do |name|
3.times do |n|
n += 1
Workplace.create(:name => 'РМ ' + name + n.to_s,
:description => 'рабочее место' + name + n.to_s,
:designation => name + n.to_s,
:location => n.to_s + '01')
end
end
puts "workplaces created"
# terms
term1 = Term.create(:name => 'электронная подпись', :shortname => 'ЭП', :description => 'электронная подпись')
puts 'terms created'
#processes
bp1 = Bproce.create(name: 'Предоставление сервисов', shortname: 'B.4.1',
fullname: 'Предоставление сервисов', user_id: '1')
bp11 = Bproce.create(name: 'Управление уровнем сервисов', shortname: 'SLM', fullname: 'Управление уровнем сервисов', parent_id: bp1.id)
bp12 = Bproce.create(name: 'Управление мощностями', shortname: 'CAP', fullname: 'Управление мощностями', parent_id: bp1.id)
bp13 = Bproce.create(name: 'Управление непрерывностью', shortname: 'SCM', fullname: 'Управление непрерывностью', parent_id: bp1.id)
bp14 = Bproce.create(name: 'Управление финансами', shortname: 'FIN', fullname: 'Управление финансами', parent_id: bp1.id)
bp15 = Bproce.create(name: 'Управление доступностью', shortname: 'AVA', fullname: 'Управление доступностью', parent_id: bp1.id)
bp2 = Bproce.create(name: 'Поддержка сервисов', shortname: 'B.4.2', fullname: 'Поддержка сервисов')
bp21 = Bproce.create(name: 'Управление инцидентами', shortname: 'INC', fullname: 'Управление инцидентами', parent_id: bp2.id)
bp211 = Bproce.create(name: 'Служба поддержки пользователей Service Desk', shortname: 'SD', fullname: 'Служба поддержки пользователей Service Desk', parent_id: bp21.id)
bp22 = Bproce.create(name: 'Управление проблемами', shortname: 'PRB', fullname: 'Управление проблемами', parent_id: bp2.id)
bp23 = Bproce.create(name: 'Управление конфигурациями', shortname: 'CFG', fullname: 'Управление конфигурациями', parent_id: bp2.id)
bp23 = Bproce.create(name: 'Управление релизами', shortname: 'REL', fullname: 'Управление релизами', parent_id: bp2.id)
bp23 = Bproce.create(name: 'Управление изменениями', shortname: 'CNG', fullname: 'Управление изменениями', parent_id: bp2.id, user_id: user6)
puts "processes created"
m = Metric.create(name: 'ИнцидентовВсего', description: 'количество инцидентов, зарегистрированных в системе', depth: '3', bproce_id: bp211.id)
puts "metrics created"
PublicActivity.enabled = true |
# -*- encoding : utf-8 -*-
module VersacommerceAPI
VERSION = '1.0.13'
end
Bump version to 1.0.14
# -*- encoding : utf-8 -*-
module VersacommerceAPI
VERSION = '1.0.14'
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
ship_masters = [
{
book_no: 1,
ship_class: '長門型',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: '長門',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 2,
ship_class: '長門型',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: '陸奥',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 3,
ship_class: '伊勢型',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: '伊勢',
variation_num: 3,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 4,
ship_class: '伊勢型',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: '日向',
variation_num: 3,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 5,
ship_class: '陽炎型',
ship_class_index: 8,
ship_type: '駆逐艦',
ship_name: '雪風',
variation_num: 6,
# 2016-05-26:5隻追加(雪風、睦月、如月、古鷹、加古)
implemented_at: '2016-05-26T07:00:00+09:00',
},
{
book_no: 6,
ship_class: '赤城型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '赤城',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 7,
ship_class: '加賀型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '加賀',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 8,
ship_class: '蒼龍型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '蒼龍',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 9,
ship_class: '飛龍型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '飛龍',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 10,
ship_class: '島風型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '島風',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 11,
ship_class: '吹雪型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '吹雪',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 12,
ship_class: '吹雪型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '白雪',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 13,
ship_class: '吹雪型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '初雪',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 14,
ship_class: '吹雪型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '深雪',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 15,
ship_class: '吹雪型',
ship_class_index: 5,
ship_type: '駆逐艦',
ship_name: '叢雲',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 16,
ship_class: '吹雪型',
ship_class_index: 9,
ship_type: '駆逐艦',
ship_name: '磯波',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 17,
ship_class: '綾波型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '綾波',
variation_num: 6,
# 2016-06-30:5隻追加(綾波、敷波、那智、足柄、羽黒)
implemented_at: '2016-06-30T07:00:00+09:00',
},
{
book_no: 18,
ship_class: '綾波型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '敷波',
variation_num: 6,
# 2016-06-30:5隻追加(綾波、敷波、那智、足柄、羽黒)
implemented_at: '2016-06-30T07:00:00+09:00',
},
{
book_no: 19,
ship_class: '球磨型',
ship_class_index: 4,
ship_type: '軽巡洋艦',
ship_name: '大井',
variation_num: 3,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 20,
ship_class: '球磨型',
ship_class_index: 3,
ship_type: '軽巡洋艦',
ship_name: '北上',
variation_num: 3,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 21,
ship_class: '金剛型',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: '金剛',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 22,
ship_class: '金剛型',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: '比叡',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 23,
ship_class: '金剛型',
ship_class_index: 3,
ship_type: '戦艦',
ship_name: '榛名',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 24,
ship_class: '金剛型',
ship_class_index: 4,
ship_type: '戦艦',
ship_name: '霧島',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 25,
ship_class: '鳳翔型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '鳳翔',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 26,
ship_class: '扶桑型',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: '扶桑',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 27,
ship_class: '扶桑型',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: '山城',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 28,
ship_class: '天龍型',
ship_class_index: 1,
ship_type: '軽巡洋艦',
ship_name: '天龍',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 29,
ship_class: '天龍型',
ship_class_index: 2,
ship_type: '軽巡洋艦',
ship_name: '龍田',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 30,
ship_class: '龍驤型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '龍驤',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 31,
ship_class: '睦月型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '睦月',
variation_num: 6,
# 2016-05-26:5隻追加(雪風、睦月、如月、古鷹、加古)
implemented_at: '2016-05-26T07:00:00+09:00',
},
{
book_no: 32,
ship_class: '睦月型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '如月',
variation_num: 6,
# 2016-05-26:5隻追加(雪風、睦月、如月、古鷹、加古)
implemented_at: '2016-05-26T07:00:00+09:00',
},
{
book_no: 33,
ship_class: '睦月型',
ship_class_index: 5,
ship_type: '駆逐艦',
ship_name: '皐月',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 34,
ship_class: '睦月型',
ship_class_index: 7,
ship_type: '駆逐艦',
ship_name: '文月',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 35,
ship_class: '睦月型',
ship_class_index: 8,
ship_type: '駆逐艦',
ship_name: '長月',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 36,
ship_class: '睦月型',
ship_class_index: 9,
ship_type: '駆逐艦',
ship_name: '菊月',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 37,
ship_class: '睦月型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '三日月',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 38,
ship_class: '睦月型',
ship_class_index: 11,
ship_type: '駆逐艦',
ship_name: '望月',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 39,
ship_class: '球磨型',
ship_class_index: 1,
ship_type: '軽巡洋艦',
ship_name: '球磨',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 40,
ship_class: '球磨型',
ship_class_index: 2,
ship_type: '軽巡洋艦',
ship_name: '多摩',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 41,
ship_class: '球磨型',
ship_class_index: 5,
ship_type: '軽巡洋艦',
ship_name: '木曾',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 42,
ship_class: '長良型',
ship_class_index: 1,
ship_type: '軽巡洋艦',
ship_name: '長良',
variation_num: 6,
# 2016-08-23:4隻追加(長良、五十鈴、名取、由良)
implemented_at: '2016-08-23T07:00:00+09:00',
},
{
book_no: 43,
ship_class: '長良型',
ship_class_index: 2,
ship_type: '軽巡洋艦',
ship_name: '五十鈴',
variation_num: 6,
# 2016-08-23:4隻追加(長良、五十鈴、名取、由良)
implemented_at: '2016-08-23T07:00:00+09:00',
},
{
book_no: 44,
ship_class: '長良型',
ship_class_index: 3,
ship_type: '軽巡洋艦',
ship_name: '名取',
variation_num: 6,
# 2016-08-23:4隻追加(長良、五十鈴、名取、由良)
implemented_at: '2016-08-23T07:00:00+09:00',
},
{
book_no: 45,
ship_class: '長良型',
ship_class_index: 4,
ship_type: '軽巡洋艦',
ship_name: '由良',
variation_num: 6,
# 2016-08-23:4隻追加(長良、五十鈴、名取、由良)
implemented_at: '2016-08-23T07:00:00+09:00',
},
{
book_no: 46,
ship_class: '川内型',
ship_class_index: 1,
ship_type: '軽巡洋艦',
ship_name: '川内',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 47,
ship_class: '川内型',
ship_class_index: 2,
ship_type: '軽巡洋艦',
ship_name: '神通',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 48,
ship_class: '川内型',
ship_class_index: 3,
ship_type: '軽巡洋艦',
ship_name: '那珂',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 49,
ship_class: '千歳型',
ship_class_index: 1,
ship_type: '水上機母艦',
ship_name: '千歳',
variation_num: 3,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 50,
ship_class: '千歳型',
ship_class_index: 2,
ship_type: '水上機母艦',
ship_name: '千代田',
variation_num: 3,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 51,
ship_class: '最上型',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: '最上',
variation_num: 3,
# 2016-09-15:4隻追加(最上、三隈、鈴谷、熊野)
implemented_at: '2016-09-15T07:00:00+09:00',
},
{
book_no: 52,
ship_class: '古鷹型',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: '古鷹',
variation_num: 6,
# 2016-05-26:5隻追加(雪風、睦月、如月、古鷹、加古)
implemented_at: '2016-05-26T07:00:00+09:00',
},
{
book_no: 53,
ship_class: '古鷹型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '加古',
variation_num: 6,
# 2016-05-26:5隻追加(雪風、睦月、如月、古鷹、加古)
implemented_at: '2016-05-26T07:00:00+09:00',
},
{
book_no: 54,
ship_class: '青葉型',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: '青葉',
variation_num: 6,
# 2017-01-12:6隻追加(初春、子日、若葉、初霜、青葉、衣笠)
implemented_at: '2017-01-12T07:00:00+09:00',
},
{
book_no: 55,
ship_class: '妙高型',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: '妙高',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 56,
ship_class: '妙高型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '那智',
variation_num: 6,
# 2016-06-30:5隻追加(綾波、敷波、那智、足柄、羽黒)
implemented_at: '2016-06-30T07:00:00+09:00',
},
{
book_no: 57,
ship_class: '妙高型',
ship_class_index: 3,
ship_type: '重巡洋艦',
ship_name: '足柄',
variation_num: 6,
# 2016-06-30:5隻追加(綾波、敷波、那智、足柄、羽黒)
implemented_at: '2016-06-30T07:00:00+09:00',
},
{
book_no: 58,
ship_class: '妙高型',
ship_class_index: 4,
ship_type: '重巡洋艦',
ship_name: '羽黒',
variation_num: 6,
# 2016-06-30:5隻追加(綾波、敷波、那智、足柄、羽黒)
implemented_at: '2016-06-30T07:00:00+09:00',
},
{
book_no: 59,
ship_class: '高雄型',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: '高雄',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 60,
ship_class: '高雄型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '愛宕',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 61,
ship_class: '高雄型',
ship_class_index: 3,
ship_type: '重巡洋艦',
ship_name: '摩耶',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 62,
ship_class: '高雄型',
ship_class_index: 4,
ship_type: '重巡洋艦',
ship_name: '鳥海',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 63,
ship_class: '利根型',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: '利根',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 64,
ship_class: '利根型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '筑摩',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 65,
ship_class: '飛鷹型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '飛鷹',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 66,
ship_class: '飛鷹型',
ship_class_index: 2,
ship_type: '軽空母',
ship_name: '隼鷹',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 67,
ship_class: '綾波型',
ship_class_index: 7,
ship_type: '駆逐艦',
ship_name: '朧',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 68,
ship_class: '綾波型',
ship_class_index: 8,
ship_type: '駆逐艦',
ship_name: '曙',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 69,
ship_class: '綾波型',
ship_class_index: 9,
ship_type: '駆逐艦',
ship_name: '漣',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 70,
ship_class: '綾波型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '潮',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 71,
ship_class: '暁型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '暁',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 72,
ship_class: '暁型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '響',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 73,
ship_class: '暁型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '雷',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 74,
ship_class: '暁型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '電',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 75,
ship_class: '初春型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '初春',
variation_num: 6,
# 2017-01-12:6隻追加(初春、子日、若葉、初霜、青葉、衣笠)
implemented_at: '2017-01-12T07:00:00+09:00',
},
{
book_no: 76,
ship_class: '初春型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '子日',
variation_num: 6,
# 2017-01-12:6隻追加(初春、子日、若葉、初霜、青葉、衣笠)
implemented_at: '2017-01-12T07:00:00+09:00',
},
{
book_no: 77,
ship_class: '初春型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '若葉',
variation_num: 6,
# 2017-01-12:6隻追加(初春、子日、若葉、初霜、青葉、衣笠)
implemented_at: '2017-01-12T07:00:00+09:00',
},
{
book_no: 78,
ship_class: '初春型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '初霜',
variation_num: 6,
# 2017-01-12:6隻追加(初春、子日、若葉、初霜、青葉、衣笠)
implemented_at: '2017-01-12T07:00:00+09:00',
},
{
book_no: 79,
ship_class: '白露型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '白露',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 80,
ship_class: '白露型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '時雨',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 81,
ship_class: '白露型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '村雨',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 82,
ship_class: '白露型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '夕立',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 83,
ship_class: '白露型',
ship_class_index: 6,
ship_type: '駆逐艦',
ship_name: '五月雨',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 84,
ship_class: '白露型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '涼風',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 85,
ship_class: '朝潮型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '朝潮',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 86,
ship_class: '朝潮型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '大潮',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 87,
ship_class: '朝潮型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '満潮',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 88,
ship_class: '朝潮型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '荒潮',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 89,
ship_class: '朝潮型',
ship_class_index: 9,
ship_type: '駆逐艦',
ship_name: '霰',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 90,
ship_class: '朝潮型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '霞',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 91,
ship_class: '陽炎型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '陽炎',
variation_num: 6,
# 2016-07-26:3隻追加(陽炎、不知火、黒潮)
implemented_at: '2016-07-26T07:00:00+09:00',
},
{
book_no: 92,
ship_class: '陽炎型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '不知火',
variation_num: 6,
# 2016-07-26:3隻追加(陽炎、不知火、黒潮)
implemented_at: '2016-07-26T07:00:00+09:00',
},
{
book_no: 93,
ship_class: '陽炎型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '黒潮',
variation_num: 6,
# 2016-07-26:3隻追加(陽炎、不知火、黒潮)
implemented_at: '2016-07-26T07:00:00+09:00',
},
{
book_no: 94,
ship_class: '祥鳳型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '祥鳳',
# 最終的には6になるが、初回実装時はノーマルのみ
# variation_num: 6,
variation_num: 3,
# 2016-10-27:4隻追加(翔鶴、瑞鶴、瑞鳳、祥鳳のノーマルのみ)
implemented_at: '2016-10-27T07:00:00+09:00',
},
{
book_no: 95,
ship_class: '千歳型',
ship_class_index: 1,
ship_type: '水上機母艦',
ship_name: '千歳改',
variation_num: 3,
remodel_level: 1,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 96,
ship_class: '千歳型',
ship_class_index: 2,
ship_type: '水上機母艦',
ship_name: '千代田改',
variation_num: 3,
remodel_level: 1,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 97,
ship_class: '球磨型',
ship_class_index: 4,
ship_type: '重雷装巡洋艦',
ship_name: '大井改',
variation_num: 3,
remodel_level: 1,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 98,
ship_class: '球磨型',
ship_class_index: 3,
ship_type: '重雷装巡洋艦',
ship_name: '北上改',
variation_num: 3,
remodel_level: 1,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 99,
ship_class: '千歳型',
ship_class_index: 1,
ship_type: '水上機母艦',
ship_name: '千歳甲',
variation_num: 3,
remodel_level: 2,
# 2017-03-23:5隻追加(卯月、大井改二、北上改二、千歳甲、千代田甲)
implemented_at: '2017-03-23T07:00:00+09:00',
},
{
book_no: 100,
ship_class: '千歳型',
ship_class_index: 2,
ship_type: '水上機母艦',
ship_name: '千代田甲',
variation_num: 3,
remodel_level: 2,
# 2017-03-23:5隻追加(卯月、大井改二、北上改二、千歳甲、千代田甲)
implemented_at: '2017-03-23T07:00:00+09:00',
},
{
book_no: 101,
ship_class: '最上型',
ship_class_index: 1,
ship_type: '航空巡洋艦',
ship_name: '最上改',
variation_num: 3,
remodel_level: 1,
# 2016-09-15:4隻追加(最上、三隈、鈴谷、熊野)
implemented_at: '2016-09-15T07:00:00+09:00',
},
{
book_no: 102,
ship_class: '伊勢型',
ship_class_index: 1,
ship_type: '航空戦艦',
ship_name: '伊勢改',
variation_num: 3,
remodel_level: 1,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 103,
ship_class: '伊勢型',
ship_class_index: 2,
ship_type: '航空戦艦',
ship_name: '日向改',
variation_num: 3,
remodel_level: 1,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 104,
ship_class: '千歳型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '千歳航',
variation_num: 3,
},
{
book_no: 105,
ship_class: '千歳型',
ship_class_index: 2,
ship_type: '軽空母',
ship_name: '千代田航',
variation_num: 3,
},
{
book_no: 106,
ship_class: '翔鶴型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '翔鶴',
# 最終的には6になるが、初回実装時はノーマルのみ
# variation_num: 6,
variation_num: 3,
# 2016-10-27:4隻追加(翔鶴、瑞鶴、瑞鳳、祥鳳のノーマルのみ)
implemented_at: '2016-10-27T07:00:00+09:00',
},
{
book_no: 107,
ship_class: '翔鶴型',
ship_class_index: 2,
ship_type: '正規空母',
ship_name: '瑞鶴',
variation_num: 3,
# 2016-10-27:4隻追加(翔鶴、瑞鶴、瑞鳳、祥鳳のノーマルのみ)
implemented_at: '2016-10-27T07:00:00+09:00',
},
{
book_no: 108,
ship_class: '翔鶴型',
ship_class_index: 2,
ship_type: '正規空母',
ship_name: '瑞鶴改',
variation_num: 3,
remodel_level: 1,
# 2017-02-07:翔鶴、瑞鶴、瑞鳳、祥鳳の「改」追加
implemented_at: '2017-02-07T07:00:00+09:00',
},
{
book_no: 109,
ship_class: '長良型',
ship_class_index: 5,
ship_type: '軽巡洋艦',
ship_name: '鬼怒',
variation_num: 6,
# 2016-12-15:3隻追加(鬼怒、阿武隈、夕張)
implemented_at: '2016-12-15T07:00:00+09:00',
},
{
book_no: 110,
ship_class: '長良型',
ship_class_index: 6,
ship_type: '軽巡洋艦',
ship_name: '阿武隈',
variation_num: 6,
# 2016-12-15:3隻追加(鬼怒、阿武隈、夕張)
implemented_at: '2016-12-15T07:00:00+09:00',
},
{
book_no: 111,
ship_class: '夕張型',
ship_class_index: 1,
ship_type: '軽巡洋艦',
ship_name: '夕張',
variation_num: 6,
# 2016-12-15:3隻追加(鬼怒、阿武隈、夕張)
implemented_at: '2016-12-15T07:00:00+09:00',
},
{
book_no: 112,
ship_class: '祥鳳型',
ship_class_index: 2,
ship_type: '軽空母',
ship_name: '瑞鳳',
variation_num: 3,
# 2016-10-27:4隻追加(翔鶴、瑞鶴、瑞鳳、祥鳳のノーマルのみ)
implemented_at: '2016-10-27T07:00:00+09:00',
},
{
book_no: 113,
ship_class: '祥鳳型',
ship_class_index: 2,
ship_type: '軽空母',
ship_name: '瑞鳳改',
variation_num: 3,
remodel_level: 1,
# 2017-02-07:翔鶴、瑞鶴、瑞鳳、祥鳳の「改」追加
implemented_at: '2017-02-07T07:00:00+09:00',
},
{
book_no: 114,
ship_class: '球磨型',
ship_class_index: 4,
ship_type: '重雷装巡洋艦',
ship_name: '大井改二',
variation_num: 3,
remodel_level: 2,
# 2017-03-23:5隻追加(卯月、大井改二、北上改二、千歳甲、千代田甲)
implemented_at: '2017-03-23T07:00:00+09:00',
},
{
book_no: 115,
ship_class: '球磨型',
ship_class_index: 3,
ship_type: '重雷装巡洋艦',
ship_name: '北上改二',
variation_num: 3,
remodel_level: 2,
# 2017-03-23:5隻追加(卯月、大井改二、北上改二、千歳甲、千代田甲)
implemented_at: '2017-03-23T07:00:00+09:00',
},
{
book_no: 116,
ship_class: '最上型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '三隈',
variation_num: 3,
# 2016-09-15:4隻追加(最上、三隈、鈴谷、熊野)
implemented_at: '2016-09-15T07:00:00+09:00',
},
{
book_no: 117,
ship_class: '最上型',
ship_class_index: 2,
ship_type: '航空巡洋艦',
ship_name: '三隈改',
variation_num: 3,
remodel_level: 1,
# 2016-09-15:4隻追加(最上、三隈、鈴谷、熊野)
implemented_at: '2016-09-15T07:00:00+09:00',
},
{
book_no: 118,
ship_class: '陽炎型',
ship_class_index: 7,
ship_type: '駆逐艦',
ship_name: '初風',
variation_num: 6,
# 2017-02-23:4隻追加(舞風、初風、秋雲、弥生)
implemented_at: '2017-02-23T07:00:00+09:00',
},
{
book_no: 119,
ship_class: '陽炎型',
ship_class_index: 18,
ship_type: '駆逐艦',
ship_name: '舞風',
variation_num: 6,
# 2017-02-23:4隻追加(舞風、初風、秋雲、弥生)
implemented_at: '2017-02-23T07:00:00+09:00',
},
{
book_no: 120,
ship_class: '青葉型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '衣笠',
variation_num: 6,
# 2017-01-12:6隻追加(初春、子日、若葉、初霜、青葉、衣笠)
implemented_at: '2017-01-12T07:00:00+09:00',
},
{
book_no: 121,
ship_class: '千歳型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '千歳航改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 122,
ship_class: '千歳型',
ship_class_index: 2,
ship_type: '軽空母',
ship_name: '千代田航改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 123,
ship_class: '巡潜乙型',
ship_class_index: 3,
ship_type: '潜水艦',
ship_name: '伊19',
variation_num: 6,
},
{
book_no: 124,
ship_class: '最上型',
ship_class_index: 3,
ship_type: '重巡洋艦',
ship_name: '鈴谷',
variation_num: 3,
# 2016-09-15:4隻追加(最上、三隈、鈴谷、熊野)
implemented_at: '2016-09-15T07:00:00+09:00',
},
{
book_no: 125,
ship_class: '最上型',
ship_class_index: 4,
ship_type: '重巡洋艦',
ship_name: '熊野',
variation_num: 3,
# 2016-09-15:4隻追加(最上、三隈、鈴谷、熊野)
implemented_at: '2016-09-15T07:00:00+09:00',
},
{
book_no: 126,
ship_class: '海大VI型',
ship_class_index: 1,
ship_type: '潜水艦',
ship_name: '伊168',
variation_num: 6,
},
{
book_no: 127,
ship_class: '巡潜乙型改二',
ship_class_index: 3,
ship_type: '潜水艦',
ship_name: '伊58',
variation_num: 6,
},
{
book_no: 128,
ship_class: '巡潜3型',
ship_class_index: 2,
ship_type: '潜水艦',
ship_name: '伊8',
variation_num: 6,
},
{
book_no: 129,
ship_class: '最上型',
ship_class_index: 3,
ship_type: '航空巡洋艦',
ship_name: '鈴谷改',
variation_num: 3,
remodel_level: 1,
# 2016-09-15:4隻追加(最上、三隈、鈴谷、熊野)
implemented_at: '2016-09-15T07:00:00+09:00',
},
{
book_no: 130,
ship_class: '最上型',
ship_class_index: 4,
ship_type: '航空巡洋艦',
ship_name: '熊野改',
variation_num: 3,
remodel_level: 1,
# 2016-09-15:4隻追加(最上、三隈、鈴谷、熊野)
implemented_at: '2016-09-15T07:00:00+09:00',
},
{
book_no: 131,
ship_class: '大和型',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: '大和',
variation_num: 3,
# 2017-05-11:2隻追加(矢矧、大和のノーマルのみ)
implemented_at: '2017-05-11T07:00:00+09:00',
},
{
book_no: 132,
ship_class: '陽炎型',
ship_class_index: 19,
ship_type: '駆逐艦',
ship_name: '秋雲',
variation_num: 6,
# 2017-02-23:4隻追加(舞風、初風、秋雲、弥生)
implemented_at: '2017-02-23T07:00:00+09:00',
},
{
book_no: 133,
ship_class: '夕雲型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '夕雲',
variation_num: 6,
},
{
book_no: 134,
ship_class: '夕雲型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '巻雲',
variation_num: 6,
},
{
book_no: 135,
ship_class: '夕雲型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '長波',
variation_num: 6,
},
{
book_no: 136,
ship_class: '大和型',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: '大和改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 137,
ship_class: '阿賀野型',
ship_class_index: 1,
ship_type: '軽巡洋艦',
ship_name: '阿賀野',
# 最終的には6になるが、初回実装時はノーマルのみ
# variation_num: 6,
variation_num: 3,
# 2017-04-26:3隻追加(阿賀野、能代、酒匂のノーマルのみ)
implemented_at: '2017-04-26T07:00:00+09:00',
},
{
book_no: 138,
ship_class: '阿賀野型',
ship_class_index: 2,
ship_type: '軽巡洋艦',
ship_name: '能代',
# 最終的には6になるが、初回実装時はノーマルのみ
# variation_num: 6,
variation_num: 3,
# 2017-04-26:3隻追加(阿賀野、能代、酒匂のノーマルのみ)
implemented_at: '2017-04-26T07:00:00+09:00',
},
{
book_no: 139,
ship_class: '阿賀野型',
ship_class_index: 3,
ship_type: '軽巡洋艦',
ship_name: '矢矧',
# 最終的には6になるが、初回実装時はノーマルのみ
# variation_num: 6,
variation_num: 3,
# 2017-05-11:2隻追加(矢矧、大和のノーマルのみ)
implemented_at: '2017-05-11T07:00:00+09:00',
},
{
book_no: 140,
ship_class: '阿賀野型',
ship_class_index: 4,
ship_type: '軽巡洋艦',
ship_name: '酒匂',
# 最終的には6になるが、初回実装時はノーマルのみ
# variation_num: 6,
variation_num: 3,
# 2017-04-26:3隻追加(阿賀野、能代、酒匂のノーマルのみ)
implemented_at: '2017-04-26T07:00:00+09:00',
},
{
book_no: 141,
ship_class: '長良型',
ship_class_index: 2,
ship_type: '軽巡洋艦',
ship_name: '五十鈴改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 142,
ship_class: '青葉型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '衣笠改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 143,
ship_class: '大和型',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: '武蔵',
variation_num: 3,
},
{
book_no: 144,
ship_class: '白露型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '夕立改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 145,
ship_class: '白露型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '時雨改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 146,
ship_class: '球磨型',
ship_class_index: 5,
ship_type: '重雷装巡洋艦',
ship_name: '木曾改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 147,
ship_class: '暁型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: 'Верный',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 148,
ship_class: '大和型',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: '武蔵改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 149,
ship_class: '金剛型',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: '金剛改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 150,
ship_class: '金剛型',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: '比叡改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 151,
ship_class: '金剛型',
ship_class_index: 3,
ship_type: '戦艦',
ship_name: '榛名改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 152,
ship_class: '金剛型',
ship_class_index: 4,
ship_type: '戦艦',
ship_name: '霧島改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 153,
ship_class: '大鳳型',
ship_class_index: 1,
ship_type: '装甲空母',
ship_name: '大鳳',
variation_num: 3,
},
{
book_no: 154,
ship_class: '香取型',
ship_class_index: 1,
ship_type: '練習巡洋艦',
ship_name: '香取',
variation_num: 6,
},
{
book_no: 155,
ship_class: '潜特型',
ship_class_index: 2,
ship_type: '潜水空母',
ship_name: '伊401',
variation_num: 6,
},
{
book_no: 156,
ship_class: '大鳳型',
ship_class_index: 1,
ship_type: '装甲空母',
ship_name: '大鳳改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 157,
ship_class: '龍驤型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '龍驤改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 158,
ship_class: '川内型',
ship_class_index: 1,
ship_type: '軽巡洋艦',
ship_name: '川内改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 159,
ship_class: '川内型',
ship_class_index: 2,
ship_type: '軽巡洋艦',
ship_name: '神通改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 160,
ship_class: '川内型',
ship_class_index: 3,
ship_type: '軽巡洋艦',
ship_name: '那珂改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 161,
ship_class: '特種船丙型',
ship_class_index: 1,
ship_type: '揚陸艦',
ship_name: 'あきつ丸',
variation_num: 3,
},
{
book_no: 163,
ship_class: '三式潜航輸送艇',
ship_class_index: 1,
ship_type: '潜水艦',
ship_name: 'まるゆ',
variation_num: 6,
},
{
book_no: 164,
ship_class: '睦月型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '弥生',
variation_num: 6,
# 2017-02-23:4隻追加(舞風、初風、秋雲、弥生)
implemented_at: '2017-02-23T07:00:00+09:00',
},
{
book_no: 165,
ship_class: '睦月型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '卯月',
variation_num: 6,
# 2017-03-23:5隻追加(卯月、大井改二、北上改二、千歳甲、千代田甲)
implemented_at: '2017-03-23T07:00:00+09:00',
},
{
book_no: 166,
ship_class: '特種船丙型',
ship_class_index: 1,
ship_type: '揚陸艦',
ship_name: 'あきつ丸改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 167,
ship_class: '陽炎型',
ship_class_index: 12,
ship_type: '駆逐艦',
ship_name: '磯風',
variation_num: 6,
},
{
book_no: 168,
ship_class: '陽炎型',
ship_class_index: 11,
ship_type: '駆逐艦',
ship_name: '浦風',
variation_num: 6,
},
{
book_no: 169,
ship_class: '陽炎型',
ship_class_index: 14,
ship_type: '駆逐艦',
ship_name: '谷風',
variation_num: 6,
},
{
book_no: 170,
ship_class: '陽炎型',
ship_class_index: 13,
ship_type: '駆逐艦',
ship_name: '浜風',
variation_num: 6,
},
{
book_no: 171,
ship_class: 'Bismarck級',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: 'Bismarck',
variation_num: 3,
},
{
book_no: 172,
ship_class: 'Bismarck級',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: 'Bismarck改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 173,
ship_class: 'Bismarck級',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: 'Bismarck zwei',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 174,
ship_class: 'Z1型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: 'Z1',
variation_num: 6,
},
{
book_no: 175,
ship_class: 'Z1型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: 'Z3',
variation_num: 6,
},
{
book_no: 176,
ship_class: 'Admiral Hipper級',
ship_class_index: 3,
ship_type: '重巡洋艦',
ship_name: 'Prinz Eugen',
variation_num: 3,
},
{
book_no: 177,
ship_class: 'Admiral Hipper級',
ship_class_index: 3,
ship_type: '重巡洋艦',
ship_name: 'Prinz Eugen改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 178,
ship_class: 'Bismarck級',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: 'Bismarck drei',
variation_num: 3,
remodel_level: 3,
},
{
book_no: 179,
ship_class: 'Z1型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: 'Z1 zwei',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 180,
ship_class: 'Z1型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: 'Z3 zwei',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 181,
ship_class: '陽炎型',
ship_class_index: 9,
ship_type: '駆逐艦',
ship_name: '天津風',
variation_num: 6,
},
{
book_no: 182,
ship_class: '明石型',
ship_class_index: 1,
ship_type: '工作艦',
ship_name: '明石',
variation_num: 3,
},
{
book_no: 183,
ship_class: '大淀型',
ship_class_index: 1,
ship_type: '軽巡洋艦',
ship_name: '大淀',
variation_num: 6,
},
{
book_no: 184,
ship_class: '大鯨型',
ship_class_index: 1,
ship_type: '潜水母艦',
ship_name: '大鯨',
variation_num: 3,
},
{
book_no: 185,
ship_class: '龍鳳型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '龍鳳',
variation_num: 3,
},
{
book_no: 186,
ship_class: '陽炎型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '時津風',
variation_num: 6,
},
{
book_no: 187,
ship_class: '明石型',
ship_class_index: 1,
ship_type: '工作艦',
ship_name: '明石改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 188,
ship_class: '利根型',
ship_class_index: 1,
ship_type: '航空巡洋艦',
ship_name: '利根改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 189,
ship_class: '利根型',
ship_class_index: 2,
ship_type: '航空巡洋艦',
ship_name: '筑摩改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 190,
ship_class: '龍鳳型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '龍鳳改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 191,
ship_class: '妙高型',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: '妙高改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 192,
ship_class: '妙高型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '那智改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 193,
ship_class: '妙高型',
ship_class_index: 3,
ship_type: '重巡洋艦',
ship_name: '足柄改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 194,
ship_class: '妙高型',
ship_class_index: 4,
ship_type: '重巡洋艦',
ship_name: '羽黒改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 195,
ship_class: '綾波型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '綾波改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 196,
ship_class: '飛龍型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '飛龍改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 197,
ship_class: '蒼龍型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '蒼龍改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 199,
ship_class: '朝潮型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '大潮改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 200,
ship_class: '長良型',
ship_class_index: 6,
ship_type: '軽巡洋艦',
ship_name: '阿武隈改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 201,
ship_class: '雲龍型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '雲龍',
variation_num: 3,
},
{
book_no: 202,
ship_class: '雲龍型',
ship_class_index: 2,
ship_type: '正規空母',
ship_name: '天城',
variation_num: 3,
},
{
book_no: 203,
ship_class: '雲龍型',
ship_class_index: 3,
ship_type: '正規空母',
ship_name: '葛城',
variation_num: 3,
},
{
book_no: 204,
ship_class: '初春型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '初春改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 205,
ship_class: '白露型',
ship_class_index: 5,
ship_type: '駆逐艦',
ship_name: '春雨',
variation_num: 6,
},
{
book_no: 206,
ship_class: '雲龍型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '雲龍改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 207,
ship_class: '綾波型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '潮改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 208,
ship_class: '飛鷹型',
ship_class_index: 2,
ship_type: '軽空母',
ship_name: '隼鷹改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 209,
ship_class: '夕雲型',
ship_class_index: 17,
ship_type: '駆逐艦',
ship_name: '早霜',
variation_num: 6,
},
{
book_no: 210,
ship_class: '夕雲型',
ship_class_index: 19,
ship_type: '駆逐艦',
ship_name: '清霜',
variation_num: 6,
},
{
book_no: 211,
ship_class: '扶桑型',
ship_class_index: 1,
ship_type: '航空戦艦',
ship_name: '扶桑改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 212,
ship_class: '扶桑型',
ship_class_index: 2,
ship_type: '航空戦艦',
ship_name: '山城改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 213,
ship_class: '朝潮型',
ship_class_index: 5,
ship_type: '駆逐艦',
ship_name: '朝雲',
variation_num: 6,
},
{
book_no: 214,
ship_class: '朝潮型',
ship_class_index: 6,
ship_type: '駆逐艦',
ship_name: '山雲',
variation_num: 6,
},
{
book_no: 215,
ship_class: '陽炎型',
ship_class_index: 15,
ship_type: '駆逐艦',
ship_name: '野分',
variation_num: 6,
},
{
book_no: 216,
ship_class: '古鷹型',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: '古鷹改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 217,
ship_class: '古鷹型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '加古改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 218,
ship_class: '睦月型',
ship_class_index: 5,
ship_type: '駆逐艦',
ship_name: '皐月改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 219,
ship_class: '初春型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '初霜改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 220,
ship_class: '吹雪型',
ship_class_index: 5,
ship_type: '駆逐艦',
ship_name: '叢雲改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 221,
ship_class: '秋月型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '秋月',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 222,
ship_class: '秋月型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '照月',
variation_num: 6,
},
{
book_no: 223,
ship_class: '秋月型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '初月',
variation_num: 6,
},
{
book_no: 224,
ship_class: '夕雲型',
ship_class_index: 6,
ship_type: '駆逐艦',
ship_name: '高波',
variation_num: 6,
},
{
book_no: 225,
ship_class: '夕雲型',
ship_class_index: 16,
ship_type: '駆逐艦',
ship_name: '朝霜',
variation_num: 6,
},
{
book_no: 226,
ship_class: '吹雪型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '吹雪改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 227,
ship_class: '高雄型',
ship_class_index: 4,
ship_type: '重巡洋艦',
ship_name: '鳥海改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 228,
ship_class: '高雄型',
ship_class_index: 3,
ship_type: '重巡洋艦',
ship_name: '摩耶改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 229,
ship_class: '雲龍型',
ship_class_index: 2,
ship_type: '正規空母',
ship_name: '天城改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 230,
ship_class: '雲龍型',
ship_class_index: 3,
ship_type: '正規空母',
ship_name: '葛城改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 231,
ship_class: 'UボートIXC型',
ship_class_index: 1,
ship_type: '潜水艦',
ship_name: 'U-511',
variation_num: 6,
},
{
book_no: 232,
ship_class: 'Graf Zeppelin級',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: 'Graf Zeppelin',
variation_num: 6,
},
{
book_no: 233,
ship_class: 'Lexington級',
ship_class_index: 2,
ship_type: '正規空母',
ship_name: 'Saratoga',
variation_num: 3,
},
{
book_no: 234,
ship_class: '睦月型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '睦月改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 235,
ship_class: '睦月型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '如月改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 236,
ship_class: '呂号潜水艦',
ship_class_index: 1,
ship_type: '潜水艦',
ship_name: '呂500',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 237,
ship_class: '暁型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '暁改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 238,
ship_class: 'Lexington級',
ship_class_index: 2,
ship_type: '正規空母',
ship_name: 'Saratoga改',
variation_num: 3,
},
{
book_no: 239,
ship_class: 'Queen Elizabeth級',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: 'Warspite',
variation_num: 6,
},
{
book_no: 240,
ship_class: 'Iowa級',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: 'Iowa',
variation_num: 6,
},
{
book_no: 241,
ship_class: 'V.Veneto級',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: 'Littorio',
variation_num: 3,
},
{
book_no: 242,
ship_class: 'V.Veneto級',
ship_class_index: 4,
ship_type: '戦艦',
ship_name: 'Roma',
variation_num: 3,
},
{
book_no: 243,
ship_class: 'Maestrale級',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: 'Libeccio',
variation_num: 6,
},
{
book_no: 244,
ship_class: 'Aquila級',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: 'Aquila',
variation_num: 6,
},
{
book_no: 245,
ship_class: '秋津洲型',
ship_class_index: 1,
ship_type: '水上機母艦',
ship_name: '秋津洲',
variation_num: 3,
},
{
book_no: 246,
ship_class: 'V.Veneto級',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: 'Italia',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 247,
ship_class: 'V.Veneto級',
ship_class_index: 4,
ship_type: '戦艦',
ship_name: 'Roma改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 248,
ship_class: 'Zara級',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: 'Zara',
variation_num: 6,
},
{
book_no: 249,
ship_class: 'Zara級',
ship_class_index: 3,
ship_type: '重巡洋艦',
ship_name: 'Pola',
variation_num: 6,
},
{
book_no: 250,
ship_class: '秋津洲型',
ship_class_index: 1,
ship_type: '水上機母艦',
ship_name: '秋津洲改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 251,
ship_class: '瑞穂型',
ship_class_index: 1,
ship_type: '水上機母艦',
ship_name: '瑞穂',
variation_num: 6,
},
{
book_no: 252,
ship_class: '夕雲型',
ship_class_index: 14,
ship_type: '駆逐艦',
ship_name: '沖波',
variation_num: 6,
},
{
book_no: 253,
ship_class: '夕雲型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '風雲',
variation_num: 6,
},
{
book_no: 254,
ship_class: '陽炎型',
ship_class_index: 16,
ship_type: '駆逐艦',
ship_name: '嵐',
variation_num: 6,
},
{
book_no: 255,
ship_class: '陽炎型',
ship_class_index: 17,
ship_type: '駆逐艦',
ship_name: '萩風',
variation_num: 6,
},
{
book_no: 256,
ship_class: '陽炎型',
ship_class_index: 14,
ship_type: '駆逐艦',
ship_name: '親潮',
variation_num: 6,
},
{
book_no: 257,
ship_class: '白露型',
ship_class_index: 8,
ship_type: '駆逐艦',
ship_name: '山風',
variation_num: 6,
},
{
book_no: 258,
ship_class: '白露型',
ship_class_index: 7,
ship_type: '駆逐艦',
ship_name: '海風',
variation_num: 6,
},
{
book_no: 259,
ship_class: '白露型',
ship_class_index: 9,
ship_type: '駆逐艦',
ship_name: '江風',
variation_num: 6,
},
{
book_no: 260,
ship_class: '改風早型',
ship_class_index: 1,
ship_type: '補給艦',
ship_name: '速吸',
variation_num: 6,
},
{
book_no: 261,
ship_class: '翔鶴型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '翔鶴改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 262,
ship_class: '翔鶴型',
ship_class_index: 2,
ship_type: '正規空母',
ship_name: '瑞鶴改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 263,
ship_class: '朝潮型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '朝潮改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 264,
ship_class: '朝潮型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '霞改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 265,
ship_class: '香取型',
ship_class_index: 2,
ship_type: '練習巡洋艦',
ship_name: '鹿島',
variation_num: 6,
},
{
book_no: 266,
ship_class: '翔鶴型',
ship_class_index: 1,
ship_type: '装甲空母',
ship_name: '翔鶴改二甲',
variation_num: 3,
remodel_level: 3,
},
{
book_no: 267,
ship_class: '翔鶴型',
ship_class_index: 2,
ship_type: '装甲空母',
ship_name: '瑞鶴改二甲',
variation_num: 3,
remodel_level: 3,
},
{
book_no: 268,
ship_class: '朝潮型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '朝潮改二丁',
variation_num: 3,
remodel_level: 3,
},
{
book_no: 269,
ship_class: '白露型',
ship_class_index: 9,
ship_type: '駆逐艦',
ship_name: '江風改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 270,
ship_class: '朝潮型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '霞改二乙',
variation_num: 3,
remodel_level: 3,
},
{
book_no: 271,
ship_class: '神風型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '神風',
variation_num: 3,
},
{
book_no: 272,
ship_class: '神風型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '朝風',
variation_num: 6,
},
{
book_no: 273,
ship_class: '神風型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '春風',
variation_num: 6,
},
{
book_no: 276,
ship_class: '神風型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '神風改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 281,
ship_class: '睦月型',
ship_class_index: 6,
ship_type: '駆逐艦',
ship_name: '水無月',
variation_num: 6,
},
{
book_no: 283,
ship_class: '巡潜乙型',
ship_class_index: 7,
ship_type: '潜水艦',
ship_name: '伊26',
variation_num: 6,
},
{
book_no: 286,
ship_class: '吹雪型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '浦波',
variation_num: 6,
},
{
book_no: 287,
ship_class: '長良型',
ship_class_index: 5,
ship_type: '軽巡洋艦',
ship_name: '鬼怒改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 291,
ship_class: 'C.Teste級',
ship_class_index: 1,
ship_type: '水上機母艦',
ship_name: 'Commandant Teste',
variation_num: 6,
},
]
ship_masters.each do |ship_master|
ShipMaster.where(book_no: ship_master[:book_no]).first_or_initialize.update(ship_master)
end
updated_ship_masters = [
{
book_no: 94,
ship_class: '祥鳳型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '祥鳳',
variation_num: 6,
# 2017-02-07:翔鶴、瑞鶴、瑞鳳、祥鳳の「改」追加
implemented_at: '2017-02-07T07:00:00+09:00',
},
{
book_no: 106,
ship_class: '翔鶴型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '翔鶴',
variation_num: 6,
# 2017-02-07:翔鶴、瑞鶴、瑞鳳、祥鳳の「改」追加
implemented_at: '2017-02-07T07:00:00+09:00',
},
]
updated_ship_masters.each do |ship_master|
UpdatedShipMaster.where(book_no: ship_master[:book_no]).first_or_initialize.update(ship_master)
end
special_ship_masters = [
{
# 日向改
book_no: 103,
card_index: 3,
remodel_level: 1,
rarity: 1,
# 第2回イベントの前段作戦開始日
implemented_at: '2017-04-26T07:00:00+09:00',
},
{
# 伊勢改
book_no: 102,
card_index: 3,
remodel_level: 1,
rarity: 1,
# 第2回イベントの前段作戦開始日
implemented_at: '2017-05-11T07:00:00+09:00',
}
]
special_ship_masters.each do |ship_master|
SpecialShipMaster.where(book_no: ship_master[:book_no], card_index: ship_master[:card_index]).first_or_initialize.update(ship_master)
end
event_masters = [
{
event_no: 1,
area_id: 1000,
event_name: '敵艦隊前線泊地殴り込み',
no_of_periods: 1,
started_at: '2016-10-27T07:00:00+09:00',
ended_at: '2016-11-25T23:59:59+09:00',
},
{
event_no: 2,
area_id: 1001,
event_name: '南方海域強襲偵察!',
no_of_periods: 2,
period1_started_at: '2017-05-11T07:00:00+09:00',
started_at: '2017-04-26T07:00:00+09:00',
ended_at: '2017-05-31T23:59:59+09:00',
},
]
event_masters.each do |event_master|
EventMaster.where(event_no: event_master[:event_no]).first_or_initialize.update(event_master)
end
event_stage_masters = [
{
event_no: 1,
level: 'HEI',
stage_no: 1,
display_stage_no: 1,
stage_mission_name: '前哨戦',
ene_military_gauge_val: 1000,
},
{
event_no: 1,
level: 'HEI',
stage_no: 2,
display_stage_no: 2,
stage_mission_name: '警戒線突破',
ene_military_gauge_val: 1000,
},
{
event_no: 1,
level: 'HEI',
stage_no: 3,
display_stage_no: 3,
stage_mission_name: '湾内突入!',
ene_military_gauge_val: 1200,
},
{
event_no: 1,
level: 'HEI',
stage_no: 4,
display_stage_no: 4,
stage_mission_name: '敵泊地強襲!',
ene_military_gauge_val: 2000,
},
{
event_no: 1,
level: 'HEI',
stage_no: 5,
display_stage_no: 0,
stage_mission_name: '掃討戦',
ene_military_gauge_val: 0,
},
{
event_no: 1,
level: 'OTU',
stage_no: 1,
display_stage_no: 1,
stage_mission_name: '前哨戦',
ene_military_gauge_val: 1500,
},
{
event_no: 1,
level: 'OTU',
stage_no: 2,
display_stage_no: 2,
stage_mission_name: '警戒線突破',
ene_military_gauge_val: 1500,
},
{
event_no: 1,
level: 'OTU',
stage_no: 3,
display_stage_no: 3,
stage_mission_name: '湾内突入!',
ene_military_gauge_val: 1800,
},
{
event_no: 1,
level: 'OTU',
stage_no: 4,
display_stage_no: 4,
stage_mission_name: '敵泊地強襲!',
ene_military_gauge_val: 2500,
},
{
event_no: 1,
level: 'OTU',
stage_no: 5,
display_stage_no: 0,
stage_mission_name: '掃討戦',
ene_military_gauge_val: 0,
},
# 第2回イベント
{
event_no: 2,
level: 'HEI',
period: 0,
stage_no: 1,
display_stage_no: 1,
stage_mission_name: '南方海域へ進出せよ!',
ene_military_gauge_val: 2000,
},
{
event_no: 2,
level: 'HEI',
period: 0,
stage_no: 2,
display_stage_no: 2,
stage_mission_name: '警戒線を突破せよ!',
ene_military_gauge_val: 2700,
},
{
event_no: 2,
level: 'HEI',
period: 0,
stage_no: 3,
display_stage_no: 3,
stage_mission_name: '敵洋上戦力を排除せよ!',
ene_military_gauge_val: 2800,
},
{
event_no: 2,
level: 'HEI',
period: 0,
stage_no: 4,
display_stage_no: 0,
stage_mission_name: '敵洋上戦力を排除せよ!',
ene_military_gauge_val: 0,
},
{
event_no: 2,
level: 'HEI',
period: 1,
stage_no: 1,
display_stage_no: 4,
stage_mission_name: '敵情偵察を開始せよ!',
ene_military_gauge_val: 2600,
},
{
event_no: 2,
level: 'HEI',
period: 1,
stage_no: 2,
display_stage_no: 5,
stage_mission_name: '敵集結地を強襲せよ!',
ene_military_gauge_val: 3400,
},
{
event_no: 2,
level: 'HEI',
period: 1,
stage_no: 3,
display_stage_no: 6,
stage_mission_name: '敵大型超弩級戦艦を叩け!',
ene_military_gauge_val: 3600,
},
{
event_no: 2,
level: 'HEI',
period: 1,
stage_no: 4,
display_stage_no: 0,
stage_mission_name: '敵大型超弩級戦艦を叩け!',
ene_military_gauge_val: 0,
},
{
event_no: 2,
level: 'OTU',
period: 0,
stage_no: 1,
display_stage_no: 1,
stage_mission_name: '南方海域へ進出せよ!',
ene_military_gauge_val: 1800,
},
{
event_no: 2,
level: 'OTU',
period: 0,
stage_no: 2,
display_stage_no: 2,
stage_mission_name: '警戒線を突破せよ!',
ene_military_gauge_val: 2500,
},
{
event_no: 2,
level: 'OTU',
period: 0,
stage_no: 3,
display_stage_no: 3,
stage_mission_name: '敵洋上戦力を排除せよ!',
ene_military_gauge_val: 2600,
},
{
event_no: 2,
level: 'OTU',
period: 0,
stage_no: 4,
display_stage_no: 0,
stage_mission_name: '敵洋上戦力を排除せよ!',
ene_military_gauge_val: 0,
},
{
event_no: 2,
level: 'OTU',
period: 1,
stage_no: 1,
display_stage_no: 4,
stage_mission_name: '敵情偵察を開始せよ!',
ene_military_gauge_val: 2500,
},
{
event_no: 2,
level: 'OTU',
period: 1,
stage_no: 2,
display_stage_no: 5,
stage_mission_name: '敵集結地を強襲せよ!',
ene_military_gauge_val: 3500,
},
{
event_no: 2,
level: 'OTU',
period: 1,
stage_no: 3,
display_stage_no: 6,
stage_mission_name: '敵大型超弩級戦艦を叩け!',
ene_military_gauge_val: 3600,
},
{
event_no: 2,
level: 'OTU',
period: 1,
stage_no: 4,
display_stage_no: 0,
stage_mission_name: '敵大型超弩級戦艦を叩け!',
ene_military_gauge_val: 0,
},
{
event_no: 2,
level: 'KOU',
period: 0,
stage_no: 1,
display_stage_no: 1,
stage_mission_name: '南方海域へ進出せよ!',
ene_military_gauge_val: 2000,
},
{
event_no: 2,
level: 'KOU',
period: 0,
stage_no: 2,
display_stage_no: 2,
stage_mission_name: '警戒線を突破せよ!',
ene_military_gauge_val: 2700,
},
{
event_no: 2,
level: 'KOU',
period: 0,
stage_no: 3,
display_stage_no: 3,
stage_mission_name: '敵洋上戦力を排除せよ!',
ene_military_gauge_val: 2800,
},
{
event_no: 2,
level: 'KOU',
period: 0,
stage_no: 4,
display_stage_no: 0,
stage_mission_name: '敵洋上戦力を排除せよ!',
ene_military_gauge_val: 0,
},
{
event_no: 2,
level: 'KOU',
period: 1,
stage_no: 1,
display_stage_no: 4,
stage_mission_name: '敵情偵察を開始せよ!',
ene_military_gauge_val: 2700,
},
{
event_no: 2,
level: 'KOU',
period: 1,
stage_no: 2,
display_stage_no: 5,
stage_mission_name: '敵集結地を強襲せよ!',
ene_military_gauge_val: 3700,
},
{
event_no: 2,
level: 'KOU',
period: 1,
stage_no: 3,
display_stage_no: 6,
stage_mission_name: '敵大型超弩級戦艦を叩け!',
ene_military_gauge_val: 3800,
},
{
event_no: 2,
level: 'KOU',
period: 1,
stage_no: 4,
display_stage_no: 0,
stage_mission_name: '敵大型超弩級戦艦を叩け!',
ene_military_gauge_val: 0,
},
]
event_stage_masters.each do |master|
EventStageMaster.where(event_no: master[:event_no], level: master[:level], period: master[:period], stage_no: master[:stage_no]).first_or_initialize.update(master)
end
6/8追加の新艦娘を登録
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
ship_masters = [
{
book_no: 1,
ship_class: '長門型',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: '長門',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 2,
ship_class: '長門型',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: '陸奥',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 3,
ship_class: '伊勢型',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: '伊勢',
variation_num: 3,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 4,
ship_class: '伊勢型',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: '日向',
variation_num: 3,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 5,
ship_class: '陽炎型',
ship_class_index: 8,
ship_type: '駆逐艦',
ship_name: '雪風',
variation_num: 6,
# 2016-05-26:5隻追加(雪風、睦月、如月、古鷹、加古)
implemented_at: '2016-05-26T07:00:00+09:00',
},
{
book_no: 6,
ship_class: '赤城型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '赤城',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 7,
ship_class: '加賀型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '加賀',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 8,
ship_class: '蒼龍型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '蒼龍',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 9,
ship_class: '飛龍型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '飛龍',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 10,
ship_class: '島風型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '島風',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 11,
ship_class: '吹雪型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '吹雪',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 12,
ship_class: '吹雪型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '白雪',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 13,
ship_class: '吹雪型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '初雪',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 14,
ship_class: '吹雪型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '深雪',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 15,
ship_class: '吹雪型',
ship_class_index: 5,
ship_type: '駆逐艦',
ship_name: '叢雲',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 16,
ship_class: '吹雪型',
ship_class_index: 9,
ship_type: '駆逐艦',
ship_name: '磯波',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 17,
ship_class: '綾波型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '綾波',
variation_num: 6,
# 2016-06-30:5隻追加(綾波、敷波、那智、足柄、羽黒)
implemented_at: '2016-06-30T07:00:00+09:00',
},
{
book_no: 18,
ship_class: '綾波型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '敷波',
variation_num: 6,
# 2016-06-30:5隻追加(綾波、敷波、那智、足柄、羽黒)
implemented_at: '2016-06-30T07:00:00+09:00',
},
{
book_no: 19,
ship_class: '球磨型',
ship_class_index: 4,
ship_type: '軽巡洋艦',
ship_name: '大井',
variation_num: 3,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 20,
ship_class: '球磨型',
ship_class_index: 3,
ship_type: '軽巡洋艦',
ship_name: '北上',
variation_num: 3,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 21,
ship_class: '金剛型',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: '金剛',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 22,
ship_class: '金剛型',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: '比叡',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 23,
ship_class: '金剛型',
ship_class_index: 3,
ship_type: '戦艦',
ship_name: '榛名',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 24,
ship_class: '金剛型',
ship_class_index: 4,
ship_type: '戦艦',
ship_name: '霧島',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 25,
ship_class: '鳳翔型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '鳳翔',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 26,
ship_class: '扶桑型',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: '扶桑',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 27,
ship_class: '扶桑型',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: '山城',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 28,
ship_class: '天龍型',
ship_class_index: 1,
ship_type: '軽巡洋艦',
ship_name: '天龍',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 29,
ship_class: '天龍型',
ship_class_index: 2,
ship_type: '軽巡洋艦',
ship_name: '龍田',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 30,
ship_class: '龍驤型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '龍驤',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 31,
ship_class: '睦月型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '睦月',
variation_num: 6,
# 2016-05-26:5隻追加(雪風、睦月、如月、古鷹、加古)
implemented_at: '2016-05-26T07:00:00+09:00',
},
{
book_no: 32,
ship_class: '睦月型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '如月',
variation_num: 6,
# 2016-05-26:5隻追加(雪風、睦月、如月、古鷹、加古)
implemented_at: '2016-05-26T07:00:00+09:00',
},
{
book_no: 33,
ship_class: '睦月型',
ship_class_index: 5,
ship_type: '駆逐艦',
ship_name: '皐月',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 34,
ship_class: '睦月型',
ship_class_index: 7,
ship_type: '駆逐艦',
ship_name: '文月',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 35,
ship_class: '睦月型',
ship_class_index: 8,
ship_type: '駆逐艦',
ship_name: '長月',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 36,
ship_class: '睦月型',
ship_class_index: 9,
ship_type: '駆逐艦',
ship_name: '菊月',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 37,
ship_class: '睦月型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '三日月',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 38,
ship_class: '睦月型',
ship_class_index: 11,
ship_type: '駆逐艦',
ship_name: '望月',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 39,
ship_class: '球磨型',
ship_class_index: 1,
ship_type: '軽巡洋艦',
ship_name: '球磨',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 40,
ship_class: '球磨型',
ship_class_index: 2,
ship_type: '軽巡洋艦',
ship_name: '多摩',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 41,
ship_class: '球磨型',
ship_class_index: 5,
ship_type: '軽巡洋艦',
ship_name: '木曾',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 42,
ship_class: '長良型',
ship_class_index: 1,
ship_type: '軽巡洋艦',
ship_name: '長良',
variation_num: 6,
# 2016-08-23:4隻追加(長良、五十鈴、名取、由良)
implemented_at: '2016-08-23T07:00:00+09:00',
},
{
book_no: 43,
ship_class: '長良型',
ship_class_index: 2,
ship_type: '軽巡洋艦',
ship_name: '五十鈴',
variation_num: 6,
# 2016-08-23:4隻追加(長良、五十鈴、名取、由良)
implemented_at: '2016-08-23T07:00:00+09:00',
},
{
book_no: 44,
ship_class: '長良型',
ship_class_index: 3,
ship_type: '軽巡洋艦',
ship_name: '名取',
variation_num: 6,
# 2016-08-23:4隻追加(長良、五十鈴、名取、由良)
implemented_at: '2016-08-23T07:00:00+09:00',
},
{
book_no: 45,
ship_class: '長良型',
ship_class_index: 4,
ship_type: '軽巡洋艦',
ship_name: '由良',
variation_num: 6,
# 2016-08-23:4隻追加(長良、五十鈴、名取、由良)
implemented_at: '2016-08-23T07:00:00+09:00',
},
{
book_no: 46,
ship_class: '川内型',
ship_class_index: 1,
ship_type: '軽巡洋艦',
ship_name: '川内',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 47,
ship_class: '川内型',
ship_class_index: 2,
ship_type: '軽巡洋艦',
ship_name: '神通',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 48,
ship_class: '川内型',
ship_class_index: 3,
ship_type: '軽巡洋艦',
ship_name: '那珂',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 49,
ship_class: '千歳型',
ship_class_index: 1,
ship_type: '水上機母艦',
ship_name: '千歳',
variation_num: 3,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 50,
ship_class: '千歳型',
ship_class_index: 2,
ship_type: '水上機母艦',
ship_name: '千代田',
variation_num: 3,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 51,
ship_class: '最上型',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: '最上',
variation_num: 3,
# 2016-09-15:4隻追加(最上、三隈、鈴谷、熊野)
implemented_at: '2016-09-15T07:00:00+09:00',
},
{
book_no: 52,
ship_class: '古鷹型',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: '古鷹',
variation_num: 6,
# 2016-05-26:5隻追加(雪風、睦月、如月、古鷹、加古)
implemented_at: '2016-05-26T07:00:00+09:00',
},
{
book_no: 53,
ship_class: '古鷹型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '加古',
variation_num: 6,
# 2016-05-26:5隻追加(雪風、睦月、如月、古鷹、加古)
implemented_at: '2016-05-26T07:00:00+09:00',
},
{
book_no: 54,
ship_class: '青葉型',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: '青葉',
variation_num: 6,
# 2017-01-12:6隻追加(初春、子日、若葉、初霜、青葉、衣笠)
implemented_at: '2017-01-12T07:00:00+09:00',
},
{
book_no: 55,
ship_class: '妙高型',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: '妙高',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 56,
ship_class: '妙高型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '那智',
variation_num: 6,
# 2016-06-30:5隻追加(綾波、敷波、那智、足柄、羽黒)
implemented_at: '2016-06-30T07:00:00+09:00',
},
{
book_no: 57,
ship_class: '妙高型',
ship_class_index: 3,
ship_type: '重巡洋艦',
ship_name: '足柄',
variation_num: 6,
# 2016-06-30:5隻追加(綾波、敷波、那智、足柄、羽黒)
implemented_at: '2016-06-30T07:00:00+09:00',
},
{
book_no: 58,
ship_class: '妙高型',
ship_class_index: 4,
ship_type: '重巡洋艦',
ship_name: '羽黒',
variation_num: 6,
# 2016-06-30:5隻追加(綾波、敷波、那智、足柄、羽黒)
implemented_at: '2016-06-30T07:00:00+09:00',
},
{
book_no: 59,
ship_class: '高雄型',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: '高雄',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 60,
ship_class: '高雄型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '愛宕',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 61,
ship_class: '高雄型',
ship_class_index: 3,
ship_type: '重巡洋艦',
ship_name: '摩耶',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 62,
ship_class: '高雄型',
ship_class_index: 4,
ship_type: '重巡洋艦',
ship_name: '鳥海',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 63,
ship_class: '利根型',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: '利根',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 64,
ship_class: '利根型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '筑摩',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 65,
ship_class: '飛鷹型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '飛鷹',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 66,
ship_class: '飛鷹型',
ship_class_index: 2,
ship_type: '軽空母',
ship_name: '隼鷹',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 67,
ship_class: '綾波型',
ship_class_index: 7,
ship_type: '駆逐艦',
ship_name: '朧',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 68,
ship_class: '綾波型',
ship_class_index: 8,
ship_type: '駆逐艦',
ship_name: '曙',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 69,
ship_class: '綾波型',
ship_class_index: 9,
ship_type: '駆逐艦',
ship_name: '漣',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 70,
ship_class: '綾波型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '潮',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 71,
ship_class: '暁型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '暁',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 72,
ship_class: '暁型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '響',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 73,
ship_class: '暁型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '雷',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 74,
ship_class: '暁型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '電',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 75,
ship_class: '初春型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '初春',
variation_num: 6,
# 2017-01-12:6隻追加(初春、子日、若葉、初霜、青葉、衣笠)
implemented_at: '2017-01-12T07:00:00+09:00',
},
{
book_no: 76,
ship_class: '初春型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '子日',
variation_num: 6,
# 2017-01-12:6隻追加(初春、子日、若葉、初霜、青葉、衣笠)
implemented_at: '2017-01-12T07:00:00+09:00',
},
{
book_no: 77,
ship_class: '初春型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '若葉',
variation_num: 6,
# 2017-01-12:6隻追加(初春、子日、若葉、初霜、青葉、衣笠)
implemented_at: '2017-01-12T07:00:00+09:00',
},
{
book_no: 78,
ship_class: '初春型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '初霜',
variation_num: 6,
# 2017-01-12:6隻追加(初春、子日、若葉、初霜、青葉、衣笠)
implemented_at: '2017-01-12T07:00:00+09:00',
},
{
book_no: 79,
ship_class: '白露型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '白露',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 80,
ship_class: '白露型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '時雨',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 81,
ship_class: '白露型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '村雨',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 82,
ship_class: '白露型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '夕立',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 83,
ship_class: '白露型',
ship_class_index: 6,
ship_type: '駆逐艦',
ship_name: '五月雨',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 84,
ship_class: '白露型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '涼風',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 85,
ship_class: '朝潮型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '朝潮',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 86,
ship_class: '朝潮型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '大潮',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 87,
ship_class: '朝潮型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '満潮',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 88,
ship_class: '朝潮型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '荒潮',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 89,
ship_class: '朝潮型',
ship_class_index: 9,
ship_type: '駆逐艦',
ship_name: '霰',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 90,
ship_class: '朝潮型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '霞',
variation_num: 6,
# 2016-04-28:9隻追加(長門、陸奥、白雪、初雪、深雪、磯波、涼風、霰、霞)
implemented_at: '2016-04-28T07:00:00+09:00',
},
{
book_no: 91,
ship_class: '陽炎型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '陽炎',
variation_num: 6,
# 2016-07-26:3隻追加(陽炎、不知火、黒潮)
implemented_at: '2016-07-26T07:00:00+09:00',
},
{
book_no: 92,
ship_class: '陽炎型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '不知火',
variation_num: 6,
# 2016-07-26:3隻追加(陽炎、不知火、黒潮)
implemented_at: '2016-07-26T07:00:00+09:00',
},
{
book_no: 93,
ship_class: '陽炎型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '黒潮',
variation_num: 6,
# 2016-07-26:3隻追加(陽炎、不知火、黒潮)
implemented_at: '2016-07-26T07:00:00+09:00',
},
{
book_no: 94,
ship_class: '祥鳳型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '祥鳳',
# 最終的には6になるが、初回実装時はノーマルのみ
# variation_num: 6,
variation_num: 3,
# 2016-10-27:4隻追加(翔鶴、瑞鶴、瑞鳳、祥鳳のノーマルのみ)
implemented_at: '2016-10-27T07:00:00+09:00',
},
{
book_no: 95,
ship_class: '千歳型',
ship_class_index: 1,
ship_type: '水上機母艦',
ship_name: '千歳改',
variation_num: 3,
remodel_level: 1,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 96,
ship_class: '千歳型',
ship_class_index: 2,
ship_type: '水上機母艦',
ship_name: '千代田改',
variation_num: 3,
remodel_level: 1,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 97,
ship_class: '球磨型',
ship_class_index: 4,
ship_type: '重雷装巡洋艦',
ship_name: '大井改',
variation_num: 3,
remodel_level: 1,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 98,
ship_class: '球磨型',
ship_class_index: 3,
ship_type: '重雷装巡洋艦',
ship_name: '北上改',
variation_num: 3,
remodel_level: 1,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 99,
ship_class: '千歳型',
ship_class_index: 1,
ship_type: '水上機母艦',
ship_name: '千歳甲',
variation_num: 3,
remodel_level: 2,
# 2017-03-23:5隻追加(卯月、大井改二、北上改二、千歳甲、千代田甲)
implemented_at: '2017-03-23T07:00:00+09:00',
},
{
book_no: 100,
ship_class: '千歳型',
ship_class_index: 2,
ship_type: '水上機母艦',
ship_name: '千代田甲',
variation_num: 3,
remodel_level: 2,
# 2017-03-23:5隻追加(卯月、大井改二、北上改二、千歳甲、千代田甲)
implemented_at: '2017-03-23T07:00:00+09:00',
},
{
book_no: 101,
ship_class: '最上型',
ship_class_index: 1,
ship_type: '航空巡洋艦',
ship_name: '最上改',
variation_num: 3,
remodel_level: 1,
# 2016-09-15:4隻追加(最上、三隈、鈴谷、熊野)
implemented_at: '2016-09-15T07:00:00+09:00',
},
{
book_no: 102,
ship_class: '伊勢型',
ship_class_index: 1,
ship_type: '航空戦艦',
ship_name: '伊勢改',
variation_num: 3,
remodel_level: 1,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 103,
ship_class: '伊勢型',
ship_class_index: 2,
ship_type: '航空戦艦',
ship_name: '日向改',
variation_num: 3,
remodel_level: 1,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 104,
ship_class: '千歳型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '千歳航',
variation_num: 3,
},
{
book_no: 105,
ship_class: '千歳型',
ship_class_index: 2,
ship_type: '軽空母',
ship_name: '千代田航',
variation_num: 3,
},
{
book_no: 106,
ship_class: '翔鶴型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '翔鶴',
# 最終的には6になるが、初回実装時はノーマルのみ
# variation_num: 6,
variation_num: 3,
# 2016-10-27:4隻追加(翔鶴、瑞鶴、瑞鳳、祥鳳のノーマルのみ)
implemented_at: '2016-10-27T07:00:00+09:00',
},
{
book_no: 107,
ship_class: '翔鶴型',
ship_class_index: 2,
ship_type: '正規空母',
ship_name: '瑞鶴',
variation_num: 3,
# 2016-10-27:4隻追加(翔鶴、瑞鶴、瑞鳳、祥鳳のノーマルのみ)
implemented_at: '2016-10-27T07:00:00+09:00',
},
{
book_no: 108,
ship_class: '翔鶴型',
ship_class_index: 2,
ship_type: '正規空母',
ship_name: '瑞鶴改',
variation_num: 3,
remodel_level: 1,
# 2017-02-07:翔鶴、瑞鶴、瑞鳳、祥鳳の「改」追加
implemented_at: '2017-02-07T07:00:00+09:00',
},
{
book_no: 109,
ship_class: '長良型',
ship_class_index: 5,
ship_type: '軽巡洋艦',
ship_name: '鬼怒',
variation_num: 6,
# 2016-12-15:3隻追加(鬼怒、阿武隈、夕張)
implemented_at: '2016-12-15T07:00:00+09:00',
},
{
book_no: 110,
ship_class: '長良型',
ship_class_index: 6,
ship_type: '軽巡洋艦',
ship_name: '阿武隈',
variation_num: 6,
# 2016-12-15:3隻追加(鬼怒、阿武隈、夕張)
implemented_at: '2016-12-15T07:00:00+09:00',
},
{
book_no: 111,
ship_class: '夕張型',
ship_class_index: 1,
ship_type: '軽巡洋艦',
ship_name: '夕張',
variation_num: 6,
# 2016-12-15:3隻追加(鬼怒、阿武隈、夕張)
implemented_at: '2016-12-15T07:00:00+09:00',
},
{
book_no: 112,
ship_class: '祥鳳型',
ship_class_index: 2,
ship_type: '軽空母',
ship_name: '瑞鳳',
variation_num: 3,
# 2016-10-27:4隻追加(翔鶴、瑞鶴、瑞鳳、祥鳳のノーマルのみ)
implemented_at: '2016-10-27T07:00:00+09:00',
},
{
book_no: 113,
ship_class: '祥鳳型',
ship_class_index: 2,
ship_type: '軽空母',
ship_name: '瑞鳳改',
variation_num: 3,
remodel_level: 1,
# 2017-02-07:翔鶴、瑞鶴、瑞鳳、祥鳳の「改」追加
implemented_at: '2017-02-07T07:00:00+09:00',
},
{
book_no: 114,
ship_class: '球磨型',
ship_class_index: 4,
ship_type: '重雷装巡洋艦',
ship_name: '大井改二',
variation_num: 3,
remodel_level: 2,
# 2017-03-23:5隻追加(卯月、大井改二、北上改二、千歳甲、千代田甲)
implemented_at: '2017-03-23T07:00:00+09:00',
},
{
book_no: 115,
ship_class: '球磨型',
ship_class_index: 3,
ship_type: '重雷装巡洋艦',
ship_name: '北上改二',
variation_num: 3,
remodel_level: 2,
# 2017-03-23:5隻追加(卯月、大井改二、北上改二、千歳甲、千代田甲)
implemented_at: '2017-03-23T07:00:00+09:00',
},
{
book_no: 116,
ship_class: '最上型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '三隈',
variation_num: 3,
# 2016-09-15:4隻追加(最上、三隈、鈴谷、熊野)
implemented_at: '2016-09-15T07:00:00+09:00',
},
{
book_no: 117,
ship_class: '最上型',
ship_class_index: 2,
ship_type: '航空巡洋艦',
ship_name: '三隈改',
variation_num: 3,
remodel_level: 1,
# 2016-09-15:4隻追加(最上、三隈、鈴谷、熊野)
implemented_at: '2016-09-15T07:00:00+09:00',
},
{
book_no: 118,
ship_class: '陽炎型',
ship_class_index: 7,
ship_type: '駆逐艦',
ship_name: '初風',
variation_num: 6,
# 2017-02-23:4隻追加(舞風、初風、秋雲、弥生)
implemented_at: '2017-02-23T07:00:00+09:00',
},
{
book_no: 119,
ship_class: '陽炎型',
ship_class_index: 18,
ship_type: '駆逐艦',
ship_name: '舞風',
variation_num: 6,
# 2017-02-23:4隻追加(舞風、初風、秋雲、弥生)
implemented_at: '2017-02-23T07:00:00+09:00',
},
{
book_no: 120,
ship_class: '青葉型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '衣笠',
variation_num: 6,
# 2017-01-12:6隻追加(初春、子日、若葉、初霜、青葉、衣笠)
implemented_at: '2017-01-12T07:00:00+09:00',
},
{
book_no: 121,
ship_class: '千歳型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '千歳航改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 122,
ship_class: '千歳型',
ship_class_index: 2,
ship_type: '軽空母',
ship_name: '千代田航改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 123,
ship_class: '巡潜乙型',
ship_class_index: 3,
ship_type: '潜水艦',
ship_name: '伊19',
variation_num: 6,
},
{
book_no: 124,
ship_class: '最上型',
ship_class_index: 3,
ship_type: '重巡洋艦',
ship_name: '鈴谷',
variation_num: 3,
# 2016-09-15:4隻追加(最上、三隈、鈴谷、熊野)
implemented_at: '2016-09-15T07:00:00+09:00',
},
{
book_no: 125,
ship_class: '最上型',
ship_class_index: 4,
ship_type: '重巡洋艦',
ship_name: '熊野',
variation_num: 3,
# 2016-09-15:4隻追加(最上、三隈、鈴谷、熊野)
implemented_at: '2016-09-15T07:00:00+09:00',
},
{
book_no: 126,
ship_class: '海大VI型',
ship_class_index: 1,
ship_type: '潜水艦',
ship_name: '伊168',
variation_num: 6,
},
{
book_no: 127,
ship_class: '巡潜乙型改二',
ship_class_index: 3,
ship_type: '潜水艦',
ship_name: '伊58',
variation_num: 6,
},
{
book_no: 128,
ship_class: '巡潜3型',
ship_class_index: 2,
ship_type: '潜水艦',
ship_name: '伊8',
variation_num: 6,
},
{
book_no: 129,
ship_class: '最上型',
ship_class_index: 3,
ship_type: '航空巡洋艦',
ship_name: '鈴谷改',
variation_num: 3,
remodel_level: 1,
# 2016-09-15:4隻追加(最上、三隈、鈴谷、熊野)
implemented_at: '2016-09-15T07:00:00+09:00',
},
{
book_no: 130,
ship_class: '最上型',
ship_class_index: 4,
ship_type: '航空巡洋艦',
ship_name: '熊野改',
variation_num: 3,
remodel_level: 1,
# 2016-09-15:4隻追加(最上、三隈、鈴谷、熊野)
implemented_at: '2016-09-15T07:00:00+09:00',
},
{
book_no: 131,
ship_class: '大和型',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: '大和',
variation_num: 3,
# 2017-05-11:2隻追加(矢矧、大和のノーマルのみ)
implemented_at: '2017-05-11T07:00:00+09:00',
},
{
book_no: 132,
ship_class: '陽炎型',
ship_class_index: 19,
ship_type: '駆逐艦',
ship_name: '秋雲',
variation_num: 6,
# 2017-02-23:4隻追加(舞風、初風、秋雲、弥生)
implemented_at: '2017-02-23T07:00:00+09:00',
},
{
book_no: 133,
ship_class: '夕雲型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '夕雲',
variation_num: 6,
# 2017-06-08:3隻追加(夕雲、巻雲、長波)
implemented_at: '2017-06-08T07:00:00+09:00',
},
{
book_no: 134,
ship_class: '夕雲型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '巻雲',
variation_num: 6,
# 2017-06-08:3隻追加(夕雲、巻雲、長波)
implemented_at: '2017-06-08T07:00:00+09:00',
},
{
book_no: 135,
ship_class: '夕雲型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '長波',
variation_num: 6,
# 2017-06-08:3隻追加(夕雲、巻雲、長波)
implemented_at: '2017-06-08T07:00:00+09:00',
},
{
book_no: 136,
ship_class: '大和型',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: '大和改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 137,
ship_class: '阿賀野型',
ship_class_index: 1,
ship_type: '軽巡洋艦',
ship_name: '阿賀野',
# 最終的には6になるが、初回実装時はノーマルのみ
# variation_num: 6,
variation_num: 3,
# 2017-04-26:3隻追加(阿賀野、能代、酒匂のノーマルのみ)
implemented_at: '2017-04-26T07:00:00+09:00',
},
{
book_no: 138,
ship_class: '阿賀野型',
ship_class_index: 2,
ship_type: '軽巡洋艦',
ship_name: '能代',
# 最終的には6になるが、初回実装時はノーマルのみ
# variation_num: 6,
variation_num: 3,
# 2017-04-26:3隻追加(阿賀野、能代、酒匂のノーマルのみ)
implemented_at: '2017-04-26T07:00:00+09:00',
},
{
book_no: 139,
ship_class: '阿賀野型',
ship_class_index: 3,
ship_type: '軽巡洋艦',
ship_name: '矢矧',
# 最終的には6になるが、初回実装時はノーマルのみ
# variation_num: 6,
variation_num: 3,
# 2017-05-11:2隻追加(矢矧、大和のノーマルのみ)
implemented_at: '2017-05-11T07:00:00+09:00',
},
{
book_no: 140,
ship_class: '阿賀野型',
ship_class_index: 4,
ship_type: '軽巡洋艦',
ship_name: '酒匂',
# 最終的には6になるが、初回実装時はノーマルのみ
# variation_num: 6,
variation_num: 3,
# 2017-04-26:3隻追加(阿賀野、能代、酒匂のノーマルのみ)
implemented_at: '2017-04-26T07:00:00+09:00',
},
{
book_no: 141,
ship_class: '長良型',
ship_class_index: 2,
ship_type: '軽巡洋艦',
ship_name: '五十鈴改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 142,
ship_class: '青葉型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '衣笠改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 143,
ship_class: '大和型',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: '武蔵',
variation_num: 3,
},
{
book_no: 144,
ship_class: '白露型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '夕立改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 145,
ship_class: '白露型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '時雨改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 146,
ship_class: '球磨型',
ship_class_index: 5,
ship_type: '重雷装巡洋艦',
ship_name: '木曾改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 147,
ship_class: '暁型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: 'Верный',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 148,
ship_class: '大和型',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: '武蔵改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 149,
ship_class: '金剛型',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: '金剛改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 150,
ship_class: '金剛型',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: '比叡改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 151,
ship_class: '金剛型',
ship_class_index: 3,
ship_type: '戦艦',
ship_name: '榛名改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 152,
ship_class: '金剛型',
ship_class_index: 4,
ship_type: '戦艦',
ship_name: '霧島改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 153,
ship_class: '大鳳型',
ship_class_index: 1,
ship_type: '装甲空母',
ship_name: '大鳳',
variation_num: 3,
},
{
book_no: 154,
ship_class: '香取型',
ship_class_index: 1,
ship_type: '練習巡洋艦',
ship_name: '香取',
variation_num: 6,
},
{
book_no: 155,
ship_class: '潜特型',
ship_class_index: 2,
ship_type: '潜水空母',
ship_name: '伊401',
variation_num: 6,
},
{
book_no: 156,
ship_class: '大鳳型',
ship_class_index: 1,
ship_type: '装甲空母',
ship_name: '大鳳改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 157,
ship_class: '龍驤型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '龍驤改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 158,
ship_class: '川内型',
ship_class_index: 1,
ship_type: '軽巡洋艦',
ship_name: '川内改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 159,
ship_class: '川内型',
ship_class_index: 2,
ship_type: '軽巡洋艦',
ship_name: '神通改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 160,
ship_class: '川内型',
ship_class_index: 3,
ship_type: '軽巡洋艦',
ship_name: '那珂改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 161,
ship_class: '特種船丙型',
ship_class_index: 1,
ship_type: '揚陸艦',
ship_name: 'あきつ丸',
variation_num: 3,
},
{
book_no: 163,
ship_class: '三式潜航輸送艇',
ship_class_index: 1,
ship_type: '潜水艦',
ship_name: 'まるゆ',
variation_num: 6,
},
{
book_no: 164,
ship_class: '睦月型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '弥生',
variation_num: 6,
# 2017-02-23:4隻追加(舞風、初風、秋雲、弥生)
implemented_at: '2017-02-23T07:00:00+09:00',
},
{
book_no: 165,
ship_class: '睦月型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '卯月',
variation_num: 6,
# 2017-03-23:5隻追加(卯月、大井改二、北上改二、千歳甲、千代田甲)
implemented_at: '2017-03-23T07:00:00+09:00',
},
{
book_no: 166,
ship_class: '特種船丙型',
ship_class_index: 1,
ship_type: '揚陸艦',
ship_name: 'あきつ丸改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 167,
ship_class: '陽炎型',
ship_class_index: 12,
ship_type: '駆逐艦',
ship_name: '磯風',
variation_num: 6,
},
{
book_no: 168,
ship_class: '陽炎型',
ship_class_index: 11,
ship_type: '駆逐艦',
ship_name: '浦風',
variation_num: 6,
},
{
book_no: 169,
ship_class: '陽炎型',
ship_class_index: 14,
ship_type: '駆逐艦',
ship_name: '谷風',
variation_num: 6,
},
{
book_no: 170,
ship_class: '陽炎型',
ship_class_index: 13,
ship_type: '駆逐艦',
ship_name: '浜風',
variation_num: 6,
},
{
book_no: 171,
ship_class: 'Bismarck級',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: 'Bismarck',
variation_num: 3,
},
{
book_no: 172,
ship_class: 'Bismarck級',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: 'Bismarck改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 173,
ship_class: 'Bismarck級',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: 'Bismarck zwei',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 174,
ship_class: 'Z1型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: 'Z1',
variation_num: 6,
},
{
book_no: 175,
ship_class: 'Z1型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: 'Z3',
variation_num: 6,
},
{
book_no: 176,
ship_class: 'Admiral Hipper級',
ship_class_index: 3,
ship_type: '重巡洋艦',
ship_name: 'Prinz Eugen',
variation_num: 3,
},
{
book_no: 177,
ship_class: 'Admiral Hipper級',
ship_class_index: 3,
ship_type: '重巡洋艦',
ship_name: 'Prinz Eugen改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 178,
ship_class: 'Bismarck級',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: 'Bismarck drei',
variation_num: 3,
remodel_level: 3,
},
{
book_no: 179,
ship_class: 'Z1型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: 'Z1 zwei',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 180,
ship_class: 'Z1型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: 'Z3 zwei',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 181,
ship_class: '陽炎型',
ship_class_index: 9,
ship_type: '駆逐艦',
ship_name: '天津風',
variation_num: 6,
},
{
book_no: 182,
ship_class: '明石型',
ship_class_index: 1,
ship_type: '工作艦',
ship_name: '明石',
variation_num: 3,
},
{
book_no: 183,
ship_class: '大淀型',
ship_class_index: 1,
ship_type: '軽巡洋艦',
ship_name: '大淀',
variation_num: 6,
},
{
book_no: 184,
ship_class: '大鯨型',
ship_class_index: 1,
ship_type: '潜水母艦',
ship_name: '大鯨',
variation_num: 3,
},
{
book_no: 185,
ship_class: '龍鳳型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '龍鳳',
variation_num: 3,
},
{
book_no: 186,
ship_class: '陽炎型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '時津風',
variation_num: 6,
},
{
book_no: 187,
ship_class: '明石型',
ship_class_index: 1,
ship_type: '工作艦',
ship_name: '明石改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 188,
ship_class: '利根型',
ship_class_index: 1,
ship_type: '航空巡洋艦',
ship_name: '利根改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 189,
ship_class: '利根型',
ship_class_index: 2,
ship_type: '航空巡洋艦',
ship_name: '筑摩改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 190,
ship_class: '龍鳳型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '龍鳳改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 191,
ship_class: '妙高型',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: '妙高改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 192,
ship_class: '妙高型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '那智改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 193,
ship_class: '妙高型',
ship_class_index: 3,
ship_type: '重巡洋艦',
ship_name: '足柄改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 194,
ship_class: '妙高型',
ship_class_index: 4,
ship_type: '重巡洋艦',
ship_name: '羽黒改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 195,
ship_class: '綾波型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '綾波改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 196,
ship_class: '飛龍型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '飛龍改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 197,
ship_class: '蒼龍型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '蒼龍改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 199,
ship_class: '朝潮型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '大潮改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 200,
ship_class: '長良型',
ship_class_index: 6,
ship_type: '軽巡洋艦',
ship_name: '阿武隈改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 201,
ship_class: '雲龍型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '雲龍',
variation_num: 3,
},
{
book_no: 202,
ship_class: '雲龍型',
ship_class_index: 2,
ship_type: '正規空母',
ship_name: '天城',
variation_num: 3,
},
{
book_no: 203,
ship_class: '雲龍型',
ship_class_index: 3,
ship_type: '正規空母',
ship_name: '葛城',
variation_num: 3,
},
{
book_no: 204,
ship_class: '初春型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '初春改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 205,
ship_class: '白露型',
ship_class_index: 5,
ship_type: '駆逐艦',
ship_name: '春雨',
variation_num: 6,
},
{
book_no: 206,
ship_class: '雲龍型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '雲龍改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 207,
ship_class: '綾波型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '潮改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 208,
ship_class: '飛鷹型',
ship_class_index: 2,
ship_type: '軽空母',
ship_name: '隼鷹改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 209,
ship_class: '夕雲型',
ship_class_index: 17,
ship_type: '駆逐艦',
ship_name: '早霜',
variation_num: 6,
},
{
book_no: 210,
ship_class: '夕雲型',
ship_class_index: 19,
ship_type: '駆逐艦',
ship_name: '清霜',
variation_num: 6,
},
{
book_no: 211,
ship_class: '扶桑型',
ship_class_index: 1,
ship_type: '航空戦艦',
ship_name: '扶桑改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 212,
ship_class: '扶桑型',
ship_class_index: 2,
ship_type: '航空戦艦',
ship_name: '山城改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 213,
ship_class: '朝潮型',
ship_class_index: 5,
ship_type: '駆逐艦',
ship_name: '朝雲',
variation_num: 6,
},
{
book_no: 214,
ship_class: '朝潮型',
ship_class_index: 6,
ship_type: '駆逐艦',
ship_name: '山雲',
variation_num: 6,
},
{
book_no: 215,
ship_class: '陽炎型',
ship_class_index: 15,
ship_type: '駆逐艦',
ship_name: '野分',
variation_num: 6,
},
{
book_no: 216,
ship_class: '古鷹型',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: '古鷹改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 217,
ship_class: '古鷹型',
ship_class_index: 2,
ship_type: '重巡洋艦',
ship_name: '加古改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 218,
ship_class: '睦月型',
ship_class_index: 5,
ship_type: '駆逐艦',
ship_name: '皐月改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 219,
ship_class: '初春型',
ship_class_index: 4,
ship_type: '駆逐艦',
ship_name: '初霜改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 220,
ship_class: '吹雪型',
ship_class_index: 5,
ship_type: '駆逐艦',
ship_name: '叢雲改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 221,
ship_class: '秋月型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '秋月',
variation_num: 6,
# リリースと同時に実装
implemented_at: '2016-04-26T07:00:00+09:00',
},
{
book_no: 222,
ship_class: '秋月型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '照月',
variation_num: 6,
},
{
book_no: 223,
ship_class: '秋月型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '初月',
variation_num: 6,
},
{
book_no: 224,
ship_class: '夕雲型',
ship_class_index: 6,
ship_type: '駆逐艦',
ship_name: '高波',
variation_num: 6,
},
{
book_no: 225,
ship_class: '夕雲型',
ship_class_index: 16,
ship_type: '駆逐艦',
ship_name: '朝霜',
variation_num: 6,
},
{
book_no: 226,
ship_class: '吹雪型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '吹雪改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 227,
ship_class: '高雄型',
ship_class_index: 4,
ship_type: '重巡洋艦',
ship_name: '鳥海改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 228,
ship_class: '高雄型',
ship_class_index: 3,
ship_type: '重巡洋艦',
ship_name: '摩耶改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 229,
ship_class: '雲龍型',
ship_class_index: 2,
ship_type: '正規空母',
ship_name: '天城改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 230,
ship_class: '雲龍型',
ship_class_index: 3,
ship_type: '正規空母',
ship_name: '葛城改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 231,
ship_class: 'UボートIXC型',
ship_class_index: 1,
ship_type: '潜水艦',
ship_name: 'U-511',
variation_num: 6,
},
{
book_no: 232,
ship_class: 'Graf Zeppelin級',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: 'Graf Zeppelin',
variation_num: 6,
},
{
book_no: 233,
ship_class: 'Lexington級',
ship_class_index: 2,
ship_type: '正規空母',
ship_name: 'Saratoga',
variation_num: 3,
},
{
book_no: 234,
ship_class: '睦月型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '睦月改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 235,
ship_class: '睦月型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '如月改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 236,
ship_class: '呂号潜水艦',
ship_class_index: 1,
ship_type: '潜水艦',
ship_name: '呂500',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 237,
ship_class: '暁型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '暁改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 238,
ship_class: 'Lexington級',
ship_class_index: 2,
ship_type: '正規空母',
ship_name: 'Saratoga改',
variation_num: 3,
},
{
book_no: 239,
ship_class: 'Queen Elizabeth級',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: 'Warspite',
variation_num: 6,
},
{
book_no: 240,
ship_class: 'Iowa級',
ship_class_index: 1,
ship_type: '戦艦',
ship_name: 'Iowa',
variation_num: 6,
},
{
book_no: 241,
ship_class: 'V.Veneto級',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: 'Littorio',
variation_num: 3,
},
{
book_no: 242,
ship_class: 'V.Veneto級',
ship_class_index: 4,
ship_type: '戦艦',
ship_name: 'Roma',
variation_num: 3,
},
{
book_no: 243,
ship_class: 'Maestrale級',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: 'Libeccio',
variation_num: 6,
},
{
book_no: 244,
ship_class: 'Aquila級',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: 'Aquila',
variation_num: 6,
},
{
book_no: 245,
ship_class: '秋津洲型',
ship_class_index: 1,
ship_type: '水上機母艦',
ship_name: '秋津洲',
variation_num: 3,
},
{
book_no: 246,
ship_class: 'V.Veneto級',
ship_class_index: 2,
ship_type: '戦艦',
ship_name: 'Italia',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 247,
ship_class: 'V.Veneto級',
ship_class_index: 4,
ship_type: '戦艦',
ship_name: 'Roma改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 248,
ship_class: 'Zara級',
ship_class_index: 1,
ship_type: '重巡洋艦',
ship_name: 'Zara',
variation_num: 6,
},
{
book_no: 249,
ship_class: 'Zara級',
ship_class_index: 3,
ship_type: '重巡洋艦',
ship_name: 'Pola',
variation_num: 6,
},
{
book_no: 250,
ship_class: '秋津洲型',
ship_class_index: 1,
ship_type: '水上機母艦',
ship_name: '秋津洲改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 251,
ship_class: '瑞穂型',
ship_class_index: 1,
ship_type: '水上機母艦',
ship_name: '瑞穂',
variation_num: 6,
},
{
book_no: 252,
ship_class: '夕雲型',
ship_class_index: 14,
ship_type: '駆逐艦',
ship_name: '沖波',
variation_num: 6,
},
{
book_no: 253,
ship_class: '夕雲型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '風雲',
variation_num: 6,
},
{
book_no: 254,
ship_class: '陽炎型',
ship_class_index: 16,
ship_type: '駆逐艦',
ship_name: '嵐',
variation_num: 6,
},
{
book_no: 255,
ship_class: '陽炎型',
ship_class_index: 17,
ship_type: '駆逐艦',
ship_name: '萩風',
variation_num: 6,
},
{
book_no: 256,
ship_class: '陽炎型',
ship_class_index: 14,
ship_type: '駆逐艦',
ship_name: '親潮',
variation_num: 6,
},
{
book_no: 257,
ship_class: '白露型',
ship_class_index: 8,
ship_type: '駆逐艦',
ship_name: '山風',
variation_num: 6,
},
{
book_no: 258,
ship_class: '白露型',
ship_class_index: 7,
ship_type: '駆逐艦',
ship_name: '海風',
variation_num: 6,
},
{
book_no: 259,
ship_class: '白露型',
ship_class_index: 9,
ship_type: '駆逐艦',
ship_name: '江風',
variation_num: 6,
},
{
book_no: 260,
ship_class: '改風早型',
ship_class_index: 1,
ship_type: '補給艦',
ship_name: '速吸',
variation_num: 6,
},
{
book_no: 261,
ship_class: '翔鶴型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '翔鶴改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 262,
ship_class: '翔鶴型',
ship_class_index: 2,
ship_type: '正規空母',
ship_name: '瑞鶴改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 263,
ship_class: '朝潮型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '朝潮改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 264,
ship_class: '朝潮型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '霞改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 265,
ship_class: '香取型',
ship_class_index: 2,
ship_type: '練習巡洋艦',
ship_name: '鹿島',
variation_num: 6,
},
{
book_no: 266,
ship_class: '翔鶴型',
ship_class_index: 1,
ship_type: '装甲空母',
ship_name: '翔鶴改二甲',
variation_num: 3,
remodel_level: 3,
},
{
book_no: 267,
ship_class: '翔鶴型',
ship_class_index: 2,
ship_type: '装甲空母',
ship_name: '瑞鶴改二甲',
variation_num: 3,
remodel_level: 3,
},
{
book_no: 268,
ship_class: '朝潮型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '朝潮改二丁',
variation_num: 3,
remodel_level: 3,
},
{
book_no: 269,
ship_class: '白露型',
ship_class_index: 9,
ship_type: '駆逐艦',
ship_name: '江風改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 270,
ship_class: '朝潮型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '霞改二乙',
variation_num: 3,
remodel_level: 3,
},
{
book_no: 271,
ship_class: '神風型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '神風',
variation_num: 3,
},
{
book_no: 272,
ship_class: '神風型',
ship_class_index: 2,
ship_type: '駆逐艦',
ship_name: '朝風',
variation_num: 6,
},
{
book_no: 273,
ship_class: '神風型',
ship_class_index: 3,
ship_type: '駆逐艦',
ship_name: '春風',
variation_num: 6,
},
{
book_no: 276,
ship_class: '神風型',
ship_class_index: 1,
ship_type: '駆逐艦',
ship_name: '神風改',
variation_num: 3,
remodel_level: 1,
},
{
book_no: 281,
ship_class: '睦月型',
ship_class_index: 6,
ship_type: '駆逐艦',
ship_name: '水無月',
variation_num: 6,
},
{
book_no: 283,
ship_class: '巡潜乙型',
ship_class_index: 7,
ship_type: '潜水艦',
ship_name: '伊26',
variation_num: 6,
},
{
book_no: 286,
ship_class: '吹雪型',
ship_class_index: 10,
ship_type: '駆逐艦',
ship_name: '浦波',
variation_num: 6,
},
{
book_no: 287,
ship_class: '長良型',
ship_class_index: 5,
ship_type: '軽巡洋艦',
ship_name: '鬼怒改二',
variation_num: 3,
remodel_level: 2,
},
{
book_no: 291,
ship_class: 'C.Teste級',
ship_class_index: 1,
ship_type: '水上機母艦',
ship_name: 'Commandant Teste',
variation_num: 6,
},
]
ship_masters.each do |ship_master|
ShipMaster.where(book_no: ship_master[:book_no]).first_or_initialize.update(ship_master)
end
updated_ship_masters = [
{
book_no: 94,
ship_class: '祥鳳型',
ship_class_index: 1,
ship_type: '軽空母',
ship_name: '祥鳳',
variation_num: 6,
# 2017-02-07:翔鶴、瑞鶴、瑞鳳、祥鳳の「改」追加
implemented_at: '2017-02-07T07:00:00+09:00',
},
{
book_no: 106,
ship_class: '翔鶴型',
ship_class_index: 1,
ship_type: '正規空母',
ship_name: '翔鶴',
variation_num: 6,
# 2017-02-07:翔鶴、瑞鶴、瑞鳳、祥鳳の「改」追加
implemented_at: '2017-02-07T07:00:00+09:00',
},
]
updated_ship_masters.each do |ship_master|
UpdatedShipMaster.where(book_no: ship_master[:book_no]).first_or_initialize.update(ship_master)
end
special_ship_masters = [
{
# 日向改
book_no: 103,
card_index: 3,
remodel_level: 1,
rarity: 1,
# 第2回イベントの前段作戦開始日
implemented_at: '2017-04-26T07:00:00+09:00',
},
{
# 伊勢改
book_no: 102,
card_index: 3,
remodel_level: 1,
rarity: 1,
# 第2回イベントの前段作戦開始日
implemented_at: '2017-05-11T07:00:00+09:00',
}
]
special_ship_masters.each do |ship_master|
SpecialShipMaster.where(book_no: ship_master[:book_no], card_index: ship_master[:card_index]).first_or_initialize.update(ship_master)
end
event_masters = [
{
event_no: 1,
area_id: 1000,
event_name: '敵艦隊前線泊地殴り込み',
no_of_periods: 1,
started_at: '2016-10-27T07:00:00+09:00',
ended_at: '2016-11-25T23:59:59+09:00',
},
{
event_no: 2,
area_id: 1001,
event_name: '南方海域強襲偵察!',
no_of_periods: 2,
period1_started_at: '2017-05-11T07:00:00+09:00',
started_at: '2017-04-26T07:00:00+09:00',
ended_at: '2017-05-31T23:59:59+09:00',
},
]
event_masters.each do |event_master|
EventMaster.where(event_no: event_master[:event_no]).first_or_initialize.update(event_master)
end
event_stage_masters = [
{
event_no: 1,
level: 'HEI',
stage_no: 1,
display_stage_no: 1,
stage_mission_name: '前哨戦',
ene_military_gauge_val: 1000,
},
{
event_no: 1,
level: 'HEI',
stage_no: 2,
display_stage_no: 2,
stage_mission_name: '警戒線突破',
ene_military_gauge_val: 1000,
},
{
event_no: 1,
level: 'HEI',
stage_no: 3,
display_stage_no: 3,
stage_mission_name: '湾内突入!',
ene_military_gauge_val: 1200,
},
{
event_no: 1,
level: 'HEI',
stage_no: 4,
display_stage_no: 4,
stage_mission_name: '敵泊地強襲!',
ene_military_gauge_val: 2000,
},
{
event_no: 1,
level: 'HEI',
stage_no: 5,
display_stage_no: 0,
stage_mission_name: '掃討戦',
ene_military_gauge_val: 0,
},
{
event_no: 1,
level: 'OTU',
stage_no: 1,
display_stage_no: 1,
stage_mission_name: '前哨戦',
ene_military_gauge_val: 1500,
},
{
event_no: 1,
level: 'OTU',
stage_no: 2,
display_stage_no: 2,
stage_mission_name: '警戒線突破',
ene_military_gauge_val: 1500,
},
{
event_no: 1,
level: 'OTU',
stage_no: 3,
display_stage_no: 3,
stage_mission_name: '湾内突入!',
ene_military_gauge_val: 1800,
},
{
event_no: 1,
level: 'OTU',
stage_no: 4,
display_stage_no: 4,
stage_mission_name: '敵泊地強襲!',
ene_military_gauge_val: 2500,
},
{
event_no: 1,
level: 'OTU',
stage_no: 5,
display_stage_no: 0,
stage_mission_name: '掃討戦',
ene_military_gauge_val: 0,
},
# 第2回イベント
{
event_no: 2,
level: 'HEI',
period: 0,
stage_no: 1,
display_stage_no: 1,
stage_mission_name: '南方海域へ進出せよ!',
ene_military_gauge_val: 2000,
},
{
event_no: 2,
level: 'HEI',
period: 0,
stage_no: 2,
display_stage_no: 2,
stage_mission_name: '警戒線を突破せよ!',
ene_military_gauge_val: 2700,
},
{
event_no: 2,
level: 'HEI',
period: 0,
stage_no: 3,
display_stage_no: 3,
stage_mission_name: '敵洋上戦力を排除せよ!',
ene_military_gauge_val: 2800,
},
{
event_no: 2,
level: 'HEI',
period: 0,
stage_no: 4,
display_stage_no: 0,
stage_mission_name: '敵洋上戦力を排除せよ!',
ene_military_gauge_val: 0,
},
{
event_no: 2,
level: 'HEI',
period: 1,
stage_no: 1,
display_stage_no: 4,
stage_mission_name: '敵情偵察を開始せよ!',
ene_military_gauge_val: 2600,
},
{
event_no: 2,
level: 'HEI',
period: 1,
stage_no: 2,
display_stage_no: 5,
stage_mission_name: '敵集結地を強襲せよ!',
ene_military_gauge_val: 3400,
},
{
event_no: 2,
level: 'HEI',
period: 1,
stage_no: 3,
display_stage_no: 6,
stage_mission_name: '敵大型超弩級戦艦を叩け!',
ene_military_gauge_val: 3600,
},
{
event_no: 2,
level: 'HEI',
period: 1,
stage_no: 4,
display_stage_no: 0,
stage_mission_name: '敵大型超弩級戦艦を叩け!',
ene_military_gauge_val: 0,
},
{
event_no: 2,
level: 'OTU',
period: 0,
stage_no: 1,
display_stage_no: 1,
stage_mission_name: '南方海域へ進出せよ!',
ene_military_gauge_val: 1800,
},
{
event_no: 2,
level: 'OTU',
period: 0,
stage_no: 2,
display_stage_no: 2,
stage_mission_name: '警戒線を突破せよ!',
ene_military_gauge_val: 2500,
},
{
event_no: 2,
level: 'OTU',
period: 0,
stage_no: 3,
display_stage_no: 3,
stage_mission_name: '敵洋上戦力を排除せよ!',
ene_military_gauge_val: 2600,
},
{
event_no: 2,
level: 'OTU',
period: 0,
stage_no: 4,
display_stage_no: 0,
stage_mission_name: '敵洋上戦力を排除せよ!',
ene_military_gauge_val: 0,
},
{
event_no: 2,
level: 'OTU',
period: 1,
stage_no: 1,
display_stage_no: 4,
stage_mission_name: '敵情偵察を開始せよ!',
ene_military_gauge_val: 2500,
},
{
event_no: 2,
level: 'OTU',
period: 1,
stage_no: 2,
display_stage_no: 5,
stage_mission_name: '敵集結地を強襲せよ!',
ene_military_gauge_val: 3500,
},
{
event_no: 2,
level: 'OTU',
period: 1,
stage_no: 3,
display_stage_no: 6,
stage_mission_name: '敵大型超弩級戦艦を叩け!',
ene_military_gauge_val: 3600,
},
{
event_no: 2,
level: 'OTU',
period: 1,
stage_no: 4,
display_stage_no: 0,
stage_mission_name: '敵大型超弩級戦艦を叩け!',
ene_military_gauge_val: 0,
},
{
event_no: 2,
level: 'KOU',
period: 0,
stage_no: 1,
display_stage_no: 1,
stage_mission_name: '南方海域へ進出せよ!',
ene_military_gauge_val: 2000,
},
{
event_no: 2,
level: 'KOU',
period: 0,
stage_no: 2,
display_stage_no: 2,
stage_mission_name: '警戒線を突破せよ!',
ene_military_gauge_val: 2700,
},
{
event_no: 2,
level: 'KOU',
period: 0,
stage_no: 3,
display_stage_no: 3,
stage_mission_name: '敵洋上戦力を排除せよ!',
ene_military_gauge_val: 2800,
},
{
event_no: 2,
level: 'KOU',
period: 0,
stage_no: 4,
display_stage_no: 0,
stage_mission_name: '敵洋上戦力を排除せよ!',
ene_military_gauge_val: 0,
},
{
event_no: 2,
level: 'KOU',
period: 1,
stage_no: 1,
display_stage_no: 4,
stage_mission_name: '敵情偵察を開始せよ!',
ene_military_gauge_val: 2700,
},
{
event_no: 2,
level: 'KOU',
period: 1,
stage_no: 2,
display_stage_no: 5,
stage_mission_name: '敵集結地を強襲せよ!',
ene_military_gauge_val: 3700,
},
{
event_no: 2,
level: 'KOU',
period: 1,
stage_no: 3,
display_stage_no: 6,
stage_mission_name: '敵大型超弩級戦艦を叩け!',
ene_military_gauge_val: 3800,
},
{
event_no: 2,
level: 'KOU',
period: 1,
stage_no: 4,
display_stage_no: 0,
stage_mission_name: '敵大型超弩級戦艦を叩け!',
ene_military_gauge_val: 0,
},
]
event_stage_masters.each do |master|
EventStageMaster.where(event_no: master[:event_no], level: master[:level], period: master[:period], stage_no: master[:stage_no]).first_or_initialize.update(master)
end
|
module Vidibus
module Permalink
module Mongoid
extend ActiveSupport::Concern
class PermalinkConfigurationError < StandardError; end
included do
field :permalink, type: String
field :static_permalink, type: String
index({permalink: 1}, {sparse: true})
index({static_permalink: 1}, {sparse: true})
attr_accessor :skip_permalink
before_validation :set_permalink, unless: :skip_permalink
validates :permalink, presence: true, unless: :skip_permalink
after_save :store_permalink_object, unless: :skip_permalink
after_destroy :destroy_permalink_objects
end
module ClassMethods
# Sets permalink attributes.
# Usage:
# permalink :some, :fields, :scope => {:realm => "rugby"}
def permalink(*args)
options = args.extract_options!
class_eval <<-EOS
def self.permalink_attributes
#{args.inspect}
end
def self.permalink_options
#{options.inspect}
end
EOS
end
end
# Ensure that a current permalink object exists for this record.
def ensure_permalink_object
if permalink_repository
permalink_object || begin
obj = permalink_object_by_value(permalink)
obj.sanitize_value!
obj.current!
obj.save
end
end
end
# Returns the defined permalink repository object.
def permalink_repository
@permalink_repository ||= begin
self.class.permalink_options[:repository] == false ? nil : ::Permalink
end
end
# Returns the current permalink object.
def permalink_object
@permalink_object || if permalink_repository
permalink_repository.for_linkable(self).where(_current: true).first
end
end
# Returns all permalink objects ordered by time of update.
def permalink_objects
if permalink_repository
permalink_repository.for_linkable(self).asc(:updated_at)
end
end
# Returns permalink scope.
def permalink_scope
@permalink_scope ||= get_scope
end
private
# Returns a existing or new permalink object with wanted value.
# The permalink scope is also applied
def permalink_object_by_value(value)
item = permalink_repository
.for_linkable(self)
.for_value(value)
.for_scope(permalink_scope)
.first
item ||= permalink_repository.new({
value: value,
scope: permalink_scope,
linkable: self
})
end
def get_scope
scope = self.class.permalink_options[:scope]
return unless scope
{}.tap do |hash|
scope.each do |key, value|
if value.kind_of?(String)
hash[key] = value
elsif value.kind_of?(Symbol) && respond_to?(value)
hash[key] = send(value)
else
raise PermalinkConfigurationError.new(
%Q{No scope value for key "#{key}" found.}
)
end
end
end
end
# Initializes a new permalink object and sets permalink attribute.
def set_permalink
begin
attribute_names = self.class.permalink_attributes
rescue NoMethodError
raise PermalinkConfigurationError.new("#{self.class}.permalink_attributes have not been assigned! Use #{self.class}.permalink(:my_field) to set it up.")
end
changed = false
values = []
attribute_names.each do |name|
changed ||= send("#{name}_changed?")
values << send(name)
end
return unless permalink.blank? || changed
value = values.join(' ')
if permalink_repository
@permalink_object = permalink_object_by_value(value)
@permalink_object.sanitize_value!
@permalink_object.current!
self.permalink = @permalink_object.value
else
self.permalink = ::Permalink.sanitize(value)
end
if new_record?
self.static_permalink = self.permalink
else
self.static_permalink ||= self.permalink
end
end
# Stores current new permalink object or updates an existing one that matches.
def store_permalink_object
return unless obj = @permalink_object
@permalink_object = nil # reset to avoid storing it again
obj.updated_at = Time.now
obj.save!
end
def destroy_permalink_objects
if permalink_repository
permalink_repository.where(linkable_id: id).delete
end
end
end
end
end
Allow force for setting the permalink
module Vidibus
module Permalink
module Mongoid
extend ActiveSupport::Concern
class PermalinkConfigurationError < StandardError; end
included do
field :permalink, type: String
field :static_permalink, type: String
index({permalink: 1}, {sparse: true})
index({static_permalink: 1}, {sparse: true})
attr_accessor :skip_permalink
before_validation :set_permalink, unless: :skip_permalink
validates :permalink, presence: true, unless: :skip_permalink
after_save :store_permalink_object, unless: :skip_permalink
after_destroy :destroy_permalink_objects
end
module ClassMethods
# Sets permalink attributes.
# Usage:
# permalink :some, :fields, :scope => {:realm => "rugby"}
def permalink(*args)
options = args.extract_options!
class_eval <<-EOS
def self.permalink_attributes
#{args.inspect}
end
def self.permalink_options
#{options.inspect}
end
EOS
end
end
# Ensure that a current permalink object exists for this record.
def ensure_permalink_object
if permalink_repository
permalink_object || begin
obj = permalink_object_by_value(permalink)
obj.sanitize_value!
obj.current!
obj.save
end
end
end
# Returns the defined permalink repository object.
def permalink_repository
@permalink_repository ||= begin
self.class.permalink_options[:repository] == false ? nil : ::Permalink
end
end
# Returns the current permalink object.
def permalink_object
@permalink_object || if permalink_repository
permalink_repository.for_linkable(self).where(_current: true).first
end
end
# Returns all permalink objects ordered by time of update.
def permalink_objects
if permalink_repository
permalink_repository.for_linkable(self).asc(:updated_at)
end
end
# Returns permalink scope.
def permalink_scope
@permalink_scope ||= get_scope
end
private
# Returns a existing or new permalink object with wanted value.
# The permalink scope is also applied
def permalink_object_by_value(value)
item = permalink_repository
.for_linkable(self)
.for_value(value)
.for_scope(permalink_scope)
.first
item ||= permalink_repository.new({
value: value,
scope: permalink_scope,
linkable: self
})
end
def get_scope
scope = self.class.permalink_options[:scope]
return unless scope
{}.tap do |hash|
scope.each do |key, value|
if value.kind_of?(String)
hash[key] = value
elsif value.kind_of?(Symbol) && respond_to?(value)
hash[key] = send(value)
else
raise PermalinkConfigurationError.new(
%Q{No scope value for key "#{key}" found.}
)
end
end
end
end
# Initializes a new permalink object and sets permalink attribute.
def set_permalink(force = false)
begin
attribute_names = self.class.permalink_attributes
rescue NoMethodError
raise PermalinkConfigurationError.new("#{self.class}.permalink_attributes have not been assigned! Use #{self.class}.permalink(:my_field) to set it up.")
end
changed = false
values = []
attribute_names.each do |name|
changed ||= send("#{name}_changed?")
values << send(name)
end
return unless permalink.blank? || changed || force
value = values.join(' ')
if permalink_repository
@permalink_object = permalink_object_by_value(value)
@permalink_object.sanitize_value!
@permalink_object.current!
self.permalink = @permalink_object.value
else
self.permalink = ::Permalink.sanitize(value)
end
if new_record?
self.static_permalink = self.permalink
else
self.static_permalink ||= self.permalink
end
end
# Stores current new permalink object or updates an existing one that matches.
def store_permalink_object
return unless obj = @permalink_object
@permalink_object = nil # reset to avoid storing it again
obj.updated_at = Time.now
obj.save!
end
def destroy_permalink_objects
if permalink_repository
permalink_repository.where(linkable_id: id).delete
end
end
end
end
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
User.create!(email: "jmessenger@advaoptical.com", password: "ponytail", password_confirmation: "ponytail", admin: true, debugger: true)
Minst.create([
{ code: "P" , name: "Published" },
{ code: "A" , name: "Approved" },
{ code: "B" , name: "Ready for Ballot" },
{ code: "CB", name: "Complete then Ballot" },
{ code: "CE", name: "Complete then Errata" },
{ code: "E" , name: "Errata" },
{ code: "F" , name: "Failed" },
{ code: "I" , name: "Incomplete" },
{ code: "J" , name: "Rejected" },
{ code: "R" , name: "Received" },
{ code: "S" , name: "Errata Sheet Published" },
{ code: "T" , name: "Technical experts review" },
{ code: "V" , name: "Balloting" },
{ code: "W" , name: "Withdrawn" }
])
Add a comment to remind you why not to delete the seeded values for
Minsts.
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
User.create!(email: "jmessenger@advaoptical.com", password: "ponytail", password_confirmation: "ponytail", admin: true, debugger: true)
# Note: initial values are seeded. Reading from a spreadsheet replaces these.
Minst.create([
{ code: "P" , name: "Published" },
{ code: "A" , name: "Approved" },
{ code: "B" , name: "Ready for Ballot" },
{ code: "CB", name: "Complete then Ballot" },
{ code: "CE", name: "Complete then Errata" },
{ code: "E" , name: "Errata" },
{ code: "F" , name: "Failed" },
{ code: "I" , name: "Incomplete" },
{ code: "J" , name: "Rejected" },
{ code: "R" , name: "Received" },
{ code: "S" , name: "Errata Sheet Published" },
{ code: "T" , name: "Technical experts review" },
{ code: "V" , name: "Balloting" },
{ code: "W" , name: "Withdrawn" }
])
|
module Warden
module GoogleApps
VERSION = "0.0.6.1"
end
end
next version is 0.1.1
module Warden
module GoogleApps
VERSION = "0.1.1"
end
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
Added roles to the db seed
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
roles = Role.create([
{
colour: '5cb85c',
description: 'Developer',
identifier: 3,
name: 'A Developer on The Tree.'
},
{
colour: '5bc0de',
description: 'User',
identifier: 2,
name: 'A User of Branch App.'
},
{
colour: '999999',
description: 'Validating',
identifier: 1,
name: 'A Validating User of Branch App.'
},
{
colour: 'd9534f',
description: 'Banned',
identifier: 0,
name: 'A Banned User of Branch App.'
}
]) |
require 'ostruct'
require 'erb'
require 'json'
require 'json-schema'
require 'safe_yaml'
require 'mail'
require 'rxarf/schema'
require 'rxarf/report'
class XARF
class Header < OpenStruct
def initialize(arg = {})
super
end
def []=(key, val)
self.send(key.to_s + '=', val)
end
def [](key)
self.send(key)
end
def to_hash
self.marshal_dump
end
end
class Message
attr_accessor :mail
attr_accessor :human_readable
attr_accessor :attachment
attr_accessor :schema
attr_reader :header
attr_reader :report
SafeYAML::OPTIONS[:default_mode] = :safe
def initialize(args, header_defaults = {}, report_defaults = {}, &block)
@header_defaults = header_defaults
@report_defaults = report_defaults
if args.is_a? Hash
init_with_hash(args, &block)
else
init_with_string(args, &block)
end
end
def init_with_hash(args, &block)
@schema = args[:schema]
if block_given?
@header = Header.new
@report = Report.new(@schema)
yield self
else
@header = Header.new(args[:header])
@report = Report.new(@schema, args[:report])
@human_readable = args[:human_readable]
end
assemble_report
assemble_mail
end
def header=(arg)
@header = Header.new(arg)
end
def report=(arg)
@report = Report.new(@schema, arg)
end
def init_with_string(str, &block)
@mail = Mail.read_from_string str
unless @mail.mime_type == 'multipart/mixed'
raise(ValidationError, "Content-Type is '#{@mail.mime_type}', should be 'multipart/mixed'")
end
unless @mail.parts.length.between?(2,3)
raise(ValidationError, 'wrong number of mime parts in mail')
end
unless @mail.header['X-XARF']
raise(ValidationError, 'missing X-XARF header')
end
unless @mail.header['X-XARF'].to_s == 'PLAIN'
raise(ValidationError, "X-XARF header not set to 'PLAIN'")
end
unless @mail.parts[0].content_type_parameters['charset'].to_s.casecmp 'utf-8'
raise(ValidationError, 'first mime-part not utf-8')
end
unless @mail.parts[0].content_type.include? 'text/plain'
raise(ValidationError, 'first mime-part not text/plain')
end
unless @mail.parts[1].content_type_parameters['charset'].to_s.casecmp 'utf-8'
raise(ValidationError, 'second mime-part not utf-8')
end
unless @mail.parts[1].content_type.include? 'text/plain'
raise(ValidationError, 'second mime-part not text/plain')
end
unless @mail.parts[1].content_type_parameters['name'] == 'report.txt'
raise(ValidationError, "content type parameter name is not 'report.txt' for second mime-part")
end
@human_readable = @mail.parts[0].body.decoded
begin
report = YAML.load(@mail.parts[1].body.decoded)
rescue => e
raise(ValidationError, "could not parse YAML: #{e.class}: #{e.message}")
end
unless report['Schema-URL']
raise(ValidationError, "'Schema-URL' not specified")
end
yield(self, report['Schema-URL'])
@report = Report.new(@schema, report)
report_errors = @report.validate
unless report_errors.empty?
raise(ValidationError, "#{report_errors.join(', ')}")
end
if @report[:attachment]
attachment_content_type = @report[:attachment]
attachment = @mail.parts[2]
if attachment.nil?
raise(ValidationError, 'YAML report specifies attachment, but no attachment is provided')
end
unless @mail.parts[1].content_type.include? attachment_content_type
raise(ValidationError, 'content type mismatch')
end
@attachment = @mail.attachments[1]
end
end
private
def assemble_mail
unless @human_readable
raise(ValidationError, 'body of 2nd mime part cannot be empty')
end
@mail = Mail.new
@mail.content_type = 'multipart/mixed'
assemble_mail_header
renderer = ERB.new(@human_readable)
@mail.text_part = Mail::Part.new renderer.result(binding)
report = Mail::Part.new
report.content_type_parameters['name'] = 'report.txt'
report.body = @report.to_yaml
@mail.text_part = report
end
def assemble_mail_header
@mail.header['Auto-Submitted'] = 'auto-generated'
@mail.header['X-ARF'] = 'Yes'
@mail.header['X-RARF'] = 'PLAIN'
set_header_defaults
@header.each_pair { |key, value| @mail.header[key] = value }
end
def set_header_defaults
@header[:subject] ||= auto_subject
Header.new(@header_defaults.merge(@header))
end
def auto_subject
"abuse report about #{@report[:source]} - #{Time.now.strftime('%FT%TZ')}"
end
def assemble_report
@report = Report.new(@schema, @report_defaults.merge(@report)) # set reported_from, report-id
end
end
end
fix typo
require 'ostruct'
require 'erb'
require 'json'
require 'json-schema'
require 'safe_yaml'
require 'mail'
require 'rxarf/schema'
require 'rxarf/report'
class XARF
class Header < OpenStruct
def initialize(arg = {})
super
end
def []=(key, val)
self.send(key.to_s + '=', val)
end
def [](key)
self.send(key)
end
def to_hash
self.marshal_dump
end
end
class Message
attr_accessor :mail
attr_accessor :human_readable
attr_accessor :attachment
attr_accessor :schema
attr_reader :header
attr_reader :report
SafeYAML::OPTIONS[:default_mode] = :safe
def initialize(args, header_defaults = {}, report_defaults = {}, &block)
@header_defaults = header_defaults
@report_defaults = report_defaults
if args.is_a? Hash
init_with_hash(args, &block)
else
init_with_string(args, &block)
end
end
def init_with_hash(args, &block)
@schema = args[:schema]
if block_given?
@header = Header.new
@report = Report.new(@schema)
yield self
else
@header = Header.new(args[:header])
@report = Report.new(@schema, args[:report])
@human_readable = args[:human_readable]
end
assemble_report
assemble_mail
end
def header=(arg)
@header = Header.new(arg)
end
def report=(arg)
@report = Report.new(@schema, arg)
end
def init_with_string(str, &block)
@mail = Mail.read_from_string str
unless @mail.mime_type == 'multipart/mixed'
raise(ValidationError, "Content-Type is '#{@mail.mime_type}', should be 'multipart/mixed'")
end
unless @mail.parts.length.between?(2,3)
raise(ValidationError, 'wrong number of mime parts in mail')
end
unless @mail.header['X-XARF']
raise(ValidationError, 'missing X-XARF header')
end
unless @mail.header['X-XARF'].to_s == 'PLAIN'
raise(ValidationError, "X-XARF header not set to 'PLAIN'")
end
unless @mail.parts[0].content_type_parameters['charset'].to_s.casecmp 'utf-8'
raise(ValidationError, 'first mime-part not utf-8')
end
unless @mail.parts[0].content_type.include? 'text/plain'
raise(ValidationError, 'first mime-part not text/plain')
end
unless @mail.parts[1].content_type_parameters['charset'].to_s.casecmp 'utf-8'
raise(ValidationError, 'second mime-part not utf-8')
end
unless @mail.parts[1].content_type.include? 'text/plain'
raise(ValidationError, 'second mime-part not text/plain')
end
unless @mail.parts[1].content_type_parameters['name'] == 'report.txt'
raise(ValidationError, "content type parameter name is not 'report.txt' for second mime-part")
end
@human_readable = @mail.parts[0].body.decoded
begin
report = YAML.load(@mail.parts[1].body.decoded)
rescue => e
raise(ValidationError, "could not parse YAML: #{e.class}: #{e.message}")
end
unless report['Schema-URL']
raise(ValidationError, "'Schema-URL' not specified")
end
yield(self, report['Schema-URL'])
@report = Report.new(@schema, report)
report_errors = @report.validate
unless report_errors.empty?
raise(ValidationError, "#{report_errors.join(', ')}")
end
if @report[:attachment]
attachment_content_type = @report[:attachment]
attachment = @mail.parts[2]
if attachment.nil?
raise(ValidationError, 'YAML report specifies attachment, but no attachment is provided')
end
unless @mail.parts[1].content_type.include? attachment_content_type
raise(ValidationError, 'content type mismatch')
end
@attachment = @mail.attachments[1]
end
end
private
def assemble_mail
unless @human_readable
raise(ValidationError, 'body of 2nd mime part cannot be empty')
end
@mail = Mail.new
@mail.content_type = 'multipart/mixed'
assemble_mail_header
renderer = ERB.new(@human_readable)
@mail.text_part = Mail::Part.new renderer.result(binding)
report = Mail::Part.new
report.content_type_parameters['name'] = 'report.txt'
report.body = @report.to_yaml
@mail.text_part = report
end
def assemble_mail_header
@mail.header['Auto-Submitted'] = 'auto-generated'
@mail.header['X-ARF'] = 'Yes'
@mail.header['X-XARF'] = 'PLAIN'
set_header_defaults
@header.each_pair { |key, value| @mail.header[key] = value }
end
def set_header_defaults
@header[:subject] ||= auto_subject
Header.new(@header_defaults.merge(@header))
end
def auto_subject
"abuse report about #{@report[:source]} - #{Time.now.strftime('%FT%TZ')}"
end
def assemble_report
@report = Report.new(@schema, @report_defaults.merge(@report)) # set reported_from, report-id
end
end
end |
require_relative './data_tasks'
# will exit if plan already exists (in any form)
OnceOffTemplateLoad.new.load_template_plan 'Warrandyte Template', '3113'
# plans (by id) to preserve
WhiteListedDataDestroyer.new.clear_out_all_plans_and_data_except_for_these_plans do
(18..30).to_a + [
Plan.find_by_name_and_postcode('Warrandyte Template', '3113')
].compact.map(&:id)
end
# remove all tags from these tasks
Task.find_all_by_id([2973,2974,2975,2976,2977,2978]).each do |t|
t.tag_list = []
t.save
end
disable WhiteListedDataDestroyer on seed for now
require_relative './data_tasks'
# will exit if plan already exists (in any form)
OnceOffTemplateLoad.new.load_template_plan 'Warrandyte Template', '3113'
# plans (by id) to preserve
# WhiteListedDataDestroyer.new.clear_out_all_plans_and_data_except_for_these_plans do
# (18..30).to_a + [
# Plan.find_by_name_and_postcode('Warrandyte Template', '3113')
# ].compact.map(&:id)
# end
# remove all tags from these tasks
Task.find_all_by_id([2973,2974,2975,2976,2977,2978]).each do |t|
t.tag_list = []
t.save
end |
module S3MPI
module VERSION #:nodoc:
MAJOR = 0
MINOR = 1
PATCH = 0
BUILD = 1
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.');
end
end
update version to 0.1.0.2
module S3MPI
module VERSION #:nodoc:
MAJOR = 0
MINOR = 1
PATCH = 0
BUILD = 2
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.');
end
end
|
#encoding: utf-8
#TransamCore::Engine.load_seed
#TransamSpatial::Engine.load_seed
# determine if we are using postgres or mysql
is_mysql = (ActiveRecord::Base.configurations[Rails.env]['adapter'] == 'mysql2')
is_sqlite = (ActiveRecord::Base.configurations[Rails.env]['adapter'] == 'sqlite3')
puts "======= Processing TransAM Transit Lookup Tables ======="
#------------------------------------------------------------------------------
#
# Customized Lookup Tables
#
# These are the specific to TransAM Transit
#
#------------------------------------------------------------------------------
fuel_types = [
{:active => 1, :name => 'Unknown', :code => 'XX', :description => 'No Fuel type specified.'},
{:active => 1, :name => 'Biodiesel', :code => 'BD', :description => 'Biodiesel.'},
{:active => 1, :name => 'Bunker Fuel', :code => 'BF', :description => 'Bunker Fuel.'},
{:active => 1, :name => 'Compressed Natural Gas', :code => 'CN', :description => 'Compressed Natutral Gas.'},
{:active => 1, :name => 'Diesel Fuel', :code => 'DF', :description => 'Diesel Fuel.'},
{:active => 1, :name => 'Dual Fuel', :code => 'DU', :description => 'Dual Fuel.'},
{:active => 1, :name => 'Electric Battery', :code => 'EB', :description => 'Electric Battery.'},
{:active => 1, :name => 'Electric Propulsion', :code => 'EP', :description => 'Electric Propulsion.'},
{:active => 1, :name => 'Ethanol', :code => 'ET', :description => 'Ethanol.'},
{:active => 1, :name => 'Gasoline', :code => 'GA', :description => 'Gasoline.'},
{:active => 1, :name => 'Hybrid Diesel', :code => 'HD', :description => 'Hybrid Diesel.'},
{:active => 1, :name => 'Hybrid Gasoline', :code => 'HG', :description => 'Hybrid Gasoline.'},
{:active => 1, :name => 'Hydrogen', :code => 'HY', :description => 'Hydrogen.'},
{:active => 1, :name => 'Kerosene', :code => 'KE', :description => 'Kerosene.'},
{:active => 1, :name => 'Liquefied Natural Gas', :code => 'LN', :description => 'Liquefied Natural Gas.'},
{:active => 1, :name => 'Liquefied Petroleum Gas', :code => 'LP', :description => 'Liquefied Petroleum Gas.'},
{:active => 1, :name => 'Methanol', :code => 'MT', :description => 'Methanol.'},
{:active => 1, :name => 'Other', :code => 'OR', :description => 'Other.'}
]
vehicle_features = [
{:active => 1, :name => 'AVL System', :code => 'AS', :description => 'Automatic Vehicle Location System.'},
{:active => 1, :name => 'Lift Equipped', :code => 'LE', :description => 'Lift Equipped.'},
{:active => 1, :name => 'Electronic Ramp', :code => 'ER', :description => 'Electronic Ramp.'},
{:active => 1, :name => 'Video Cameras', :code => 'VC', :description => 'Video Cameras.'},
{:active => 1, :name => 'Fare Box (Standard)', :code => 'FBS', :description => 'Fare Box (Standard).'},
{:active => 1, :name => 'Fare Box (Electronic)',:code => 'FBE', :description => 'Fare Box (Electronic).'},
{:active => 1, :name => 'Radio Equipped', :code => 'RE', :description => 'Radio Equipped.'},
{:active => 1, :name => 'Bike Rack', :code => 'BR', :description => 'Bike Rack.'},
{:active => 1, :name => 'Scheduling Software', :code => 'SS', :description => 'Scheduling Software.'},
{:active => 1, :name => 'WIFI', :code => 'WI', :description => 'WIFI.'}
]
vehicle_usage_codes = [
{:active => 1, :name => 'Unknown', :code => 'X', :description => 'No Vehicle usage specified.'},
{:active => 1, :name => 'Revenue vehicle', :code => 'R', :description => 'Revenue vehicle.'},
{:active => 1, :name => 'Support Vehicle', :code => 'S', :description => 'Support vehicle.'},
{:active => 1, :name => 'Van Pool', :code => 'V', :description => 'Van Pool.'},
{:active => 1, :name => 'Paratransit', :code => 'P', :description => 'Paratransit.'},
{:active => 1, :name => 'Spare Inventory', :code => 'I', :description => 'Spare Inventory.'}
]
fta_mode_types = [
{:active => 1, :name => 'Unknown', :code => 'XX', :description => 'No FTA mode type specified.'},
{:active => 1, :name => 'Aerial Tramway', :code => 'TR', :description => 'Aerial Tramway.'},
{:active => 1, :name => 'Bus', :code => 'MB', :description => 'Bus.'},
{:active => 1, :name => 'Bus Rapid Transit', :code => 'RB', :description => 'Bus rapid transit.'},
{:active => 1, :name => 'Commuter Bus', :code => 'CB', :description => 'Commuter bus.'},
{:active => 1, :name => 'Demand Response', :code => 'DR', :description => 'Demand Response.'},
{:active => 1, :name => 'Ferry Boat', :code => 'FB', :description => 'Ferryboat.'},
{:active => 1, :name => 'Jitney', :code => 'JT', :description => 'Jitney.'},
{:active => 1, :name => 'Publico', :code => 'PB', :description => 'Publico.'},
{:active => 1, :name => 'Trolley Bus', :code => 'TB', :description => 'Trolleybus.'},
{:active => 1, :name => 'Van Pool', :code => 'VP', :description => 'Vanpool.'},
{:active => 1, :name => 'Alaska Railroad', :code => 'AR', :description => 'Alaska Railroad.'},
{:active => 1, :name => 'Monorail/Automated Guideway Transit', :code => 'MG', :description => 'Monorail/Automated guideway transit.'},
{:active => 1, :name => 'Cable Car', :code => 'CC', :description => 'Cable car.'},
{:active => 1, :name => 'Commuter Rail', :code => 'CR', :description => 'Commuter rail.'},
{:active => 1, :name => 'Heavy Rail', :code => 'HR', :description => 'Heavy rail.'},
{:active => 1, :name => 'Inclined Plane', :code => 'IP', :description => 'Inclined plane.'},
{:active => 1, :name => 'Light Rail', :code => 'LR', :description => 'Light rail.'},
{:active => 1, :name => 'Street Car', :code => 'SR', :description => 'Streetcar.'},
{:active => 1, :name => 'Hybrid Rail', :code => 'HR', :description => 'Hybrid rail.'}
]
fta_service_types = [
{:active => 1, :name => 'Unknown', :code => 'XX', :description => 'FTA Service type not specified.'},
{:active => 1, :name => 'Directly Operated', :code => 'DO', :description => 'Directly Operated.'},
{:active => 1, :name => 'Purchased Transportation', :code => 'PT', :description => 'Purchased Transportation.'}
]
fta_agency_types = [
{:active => 1, :name => 'Public Agency (Not DOT or Tribal)', :description => 'Public Agency (Not DOT or Tribal).'},
{:active => 1, :name => 'Public Agency (State DOT)', :description => 'Public Agency (State DOT).'},
{:active => 1, :name => 'Public Agency (Tribal)', :description => 'Public Agency (Tribal).'},
{:active => 1, :name => 'Private (Not for profit)', :description => 'Private (Not for profit).'}
]
fta_service_area_types = [
{:active => 1, :name => 'County / Independent city', :description => 'County / Independent city.'},
{:active => 1, :name => 'Multi-county / Independent city', :description => 'Multi-county / Independent city.'},
{:active => 1, :name => 'Multi-state', :description => 'Multi-state.'},
{:active => 1, :name => 'Municipality', :description => 'Municipality.'},
{:active => 1, :name => 'Reservation', :description => 'Reservation.'},
{:active => 1, :name => 'Other', :description => 'Other.'}
]
fta_funding_types = [
{:active => 1, :name => 'Unknown', :code => 'XX', :description => 'FTA funding type not specified.'},
{:active => 1, :name => 'Urbanized Area Formula Program', :code => 'UA', :description => 'UA -Urbanized Area Formula Program.'},
{:active => 1, :name => 'Other Federal funds', :code => 'OF', :description => 'OF-Other Federal funds.'},
{:active => 1, :name => 'Non-Federal public funds', :code => 'NFPA', :description => 'NFPA-Non-Federal public funds.'},
{:active => 1, :name => 'Non-Federal private funds', :code => 'NFPE', :description => 'NFPE-Non-Federal private funds.'}
]
fta_ownership_types = [
{:active => 1, :name => 'Unknown', :code => 'XX', :description => 'FTA ownership type not specified.'},
{:active => 1, :name => 'Lease purchase by a public agency', :code => 'LPPA', :description => 'Leased under lease purchase agreement by a public agency.'},
{:active => 1, :name => 'Lease purchase by a private entity', :code => 'LPPE', :description => 'Leased under lease purchase agreement by a private entity.'},
{:active => 1, :name => 'Lease or borrowed by a public agency', :code => 'LRPA', :description => 'Leased or borrowed from related parties by a public agency.'},
{:active => 1, :name => 'Lease or borrowed by a private agency',:code => 'LRPE', :description => 'Leased or borrowed from related parties by a private entity.'},
{:active => 1, :name => 'Owned outright by a public agency', :code => 'OOPA', :description => 'Owned outright by a public agency (includes safe-harbor leasing agreements where only the tax title is sold).'},
{:active => 1, :name => 'Owned outright by a private entity', :code => 'OOPE', :description => 'Owned outright by a private entity (includes safe-harbor leasing agreements where only the tax title is sold).'},
{:active => 1, :name => 'True lease by a public agency', :code => 'TLPA', :description => 'True lease by a public agency.'},
{:active => 1, :name => 'True lease by a private entity', :code => 'TLPE', :description => 'True lease by a private entity.'},
{:active => 1, :name => 'Other', :code => 'OR', :description => 'Other.'}
]
fta_vehicle_types = [
{:active => 1, :name => 'Unknown', :code => 'XX', :description => 'Vehicle type not specified.'},
{:active => 1, :name => 'Articulated Bus', :code => 'AB', :description => 'Articulated Bus.'},
{:active => 1, :name => 'Automated Guideway Vehicle', :code => 'AG', :description => 'Automated Guideway Vehicle.'},
{:active => 1, :name => 'Automobile', :code => 'AO', :description => 'Automobile.'},
{:active => 1, :name => 'Over-The-Road Bus', :code => 'BR', :description => 'Over-The-Road Bus.'},
{:active => 1, :name => 'Bus', :code => 'BU', :description => 'Bus.'},
{:active => 1, :name => 'Cable Car', :code => 'CC', :description => 'Cable Car.'},
{:active => 1, :name => 'Cutaway', :code => 'CU', :description => 'Cutaway.'},
{:active => 1, :name => 'Double Decker Bus', :code => 'DB', :description => 'Double Decker Bus.'},
{:active => 1, :name => 'Ferry Boat', :code => 'FB', :description => 'Ferryboat.'},
{:active => 1, :name => 'Heavy Rail Passenger Car', :code => 'HR', :description => 'Heavy Rail Passenger Car.'},
{:active => 1, :name => 'Inclined Plane Vehicle', :code => 'IP', :description => 'Inclined Plane Vehicle.'},
{:active => 1, :name => 'Light Rail Vehicle', :code => 'LR', :description => 'Light Rail Vehicle.'},
{:active => 1, :name => 'Monorail/Automated Guideway', :code => 'MO', :description => 'Monorail/Automated Guideway.'},
{:active => 1, :name => 'Mini Van', :code => 'MV', :description => 'Minivan.'},
{:active => 1, :name => 'Commuter Rail Locomotive', :code => 'RL', :description => 'Commuter Rail Locomotive.'},
{:active => 1, :name => 'Commuter Rail Passenger Coach', :code => 'RP', :description => 'Commuter Rail Passenger Coach.'},
{:active => 1, :name => 'Commuter Rail Self-Propelled Passenger Car', :code => 'RS', :description => 'Commuter Rail Self-Propelled Passenger Car.'},
{:active => 1, :name => 'School Bus', :code => 'SB', :description => 'School Bus.'},
{:active => 1, :name => 'Sports Utility Vehicle', :code => 'SV', :description => 'Sports Utility Vehicle.'},
{:active => 1, :name => 'Trolley Bus', :code => 'TB', :description => 'Trolley Bus.'},
{:active => 1, :name => 'Aerial Tramway', :code => 'TR', :description => 'Aerial Tramway.'},
{:active => 1, :name => 'Taxicab Sedan', :code => 'TS', :description => 'Taxicab Sedan.'},
{:active => 1, :name => 'Taxicab Van', :code => 'TV', :description => 'Taxicab Van.'},
{:active => 1, :name => 'Taxicab Station Wagon', :code => 'TW', :description => 'Taxicab Station Wagon.'},
{:active => 1, :name => 'Van', :code => 'VN', :description => 'Van.'},
{:active => 1, :name => 'Vintage Trolley/Streetcar',:code => 'VT', :description => 'Vintage Trolley/Streetcar.'}
]
facility_capacity_types = [
{:active => 1, :name => 'N/A', :description => 'Not applicable.'},
{:active => 1, :name => 'Less than 200 vehicles', :description => 'Less than 200 vehicles.'},
{:active => 1, :name => 'Between 200 and 300 vehicles', :description => 'Between 200 and 300 vehicles.'},
{:active => 1, :name => 'Over 300 vehicles', :description => 'Over 300 vehicles.'}
]
facility_features = [
{:active => 1, :name => 'Moving walkways', :code => 'MW', :description => 'Moving walkways.'},
{:active => 1, :name => 'Ticketing', :code => 'TK', :description => 'Ticketing.'},
{:active => 1, :name => 'Information kiosks', :code => 'IK', :description => 'Information kiosks.'},
{:active => 1, :name => 'Restrooms', :code => 'RR', :description => 'Restrooms.'},
{:active => 1, :name => 'Concessions', :code => 'CS', :description => 'Concessions.'},
{:active => 1, :name => 'Telephones', :code => 'TP', :description => 'Telephones.'},
{:active => 1, :name => 'ATM', :code => 'AT', :description => 'ATM.'},
{:active => 1, :name => 'WIFI', :code => 'WI', :description => 'WIFI.'}
]
service_types = [
{:active => 1, :name => 'Urban', :code => 'URB', :description => 'Operates in an urban area.'},
{:active => 1, :name => 'Rural', :code => 'RUR', :description => 'Operates in a rural area.'},
{:active => 1, :name => 'Shared Ride', :code => 'SHR', :description => 'Provides shared ride services.'},
{:active => 1, :name => 'Intercity Bus', :code => 'ICB', :description => 'Provides intercity bus services.'},
{:active => 1, :name => 'Intercity Rail', :code => 'ICR', :description => 'Provides intercity rail services.'},
{:active => 1, :name => '5310', :code => '5310', :description => 'Provides 5310 services.'},
{:active => 1, :name => 'NFRDM', :code => 'NFRDM', :description => 'Provides NFRDM services.'},
{:active => 1, :name => 'WTW', :code => 'WTW', :description => 'Provides WTW services.'},
{:active => 1, :name => 'Other', :code => 'OTH', :description => 'Provides other services.'}
]
district_types = [
{:active => 1, :name => 'State', :description => 'State.'},
{:active => 1, :name => 'District', :description => 'Engineering District.'},
{:active => 1, :name => 'MSA', :description => 'Metropolitan Statistical Area.'},
{:active => 1, :name => 'County', :description => 'County.'},
{:active => 1, :name => 'City', :description => 'City.'},
{:active => 1, :name => 'Borough', :description => 'Borough.'},
{:active => 1, :name => 'MPO/RPO', :description => 'MPO or RPO planning area.'},
{:active => 1, :name => 'Postal Code', :description => 'ZIP Code or Postal Area.'}
]
asset_types = [
{:active => 1, :name => 'Vehicle', :description => 'Vehicle', :class_name => 'Vehicle', :map_icon_name => "redIcon", :display_icon_name => "fa fa-bus", :new_inventory_template_name => 'new_inventory_template_v_3_4.xlsx'},
{:active => 1, :name => 'Rail Car', :description => 'Rail Car', :class_name => 'RailCar', :map_icon_name => "orangeIcon", :display_icon_name => "fa travelcon travelcon-subway", :new_inventory_template_name => 'new_inventory_template_v_3_4.xlsx'},
{:active => 1, :name => 'Locomotive', :description => 'Locomotive', :class_name => 'Locomotive', :map_icon_name => "greenIcon", :display_icon_name => "fa travelcon travelcon-train", :new_inventory_template_name => 'new_inventory_template_v_3_4.xlsx'},
{:active => 1, :name => 'Transit Facility', :description => 'Transit Facility', :class_name => 'TransitFacility', :map_icon_name => "greenIcon", :display_icon_name => "fa fa-building-o", :new_inventory_template_name => 'new_facility_inventory_template_v_1_0.xlsx'},
{:active => 1, :name => 'Support Facility', :description => 'Support Facility', :class_name => 'SupportFacility', :map_icon_name => "blueIcon", :display_icon_name => "fa fa-building", :new_inventory_template_name => 'new_facility_inventory_template_v_1_0.xlsx'},
{:active => 1, :name => 'Bridge/Tunnel', :description => 'Bridges and Tunnels', :class_name => 'BridgeTunnel', :map_icon_name => "redIcon", :display_icon_name => "fa fa-square", :new_inventory_template_name => 'new_facility_inventory_template_v_1_0.xlsx'},
{:active => 1, :name => 'Support Vehicle', :description => 'Support Vehicle', :class_name => 'SupportVehicle', :map_icon_name => "redIcon", :display_icon_name => "fa fa-truck", :new_inventory_template_name => 'new_inventory_template_v_3_4.xlsx'}
]
file_content_types = [
{:active => 1, :name => 'New Inventory', :class_name => 'NewInventoryFileHandler', :builder_name => "NewInventoryTemplateBuilder", :description => 'Worksheet contains new inventory to be loaded into TransAM.'},
{:active => 1, :name => 'Status Updates', :class_name => 'StatusUpdatesFileHandler', :builder_name => "StatusUpdatesTemplateBuilder", :description => 'Worksheet records condition, usage, and operational updates for exisiting inventory.'},
{:active => 1, :name => 'Disposition Updates', :class_name => 'DispositionUpdatesFileHandler', :builder_name => "DispositionUpdatesTemplateBuilder", :description => 'Worksheet contains final disposition updates for existing inventory.'}
]
service_provider_types = [
{:active => 1, :name => 'Rural General Public Transit Service Provider', :code => 'RU-20', :description => 'Rural General Public Transit Service provider.'},
{:active => 1, :name => 'Intercity Bus Service Provider', :code => 'RU-21', :description => 'Intercity Bus Service provider.'},
{:active => 1, :name => 'Rural Recipient Reporting Separately', :code => 'RU-22', :description => 'Rural Recipient Reporting Separately.'},
{:active => 1, :name => 'Urban Recipient', :code => 'RU-23', :description => 'Urban Recipient.'}
]
vehicle_storage_method_types = [
{:active => 1, :name => 'Unknown',:code => 'X', :description => 'Vehicle storage method not supplied.'},
{:active => 1, :name => 'Indoors', :code => 'I', :description => 'Vehicle is always stored indoors.'},
{:active => 1, :name => 'Outdoors', :code => 'O', :description => 'Vehicle is always stored outdoors.'},
{:active => 1, :name => 'Indoor/Outdoor', :code => 'B', :description => 'Vehicle is stored both indoors and outdoors.'}
]
maintenance_provider_types = [
{:active => 1, :name => 'Unknown', :code => 'XX', :description => 'Maintenance provider not supplied.'},
{:active => 1, :name => 'Self Maintained', :code => 'SM', :description => 'Self Maintained.'},
{:active => 1, :name => 'County', :code => 'CO', :description => 'County.'},
{:active => 1, :name => 'Public Agency', :code => 'PA', :description => 'Public Agency.'},
{:active => 1, :name => 'Private Entity', :code => 'PE', :description => 'Private Entity.'}
]
funding_source_types = [
{:active => 1, :name => 'Federal', :description => 'Federal Funding Source'},
{:active => 1, :name => 'State', :description => 'State Funding Source'},
{:active => 1, :name => 'Other', :description => 'Other Funding Source'}
]
replace_tables = %w{ fuel_types vehicle_features vehicle_usage_codes fta_mode_types fta_agency_types fta_service_area_types
fta_service_types fta_funding_types fta_ownership_types fta_vehicle_types facility_capacity_types
facility_features service_types asset_types district_types maintenance_provider_types funding_source_types
file_content_types service_provider_types
vehicle_storage_method_types
}
replace_tables.each do |table_name|
puts " Loading #{table_name}"
if is_mysql
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table_name};")
elsif is_sqlite
ActiveRecord::Base.connection.execute("DELETE FROM #{table_name};")
else
ActiveRecord::Base.connection.execute("TRUNCATE #{table_name} RESTART IDENTITY;")
end
data = eval(table_name)
klass = table_name.classify.constantize
data.each do |row|
x = klass.new(row)
x.save!
end
end
require_relative File.join("seeds", 'team_ali_code_seeds') # TEAM ALI Codes are seeded from a separate file
# These tables are merged with core tables
asset_event_types = [
{:active => 1, :name => 'Update the mileage', :display_icon_name => "fa fa-road", :description => 'Mileage Update', :class_name => 'MileageUpdateEvent', :job_name => 'AssetMileageUpdateJob'},
{:active => 1, :name => 'Update the location', :display_icon_name => "fa fa-map-marker", :description => 'Location Update', :class_name => 'LocationUpdateEvent', :job_name => 'AssetLocationUpdateJob'},
{:active => 1, :name => 'Update the operations metrics', :display_icon_name => "fa fa-calculator", :description => 'Operations Update',:class_name => 'OperationsUpdateEvent', :job_name => 'AssetOperationsUpdateJob'},
{:active => 1, :name => 'Update the use metrics', :display_icon_name => "fa fa-line-chart", :description => 'Usage Update', :class_name => 'UsageUpdateEvent', :job_name => 'AssetUsageUpdateJob'},
{:active => 1, :name => 'Update the storage method', :display_icon_name => "fa fa-star-half-o", :description => 'Storage Method', :class_name => 'StorageMethodUpdateEvent', :job_name => 'AssetStorageMethodUpdateJob'},
{:active => 1, :name => 'Update the usage codes', :display_icon_name => "fa fa-star-half-o", :description => 'Usage Codes', :class_name => 'UsageCodesUpdateEvent', :job_name => 'AssetUsageCodesUpdateJob'}
]
condition_estimation_types = [
{:active => 1, :name => 'TERM', :class_name => 'TermEstimationCalculator', :description => 'Asset condition is estimated using FTA TERM approximations.'}
]
service_life_calculation_types = [
{:active => 1, :name => 'Age and Mileage', :class_name => 'ServiceLifeAgeAndMileage', :description => 'Calculate the replacement year based on the age of the asset or mileage whichever minimizes asset life.'}
]
merge_tables = %w{ asset_event_types condition_estimation_types service_life_calculation_types }
merge_tables.each do |table_name|
puts " Merging #{table_name}"
data = eval(table_name)
klass = table_name.classify.constantize
data.each do |row|
x = klass.new(row)
x.save!
end
end
asset_subtypes = [
{:active => 1, :ali_code => '01', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Std 40 FT', :image => 'bus_std_40_ft.png', :description => 'Bus Std 40 FT'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Std 35 FT', :image => 'bus_std_35_ft.png', :description => 'Bus Std 35 FT'},
{:active => 1, :ali_code => '03', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus 30 FT', :image => 'bus_std_30_ft.png', :description => 'Bus 30 FT'},
{:active => 1, :ali_code => '04', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus < 30 FT', :image => 'bus_std_lt_30_ft.jpg', :description => 'Bus < 30 FT'},
{:active => 1, :ali_code => '05', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus School', :image => 'bus_school.jpg', :description => 'Bus School'},
{:active => 1, :ali_code => '06', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Articulated', :image => 'bus_articulated.jpg', :description => 'Bus Articulated'},
{:active => 1, :ali_code => '07', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Commuter/Suburban', :image => 'bus_commuter.png', :description => 'Bus Commuter/Suburban'},
{:active => 1, :ali_code => '08', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Intercity', :image => 'bus_intercity.jpg', :description => 'Bus Intercity'},
{:active => 1, :ali_code => '09', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Trolley Std', :image => 'trolley_std.jpg', :description => 'Bus Trolley Std'},
{:active => 1, :ali_code => '10', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Trolley Articulated',:image => 'trolley_articulated.png', :description => 'Bus Trolley Articulated'},
{:active => 1, :ali_code => '11', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Double Deck', :image => 'bus_double_deck.jpg', :description => 'Bus Double Deck'},
{:active => 1, :ali_code => '14', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Dual Mode', :image => 'bus_dual_mode.png', :description => 'Bus Dual Mode'},
{:active => 1, :ali_code => '15', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Van', :image => 'van.jpg', :description => 'Van'},
{:active => 1, :ali_code => '16', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Sedan/Station Wagon', :image => 'sedan.jpg', :description => 'Sedan/Station Wagon'},
{:active => 1, :ali_code => '33', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Ferry Boat', :image => 'ferry.jpg', :description => 'Ferry Boat'},
{:active => 1, :ali_code => '20', :belongs_to => 'asset_type', :type => 'Rail Car', :name => 'Light Rail Car', :image => 'light_rail.png', :description => 'Light Rail Car'},
{:active => 1, :ali_code => '21', :belongs_to => 'asset_type', :type => 'Rail Car', :name => 'Heavy Rail Car', :image => 'heavy_rail.png', :description => 'Heavy Rail Car'},
{:active => 1, :ali_code => '22', :belongs_to => 'asset_type', :type => 'Rail Car', :name => 'Commuter Rail Self Propelled (Elec)',:image => 'commuter_rail_self_propelled_elec.png', :description => 'Commuter Rail Self Propelled (Elec)'},
{:active => 1, :ali_code => '28', :belongs_to => 'asset_type', :type => 'Rail Car', :name => 'Commuter Rail Self Propelled (Diesel)', :image => 'commuter_rail_self_propelled_diesel.png', :description => 'Commuter Rail Self Propelled (Diesel)'},
{:active => 1, :ali_code => '23', :belongs_to => 'asset_type', :type => 'Rail Car', :name => 'Commuter Rail Car Trailer', :image => 'commuter_rail_car_trailer.png', :description => 'Commuter Rail Car Trailer'},
{:active => 1, :ali_code => '32', :belongs_to => 'asset_type', :type => 'Rail Car', :name => 'Incline Railway Car', :image => 'inclined_plane.jpg', :description => 'Commuter Rail Car Trailer'},
{:active => 1, :ali_code => '30', :belongs_to => 'asset_type', :type => 'Rail Car', :name => 'Cable Car', :image => 'cable_car.png', :description => 'Commuter Rail Car Trailer'},
{:active => 1, :ali_code => '24', :belongs_to => 'asset_type', :type => 'Locomotive', :name => 'Commuter Locomotive Diesel', :image => 'diesel_locomotive.jpg', :description => 'Commuter Locomotive'},
{:active => 1, :ali_code => '25', :belongs_to => 'asset_type', :type => 'Locomotive', :name => 'Commuter Locomotive Electric',:image => 'electric_locomotive.jpg', :description => 'Commuter Locomotive'},
{:active => 1, :ali_code => '10', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Bus Shelter', :image => 'bus_shelter.png', :description => 'Bus Shelter'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Bus Station', :image => 'bus_station.png', :description => 'Bus Station'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Commuter Rail Station', :image => 'commuter_rail_station.png', :description => 'Commuter Rail Station'},
{:active => 1, :ali_code => '05', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Ferry Dock', :image => 'ferry_dock.png', :description => 'Ferry Dock'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Heavy Rail Station', :image => 'heavy_rail_station.png', :description => 'Heavy Rail Station'},
{:active => 1, :ali_code => '03', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Intermodal Terminal', :image => 'intermodal_terminal.png', :description => 'Intermodal Terminal'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Light Rail Station', :image => 'light_rail_station.png', :description => 'Light Rail Station'},
{:active => 1, :ali_code => '04', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Park and Ride Lot', :image => 'park_and_ride_lot.png', :description => 'Park and Ride Lot'},
{:active => 1, :ali_code => '04', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Parking Garage', :image => 'parking_garage.png', :description => 'Parking Garage'},
{:active => 1, :ali_code => '04', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Parking Lot', :image => 'parking_lot.png', :description => 'Parking Lot'},
{:active => 1, :ali_code => '01', :belongs_to => 'asset_type', :type => 'Support Facility', :name => 'Administration Building', :image => 'administration_building.png', :description => 'Administration Building'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Support Facility', :name => 'Bus Maintenance Facility', :image => 'bus_maintenance_facility.png', :description => 'Bus Maintenance Facility'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Support Facility', :name => 'Bus Parking Facility', :image => 'bus_parking_facility.png', :description => 'Bus Parking Facility'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Support Facility', :name => 'Bus Turnaround Facility', :image => 'bus_turnaround_facility.png', :description => 'Bus Turnaround Facility'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Support Facility', :name => 'Heavy Rail Maintenance Facility', :image => 'heavy_rail_maintenance_facility.png', :description => 'Heavy Rail Maintenance Facility'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Support Facility', :name => 'Light Rail Maintenance Facility', :image => 'light_rail_maintenance_facility.png', :description => 'Light Rail Maintenance Facility'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Support Facility', :name => 'Storage Yard', :image => 'storage_yard.png', :description => 'Storage Yard'},
{:active => 1, :ali_code => '11', :belongs_to => 'asset_type', :type => 'Support Vehicle', :name => 'Van', :image => 'van.jpg', :description => 'Van'},
{:active => 1, :ali_code => '11', :belongs_to => 'asset_type', :type => 'Support Vehicle', :name => 'Tow Truck', :image => 'tow_truck.jpg', :description => 'Tow Truck'},
{:active => 1, :ali_code => '11', :belongs_to => 'asset_type', :type => 'Support Vehicle', :name => 'Sedan/Station Wagon', :image => 'sedan.jpg', :description => 'Sedan/Station Wagon'},
{:active => 1, :ali_code => '11', :belongs_to => 'asset_type', :type => 'Support Vehicle', :name => 'Pickup Truck', :image => 'pickup_truck.png', :description => 'Pickup/Utility Truck'}
]
table_name = 'asset_subtypes'
puts " Loading #{table_name}"
if is_mysql
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table_name};")
elsif is_sqlite
ActiveRecord::Base.connection.execute("DELETE FROM #{table_name};")
else
ActiveRecord::Base.connection.execute("TRUNCATE #{table_name} RESTART IDENTITY;")
end
data = eval(table_name)
data.each do |row|
x = AssetSubtype.new(row.except(:belongs_to, :type))
x.asset_type = AssetType.where(:name => row[:type]).first
x.save!
end
puts "======= Processing TransAM Transit Reports ======="
reports = [
{:active => 1, :belongs_to => 'report_type', :type => "Inventory Report",
:name => 'Useful Life Consumed Report',
:class_name => "ServiceLifeConsumedReport",
:view_name => "generic_chart",
:show_in_nav => 1,
:show_in_dashboard => 1,
:roles => 'user,manager',
:description => 'Displays a summary of the amount of useful life that has been consumed as a percentage of all assets.',
:chart_type => 'column',
:chart_options => "{is3D : true, isStacked: true, fontSize: 10, hAxis: {title: 'Percent of expected useful life consumed'}, vAxis: {title: 'Share of all assets'}}"},
{:active => 1, :belongs_to => 'report_type', :type => "Inventory Report",
:name => 'Asset Condition Report',
:class_name => "AssetConditionReport",
:view_name => "generic_chart",
:show_in_nav => 1,
:show_in_dashboard => 0,
:roles => 'user,manager',
:description => 'Displays asset counts by condition.',
:chart_type => 'pie',
:chart_options => '{is3D : true}'},
{:active => 1, :belongs_to => 'report_type', :type => "Inventory Report",
:name => 'Asset Subtype Report',
:class_name => "AssetSubtypeReport",
:view_name => "generic_chart",
:show_in_nav => 1,
:show_in_dashboard => 0,
:roles => 'user,manager',
:description => 'Displays asset counts by subtypes.',
:chart_type => 'pie',
:chart_options => '{is3D : true}'},
{:active => 1, :belongs_to => 'report_type', :type => "Inventory Report",
:name => 'Asset Age Report',
:class_name => "AssetAgeReport",
:view_name => "generic_chart",
:show_in_nav => 1,
:show_in_dashboard => 0,
:roles => 'user,manager',
:description => 'Displays asset counts by age.',
:chart_type => 'column',
:chart_options => "{is3D : true, isStacked : true, hAxis: {title: 'Age (years)'}, vAxis: {title: 'Count'}}"},
{:active => 1, :belongs_to => 'report_type', :type => "Capital Needs Report",
:name => 'Backlog Report',
:class_name => "BacklogReport",
:view_name => "generic_report",
:show_in_nav => 1,
:show_in_dashboard => 0,
:roles => 'user,manager',
:description => 'Determines backlog needs.'},
{:active => 1, :belongs_to => 'report_type', :type => "Inventory Report",
:name => 'Asset Type by Org Report',
:class_name => "CustomSqlReport",
:view_name => "generic_report_table",
:show_in_nav => 0,
:show_in_dashboard => 0,
:roles => 'user,manager',
:description => 'Displays a sumamry of asset types by agency.',
:custom_sql => "SELECT c.short_name AS 'Org', b.name AS 'Type', COUNT(*) AS 'Count' FROM assets a LEFT JOIN asset_subtypes b ON a.asset_subtype_id = b.id LEFT JOIN organizations c ON a.organization_id = c.id GROUP BY a.organization_id, a.asset_subtype_id ORDER BY c.short_name, b.name"}
]
table_name = 'reports'
puts " Merging #{table_name}"
data = eval(table_name)
data.each do |row|
puts "Creating Report #{row[:name]}"
x = Report.new(row.except(:belongs_to, :type))
x.report_type = ReportType.find_by(:name => row[:type])
x.save!
end
Add SUVs to support vehicle asset subtype
#encoding: utf-8
#TransamCore::Engine.load_seed
#TransamSpatial::Engine.load_seed
# determine if we are using postgres or mysql
is_mysql = (ActiveRecord::Base.configurations[Rails.env]['adapter'] == 'mysql2')
is_sqlite = (ActiveRecord::Base.configurations[Rails.env]['adapter'] == 'sqlite3')
puts "======= Processing TransAM Transit Lookup Tables ======="
#------------------------------------------------------------------------------
#
# Customized Lookup Tables
#
# These are the specific to TransAM Transit
#
#------------------------------------------------------------------------------
fuel_types = [
{:active => 1, :name => 'Unknown', :code => 'XX', :description => 'No Fuel type specified.'},
{:active => 1, :name => 'Biodiesel', :code => 'BD', :description => 'Biodiesel.'},
{:active => 1, :name => 'Bunker Fuel', :code => 'BF', :description => 'Bunker Fuel.'},
{:active => 1, :name => 'Compressed Natural Gas', :code => 'CN', :description => 'Compressed Natutral Gas.'},
{:active => 1, :name => 'Diesel Fuel', :code => 'DF', :description => 'Diesel Fuel.'},
{:active => 1, :name => 'Dual Fuel', :code => 'DU', :description => 'Dual Fuel.'},
{:active => 1, :name => 'Electric Battery', :code => 'EB', :description => 'Electric Battery.'},
{:active => 1, :name => 'Electric Propulsion', :code => 'EP', :description => 'Electric Propulsion.'},
{:active => 1, :name => 'Ethanol', :code => 'ET', :description => 'Ethanol.'},
{:active => 1, :name => 'Gasoline', :code => 'GA', :description => 'Gasoline.'},
{:active => 1, :name => 'Hybrid Diesel', :code => 'HD', :description => 'Hybrid Diesel.'},
{:active => 1, :name => 'Hybrid Gasoline', :code => 'HG', :description => 'Hybrid Gasoline.'},
{:active => 1, :name => 'Hydrogen', :code => 'HY', :description => 'Hydrogen.'},
{:active => 1, :name => 'Kerosene', :code => 'KE', :description => 'Kerosene.'},
{:active => 1, :name => 'Liquefied Natural Gas', :code => 'LN', :description => 'Liquefied Natural Gas.'},
{:active => 1, :name => 'Liquefied Petroleum Gas', :code => 'LP', :description => 'Liquefied Petroleum Gas.'},
{:active => 1, :name => 'Methanol', :code => 'MT', :description => 'Methanol.'},
{:active => 1, :name => 'Other', :code => 'OR', :description => 'Other.'}
]
vehicle_features = [
{:active => 1, :name => 'AVL System', :code => 'AS', :description => 'Automatic Vehicle Location System.'},
{:active => 1, :name => 'Lift Equipped', :code => 'LE', :description => 'Lift Equipped.'},
{:active => 1, :name => 'Electronic Ramp', :code => 'ER', :description => 'Electronic Ramp.'},
{:active => 1, :name => 'Video Cameras', :code => 'VC', :description => 'Video Cameras.'},
{:active => 1, :name => 'Fare Box (Standard)', :code => 'FBS', :description => 'Fare Box (Standard).'},
{:active => 1, :name => 'Fare Box (Electronic)',:code => 'FBE', :description => 'Fare Box (Electronic).'},
{:active => 1, :name => 'Radio Equipped', :code => 'RE', :description => 'Radio Equipped.'},
{:active => 1, :name => 'Bike Rack', :code => 'BR', :description => 'Bike Rack.'},
{:active => 1, :name => 'Scheduling Software', :code => 'SS', :description => 'Scheduling Software.'},
{:active => 1, :name => 'WIFI', :code => 'WI', :description => 'WIFI.'}
]
vehicle_usage_codes = [
{:active => 1, :name => 'Unknown', :code => 'X', :description => 'No Vehicle usage specified.'},
{:active => 1, :name => 'Revenue vehicle', :code => 'R', :description => 'Revenue vehicle.'},
{:active => 1, :name => 'Support Vehicle', :code => 'S', :description => 'Support vehicle.'},
{:active => 1, :name => 'Van Pool', :code => 'V', :description => 'Van Pool.'},
{:active => 1, :name => 'Paratransit', :code => 'P', :description => 'Paratransit.'},
{:active => 1, :name => 'Spare Inventory', :code => 'I', :description => 'Spare Inventory.'}
]
fta_mode_types = [
{:active => 1, :name => 'Unknown', :code => 'XX', :description => 'No FTA mode type specified.'},
{:active => 1, :name => 'Aerial Tramway', :code => 'TR', :description => 'Aerial Tramway.'},
{:active => 1, :name => 'Bus', :code => 'MB', :description => 'Bus.'},
{:active => 1, :name => 'Bus Rapid Transit', :code => 'RB', :description => 'Bus rapid transit.'},
{:active => 1, :name => 'Commuter Bus', :code => 'CB', :description => 'Commuter bus.'},
{:active => 1, :name => 'Demand Response', :code => 'DR', :description => 'Demand Response.'},
{:active => 1, :name => 'Ferry Boat', :code => 'FB', :description => 'Ferryboat.'},
{:active => 1, :name => 'Jitney', :code => 'JT', :description => 'Jitney.'},
{:active => 1, :name => 'Publico', :code => 'PB', :description => 'Publico.'},
{:active => 1, :name => 'Trolley Bus', :code => 'TB', :description => 'Trolleybus.'},
{:active => 1, :name => 'Van Pool', :code => 'VP', :description => 'Vanpool.'},
{:active => 1, :name => 'Alaska Railroad', :code => 'AR', :description => 'Alaska Railroad.'},
{:active => 1, :name => 'Monorail/Automated Guideway Transit', :code => 'MG', :description => 'Monorail/Automated guideway transit.'},
{:active => 1, :name => 'Cable Car', :code => 'CC', :description => 'Cable car.'},
{:active => 1, :name => 'Commuter Rail', :code => 'CR', :description => 'Commuter rail.'},
{:active => 1, :name => 'Heavy Rail', :code => 'HR', :description => 'Heavy rail.'},
{:active => 1, :name => 'Inclined Plane', :code => 'IP', :description => 'Inclined plane.'},
{:active => 1, :name => 'Light Rail', :code => 'LR', :description => 'Light rail.'},
{:active => 1, :name => 'Street Car', :code => 'SR', :description => 'Streetcar.'},
{:active => 1, :name => 'Hybrid Rail', :code => 'HR', :description => 'Hybrid rail.'}
]
fta_service_types = [
{:active => 1, :name => 'Unknown', :code => 'XX', :description => 'FTA Service type not specified.'},
{:active => 1, :name => 'Directly Operated', :code => 'DO', :description => 'Directly Operated.'},
{:active => 1, :name => 'Purchased Transportation', :code => 'PT', :description => 'Purchased Transportation.'}
]
fta_agency_types = [
{:active => 1, :name => 'Public Agency (Not DOT or Tribal)', :description => 'Public Agency (Not DOT or Tribal).'},
{:active => 1, :name => 'Public Agency (State DOT)', :description => 'Public Agency (State DOT).'},
{:active => 1, :name => 'Public Agency (Tribal)', :description => 'Public Agency (Tribal).'},
{:active => 1, :name => 'Private (Not for profit)', :description => 'Private (Not for profit).'}
]
fta_service_area_types = [
{:active => 1, :name => 'County / Independent city', :description => 'County / Independent city.'},
{:active => 1, :name => 'Multi-county / Independent city', :description => 'Multi-county / Independent city.'},
{:active => 1, :name => 'Multi-state', :description => 'Multi-state.'},
{:active => 1, :name => 'Municipality', :description => 'Municipality.'},
{:active => 1, :name => 'Reservation', :description => 'Reservation.'},
{:active => 1, :name => 'Other', :description => 'Other.'}
]
fta_funding_types = [
{:active => 1, :name => 'Unknown', :code => 'XX', :description => 'FTA funding type not specified.'},
{:active => 1, :name => 'Urbanized Area Formula Program', :code => 'UA', :description => 'UA -Urbanized Area Formula Program.'},
{:active => 1, :name => 'Other Federal funds', :code => 'OF', :description => 'OF-Other Federal funds.'},
{:active => 1, :name => 'Non-Federal public funds', :code => 'NFPA', :description => 'NFPA-Non-Federal public funds.'},
{:active => 1, :name => 'Non-Federal private funds', :code => 'NFPE', :description => 'NFPE-Non-Federal private funds.'}
]
fta_ownership_types = [
{:active => 1, :name => 'Unknown', :code => 'XX', :description => 'FTA ownership type not specified.'},
{:active => 1, :name => 'Lease purchase by a public agency', :code => 'LPPA', :description => 'Leased under lease purchase agreement by a public agency.'},
{:active => 1, :name => 'Lease purchase by a private entity', :code => 'LPPE', :description => 'Leased under lease purchase agreement by a private entity.'},
{:active => 1, :name => 'Lease or borrowed by a public agency', :code => 'LRPA', :description => 'Leased or borrowed from related parties by a public agency.'},
{:active => 1, :name => 'Lease or borrowed by a private agency',:code => 'LRPE', :description => 'Leased or borrowed from related parties by a private entity.'},
{:active => 1, :name => 'Owned outright by a public agency', :code => 'OOPA', :description => 'Owned outright by a public agency (includes safe-harbor leasing agreements where only the tax title is sold).'},
{:active => 1, :name => 'Owned outright by a private entity', :code => 'OOPE', :description => 'Owned outright by a private entity (includes safe-harbor leasing agreements where only the tax title is sold).'},
{:active => 1, :name => 'True lease by a public agency', :code => 'TLPA', :description => 'True lease by a public agency.'},
{:active => 1, :name => 'True lease by a private entity', :code => 'TLPE', :description => 'True lease by a private entity.'},
{:active => 1, :name => 'Other', :code => 'OR', :description => 'Other.'}
]
fta_vehicle_types = [
{:active => 1, :name => 'Unknown', :code => 'XX', :description => 'Vehicle type not specified.'},
{:active => 1, :name => 'Articulated Bus', :code => 'AB', :description => 'Articulated Bus.'},
{:active => 1, :name => 'Automated Guideway Vehicle', :code => 'AG', :description => 'Automated Guideway Vehicle.'},
{:active => 1, :name => 'Automobile', :code => 'AO', :description => 'Automobile.'},
{:active => 1, :name => 'Over-The-Road Bus', :code => 'BR', :description => 'Over-The-Road Bus.'},
{:active => 1, :name => 'Bus', :code => 'BU', :description => 'Bus.'},
{:active => 1, :name => 'Cable Car', :code => 'CC', :description => 'Cable Car.'},
{:active => 1, :name => 'Cutaway', :code => 'CU', :description => 'Cutaway.'},
{:active => 1, :name => 'Double Decker Bus', :code => 'DB', :description => 'Double Decker Bus.'},
{:active => 1, :name => 'Ferry Boat', :code => 'FB', :description => 'Ferryboat.'},
{:active => 1, :name => 'Heavy Rail Passenger Car', :code => 'HR', :description => 'Heavy Rail Passenger Car.'},
{:active => 1, :name => 'Inclined Plane Vehicle', :code => 'IP', :description => 'Inclined Plane Vehicle.'},
{:active => 1, :name => 'Light Rail Vehicle', :code => 'LR', :description => 'Light Rail Vehicle.'},
{:active => 1, :name => 'Monorail/Automated Guideway', :code => 'MO', :description => 'Monorail/Automated Guideway.'},
{:active => 1, :name => 'Mini Van', :code => 'MV', :description => 'Minivan.'},
{:active => 1, :name => 'Commuter Rail Locomotive', :code => 'RL', :description => 'Commuter Rail Locomotive.'},
{:active => 1, :name => 'Commuter Rail Passenger Coach', :code => 'RP', :description => 'Commuter Rail Passenger Coach.'},
{:active => 1, :name => 'Commuter Rail Self-Propelled Passenger Car', :code => 'RS', :description => 'Commuter Rail Self-Propelled Passenger Car.'},
{:active => 1, :name => 'School Bus', :code => 'SB', :description => 'School Bus.'},
{:active => 1, :name => 'Sports Utility Vehicle', :code => 'SV', :description => 'Sports Utility Vehicle.'},
{:active => 1, :name => 'Trolley Bus', :code => 'TB', :description => 'Trolley Bus.'},
{:active => 1, :name => 'Aerial Tramway', :code => 'TR', :description => 'Aerial Tramway.'},
{:active => 1, :name => 'Taxicab Sedan', :code => 'TS', :description => 'Taxicab Sedan.'},
{:active => 1, :name => 'Taxicab Van', :code => 'TV', :description => 'Taxicab Van.'},
{:active => 1, :name => 'Taxicab Station Wagon', :code => 'TW', :description => 'Taxicab Station Wagon.'},
{:active => 1, :name => 'Van', :code => 'VN', :description => 'Van.'},
{:active => 1, :name => 'Vintage Trolley/Streetcar',:code => 'VT', :description => 'Vintage Trolley/Streetcar.'}
]
facility_capacity_types = [
{:active => 1, :name => 'N/A', :description => 'Not applicable.'},
{:active => 1, :name => 'Less than 200 vehicles', :description => 'Less than 200 vehicles.'},
{:active => 1, :name => 'Between 200 and 300 vehicles', :description => 'Between 200 and 300 vehicles.'},
{:active => 1, :name => 'Over 300 vehicles', :description => 'Over 300 vehicles.'}
]
facility_features = [
{:active => 1, :name => 'Moving walkways', :code => 'MW', :description => 'Moving walkways.'},
{:active => 1, :name => 'Ticketing', :code => 'TK', :description => 'Ticketing.'},
{:active => 1, :name => 'Information kiosks', :code => 'IK', :description => 'Information kiosks.'},
{:active => 1, :name => 'Restrooms', :code => 'RR', :description => 'Restrooms.'},
{:active => 1, :name => 'Concessions', :code => 'CS', :description => 'Concessions.'},
{:active => 1, :name => 'Telephones', :code => 'TP', :description => 'Telephones.'},
{:active => 1, :name => 'ATM', :code => 'AT', :description => 'ATM.'},
{:active => 1, :name => 'WIFI', :code => 'WI', :description => 'WIFI.'}
]
service_types = [
{:active => 1, :name => 'Urban', :code => 'URB', :description => 'Operates in an urban area.'},
{:active => 1, :name => 'Rural', :code => 'RUR', :description => 'Operates in a rural area.'},
{:active => 1, :name => 'Shared Ride', :code => 'SHR', :description => 'Provides shared ride services.'},
{:active => 1, :name => 'Intercity Bus', :code => 'ICB', :description => 'Provides intercity bus services.'},
{:active => 1, :name => 'Intercity Rail', :code => 'ICR', :description => 'Provides intercity rail services.'},
{:active => 1, :name => '5310', :code => '5310', :description => 'Provides 5310 services.'},
{:active => 1, :name => 'NFRDM', :code => 'NFRDM', :description => 'Provides NFRDM services.'},
{:active => 1, :name => 'WTW', :code => 'WTW', :description => 'Provides WTW services.'},
{:active => 1, :name => 'Other', :code => 'OTH', :description => 'Provides other services.'}
]
district_types = [
{:active => 1, :name => 'State', :description => 'State.'},
{:active => 1, :name => 'District', :description => 'Engineering District.'},
{:active => 1, :name => 'MSA', :description => 'Metropolitan Statistical Area.'},
{:active => 1, :name => 'County', :description => 'County.'},
{:active => 1, :name => 'City', :description => 'City.'},
{:active => 1, :name => 'Borough', :description => 'Borough.'},
{:active => 1, :name => 'MPO/RPO', :description => 'MPO or RPO planning area.'},
{:active => 1, :name => 'Postal Code', :description => 'ZIP Code or Postal Area.'}
]
asset_types = [
{:active => 1, :name => 'Vehicle', :description => 'Vehicle', :class_name => 'Vehicle', :map_icon_name => "redIcon", :display_icon_name => "fa fa-bus", :new_inventory_template_name => 'new_inventory_template_v_3_4.xlsx'},
{:active => 1, :name => 'Rail Car', :description => 'Rail Car', :class_name => 'RailCar', :map_icon_name => "orangeIcon", :display_icon_name => "fa travelcon travelcon-subway", :new_inventory_template_name => 'new_inventory_template_v_3_4.xlsx'},
{:active => 1, :name => 'Locomotive', :description => 'Locomotive', :class_name => 'Locomotive', :map_icon_name => "greenIcon", :display_icon_name => "fa travelcon travelcon-train", :new_inventory_template_name => 'new_inventory_template_v_3_4.xlsx'},
{:active => 1, :name => 'Transit Facility', :description => 'Transit Facility', :class_name => 'TransitFacility', :map_icon_name => "greenIcon", :display_icon_name => "fa fa-building-o", :new_inventory_template_name => 'new_facility_inventory_template_v_1_0.xlsx'},
{:active => 1, :name => 'Support Facility', :description => 'Support Facility', :class_name => 'SupportFacility', :map_icon_name => "blueIcon", :display_icon_name => "fa fa-building", :new_inventory_template_name => 'new_facility_inventory_template_v_1_0.xlsx'},
{:active => 1, :name => 'Bridge/Tunnel', :description => 'Bridges and Tunnels', :class_name => 'BridgeTunnel', :map_icon_name => "redIcon", :display_icon_name => "fa fa-square", :new_inventory_template_name => 'new_facility_inventory_template_v_1_0.xlsx'},
{:active => 1, :name => 'Support Vehicle', :description => 'Support Vehicle', :class_name => 'SupportVehicle', :map_icon_name => "redIcon", :display_icon_name => "fa fa-truck", :new_inventory_template_name => 'new_inventory_template_v_3_4.xlsx'}
]
file_content_types = [
{:active => 1, :name => 'New Inventory', :class_name => 'NewInventoryFileHandler', :builder_name => "NewInventoryTemplateBuilder", :description => 'Worksheet contains new inventory to be loaded into TransAM.'},
{:active => 1, :name => 'Status Updates', :class_name => 'StatusUpdatesFileHandler', :builder_name => "StatusUpdatesTemplateBuilder", :description => 'Worksheet records condition, usage, and operational updates for exisiting inventory.'},
{:active => 1, :name => 'Disposition Updates', :class_name => 'DispositionUpdatesFileHandler', :builder_name => "DispositionUpdatesTemplateBuilder", :description => 'Worksheet contains final disposition updates for existing inventory.'}
]
service_provider_types = [
{:active => 1, :name => 'Rural General Public Transit Service Provider', :code => 'RU-20', :description => 'Rural General Public Transit Service provider.'},
{:active => 1, :name => 'Intercity Bus Service Provider', :code => 'RU-21', :description => 'Intercity Bus Service provider.'},
{:active => 1, :name => 'Rural Recipient Reporting Separately', :code => 'RU-22', :description => 'Rural Recipient Reporting Separately.'},
{:active => 1, :name => 'Urban Recipient', :code => 'RU-23', :description => 'Urban Recipient.'}
]
vehicle_storage_method_types = [
{:active => 1, :name => 'Unknown',:code => 'X', :description => 'Vehicle storage method not supplied.'},
{:active => 1, :name => 'Indoors', :code => 'I', :description => 'Vehicle is always stored indoors.'},
{:active => 1, :name => 'Outdoors', :code => 'O', :description => 'Vehicle is always stored outdoors.'},
{:active => 1, :name => 'Indoor/Outdoor', :code => 'B', :description => 'Vehicle is stored both indoors and outdoors.'}
]
maintenance_provider_types = [
{:active => 1, :name => 'Unknown', :code => 'XX', :description => 'Maintenance provider not supplied.'},
{:active => 1, :name => 'Self Maintained', :code => 'SM', :description => 'Self Maintained.'},
{:active => 1, :name => 'County', :code => 'CO', :description => 'County.'},
{:active => 1, :name => 'Public Agency', :code => 'PA', :description => 'Public Agency.'},
{:active => 1, :name => 'Private Entity', :code => 'PE', :description => 'Private Entity.'}
]
funding_source_types = [
{:active => 1, :name => 'Federal', :description => 'Federal Funding Source'},
{:active => 1, :name => 'State', :description => 'State Funding Source'},
{:active => 1, :name => 'Other', :description => 'Other Funding Source'}
]
replace_tables = %w{ fuel_types vehicle_features vehicle_usage_codes fta_mode_types fta_agency_types fta_service_area_types
fta_service_types fta_funding_types fta_ownership_types fta_vehicle_types facility_capacity_types
facility_features service_types asset_types district_types maintenance_provider_types funding_source_types
file_content_types service_provider_types
vehicle_storage_method_types
}
replace_tables.each do |table_name|
puts " Loading #{table_name}"
if is_mysql
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table_name};")
elsif is_sqlite
ActiveRecord::Base.connection.execute("DELETE FROM #{table_name};")
else
ActiveRecord::Base.connection.execute("TRUNCATE #{table_name} RESTART IDENTITY;")
end
data = eval(table_name)
klass = table_name.classify.constantize
data.each do |row|
x = klass.new(row)
x.save!
end
end
require_relative File.join("seeds", 'team_ali_code_seeds') # TEAM ALI Codes are seeded from a separate file
# These tables are merged with core tables
asset_event_types = [
{:active => 1, :name => 'Update the mileage', :display_icon_name => "fa fa-road", :description => 'Mileage Update', :class_name => 'MileageUpdateEvent', :job_name => 'AssetMileageUpdateJob'},
{:active => 1, :name => 'Update the location', :display_icon_name => "fa fa-map-marker", :description => 'Location Update', :class_name => 'LocationUpdateEvent', :job_name => 'AssetLocationUpdateJob'},
{:active => 1, :name => 'Update the operations metrics', :display_icon_name => "fa fa-calculator", :description => 'Operations Update',:class_name => 'OperationsUpdateEvent', :job_name => 'AssetOperationsUpdateJob'},
{:active => 1, :name => 'Update the use metrics', :display_icon_name => "fa fa-line-chart", :description => 'Usage Update', :class_name => 'UsageUpdateEvent', :job_name => 'AssetUsageUpdateJob'},
{:active => 1, :name => 'Update the storage method', :display_icon_name => "fa fa-star-half-o", :description => 'Storage Method', :class_name => 'StorageMethodUpdateEvent', :job_name => 'AssetStorageMethodUpdateJob'},
{:active => 1, :name => 'Update the usage codes', :display_icon_name => "fa fa-star-half-o", :description => 'Usage Codes', :class_name => 'UsageCodesUpdateEvent', :job_name => 'AssetUsageCodesUpdateJob'}
]
condition_estimation_types = [
{:active => 1, :name => 'TERM', :class_name => 'TermEstimationCalculator', :description => 'Asset condition is estimated using FTA TERM approximations.'}
]
service_life_calculation_types = [
{:active => 1, :name => 'Age and Mileage', :class_name => 'ServiceLifeAgeAndMileage', :description => 'Calculate the replacement year based on the age of the asset or mileage whichever minimizes asset life.'}
]
merge_tables = %w{ asset_event_types condition_estimation_types service_life_calculation_types }
merge_tables.each do |table_name|
puts " Merging #{table_name}"
data = eval(table_name)
klass = table_name.classify.constantize
data.each do |row|
x = klass.new(row)
x.save!
end
end
asset_subtypes = [
{:active => 1, :ali_code => '01', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Std 40 FT', :image => 'bus_std_40_ft.png', :description => 'Bus Std 40 FT'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Std 35 FT', :image => 'bus_std_35_ft.png', :description => 'Bus Std 35 FT'},
{:active => 1, :ali_code => '03', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus 30 FT', :image => 'bus_std_30_ft.png', :description => 'Bus 30 FT'},
{:active => 1, :ali_code => '04', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus < 30 FT', :image => 'bus_std_lt_30_ft.jpg', :description => 'Bus < 30 FT'},
{:active => 1, :ali_code => '05', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus School', :image => 'bus_school.jpg', :description => 'Bus School'},
{:active => 1, :ali_code => '06', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Articulated', :image => 'bus_articulated.jpg', :description => 'Bus Articulated'},
{:active => 1, :ali_code => '07', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Commuter/Suburban', :image => 'bus_commuter.png', :description => 'Bus Commuter/Suburban'},
{:active => 1, :ali_code => '08', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Intercity', :image => 'bus_intercity.jpg', :description => 'Bus Intercity'},
{:active => 1, :ali_code => '09', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Trolley Std', :image => 'trolley_std.jpg', :description => 'Bus Trolley Std'},
{:active => 1, :ali_code => '10', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Trolley Articulated',:image => 'trolley_articulated.png', :description => 'Bus Trolley Articulated'},
{:active => 1, :ali_code => '11', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Double Deck', :image => 'bus_double_deck.jpg', :description => 'Bus Double Deck'},
{:active => 1, :ali_code => '14', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Bus Dual Mode', :image => 'bus_dual_mode.png', :description => 'Bus Dual Mode'},
{:active => 1, :ali_code => '15', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Van', :image => 'van.jpg', :description => 'Van'},
{:active => 1, :ali_code => '16', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Sedan/Station Wagon', :image => 'sedan.jpg', :description => 'Sedan/Station Wagon'},
{:active => 1, :ali_code => '33', :belongs_to => 'asset_type', :type => 'Vehicle', :name => 'Ferry Boat', :image => 'ferry.jpg', :description => 'Ferry Boat'},
{:active => 1, :ali_code => '20', :belongs_to => 'asset_type', :type => 'Rail Car', :name => 'Light Rail Car', :image => 'light_rail.png', :description => 'Light Rail Car'},
{:active => 1, :ali_code => '21', :belongs_to => 'asset_type', :type => 'Rail Car', :name => 'Heavy Rail Car', :image => 'heavy_rail.png', :description => 'Heavy Rail Car'},
{:active => 1, :ali_code => '22', :belongs_to => 'asset_type', :type => 'Rail Car', :name => 'Commuter Rail Self Propelled (Elec)',:image => 'commuter_rail_self_propelled_elec.png', :description => 'Commuter Rail Self Propelled (Elec)'},
{:active => 1, :ali_code => '28', :belongs_to => 'asset_type', :type => 'Rail Car', :name => 'Commuter Rail Self Propelled (Diesel)', :image => 'commuter_rail_self_propelled_diesel.png', :description => 'Commuter Rail Self Propelled (Diesel)'},
{:active => 1, :ali_code => '23', :belongs_to => 'asset_type', :type => 'Rail Car', :name => 'Commuter Rail Car Trailer', :image => 'commuter_rail_car_trailer.png', :description => 'Commuter Rail Car Trailer'},
{:active => 1, :ali_code => '32', :belongs_to => 'asset_type', :type => 'Rail Car', :name => 'Incline Railway Car', :image => 'inclined_plane.jpg', :description => 'Commuter Rail Car Trailer'},
{:active => 1, :ali_code => '30', :belongs_to => 'asset_type', :type => 'Rail Car', :name => 'Cable Car', :image => 'cable_car.png', :description => 'Commuter Rail Car Trailer'},
{:active => 1, :ali_code => '24', :belongs_to => 'asset_type', :type => 'Locomotive', :name => 'Commuter Locomotive Diesel', :image => 'diesel_locomotive.jpg', :description => 'Commuter Locomotive'},
{:active => 1, :ali_code => '25', :belongs_to => 'asset_type', :type => 'Locomotive', :name => 'Commuter Locomotive Electric',:image => 'electric_locomotive.jpg', :description => 'Commuter Locomotive'},
{:active => 1, :ali_code => '10', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Bus Shelter', :image => 'bus_shelter.png', :description => 'Bus Shelter'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Bus Station', :image => 'bus_station.png', :description => 'Bus Station'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Commuter Rail Station', :image => 'commuter_rail_station.png', :description => 'Commuter Rail Station'},
{:active => 1, :ali_code => '05', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Ferry Dock', :image => 'ferry_dock.png', :description => 'Ferry Dock'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Heavy Rail Station', :image => 'heavy_rail_station.png', :description => 'Heavy Rail Station'},
{:active => 1, :ali_code => '03', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Intermodal Terminal', :image => 'intermodal_terminal.png', :description => 'Intermodal Terminal'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Light Rail Station', :image => 'light_rail_station.png', :description => 'Light Rail Station'},
{:active => 1, :ali_code => '04', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Park and Ride Lot', :image => 'park_and_ride_lot.png', :description => 'Park and Ride Lot'},
{:active => 1, :ali_code => '04', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Parking Garage', :image => 'parking_garage.png', :description => 'Parking Garage'},
{:active => 1, :ali_code => '04', :belongs_to => 'asset_type', :type => 'Transit Facility', :name => 'Parking Lot', :image => 'parking_lot.png', :description => 'Parking Lot'},
{:active => 1, :ali_code => '01', :belongs_to => 'asset_type', :type => 'Support Facility', :name => 'Administration Building', :image => 'administration_building.png', :description => 'Administration Building'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Support Facility', :name => 'Bus Maintenance Facility', :image => 'bus_maintenance_facility.png', :description => 'Bus Maintenance Facility'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Support Facility', :name => 'Bus Parking Facility', :image => 'bus_parking_facility.png', :description => 'Bus Parking Facility'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Support Facility', :name => 'Bus Turnaround Facility', :image => 'bus_turnaround_facility.png', :description => 'Bus Turnaround Facility'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Support Facility', :name => 'Heavy Rail Maintenance Facility', :image => 'heavy_rail_maintenance_facility.png', :description => 'Heavy Rail Maintenance Facility'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Support Facility', :name => 'Light Rail Maintenance Facility', :image => 'light_rail_maintenance_facility.png', :description => 'Light Rail Maintenance Facility'},
{:active => 1, :ali_code => '02', :belongs_to => 'asset_type', :type => 'Support Facility', :name => 'Storage Yard', :image => 'storage_yard.png', :description => 'Storage Yard'},
{:active => 1, :ali_code => '11', :belongs_to => 'asset_type', :type => 'Support Vehicle', :name => 'Van', :image => 'van.jpg', :description => 'Van'},
{:active => 1, :ali_code => '11', :belongs_to => 'asset_type', :type => 'Support Vehicle', :name => 'Tow Truck', :image => 'tow_truck.jpg', :description => 'Tow Truck'},
{:active => 1, :ali_code => '11', :belongs_to => 'asset_type', :type => 'Support Vehicle', :name => 'Sedan/Station Wagon', :image => 'sedan.jpg', :description => 'Sedan/Station Wagon'},
{:active => 1, :ali_code => '11', :belongs_to => 'asset_type', :type => 'Support Vehicle', :name => 'Pickup Truck', :image => 'pickup_truck.png', :description => 'Pickup/Utility Truck'},
{:active => 1, :ali_code => '11', :belongs_to => 'asset_type', :type => 'Support Vehicle', :name => 'Sports Utility Vehicle', :image => 'pickup_truck.png', :description => 'Sports Utility Vehicle'}
]
table_name = 'asset_subtypes'
puts " Loading #{table_name}"
if is_mysql
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table_name};")
elsif is_sqlite
ActiveRecord::Base.connection.execute("DELETE FROM #{table_name};")
else
ActiveRecord::Base.connection.execute("TRUNCATE #{table_name} RESTART IDENTITY;")
end
data = eval(table_name)
data.each do |row|
x = AssetSubtype.new(row.except(:belongs_to, :type))
x.asset_type = AssetType.where(:name => row[:type]).first
x.save!
end
puts "======= Processing TransAM Transit Reports ======="
reports = [
{:active => 1, :belongs_to => 'report_type', :type => "Inventory Report",
:name => 'Useful Life Consumed Report',
:class_name => "ServiceLifeConsumedReport",
:view_name => "generic_chart",
:show_in_nav => 1,
:show_in_dashboard => 1,
:roles => 'user,manager',
:description => 'Displays a summary of the amount of useful life that has been consumed as a percentage of all assets.',
:chart_type => 'column',
:chart_options => "{is3D : true, isStacked: true, fontSize: 10, hAxis: {title: 'Percent of expected useful life consumed'}, vAxis: {title: 'Share of all assets'}}"},
{:active => 1, :belongs_to => 'report_type', :type => "Inventory Report",
:name => 'Asset Condition Report',
:class_name => "AssetConditionReport",
:view_name => "generic_chart",
:show_in_nav => 1,
:show_in_dashboard => 0,
:roles => 'user,manager',
:description => 'Displays asset counts by condition.',
:chart_type => 'pie',
:chart_options => '{is3D : true}'},
{:active => 1, :belongs_to => 'report_type', :type => "Inventory Report",
:name => 'Asset Subtype Report',
:class_name => "AssetSubtypeReport",
:view_name => "generic_chart",
:show_in_nav => 1,
:show_in_dashboard => 0,
:roles => 'user,manager',
:description => 'Displays asset counts by subtypes.',
:chart_type => 'pie',
:chart_options => '{is3D : true}'},
{:active => 1, :belongs_to => 'report_type', :type => "Inventory Report",
:name => 'Asset Age Report',
:class_name => "AssetAgeReport",
:view_name => "generic_chart",
:show_in_nav => 1,
:show_in_dashboard => 0,
:roles => 'user,manager',
:description => 'Displays asset counts by age.',
:chart_type => 'column',
:chart_options => "{is3D : true, isStacked : true, hAxis: {title: 'Age (years)'}, vAxis: {title: 'Count'}}"},
{:active => 1, :belongs_to => 'report_type', :type => "Capital Needs Report",
:name => 'Backlog Report',
:class_name => "BacklogReport",
:view_name => "generic_report",
:show_in_nav => 1,
:show_in_dashboard => 0,
:roles => 'user,manager',
:description => 'Determines backlog needs.'},
{:active => 1, :belongs_to => 'report_type', :type => "Inventory Report",
:name => 'Asset Type by Org Report',
:class_name => "CustomSqlReport",
:view_name => "generic_report_table",
:show_in_nav => 0,
:show_in_dashboard => 0,
:roles => 'user,manager',
:description => 'Displays a sumamry of asset types by agency.',
:custom_sql => "SELECT c.short_name AS 'Org', b.name AS 'Type', COUNT(*) AS 'Count' FROM assets a LEFT JOIN asset_subtypes b ON a.asset_subtype_id = b.id LEFT JOIN organizations c ON a.organization_id = c.id GROUP BY a.organization_id, a.asset_subtype_id ORDER BY c.short_name, b.name"}
]
table_name = 'reports'
puts " Merging #{table_name}"
data = eval(table_name)
data.each do |row|
puts "Creating Report #{row[:name]}"
x = Report.new(row.except(:belongs_to, :type))
x.report_type = ReportType.find_by(:name => row[:type])
x.save!
end
|
module SAML2
VERSION = '1.1.5'
end
bump version
major version bump due to some API incompatibilities
Change-Id: I1f6d9399786a346cd2cce6cfd795c89dfccc042b
module SAML2
VERSION = '2.0.0'
end
|
module SampleModels
mattr_reader :models
@@models = Hash.new { |h, model_class|
h[model_class] = Model.new(model_class)
}
mattr_reader :samplers
@@samplers = Hash.new { |h, model_class|
h[model_class] = Sampler.new(model_class)
}
def self.configure(model_class, opts ={})
yield ConfigureRecipient.new(model_class) if block_given?
end
def self.hash_with_indifferent_access_class
if ActiveSupport.const_defined?('HashWithIndifferentAccess')
ActiveSupport::HashWithIndifferentAccess
else
HashWithIndifferentAccess
end
end
protected
def self.included( mod )
mod.extend ARClassMethods
super
end
class ConfigureRecipient
def initialize(model_class)
@model_class = model_class
end
def before_save(&proc)
sampler.before_save = proc
end
def method_missing(meth, *args)
if meth.to_s =~ /(.*)_sample$/
sampler.named_sample_attrs[$1] = args.first
else
Attribute.new(sampler, meth)
end
end
def sampler
SampleModels.samplers[@model_class]
end
class Attribute
def initialize(sampler, attribute)
@sampler, @attribute = sampler, attribute
end
def default_class(dc)
@sampler.polymorphic_default_classes[@attribute] = dc
end
def default(default)
if default.blank? and model.validates_presence_of?(@attribute)
raise "#{model.name} requires #{@attribute} to not be blank"
else
@sampler.configured_default_attrs[@attribute] = default
end
end
def force_unique
model.record_validation :validates_uniqueness_of, @attribute
end
def model
SampleModels.models[@sampler.model_class]
end
end
end
module ARClassMethods
def create_sample(*args)
sampler = SampleModels.samplers[self]
sampler.create_sample(*args)
end
def sample(*args)
sampler = SampleModels.samplers[self]
sampler.sample(*args)
end
end
end
module ActiveRecord
class Base
include SampleModels
end
end
validation_recipients = [ActiveRecord::Validations::ClassMethods]
if Object.const_defined?('ActiveModel')
validation_recipients << ActiveModel::Validations::HelperMethods
end
validations_to_intercept = [
:validates_email_format_of, :validates_inclusion_of, :validates_presence_of,
:validates_uniqueness_of
]
validations_to_intercept.each do |validation|
recipient = validation_recipients.detect { |vr|
vr.method_defined?(validation)
}
if recipient
method_name = "#{validation}_with_sample_models".to_sym
recipient.send(:define_method, method_name) do |*args|
send "#{validation}_without_sample_models".to_sym, *args
SampleModels.models[self].record_validation(validation, *args)
end
recipient.alias_method_chain validation, :sample_models
else
raise "Can't find who defines the validation method #{validation}"
end
end
require "#{File.dirname(__FILE__)}/sample_models/creation"
require "#{File.dirname(__FILE__)}/sample_models/finder"
require "#{File.dirname(__FILE__)}/sample_models/model"
require "#{File.dirname(__FILE__)}/sample_models/sampler"
require "#{File.dirname(__FILE__)}/../vendor/ar_query/lib/ar_query"
Don't raise if :validates_email_format_of is not defined.
Variation of https://github.com/fakingfantastic/sample_models/commit/8d778fd91bd8fb5e34aee651c5955ba464100d51
module SampleModels
mattr_reader :models
@@models = Hash.new { |h, model_class|
h[model_class] = Model.new(model_class)
}
mattr_reader :samplers
@@samplers = Hash.new { |h, model_class|
h[model_class] = Sampler.new(model_class)
}
def self.configure(model_class, opts ={})
yield ConfigureRecipient.new(model_class) if block_given?
end
def self.hash_with_indifferent_access_class
if ActiveSupport.const_defined?('HashWithIndifferentAccess')
ActiveSupport::HashWithIndifferentAccess
else
HashWithIndifferentAccess
end
end
protected
def self.included( mod )
mod.extend ARClassMethods
super
end
class ConfigureRecipient
def initialize(model_class)
@model_class = model_class
end
def before_save(&proc)
sampler.before_save = proc
end
def method_missing(meth, *args)
if meth.to_s =~ /(.*)_sample$/
sampler.named_sample_attrs[$1] = args.first
else
Attribute.new(sampler, meth)
end
end
def sampler
SampleModels.samplers[@model_class]
end
class Attribute
def initialize(sampler, attribute)
@sampler, @attribute = sampler, attribute
end
def default_class(dc)
@sampler.polymorphic_default_classes[@attribute] = dc
end
def default(default)
if default.blank? and model.validates_presence_of?(@attribute)
raise "#{model.name} requires #{@attribute} to not be blank"
else
@sampler.configured_default_attrs[@attribute] = default
end
end
def force_unique
model.record_validation :validates_uniqueness_of, @attribute
end
def model
SampleModels.models[@sampler.model_class]
end
end
end
module ARClassMethods
def create_sample(*args)
sampler = SampleModels.samplers[self]
sampler.create_sample(*args)
end
def sample(*args)
sampler = SampleModels.samplers[self]
sampler.sample(*args)
end
end
end
module ActiveRecord
class Base
include SampleModels
end
end
validation_recipients = [ActiveRecord::Validations::ClassMethods]
if Object.const_defined?('ActiveModel')
validation_recipients << ActiveModel::Validations::HelperMethods
end
validations_to_intercept = [
:validates_email_format_of, :validates_inclusion_of, :validates_presence_of,
:validates_uniqueness_of
]
optional_interceptions = [:validates_email_format_of]
validations_to_intercept.each do |validation|
recipient = validation_recipients.detect { |vr|
vr.method_defined?(validation)
}
if recipient
method_name = "#{validation}_with_sample_models".to_sym
recipient.send(:define_method, method_name) do |*args|
send "#{validation}_without_sample_models".to_sym, *args
SampleModels.models[self].record_validation(validation, *args)
end
recipient.alias_method_chain validation, :sample_models
else
unless optional_interceptions.include?(validation)
raise "Can't find who defines the validation method #{validation}"
end
end
end
require "#{File.dirname(__FILE__)}/sample_models/creation"
require "#{File.dirname(__FILE__)}/sample_models/finder"
require "#{File.dirname(__FILE__)}/sample_models/model"
require "#{File.dirname(__FILE__)}/sample_models/sampler"
require "#{File.dirname(__FILE__)}/../vendor/ar_query/lib/ar_query"
|
module Veritas
class Optimizer
module Logic
class Predicate
class Inclusion < self
include Enumerable
class EmptyRightOperand < self
include Enumerable::EmptyRightOperand
def optimize
Veritas::Logic::Proposition::False.instance
end
end # class EmptyRightOperand
class OneRightOperand < self
include Enumerable::OneRightOperand
def optimize
Veritas::Logic::Predicate::Equality.new(left, right.first)
end
end # class OneRightOperand
Veritas::Logic::Predicate::Inclusion.optimizer = chain(
ConstantOperands,
EmptyRightOperand,
OneRightOperand,
UnoptimizedOperand
)
end # class Inclusion
end # class Predicate
end # module Logic
end # class Optimizer
end # module Veritas
Added YARD docs for Optimizer::Logic::Predicate::Inclusion
module Veritas
class Optimizer
module Logic
class Predicate
# Abstract base class representing Inclusion optimizations
class Inclusion < self
include Enumerable
# Optimize when the right operand is empty
class EmptyRightOperand < self
include Enumerable::EmptyRightOperand
# An Inclusion with an empty right operand matches nothing
#
# @return [False]
#
# @api private
def optimize
Veritas::Logic::Proposition::False.instance
end
end # class EmptyRightOperand
# Optimize when the right operand has one entry
class OneRightOperand < self
include Enumerable::OneRightOperand
# An Inclusion with a single right operand is equivalent to an Equality
#
# @return [Equality]
#
# @api private
def optimize
Veritas::Logic::Predicate::Equality.new(left, right.first)
end
end # class OneRightOperand
Veritas::Logic::Predicate::Inclusion.optimizer = chain(
ConstantOperands,
EmptyRightOperand,
OneRightOperand,
UnoptimizedOperand
)
end # class Inclusion
end # class Predicate
end # module Logic
end # class Optimizer
end # module Veritas
|
module Webbastic
module Helpers
module Widgets
class HeaderWidget < Webbastic::Widget
def initialize(options)
self.name = "Header Widget"
self.page_id = options[:page_id]
super
end
def widget_headers
[['width', '100%'], ['border', '1px solid #333']]
end
def widget_content
"<div class='column span-20 prepend-2 append-2 first last' id='header'>
<p class='title'>A New Website</p>
<hr>
</div>"
end
end
end
end
end
add media_rocket widget
module Webbastic
module Helpers
module Widgets
class HeaderWidget < Webbastic::Widget
def initialize(options)
self.name = "Header Widget"
self.page_id = options[:page_id]
super
end
def widget_headers
[['width', '100%'], ['border', '1px solid #333']]
end
def widget_content
"<div class='column span-20 prepend-2 append-2 first last' id='header'>
<p class='title'>A New Website</p>
<hr>
</div>"
end
end
class MediaListWidget < Webbastic::Widget
def initialize(options)
super
self.name = "Media List"
self.page_id = options[:page_id]
super
end
def widget_headers
[['gallery_id', 1]]
end
def widget_content
gallery_id = self.headers.first(:key => 'gallery_id').value
gallery = ::MediaRocket::Gallery.first(:id => gallery_id)
medias = gallery.medias.select{|media| media.original?}
content = "<ul>"
medias.each do |media|
content << "<li><a href='#{media.url}'>#{media.url}</a></li>"
end
content << "</ul>"
end
end
end
end
end |
turnips = Crop.create(
name: 'turnips',
description: 'Turnips are lovely'
)
carrots = Crop.create(
name: 'carrots',
description: 'OMG CARROTS'
)
old_pod = Pod.create(
month: 1.month.ago.beginning_of_month,
published: true
)
pod = Pod.create(
month: Date.today.beginning_of_month,
published: true
)
Instruction.create(
crop: turnips,
pod: old_pod,
ship: true,
summary: "It's time to plant the turnips",
image_url: "http://f.cl.ly/items/3224202o082m2y211n3c/turnip-history1.jpg",
detail: 'Bacon ipsum dolor sit amet nisi broccoli in voluptate broccoli broccoli irure broccoli broccoli broccoli dolor broccoli qui.'
)
Instruction.create(
crop: carrots,
pod: pod,
ship: true,
summary: "It's time to plant the carrots, finally!",
detail: 'Bacon ipsum dolor sit amet nisi broccoli in voluptate broccoli broccoli irure broccoli broccoli broccoli dolor broccoli qui. Broccoli broccoli broccoli laboris ex elit pariatur broccoli broccoli broccoli adipisicing broccoli deserunt exercitation broccoli. Fugiat nostrud in aute anim consequat broccoli nisi eiusmod duis broccoli ut. Est broccoli broccoli broccoli esse, duis broccoli laborum broccoli cupidatat sunt officia. Broccoli broccoli anim elit aliquip, ex broccoli. Esse ut incididunt irure ut broccoli magna. Mollit non excepteur ullamco broccoli. Ut broccoli broccoli, broccoli tempor laborum broccoli. Broccoli adipisicing aute ea broccoli ut. Broccoli irure ex, culpa mollit broccoli reprehenderit elit broccoli veniam broccoli ut dolore pariatur proident. Ut laborum qui in sunt.'
)
Instruction.create(
crop: turnips,
pod: pod,
summary: "Harvesting time for turnips",
detail: 'Bacon ipsum dolor sit amet nisi broccoli in voluptate broccoli broccoli irure broccoli broccoli broccoli dolor broccoli qui. Broccoli broccoli broccoli laboris ex elit pariatur broccoli broccoli broccoli adipisicing broccoli deserunt exercitation broccoli. Fugiat nostrud in aute anim consequat broccoli nisi eiusmod duis broccoli ut. Est broccoli broccoli broccoli esse, duis broccoli laborum broccoli cupidatat sunt officia. Broccoli broccoli anim elit aliquip, ex broccoli. Esse ut incididunt irure ut broccoli magna. Mollit non excepteur ullamco broccoli. Ut broccoli broccoli, broccoli tempor laborum broccoli. Broccoli adipisicing aute ea broccoli ut. Broccoli irure ex, culpa mollit broccoli reprehenderit elit broccoli veniam broccoli ut dolore pariatur proident. Ut laborum qui in sunt.'
)
Admin.create(
email: 'admin@getseedpod.com',
password: 'testing-only'
)
user = User.create(
email: 'robinson.ran@gmail.com',
password: 'testing-only',
name: Faker::Name.name,
address_street: Faker::Address.street_address,
address_locality: Faker::Address.city,
address_region: Faker::Address.state,
address_postcode: Faker::Address.postcode,
)
subscription = Subscription.create(
user: user
)
Payment.create(
subscription: subscription,
pod: pod
)
Payment.create(
subscription: subscription,
pod: old_pod
)
Shipment.create(
pod: pod,
user: user,
shipped: true
)
Shipment.create(
pod: old_pod,
user: user,
shipped: true
)
Use factories for seeding
turnips = Crop.create(
name: 'turnips',
description: 'Turnips are lovely'
)
carrots = Crop.create(
name: 'carrots',
description: 'OMG CARROTS'
)
old_pod = Pod.create(
month: 1.month.ago.beginning_of_month,
published: true
)
pod = Pod.create(
month: Date.today.beginning_of_month,
published: true
)
Instruction.create(
crop: turnips,
pod: old_pod,
ship: true,
summary: "It's time to plant the turnips",
image_url: "http://f.cl.ly/items/3224202o082m2y211n3c/turnip-history1.jpg",
detail: 'Bacon ipsum dolor sit amet nisi broccoli in voluptate broccoli broccoli irure broccoli broccoli broccoli dolor broccoli qui.'
)
Instruction.create(
crop: carrots,
pod: pod,
ship: true,
summary: "It's time to plant the carrots, finally!",
detail: 'Bacon ipsum dolor sit amet nisi broccoli in voluptate broccoli broccoli irure broccoli broccoli broccoli dolor broccoli qui. Broccoli broccoli broccoli laboris ex elit pariatur broccoli broccoli broccoli adipisicing broccoli deserunt exercitation broccoli. Fugiat nostrud in aute anim consequat broccoli nisi eiusmod duis broccoli ut. Est broccoli broccoli broccoli esse, duis broccoli laborum broccoli cupidatat sunt officia. Broccoli broccoli anim elit aliquip, ex broccoli. Esse ut incididunt irure ut broccoli magna. Mollit non excepteur ullamco broccoli. Ut broccoli broccoli, broccoli tempor laborum broccoli. Broccoli adipisicing aute ea broccoli ut. Broccoli irure ex, culpa mollit broccoli reprehenderit elit broccoli veniam broccoli ut dolore pariatur proident. Ut laborum qui in sunt.'
)
Instruction.create(
crop: turnips,
pod: pod,
summary: "Harvesting time for turnips",
detail: 'Bacon ipsum dolor sit amet nisi broccoli in voluptate broccoli broccoli irure broccoli broccoli broccoli dolor broccoli qui. Broccoli broccoli broccoli laboris ex elit pariatur broccoli broccoli broccoli adipisicing broccoli deserunt exercitation broccoli. Fugiat nostrud in aute anim consequat broccoli nisi eiusmod duis broccoli ut. Est broccoli broccoli broccoli esse, duis broccoli laborum broccoli cupidatat sunt officia. Broccoli broccoli anim elit aliquip, ex broccoli. Esse ut incididunt irure ut broccoli magna. Mollit non excepteur ullamco broccoli. Ut broccoli broccoli, broccoli tempor laborum broccoli. Broccoli adipisicing aute ea broccoli ut. Broccoli irure ex, culpa mollit broccoli reprehenderit elit broccoli veniam broccoli ut dolore pariatur proident. Ut laborum qui in sunt.'
)
password = 'testing-only'
Admin.create(
email: 'admin@getseedpod.com',
password: password
)
user = FactoryGirl.create :user
user.update_attributes!(email: 'robinson.ran@gmail.com', password: password, password_confirmation: password)
subscription = FactoryGirl.create :subscription
subscription.update_attributes!(user: user)
Payment.create(
subscription: subscription,
pod: pod
)
Payment.create(
subscription: subscription,
pod: old_pod
)
Shipment.create(
pod: pod,
user: user,
shipped: true
)
Shipment.create(
pod: old_pod,
user: user,
shipped: true
)
|
require 'yardstick/v2_client/remote_model'
module Yardstick
module V2Client
class TestCentreTimeWindow
include RemoteModel
class Paths < Yardstick::ActiveModel::Base
attr_accessor :users, :proctors, :incidents
end
resource_uri '/v2/test_centre_time_windows'
attr_accessor :venue, :venue_id, :attachments, :global_start_datetime, :global_end_datetime, :source_id,
:source_type, :time_zone, :proctoring_options, :available_to_apply, :pending_proctor_ids,
:confirmed_proctor_ids
attr_accessor :incident_ids, :incidents, :test_centre_seats
attr_accessor :paths
alias_method :id
def id
source_id
end
def local_start_datetime
global_start_datetime.in_time_zone(ActiveSupport::TimeZone[time_zone])
end
def local_end_datetime
global_end_datetime.in_time_zone(ActiveSupport::TimeZone[time_zone])
end
def self.process_response(resp, extra = {})
attrs = super
attrs.merge!(
:venue => Venue.from_api(attrs[:venue]),
:attachments => attrs[:attachments].map { |o| Attachment.from_api(o) },
:global_end_datetime => DateTime.iso8601(attrs[:global_end_datetime]),
:global_start_datetime => DateTime.iso8601(attrs[:global_start_datetime]),
:paths => Paths.new(attrs[:paths])
)
end
def self.upcoming_and_recent(token)
query_collection(token, "#{resource_uri}/upcoming_and_recent")
end
def self.find_by_source(token, source)
uri = instance_action_uri(source[:source_id], source[:source_type].underscore)
from_api(get(uri, query: { token: token }), token: token)
end
def create_incident(incident)
response = Incident.post(paths.incidents, body: {
token: token,
incident: incident
})
Incident.from_api(response)
end
def incidents
@incidents ||= Incident.query_collection(token, paths.incidents)
end
def users
@users ||= User.query_collection(token, paths.users)
end
def proctors
@proctors ||= CollectionProxy.new do
resp = self.class.get_all(token, paths.proctors)
resp.map do |e|
e = e.dup
type = e.extract!('type')['type']
Yardstick::V2Client.const_get(type).from_api(e)
end
end
end
def apply
response = put(instance_action_uri(:apply), body: {
token: token,
source_id: params[:id],
source_type: params[:source_type]
})
end
end
end
end
alias_method fail
require 'yardstick/v2_client/remote_model'
module Yardstick
module V2Client
class TestCentreTimeWindow
include RemoteModel
class Paths < Yardstick::ActiveModel::Base
attr_accessor :users, :proctors, :incidents
end
resource_uri '/v2/test_centre_time_windows'
attr_accessor :venue, :venue_id, :attachments, :global_start_datetime, :global_end_datetime, :source_id,
:source_type, :time_zone, :proctoring_options, :available_to_apply, :pending_proctor_ids,
:confirmed_proctor_ids
attr_accessor :incident_ids, :incidents, :test_centre_seats
attr_accessor :paths
alias_method :source_id, :id
def local_start_datetime
global_start_datetime.in_time_zone(ActiveSupport::TimeZone[time_zone])
end
def local_end_datetime
global_end_datetime.in_time_zone(ActiveSupport::TimeZone[time_zone])
end
def self.process_response(resp, extra = {})
attrs = super
attrs.merge!(
:venue => Venue.from_api(attrs[:venue]),
:attachments => attrs[:attachments].map { |o| Attachment.from_api(o) },
:global_end_datetime => DateTime.iso8601(attrs[:global_end_datetime]),
:global_start_datetime => DateTime.iso8601(attrs[:global_start_datetime]),
:paths => Paths.new(attrs[:paths])
)
end
def self.upcoming_and_recent(token)
query_collection(token, "#{resource_uri}/upcoming_and_recent")
end
def self.find_by_source(token, source)
uri = instance_action_uri(source[:source_id], source[:source_type].underscore)
from_api(get(uri, query: { token: token }), token: token)
end
def create_incident(incident)
response = Incident.post(paths.incidents, body: {
token: token,
incident: incident
})
Incident.from_api(response)
end
def incidents
@incidents ||= Incident.query_collection(token, paths.incidents)
end
def users
@users ||= User.query_collection(token, paths.users)
end
def proctors
@proctors ||= CollectionProxy.new do
resp = self.class.get_all(token, paths.proctors)
resp.map do |e|
e = e.dup
type = e.extract!('type')['type']
Yardstick::V2Client.const_get(type).from_api(e)
end
end
end
def apply
response = put(instance_action_uri(:apply), body: {
token: token,
source_id: params[:id],
source_type: params[:source_type]
})
end
end
end
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
require 'net/http'
require 'uri'
def open(url)
Net::HTTP.get(URI.parse(url))
end
page_content = open('http://data.cityofnewyork.us/resource/n3p6-zve2.json')
Add call to socrata open data API to create school seed data
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
require 'net/http'
require 'uri'
require 'json'
def open(url)
Net::HTTP.get(URI.parse(url))
end
page_content = open('http://data.cityofnewyork.us/resource/n3p6-zve2.json')
School.delete_all
all_high_schools = JSON.parse(page_content)
all_high_schools.each do |x|
School.create(name: x["school_name"], dbn: x["dbn"], total_students: x["total_students"], lat: x["location_1"]["latitude"],long: x["location_1"]["longitude"], boro: x["boro"], street_address: x["primary_address_line_1"], zip: x["zip"], overview: x["overview_paragraph"], website: x["website"], phone_number: x["phone_number"], grade_span_min: x["grade_span_min"], grade_span_max: x["grade_span_max"], program_highlights: x["program_highlights"] )
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
# neighborhoods = ['Williamsburg, Brooklyn', 'Park Slope, Brooklyn', 'Greenpoint, Brooklyn', 'Crown Heights, Brooklyn', 'Dumbo, Brooklyn']
neighborhoods = ['Cobble Hill, Brooklyn', 'Fort Greene, Brooklyn']
neighborhoods.each do |neighborhood_name|
neighborhood = Neighborhood.find_or_create_by(name: neighborhood_name)
shop_response = Yelp.client.search(neighborhood_name, { term: 'coffee' })
shop_response.businesses.each do |shop|
Shop.create(name: shop.name, address: shop.location.address[0], neighborhood: neighborhood, rating: shop.rating)
end
end
# Quote.create(prose: "The best and most beautiful things in the world cannot be seen or even touched - they must be felt with the heart.", author: "Helen Keller")
# Quote.create(prose: "Live your beliefs and you can turn the world around.", author: "Henry David Thoreau")
# Quote.create(prose: "I can't change the direction of the wind, but I can adjust my sails to always reach my destination.", author: "Jimmy Dean")
# Quote.create(prose: "We know what we are, but know not what we may be.", author: "William Shakespeare")
# Quote.create(prose: "My mission in life is not merely to survive, but to thrive; and to do so with some passion, some compassion, some humor, and some style.", author: "Maya Angelou")
# Quote.create(prose: "Love has the most significant karmic impression on our souls.")
# Quote.create(prose: "Life isn't about finding yourself. Life is about creating yourself.")
Seeds
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
neighborhoods = ['Williamsburg, Brooklyn', 'Park Slope, Brooklyn', 'Greenpoint, Brooklyn', 'Crown Heights, Brooklyn', 'Dumbo, Brooklyn', 'Cobble Hill, Brooklyn', 'Fort Greene, Brooklyn']
neighborhoods.each do |neighborhood_name|
neighborhood = Neighborhood.find_or_create_by(name: neighborhood_name)
shop_response = Yelp.client.search(neighborhood_name, { term: 'coffee' })
shop_response.businesses.each do |shop|
Shop.create(name: shop.name, address: shop.location.address[0], neighborhood: neighborhood, rating: shop.rating)
end
end
Quote.create(prose: "The best and most beautiful things in the world cannot be seen or even touched - they must be felt with the heart.", author: "Helen Keller")
Quote.create(prose: "Live your beliefs and you can turn the world around.", author: "Henry David Thoreau")
Quote.create(prose: "I can't change the direction of the wind, but I can adjust my sails to always reach my destination.", author: "Jimmy Dean")
Quote.create(prose: "We know what we are, but know not what we may be.", author: "William Shakespeare")
Quote.create(prose: "My mission in life is not merely to survive, but to thrive; and to do so with some passion, some compassion, some humor, and some style.", author: "Maya Angelou")
Quote.create(prose: "Love has the most significant karmic impression on our souls.")
Quote.create(prose: "Life isn't about finding yourself. Life is about creating yourself.") |
module WLang
class Dialect
module Dispatching
module ClassMethods
def dispatching_map
@dispatching_map ||= {}
end
def tag_dispatching_name(symbols, prefix = "_dtag")
symbols = symbols.chars unless symbols.is_a?(Array)
chars = symbols.map{|s| s.ord}.join("_")
"#{prefix}_#{chars}".to_sym
end
def find_dispatching_method(symbols, subject = new)
dispatching_map[symbols] ||= begin
extra, symbols, found = [], symbols.chars.to_a, nil
begin
meth = tag_dispatching_name(symbols)
if subject.respond_to?(meth)
found = meth
break
else
extra << symbols.shift
end
end until symbols.empty?
[extra.join, found]
end
end
private
def define_tag_method(symbols, code)
case code
when Symbol
define_tag_method(symbols, instance_method(code))
when Proc
rulename = tag_dispatching_name(symbols, "_tag")
define_method(rulename, code)
define_tag_method(symbols, rulename)
when UnboundMethod
methname = tag_dispatching_name(symbols, "_dtag")
arity = code.arity - 1
define_method(methname) do |buf, fns|
with_normalized_fns(fns, arity) do |args, rest|
code.bind(self).call(buf, *args)
flush_trailing_fns(buf, rest) if rest
buf
end
end
dispatching_map[symbols] = ['', methname]
else
raise "Unable to use #{code} for a tag"
end
end
end # module ClassMethods
module InstanceMethods
def dispatch(symbols, buf, fns)
extra, meth = find_dispatching_method(symbols)
buf << extra unless extra.empty?
if meth
send(meth, buf, fns)
else
flush_trailing_fns(buf, fns)
end
end
def find_dispatching_method(symbols, subject = self)
self.class.find_dispatching_method(symbols, subject)
end
private
def tag_dispatching_name(symbols)
self.class.tag_dispatching_name(symbols)
end
def with_normalized_fns(fns, arity)
if fns.size == arity
yield(fns, nil)
elsif fns.size < arity
yield(fns.fill(nil, fns.size, arity - fns.size), nil)
else
fns.fill(nil, fns.length, arity - fns.length)
yield(fns[0...arity], fns[arity..-1])
end
end
def flush_trailing_fns(buf, fns)
start, stop = braces
fns.each do |fn|
buf << start
render(fn, nil, buf)
buf << stop
end
buf
end
end # module InstanceMethods
def self.included(mod)
mod.instance_eval{ include(Dispatching::InstanceMethods) }
mod.extend(ClassMethods)
end
end # module Dispatching
end # class Dialect
end # module WLang
Avoid unnecessary call to with_normalized_fns
module WLang
class Dialect
module Dispatching
module ClassMethods
def dispatching_map
@dispatching_map ||= {}
end
def tag_dispatching_name(symbols, prefix = "_dtag")
symbols = symbols.chars unless symbols.is_a?(Array)
chars = symbols.map{|s| s.ord}.join("_")
"#{prefix}_#{chars}".to_sym
end
def find_dispatching_method(symbols, subject = new)
dispatching_map[symbols] ||= begin
extra, symbols, found = [], symbols.chars.to_a, nil
begin
meth = tag_dispatching_name(symbols)
if subject.respond_to?(meth)
found = meth
break
else
extra << symbols.shift
end
end until symbols.empty?
[extra.join, found]
end
end
private
def define_tag_method(symbols, code)
case code
when Symbol
define_tag_method(symbols, instance_method(code))
when Proc
rulename = tag_dispatching_name(symbols, "_tag")
define_method(rulename, code)
define_tag_method(symbols, rulename)
when UnboundMethod
methname = tag_dispatching_name(symbols, "_dtag")
arity = code.arity - 1
define_method(methname) do |buf, fns|
if fns.size == arity
code.bind(self).call(buf, *fns)
else
with_normalized_fns(fns, arity) do |args, rest|
code.bind(self).call(buf, *args)
flush_trailing_fns(buf, rest) if rest
buf
end
end
end
dispatching_map[symbols] = ['', methname]
else
raise "Unable to use #{code} for a tag"
end
end
end # module ClassMethods
module InstanceMethods
def dispatch(symbols, buf, fns)
extra, meth = find_dispatching_method(symbols)
buf << extra unless extra.empty?
if meth
send(meth, buf, fns)
else
flush_trailing_fns(buf, fns)
end
end
def find_dispatching_method(symbols, subject = self)
self.class.find_dispatching_method(symbols, subject)
end
private
def tag_dispatching_name(symbols)
self.class.tag_dispatching_name(symbols)
end
def with_normalized_fns(fns, arity)
if fns.size == arity
yield(fns, nil)
elsif fns.size < arity
yield(fns.fill(nil, fns.size, arity - fns.size), nil)
else
fns.fill(nil, fns.length, arity - fns.length)
yield(fns[0...arity], fns[arity..-1])
end
end
def flush_trailing_fns(buf, fns)
start, stop = braces
fns.each do |fn|
buf << start
render(fn, nil, buf)
buf << stop
end
buf
end
end # module InstanceMethods
def self.included(mod)
mod.instance_eval{ include(Dispatching::InstanceMethods) }
mod.extend(ClassMethods)
end
end # module Dispatching
end # class Dialect
end # module WLang
|
# IfSimply User
ifsimply_user = User.new
ifsimply_user.id = 1
ifsimply_user.name = "Keith Griffis"
ifsimply_user.email = "keith.griffis@gmail.com"
ifsimply_user.password = "testing1"
ifsimply_user.description = "Tell the IfSimply community about yourself. We want to know your hopes and dreams. Click " +
"here to change it. To change your photo, drag and drop a new one from your desktop"
ifsimply_user.icon = Settings.users[:default_icon]
ifsimply_user.payment_email = Settings.paypal[:account_email]
ifsimply_user.verified = true
ifsimply_user.save
# Confirm the IfSimply User
ifsimply_user.confirm!
# IfSimply Club
ifsimply_club = ifsimply_user.clubs.first
ifsimply_club.id = 1
ifsimply_club.name = "Membership Club Secrets:"
ifsimply_club.sub_heading = "How to Build & Grow a Successful Club"
ifsimply_club.description = "Want to create a profitable and successful membership club? We will teach you how to get " +
"up and running fast, the essential elements of a club, and take you step by step through " +
"the process of building a successful club."
ifsimply_club.price = "40.00"
ifsimply_club.save
# IfSimply Sales Page
ifsimply_sales = ifsimply_club.sales_page
ifsimply_sales.heading = "Build & Grow a Profitable Membership Club"
ifsimply_sales.sub_heading = "Learn our best membership club secrets"
ifsimply_sales.video = "http://youtu.be/zHfjpuWAWCE"
ifsimply_sales.call_to_action = "Become an Insider"
ifsimply_sales.call_details = "Join the club to access exclusive courses, articles and discussions that are members only. " +
"This is the good stuff that we only share with our favorite people like you!<div><br>" +
"</div><div>Join for free now and get access right away!</div><div></div>"
ifsimply_sales.benefit1 = "Learn the essential elements of a successful membership club"
ifsimply_sales.benefit2 = "How to create your own video courses easily and for free"
ifsimply_sales.benefit3 = "The one key thing you can do to keep people coming back monthly"
ifsimply_sales.details = "<div>I want you to reach your full potential. We created IfSimply.com to help people turn " +
"their knowledge and passion into a profitable online business. We turned to membership sites " +
"because they are an honest and valuable way to monetize your knowledge. </div><div><br>" +
"</div><div>Creating your own membership club has never been easier. This club is dedicated " +
"to showing you how. We take you step-by-step through creating articles, engaging in " +
"discussion, and creating your own video courses. </div><div><br></div><div>This is " +
"information people spend thousands to get, but we are giving it away for free. We want you " +
"to create your club on IfSimply.com and start focusing on your content and members, not the " +
"technical stuff.</div><div style=\"text-align: right;\"><br></div><div style=\"text-align: " +
"right;\">So Join now and Make it Happen! </div><div style=\"text-align: right;\"><br>" +
"</div><div style=\"text-align: right;\">Go be Great!</div><div style=\"text-align: right;\">" +
"-Keith Griffis </div><div style=\"text-align: right;\">Co-founder, IfSimply.com</div>" +
"<div></div>"
ifsimply_sales.about_owner = "<p><i>Keith Griffis is the co-founder of IfSimply.com and an internationally known marketer " +
"and new media educator. He has taught marketing courses at Massachusetts Institute of " +
"Technology (MIT), Salem State University, and colleges throughout the United States. He is " +
"an author and technology entrepreneur trying to shape the way people use new media.</i></p>" +
"<div><i>He is known for helping people discover their passion and turn it into a profitable " +
"online business.</i></div>"
ifsimply_sales.save
# IfSimply Upsell Page
ifsimply_upsell = ifsimply_club.upsell_page
ifsimply_upsell.heading = "Want to get WAY more out of this club?"
ifsimply_upsell.sub_heading = "Sign up for a Pro Membership!"
ifsimply_upsell.basic_articles_desc = "How-to articles that will keep you up to date and on the cutting edge."
ifsimply_upsell.exclusive_articles_desc = "These are premium in-depth articles and tutorials that only Pro Members can access."
ifsimply_upsell.basic_courses_desc = "Our courses will guide you with video, give you actionable lessons, and come with " +
"downloadable reference materials."
ifsimply_upsell.in_depth_courses_desc = "Our premium courses dig deep to teach you what matters. This is content you " +
"definitely won't get anywhere else."
ifsimply_upsell.discussion_forums_desc = "Community is a crucial part of the growth process. Connect with folks just like " +
"you to learn, share, and grow."
ifsimply_upsell.save
# IfSimply Discussion Board
ifsimply_discussion = ifsimply_club.discussion_board
ifsimply_discussion.name = "Membership Club Secrets Discussion"
ifsimply_discussion.description = "This is where you can get all those answers you want. Ask about how to use ifSimply.com " +
"or general membership club questions."
ifsimply_discussion.save
# IfSimply Topics
ifsimply_topic = ifsimply_discussion.topics.new
ifsimply_topic.user_id = ifsimply_user.id
ifsimply_topic.subject = "Tell Us About Yourself!"
ifsimply_topic.description = "We want to hear about who you are. Tell us about yourself, your business, and what you " +
"want to get out of this club?"
ifsimply_topic.save
# IfSimply Articles
ifsimply_article = ifsimply_club.articles.new
ifsimply_article.free = true
ifsimply_article.image = "/assets/start_your_club.png"
ifsimply_article.title = "Getting Started with Your Article Area"
ifsimply_article.content = "<p><font color=\"#000000\">Getting started with your article area is simple. You will want " +
"to replace this with your own text. If you have existing articles (or blog posts) you " +
"can copy and paste the text here. To start writing from scratch, just type it in here and " +
"hit Save above when done. To see a preview of how it will look to your members, click " +
"preview in the gray bar above. </font></p><p><font color=\"#000000\"><br></font></p>" +
"<h4 style=\"text-align: center;\"><font color=\"#000000\"><b><u><span class=\"large-bold\">" +
"Here are some quick tips about using your article area:</span></u></b></font></h4><p style=" +
"\"text-align: center;\"><br></p><p><b><u>To change any formatting of text use the gray " +
"formatting bar above.</u></b></p><p><img src=\"/assets/article_start.png\"><br></p><p>" +
"<br></p><p><b><u></u><span class=\"large-bold\"><u>To add an image, just drag and drop it " +
"into this text area or drag it over the logo to change it. </u></span></b></p><p>" +
"<img src=\"/assets/image_demo.png\"></p><p><br></p><b><u>Save Your Changes by Clicking " +
"\"Save\" in the Gray Editor Bar at the top of the screen.</u></b><div><img src=\"/assets/" +
"formatting_bar.png\" align=\"middle\"></div><div><br></div><div><br></div><div>To add a " +
"new Article, go to your \"Article\" link (in your club navigation) and choose \"Add " +
"New\":</div><div><img src=\"/assets/start_article.png\"><br></div>"
ifsimply_article.save
# IfSimply - Courses 1
ifsimply_course1 = ifsimply_club.courses.new
ifsimply_course1.logo = "/assets/get_started_course.png"
ifsimply_course1.title = "Introduction to IfSimply"
ifsimply_course1.description = "This is a quick introduction to IfSimply.com to get you familiar with the setup of the " +
"site, how to run your club, and give you the lay of the land."
ifsimply_course1.save
# IfSimply - Course 1 Lesson 1
ifsimply_course1_lesson1 = ifsimply_course1.lessons.new
ifsimply_course1_lesson1.title = "Lesson 1 - Your Club Home Page & Navigation"
ifsimply_course1_lesson1.free = true
ifsimply_course1_lesson1.video = "http://youtu.be/zHfjpuWAWCE"
ifsimply_course1_lesson1.background = "This video take you through your club home page"
ifsimply_course1_lesson1.save
# IfSimply - Course 1 Lesson 2
ifsimply_course1_lesson2 = ifsimply_course1.lessons.new
ifsimply_course1_lesson2.title = "Lesson 2 - Getting to Know Your Article Area"
ifsimply_course1_lesson2.free = true
ifsimply_course1_lesson2.background = "This takes you through the article area of your club.<div><br></div><div>" +
"<u>Key Take-aways from this lesson:</u></div><div><ol><li>How to add an " +
"article</li><li>Drag & drop images</li><li>Type over existing text" +
"</li></ol></div>"
ifsimply_course1_lesson2.save
# IfSimply - Course 1 Lesson 3
ifsimply_course1_lesson3 = ifsimply_course1.lessons.new
ifsimply_course1_lesson3.title = "Lesson 3 - How to Use Your Discussion Area"
ifsimply_course1_lesson3.free = true
ifsimply_course1_lesson3.background = "This is lesson goes through your discussion area.<div><br></div><div><u>" +
"Key Take-aways from this lesson:</u></div><div><ol><li>Only paid members " +
"of your club can post new topics</li><li>All members can reply to " +
"topics</li><li>how to create new topics and strategies to engage your " +
"members</li></ol></div>"
ifsimply_course1_lesson3.save
# IfSimply - Course 1 Lesson 4
ifsimply_course1_lesson4 = ifsimply_course1.lessons.new
ifsimply_course1_lesson4.title = "Lesson 4 - Sales Page and Upsell Page"
ifsimply_course1_lesson4.free = true
ifsimply_course1_lesson4.background = "This shows you your sales page.<div><br></div><div><u>Key Take-aways from " +
"this lesson:</u></div><div><ol><li>What is a sales page </li><li>What " +
"is an upsell page</li><li>How to edit your sales page & upsell</li><li>" +
"How to promote your club using your sales page</li><li>How to verify your " +
"club and make your club live</li></ol></div>"
ifsimply_course1_lesson4.save
# IfSimply - Course 1 Lesson 5
ifsimply_course1_lesson5 = ifsimply_course1.lessons.new
ifsimply_course1_lesson5.title = "Lesson 5 - Admin Page"
ifsimply_course1_lesson5.free = false
ifsimply_course1_lesson5.background = "This lesson gives you a quick tour of your Club Admin page.<div><br></div>" +
"<div><u>In this lesson you will learn:</u></div><div><ol><li>How to verify " +
"your club</li><li>How to promote your club link</li><li></li></ol></div>"
ifsimply_course1_lesson5.save
# IfSimply - Course 2
ifsimply_course2 = ifsimply_club.courses.new
ifsimply_course2.logo = "/assets/default_initial_course_logo.jpg"
ifsimply_course2.title = "Crafting Your First Course"
ifsimply_course2.description = "How to create a course that sells, fast! This course takes you through the steps to " +
"conceive, outline, produce, and launch your first online course. We simplified dozens of " +
"tools, tips, and knowledge into an easy to follow and simple course on courses!"
ifsimply_course2.save
# IfSimply - Course 2 Lesson 1
ifsimply_course2_lesson1 = ifsimply_course2.lessons.new
ifsimply_course2_lesson1.title = "Lesson 1 - Why Video & Choosing a Topic"
ifsimply_course2_lesson1.free = true
ifsimply_course1_lesson1.video = "http://youtu.be/Q-1m5HJZVUM"
ifsimply_course2_lesson1.background = "<div>Video courses are the most impactful for a few reasons. This video takes " +
"you through those reasons, how to find your target market, and how to find a " +
"topic.<br></div><div><br></div><div><u>Key Take-aways from this lesson:</u>" +
"</div><div><ol><li>Learn why video is the preferred medium</li><li>How to " +
"choose a topic or discover one</li><li>Why you need to know your target " +
"market</li><li>Crafting a course title and description that sells</li></ol>" +
"</div>"
ifsimply_course2_lesson1.save
# IfSimply - Course 2 Lesson 2
ifsimply_course2_lesson2 = ifsimply_course2.lessons.new
ifsimply_course2_lesson2.title = "Lesson 2 - Outlining Your Course"
ifsimply_course2_lesson2.free = true
ifsimply_course2_lesson2.background = "<div>This video takes you through the critical steps of defining what your " +
"course will teach. This takes your topic and expands it to fit your audience " +
"in a simple step by step fashion.</div><div><br></div><div><u>Key Take-aways " +
"from this lesson:</u></div><div><ol><li>Must know your target audience and " +
"their experience level</li><li>Define your end goal of the course (what do " +
"they get out of it)</li><li>Take a step by step outline approach to defining " +
"the lessons</li></ol></div>"
ifsimply_course2_lesson2.save
# IfSimply - Course 2 Lesson 3
ifsimply_course2_lesson3 = ifsimply_course2.lessons.new
ifsimply_course2_lesson3.title = "Lesson 3 - Producing Your First Lesson"
ifsimply_course2_lesson3.free = true
ifsimply_course2_lesson3.background = "This video takes you through the process of creating your course content and " +
"recording that content into video.<div><br></div><div><u>Key Take-aways from " +
"this lesson:</u></div><div><ol><li>You can use presentation with voiceover " +
"or \"Interview Style\"</li><li>Use readily available tools that work for you " +
"(i.e. your laptop or iphone)</li><li>Post videos to youtube.com in " +
"\"unlisted\" format and paste on IfSimply.com<br></li></ol></div>"
ifsimply_course2_lesson3.save
Update Seeds for IfSimply Club
Update the seeds.rb file to ensure that there is no colon within the
IfSimply Club title since this makes it look strange when it shows up in
the Memberships view.
# IfSimply User
ifsimply_user = User.new
ifsimply_user.id = 1
ifsimply_user.name = "Keith Griffis"
ifsimply_user.email = "keith.griffis@gmail.com"
ifsimply_user.password = "testing1"
ifsimply_user.description = "Tell the IfSimply community about yourself. We want to know your hopes and dreams. Click " +
"here to change it. To change your photo, drag and drop a new one from your desktop"
ifsimply_user.icon = Settings.users[:default_icon]
ifsimply_user.payment_email = Settings.paypal[:account_email]
ifsimply_user.verified = true
ifsimply_user.save
# Confirm the IfSimply User
ifsimply_user.confirm!
# IfSimply Club
ifsimply_club = ifsimply_user.clubs.first
ifsimply_club.id = 1
ifsimply_club.name = "Membership Club Secrets"
ifsimply_club.sub_heading = "How to Build & Grow a Successful Club"
ifsimply_club.description = "Want to create a profitable and successful membership club? We will teach you how to get " +
"up and running fast, the essential elements of a club, and take you step by step through " +
"the process of building a successful club."
ifsimply_club.price = "40.00"
ifsimply_club.save
# IfSimply Sales Page
ifsimply_sales = ifsimply_club.sales_page
ifsimply_sales.heading = "Build & Grow a Profitable Membership Club"
ifsimply_sales.sub_heading = "Learn our best membership club secrets"
ifsimply_sales.video = "http://youtu.be/zHfjpuWAWCE"
ifsimply_sales.call_to_action = "Become an Insider"
ifsimply_sales.call_details = "Join the club to access exclusive courses, articles and discussions that are members only. " +
"This is the good stuff that we only share with our favorite people like you!<div><br>" +
"</div><div>Join for free now and get access right away!</div><div></div>"
ifsimply_sales.benefit1 = "Learn the essential elements of a successful membership club"
ifsimply_sales.benefit2 = "How to create your own video courses easily and for free"
ifsimply_sales.benefit3 = "The one key thing you can do to keep people coming back monthly"
ifsimply_sales.details = "<div>I want you to reach your full potential. We created IfSimply.com to help people turn " +
"their knowledge and passion into a profitable online business. We turned to membership sites " +
"because they are an honest and valuable way to monetize your knowledge. </div><div><br>" +
"</div><div>Creating your own membership club has never been easier. This club is dedicated " +
"to showing you how. We take you step-by-step through creating articles, engaging in " +
"discussion, and creating your own video courses. </div><div><br></div><div>This is " +
"information people spend thousands to get, but we are giving it away for free. We want you " +
"to create your club on IfSimply.com and start focusing on your content and members, not the " +
"technical stuff.</div><div style=\"text-align: right;\"><br></div><div style=\"text-align: " +
"right;\">So Join now and Make it Happen! </div><div style=\"text-align: right;\"><br>" +
"</div><div style=\"text-align: right;\">Go be Great!</div><div style=\"text-align: right;\">" +
"-Keith Griffis </div><div style=\"text-align: right;\">Co-founder, IfSimply.com</div>" +
"<div></div>"
ifsimply_sales.about_owner = "<p><i>Keith Griffis is the co-founder of IfSimply.com and an internationally known marketer " +
"and new media educator. He has taught marketing courses at Massachusetts Institute of " +
"Technology (MIT), Salem State University, and colleges throughout the United States. He is " +
"an author and technology entrepreneur trying to shape the way people use new media.</i></p>" +
"<div><i>He is known for helping people discover their passion and turn it into a profitable " +
"online business.</i></div>"
ifsimply_sales.save
# IfSimply Upsell Page
ifsimply_upsell = ifsimply_club.upsell_page
ifsimply_upsell.heading = "Want to get WAY more out of this club?"
ifsimply_upsell.sub_heading = "Sign up for a Pro Membership!"
ifsimply_upsell.basic_articles_desc = "How-to articles that will keep you up to date and on the cutting edge."
ifsimply_upsell.exclusive_articles_desc = "These are premium in-depth articles and tutorials that only Pro Members can access."
ifsimply_upsell.basic_courses_desc = "Our courses will guide you with video, give you actionable lessons, and come with " +
"downloadable reference materials."
ifsimply_upsell.in_depth_courses_desc = "Our premium courses dig deep to teach you what matters. This is content you " +
"definitely won't get anywhere else."
ifsimply_upsell.discussion_forums_desc = "Community is a crucial part of the growth process. Connect with folks just like " +
"you to learn, share, and grow."
ifsimply_upsell.save
# IfSimply Discussion Board
ifsimply_discussion = ifsimply_club.discussion_board
ifsimply_discussion.name = "Membership Club Secrets Discussion"
ifsimply_discussion.description = "This is where you can get all those answers you want. Ask about how to use ifSimply.com " +
"or general membership club questions."
ifsimply_discussion.save
# IfSimply Topics
ifsimply_topic = ifsimply_discussion.topics.new
ifsimply_topic.user_id = ifsimply_user.id
ifsimply_topic.subject = "Tell Us About Yourself!"
ifsimply_topic.description = "We want to hear about who you are. Tell us about yourself, your business, and what you " +
"want to get out of this club?"
ifsimply_topic.save
# IfSimply Articles
ifsimply_article = ifsimply_club.articles.new
ifsimply_article.free = true
ifsimply_article.image = "/assets/start_your_club.png"
ifsimply_article.title = "Getting Started with Your Article Area"
ifsimply_article.content = "<p><font color=\"#000000\">Getting started with your article area is simple. You will want " +
"to replace this with your own text. If you have existing articles (or blog posts) you " +
"can copy and paste the text here. To start writing from scratch, just type it in here and " +
"hit Save above when done. To see a preview of how it will look to your members, click " +
"preview in the gray bar above. </font></p><p><font color=\"#000000\"><br></font></p>" +
"<h4 style=\"text-align: center;\"><font color=\"#000000\"><b><u><span class=\"large-bold\">" +
"Here are some quick tips about using your article area:</span></u></b></font></h4><p style=" +
"\"text-align: center;\"><br></p><p><b><u>To change any formatting of text use the gray " +
"formatting bar above.</u></b></p><p><img src=\"/assets/article_start.png\"><br></p><p>" +
"<br></p><p><b><u></u><span class=\"large-bold\"><u>To add an image, just drag and drop it " +
"into this text area or drag it over the logo to change it. </u></span></b></p><p>" +
"<img src=\"/assets/image_demo.png\"></p><p><br></p><b><u>Save Your Changes by Clicking " +
"\"Save\" in the Gray Editor Bar at the top of the screen.</u></b><div><img src=\"/assets/" +
"formatting_bar.png\" align=\"middle\"></div><div><br></div><div><br></div><div>To add a " +
"new Article, go to your \"Article\" link (in your club navigation) and choose \"Add " +
"New\":</div><div><img src=\"/assets/start_article.png\"><br></div>"
ifsimply_article.save
# IfSimply - Courses 1
ifsimply_course1 = ifsimply_club.courses.new
ifsimply_course1.logo = "/assets/get_started_course.png"
ifsimply_course1.title = "Introduction to IfSimply"
ifsimply_course1.description = "This is a quick introduction to IfSimply.com to get you familiar with the setup of the " +
"site, how to run your club, and give you the lay of the land."
ifsimply_course1.save
# IfSimply - Course 1 Lesson 1
ifsimply_course1_lesson1 = ifsimply_course1.lessons.new
ifsimply_course1_lesson1.title = "Lesson 1 - Your Club Home Page & Navigation"
ifsimply_course1_lesson1.free = true
ifsimply_course1_lesson1.video = "http://youtu.be/zHfjpuWAWCE"
ifsimply_course1_lesson1.background = "This video take you through your club home page"
ifsimply_course1_lesson1.save
# IfSimply - Course 1 Lesson 2
ifsimply_course1_lesson2 = ifsimply_course1.lessons.new
ifsimply_course1_lesson2.title = "Lesson 2 - Getting to Know Your Article Area"
ifsimply_course1_lesson2.free = true
ifsimply_course1_lesson2.background = "This takes you through the article area of your club.<div><br></div><div>" +
"<u>Key Take-aways from this lesson:</u></div><div><ol><li>How to add an " +
"article</li><li>Drag & drop images</li><li>Type over existing text" +
"</li></ol></div>"
ifsimply_course1_lesson2.save
# IfSimply - Course 1 Lesson 3
ifsimply_course1_lesson3 = ifsimply_course1.lessons.new
ifsimply_course1_lesson3.title = "Lesson 3 - How to Use Your Discussion Area"
ifsimply_course1_lesson3.free = true
ifsimply_course1_lesson3.background = "This is lesson goes through your discussion area.<div><br></div><div><u>" +
"Key Take-aways from this lesson:</u></div><div><ol><li>Only paid members " +
"of your club can post new topics</li><li>All members can reply to " +
"topics</li><li>how to create new topics and strategies to engage your " +
"members</li></ol></div>"
ifsimply_course1_lesson3.save
# IfSimply - Course 1 Lesson 4
ifsimply_course1_lesson4 = ifsimply_course1.lessons.new
ifsimply_course1_lesson4.title = "Lesson 4 - Sales Page and Upsell Page"
ifsimply_course1_lesson4.free = true
ifsimply_course1_lesson4.background = "This shows you your sales page.<div><br></div><div><u>Key Take-aways from " +
"this lesson:</u></div><div><ol><li>What is a sales page </li><li>What " +
"is an upsell page</li><li>How to edit your sales page & upsell</li><li>" +
"How to promote your club using your sales page</li><li>How to verify your " +
"club and make your club live</li></ol></div>"
ifsimply_course1_lesson4.save
# IfSimply - Course 1 Lesson 5
ifsimply_course1_lesson5 = ifsimply_course1.lessons.new
ifsimply_course1_lesson5.title = "Lesson 5 - Admin Page"
ifsimply_course1_lesson5.free = false
ifsimply_course1_lesson5.background = "This lesson gives you a quick tour of your Club Admin page.<div><br></div>" +
"<div><u>In this lesson you will learn:</u></div><div><ol><li>How to verify " +
"your club</li><li>How to promote your club link</li><li></li></ol></div>"
ifsimply_course1_lesson5.save
# IfSimply - Course 2
ifsimply_course2 = ifsimply_club.courses.new
ifsimply_course2.logo = "/assets/default_initial_course_logo.jpg"
ifsimply_course2.title = "Crafting Your First Course"
ifsimply_course2.description = "How to create a course that sells, fast! This course takes you through the steps to " +
"conceive, outline, produce, and launch your first online course. We simplified dozens of " +
"tools, tips, and knowledge into an easy to follow and simple course on courses!"
ifsimply_course2.save
# IfSimply - Course 2 Lesson 1
ifsimply_course2_lesson1 = ifsimply_course2.lessons.new
ifsimply_course2_lesson1.title = "Lesson 1 - Why Video & Choosing a Topic"
ifsimply_course2_lesson1.free = true
ifsimply_course1_lesson1.video = "http://youtu.be/Q-1m5HJZVUM"
ifsimply_course2_lesson1.background = "<div>Video courses are the most impactful for a few reasons. This video takes " +
"you through those reasons, how to find your target market, and how to find a " +
"topic.<br></div><div><br></div><div><u>Key Take-aways from this lesson:</u>" +
"</div><div><ol><li>Learn why video is the preferred medium</li><li>How to " +
"choose a topic or discover one</li><li>Why you need to know your target " +
"market</li><li>Crafting a course title and description that sells</li></ol>" +
"</div>"
ifsimply_course2_lesson1.save
# IfSimply - Course 2 Lesson 2
ifsimply_course2_lesson2 = ifsimply_course2.lessons.new
ifsimply_course2_lesson2.title = "Lesson 2 - Outlining Your Course"
ifsimply_course2_lesson2.free = true
ifsimply_course2_lesson2.background = "<div>This video takes you through the critical steps of defining what your " +
"course will teach. This takes your topic and expands it to fit your audience " +
"in a simple step by step fashion.</div><div><br></div><div><u>Key Take-aways " +
"from this lesson:</u></div><div><ol><li>Must know your target audience and " +
"their experience level</li><li>Define your end goal of the course (what do " +
"they get out of it)</li><li>Take a step by step outline approach to defining " +
"the lessons</li></ol></div>"
ifsimply_course2_lesson2.save
# IfSimply - Course 2 Lesson 3
ifsimply_course2_lesson3 = ifsimply_course2.lessons.new
ifsimply_course2_lesson3.title = "Lesson 3 - Producing Your First Lesson"
ifsimply_course2_lesson3.free = true
ifsimply_course2_lesson3.background = "This video takes you through the process of creating your course content and " +
"recording that content into video.<div><br></div><div><u>Key Take-aways from " +
"this lesson:</u></div><div><ol><li>You can use presentation with voiceover " +
"or \"Interview Style\"</li><li>Use readily available tools that work for you " +
"(i.e. your laptop or iphone)</li><li>Post videos to youtube.com in " +
"\"unlisted\" format and paste on IfSimply.com<br></li></ol></div>"
ifsimply_course2_lesson3.save
|
class WorkerScoreboard
VERSION = "0.0.3"
end
Bump version
class WorkerScoreboard
VERSION = "0.0.4"
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
heroes_by_role = {
support: ['Mercy', 'Zenyatta', 'Ana', 'Lúcio', 'Symmetra'],
tank: ['D.Va', 'Winston', 'Reinhardt', 'Orisa', 'Roadhog', 'Zarya'],
offense: ['McCree', 'Pharah', 'Genji', 'Tracer', 'Sombra', 'Soldier: 76', 'Reaper'],
defense: ['Hanzo', 'Widowmaker', 'Torbjörn', 'Bastion', 'Mei', 'Junkrat']
}
heroes_by_role.each do |role, hero_names|
puts "Creating #{role} heroes: #{hero_names.to_sentence}"
hero_names.each do |name|
Hero.create!(name: name, role: role)
end
end
maps_by_type = {
assault: ['Hanamura', 'Temple of Anubis', 'Volskaya Industries'],
escort: ['Dorado', 'Route 66', 'Watchpoint: Gibraltar'],
hybrid: ['Eichenwalde', 'Hollywood', "King's Row", 'Numbani'],
control: ['Ilios', 'Lijiang Tower', 'Nepal', 'Oasis'],
# arcade: ['Ecopoint: Antarctica']
}
maps_by_type.each do |type, map_names|
puts "Creating #{type} maps: #{map_names.to_sentence}"
map_names.each do |name|
Map.create!(name: name, map_type: type)
end
end
map_segments_by_map = {
'Hanamura' => ['First Point', 'Second Point'],
'Temple of Anubis' => ['First Point', 'Second Point'],
'Volskaya Industries' => ['First Point', 'Second Point'],
'Ilios' => ['Well', 'Ruins', 'Lighthouse'],
'Lijiang Tower' => ['Night Market', 'Control Center', 'Garden'],
'Nepal' => ['Village', 'Shrine', 'Sanctum'],
'Oasis' => ['City Center', 'Gardens', 'University'],
'Hollywood' => ['Point 1', 'Payload 1', 'Payload 2'],
'Dorado' => ['Payload 1', 'Payload 2', 'Payload 3'],
"King's Row" => ['Point 1', 'Payload 1', 'Payload 2'],
'Numbani' => ['Point 1', 'Payload 1', 'Payload 2'],
'Route 66' => ['Payload 1', 'Payload 2', 'Payload 3'],
'Watchpoint: Gibraltar' => ['Payload 1', 'Payload 2', 'Payload 3'],
'Eichenwalde' => ['Point 1', 'Payload 1', 'Payload 2']
}
maps_without_defense = [
'Ilios', 'Oasis', 'Lijiang Tower', 'Nepal'
]
team_roles = ['Attack', 'Defend']
map_segments_by_map.each do |map_name, base_segments|
map = Map.find_by_name(map_name)
segments = if maps_without_defense.include?(map_name)
base_segments
else
team_roles.inject([]) do |out, role|
out.concat base_segments.map { |segment| "#{role}: #{segment}" }
end
end
puts "Creating segments for map #{map.name}: #{segments.to_sentence}"
segments.each do |segment|
MapSegment.create!(map_id: map.id, name: segment)
end
end
puts "Creating anonymous user"
anon_user = User.create!(email: User::ANONYMOUS_EMAIL, password: "passworD1")
Handle anon user existing in seeds
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
heroes_by_role = {
support: ['Mercy', 'Zenyatta', 'Ana', 'Lúcio', 'Symmetra'],
tank: ['D.Va', 'Winston', 'Reinhardt', 'Orisa', 'Roadhog', 'Zarya'],
offense: ['McCree', 'Pharah', 'Genji', 'Tracer', 'Sombra', 'Soldier: 76', 'Reaper'],
defense: ['Hanzo', 'Widowmaker', 'Torbjörn', 'Bastion', 'Mei', 'Junkrat']
}
heroes_by_role.each do |role, hero_names|
puts "Creating #{role} heroes: #{hero_names.to_sentence}"
hero_names.each do |name|
Hero.create!(name: name, role: role)
end
end
maps_by_type = {
assault: ['Hanamura', 'Temple of Anubis', 'Volskaya Industries'],
escort: ['Dorado', 'Route 66', 'Watchpoint: Gibraltar'],
hybrid: ['Eichenwalde', 'Hollywood', "King's Row", 'Numbani'],
control: ['Ilios', 'Lijiang Tower', 'Nepal', 'Oasis'],
# arcade: ['Ecopoint: Antarctica']
}
maps_by_type.each do |type, map_names|
puts "Creating #{type} maps: #{map_names.to_sentence}"
map_names.each do |name|
Map.create!(name: name, map_type: type)
end
end
map_segments_by_map = {
'Hanamura' => ['First Point', 'Second Point'],
'Temple of Anubis' => ['First Point', 'Second Point'],
'Volskaya Industries' => ['First Point', 'Second Point'],
'Ilios' => ['Well', 'Ruins', 'Lighthouse'],
'Lijiang Tower' => ['Night Market', 'Control Center', 'Garden'],
'Nepal' => ['Village', 'Shrine', 'Sanctum'],
'Oasis' => ['City Center', 'Gardens', 'University'],
'Hollywood' => ['Point 1', 'Payload 1', 'Payload 2'],
'Dorado' => ['Payload 1', 'Payload 2', 'Payload 3'],
"King's Row" => ['Point 1', 'Payload 1', 'Payload 2'],
'Numbani' => ['Point 1', 'Payload 1', 'Payload 2'],
'Route 66' => ['Payload 1', 'Payload 2', 'Payload 3'],
'Watchpoint: Gibraltar' => ['Payload 1', 'Payload 2', 'Payload 3'],
'Eichenwalde' => ['Point 1', 'Payload 1', 'Payload 2']
}
maps_without_defense = [
'Ilios', 'Oasis', 'Lijiang Tower', 'Nepal'
]
team_roles = ['Attack', 'Defend']
map_segments_by_map.each do |map_name, base_segments|
map = Map.find_by_name(map_name)
segments = if maps_without_defense.include?(map_name)
base_segments
else
team_roles.inject([]) do |out, role|
out.concat base_segments.map { |segment| "#{role}: #{segment}" }
end
end
puts "Creating segments for map #{map.name}: #{segments.to_sentence}"
segments.each do |segment|
MapSegment.create!(map_id: map.id, name: segment)
end
end
puts "Creating anonymous user"
anon_user = User.anonymous || User.create!(email: User::ANONYMOUS_EMAIL,
password: "passworD1")
|
require 'yardstick/v2_client/remote_model'
module Yardstick
module V2Client
class Venue
include RemoteModel
attr_accessor :location, :id, :account, :account_id
def self.process_response(resp, extras = {})
attrs = super
attrs.merge!(
:account => Account.from_api(attrs[:account])
)
end
end
end
end
fix hash format
require 'yardstick/v2_client/remote_model'
module Yardstick
module V2Client
class Venue
include RemoteModel
attr_accessor :location, :id, :account, :account_id
def self.process_response(resp, extras = {})
attrs = super
attrs.merge!(
account: Account.from_api(attrs[:account])
)
end
end
end
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
# Create Users
Nick = User.create({name: 'Nick', email: 'nick@ncronquist.com'})
Cody = User.create({name: 'Cody', email: 'codybarrus@gmail.com'})
# Create Tools Template
# t1 = Tool.create({title: '', description: '', language: '', is_free: 1, web_url: '', repo_url: ''})
t1 = Tool.create({title: 'Moment.js', description: 'Parse, validate, manipulate, and display dates in JavaScript.', language: 'javascript', is_free: 1, web_url: 'http://momentjs.com/', repo_url: 'https://github.com/moment/moment/', avg_rating: 5})
t2 = Tool.create({title: 'ramjet', description: 'Ramjet makes it looks as though one DOM element is capable of transforming into another, no matter where the two elements sit in the DOM tree. It does so by making copies of the two elements (and all their children), setting a fixed position on each, then using CSS transforms to morph the two elements in sync.', language: 'CSS', is_free: 1, web_url: 'http://www.rich-harris.co.uk/ramjet/', repo_url: 'https://github.com/rich-harris/ramjet', avg_rating: 5})
t3 = Tool.create({title: 'Nifty Modal Window Effects', description: 'Some inspiration for different modal window appearances', language: 'javascript', is_free: 1, web_url: 'http://tympanus.net/Development/ModalWindowEffects/', repo_url: '', avg_rating: 5})
t4 = Tool.create({title: 'Creative Link Effects', description: 'Subtle and modern effects for links or menu items', language: 'javascript', is_free: 1, web_url: 'http://tympanus.net/Development/CreativeLinkEffects/', repo_url: '', avg_rating: 5})
t5 = Tool.create({title: 'Creative Loading Effects', description: 'Loading animations don\'t have to be restricted to a tiny indicator. Here is some inspiration for some creative loading effects.*', language: 'javascript', is_free: 1, web_url: '', avg_rating: 5, repo_url: 'http://tympanus.net/Development/CreativeLoadingEffects/'})
t6 = Tool.create({title: 'scrollReveal.js', description: 'Easily reveal elements as they enter the viewport.', language: 'javascript', is_free: 1, web_url: 'http://scrollrevealjs.org/', repo_url: 'https://github.com/julianlloyd/scrollReveal.js', avg_rating: 5})
t7 = Tool.create({title: 'jQuery Scoll Path', description: 'It\'s a plugin for defining custom scroll paths.', language: 'javascript', is_free: 1, web_url: 'http://joelb.me/scrollpath/', repo_url: 'https://github.com/JoelBesada/scrollpath', avg_rating: 5})
t8 = Tool.create({title: 'Animate.css', description: 'Just-add-water CSS animations', language: 'css', is_free: 1, web_url: 'http://daneden.github.io/animate.css/', repo_url: 'https://github.com/daneden/animate.css', avg_rating: 5})
t9 = Tool.create({title: 'Lettering.JS', description: 'Web type is exploding all over the web but CSS currently doesn\'t offer complete down-to-the-letter control. So we created a jQuery plugin to give you that control. Here are a few examples of what can easily be done with Lettering.js:', avg_rating: 3, language: 'javascript', is_free: 1, web_url: 'http://letteringjs.com/', repo_url: 'https://github.com/davatron5000/Lettering.js'})
t10 = Tool.create({title: 'Skrollr', description: ' Stand-alone parallax scrolling library for mobile (Android + iOS) and desktop. No jQuery. Just plain JavaScript (and some love).', language: 'javascript', is_free: 1, web_url: 'http://prinzhorn.github.io/skrollr/', repo_url: 'https://github.com/Prinzhorn/skrollr', avg_rating: 5})
t11 = Tool.create({title: 'Scrolldeck', description: 'A jQuery plugin for making scrolling presentation decks', language: 'javascript', is_free: 1, web_url: 'https://johnpolacek.github.io/scrolldeck.js', repo_url: 'https://github.com/johnpolacek/scrolldeck.js', avg_rating: 5})
t12 = Tool.create({title: 'Famous', description: 'Famous abstracts the DOM & WebGL, allowing you to do custom layout and rendering. Centering objects and rotating them can be done with only a few lines of code.', language: 'javascript', is_free: 1, web_url: 'http://famous.org/', repo_url: '', avg_rating: 4})
t13 = Tool.create({title: 'Skipper', description: 'Skipper makes it easy to implement streaming file uploads to disk, S3, or any of its supported file adapters.', language: 'javascript', is_free: 1, web_url: '', repo_url: 'https://github.com/balderdashy/skipper', avg_rating: 2})
t14 = Tool.create({title: 'Waterline', description: 'Waterline is a brand new kind of storage and retrieval engine. It provides a uniform API for accessing stuff from different kinds of databases, protocols, and 3rd party APIs. That means you write the same code to get and store things like users, whether they live in Redis, mySQL, LDAP, MongoDB, or Postgres. Waterline strives to inherit the best parts of ORMs like ActiveRecord, Hibernate, and Mongoose, but with a fresh perspective and emphasis on modularity, testability, and consistency across adapters.', language: 'javascript', is_free: 1, web_url: 'https://github.com/balderdashy/waterline-docs', repo_url: 'https://github.com/balderdashy/waterline'})
t15 = Tool.create({title: 'Mongoose', description: 'Elegant MongoDB object modeling for Node.js', language: 'javascript', is_free: 1, web_url: 'http://mongoosejs.com/', repo_url: 'https://github.com/Automattic/mongoose', avg_rating: 1})
t16 = Tool.create({title: 'bcrypt', description: 'A bcrypt library for NodeJS.', language: 'javascript', is_free: 1, web_url: 'https://www.npmjs.com/package/bcrypt', repo_url: 'https://github.com/ncb000gt/node.bcrypt.js', avg_rating: 4})
t17 = Tool.create({title: 'Ionic', description: ' The beautiful, open source front-end SDK for developing hybrid mobile apps with HTML5.', language: 'javascript', is_free: 1, web_url: 'http://ionicframework.com/', repo_url: '', avg_rating: 5})
t18 = Tool.create({title: 'NPM', description: 'A package manager for javascript and a lot of other stuff.', language: '', is_free: 1, web_url: 'https://www.npmjs.com/', repo_url: '', avg_rating: 1})
t19 = Tool.create({title: 'Foreman', description: 'Manage Procfile-based applications', language: 'ruby', is_free: 1, web_url: 'https://github.com/ddollar/foreman', repo_url: '', avg_rating: 4})
t20 = Tool.create({title: 'Passport', description: 'Passport is authentication middleware for Node.js. Extremely flexible and modular, Passport can be unobtrusively dropped in to any Express-based web application. A comprehensive set of strategies support authentication using a username and password, Facebook, Twitter, and more.', language: 'javascript', is_free: 1, web_url: 'http://passportjs.org', repo_url: 'https://github.com/jaredhanson/passport', avg_rating: 2})
t21 = Tool.create({title: 'Debug', description: "tiny node.js debugging utility modelled after node core's debugging technique.", language: 'javascript', is_free: 1, web_url: 'https://www.npmjs.com/package/debug', repo_url: 'https://github.com/visionmedia/debug', avg_rating: 5})
t22 = Tool.create({title: 'Noty', description: 'NOTY is a jQuery plugin that makes it easy to create alert - success - error - warning - information - confirmation messages as an alternative the standard alert dialog. Each notification is added to a queue. (Optional)', language: 'javascript', is_free: 1, web_url: 'http://ned.im/noty/#/about', repo_url: 'https://github.com/needim/noty/', avg_rating: 5})
t23 = Tool.create({title: 'Sails', description: 'Sails makes it easy to build custom, enterprise-grade Node.js apps. It is designed to emulate the familiar MVC pattern of frameworks like Ruby on Rails, but with support for the requirements of modern apps: data-driven APIs with a scalable, service-oriented architecture. It\'s especially good for building chat, realtime dashboards, or multiplayer games; but you can use it for any web application project - top to bottom.', language: 'javascript', is_free: 1, web_url: 'http://sailsjs.org', repo_url: 'https://github.com/balderdashy/sails/', avg_rating: 5})
t24 = Tool.create({title: 'Async.js', description: 'Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. Although originally designed for use with Node.js and installable via npm install async, it can also be used directly in the browser.', language: 'javascript', is_free: 1, web_url: '', repo_url: 'https://github.com/caolan/async', avg_rating: 3})
t25 = Tool.create({title: 'body-parser', description: 'Node.js body parsing middleware.', language: 'javascript', is_free: 1, web_url: '', repo_url: 'https://github.com/expressjs/body-parser', avg_rating: 2})
t26 = Tool.create({title: 'ExpressJS', description: 'Fast, unopinionated, minimalist web framework for Node.js', language: 'javascript', is_free: 1, web_url: 'http://expressjs.com', repo_url: 'https://github.com/strongloop/expressjs.com', avg_rating: 4})
t27 = Tool.create({title: 'Easy table', description: 'Nice utility for rendering text tables with javascript.', language: 'javascript', is_free: 1, web_url: '', repo_url: 'https://github.com/eldargab/easy-table', avg_rating: 5})
t28 = Tool.create({title: 'Sequelize', description: 'Sequelize is a promise-based ORM for Node.js and io.js. It supports the dialects PostgreSQL, MySQL, MariaDB, SQLite and MSSQL and features solid transaction support, relations, read replication and more.', language: 'javascript', is_free: 1, web_url: 'http://docs.sequelizejs.com', repo_url: 'https://github.com/sequelize/sequelize', avg_rating: 1})
t29 = Tool.create({title: 'sequelize/cli', description: 'The Sequelize Command Line Interface', language: 'javascript', is_free: 1, web_url: '', repo_url: 'https://github.com/sequelize/cli', avg_rating: 5})
t30 = Tool.create({title: 'AngularJS', description: 'HTML is great for declaring static documents, but it falters when we try to use it for declaring dynamic views in web-applications. AngularJS lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop.', language: 'javascript', is_free: 1, web_url: 'https://angularjs.org/', doc_url: 'https://angularjs.org/', repo_url: 'http://cdnjs.com/libraries/angular.js/', avg_rating: 5})
t31 = Tool.create({title: 'UI Bootstrap', description: 'Bootstrap components written in pure AngularJS by the AngularUI Team', language: 'javascript', is_free: 1, web_url: 'http://angular-ui.github.io/bootstrap/', doc_url: 'http://angular-ui.github.io/bootstrap/', repo_url: 'https://github.com/angular-ui/bootstrap', avg_rating: 5})
t32 = Tool.create({title: 'lumx', description: 'The first responsive front-end framework based on AngularJS & Google Material Design specifications.', language: 'javascript', is_free: 1, web_url: 'http://ui.lumapps.com/', doc_url: 'http://ui.lumapps.com/directives/dropdowns', repo_url: 'https://github.com/lumapps/lumX/', avg_rating: 5})
t33 = Tool.create({title: 'ngAnimate', description: 'The ngAnimate module provides support for CSS-based animations (keyframes and transitions) as well as JavaScript-based animations via callback hooks. Animations are not enabled by default, however, by including ngAnimate then the animation hooks are enabled for an Angular app.', language: 'javascript', is_free: 1, web_url: 'https://docs.angularjs.org/api/ngAnimate', doc_url: 'https://docs.angularjs.org/api/ngAnimate', repo_url: '', avg_rating: 5})
t34 = Tool.create({title: 'Angular Material', description: 'The Angular Material project is an implementation of Material Design in Angular.js. This project provides a set of reusable, well-tested, and accessible UI components based on the Material Design system.', language: 'javascript', is_free: 1, web_url: 'https://material.angularjs.org', repo_url: 'https://github.com/angular/material/tree/v0.9.7', doc_url: 'https://material.angularjs.org/latest/#/getting-started', avg_rating: 5})
t35 = Tool.create({title: 'ngInfinite Scroll', description: 'ngInfiniteScroll is a directive that you can use to implement infinite scrolling in your AngularJS applications. Simply declare which function to call when the user gets close to the bottom of the content with the directive and the module will take care of the rest. Of course, you can specify several options to ensure that the behavior is just what you\'re looking for.', language: 'javascript', is_free: 1, web_url: 'https://sroze.github.io/ngInfiniteScroll/', repo_url: 'https://github.com/sroze/ngInfiniteScroll', doc_url: 'https://sroze.github.io/ngInfiniteScroll/documentation.html', avg_rating: 5})
t36 = Tool.create({title: 'spin.js', description: 'Spin.js dynamically creates spinning activity indicators that can be used as resolution-independent replacement for AJAX loading GIFs.', language: 'javascript', is_free: 1, web_url: 'http://fgnass.github.io/spin.js/', repo_url: 'http://github.com/fgnass/spin.js', doc_url: 'http://fgnass.github.io/spin.js/', avg_rating: 5})
t37 = Tool.create({title: 'Typhoeus', description: 'Like a modern code version of the mythical beast with 100 serpent heads, Typhoeus runs HTTP requests in parallel while cleanly encapsulating handling logic.', language: 'ruby', is_free: 1, web_url: 'https://github.com/typhoeus/typhoeus', repo_url: 'https://github.com/typhoeus/typhoeus', doc_url: 'https://github.com/typhoeus/typhoeus', avg_rating: 5})
# Create Tags
terminal = Category.create({category:'terminal'})
terminal.tools << t29
terminal.tools << t27
gems = Tag.create({tag:'gem'})
gems.tools << t37
rails = Tag.create({tag:'rails'})
rails.tools << t37
requests = Tag.create({tag: 'requests'})
requests.tools << t37
angular = Tag.create({tag:'angular.js'})
angular.tools << t30
angular.tools << t31
angular.tools << t32
angular.tools << t33
angular.tools << t34
angular.tools << t35
directive = Tag.create({tag:'directive'})
directive.tools << t31
directive.tools << t32
directive.tools << t33
directive.tools << t34
directive.tools << t35
pagination = Tag.create({tag:'pagination'})
pagination.tools << t35
responsive = Tag.create({tag:'responsive'})
responsive.tools << t31
responsive.tools << t32
responsive.tools << t34
responsive.tools << t35
jquery = Tag.create(tag:'jquery')
jquery.tools << t22
jquery.tools << t36
oauth = Tag.create(tag:'oauth')
oauth.tools << t20
date = Tag.create(tag:'date')
date.tools << t1
time = Tag.create(tag:'time')
time.tools << t1
sails = Tag.create(tag:'sails.js')
sails.tools << t13
node = Tag.create(tag:'node.js')
node.tools << t15
node.tools << t23
node.tools << t20
node.tools << t21
node.tools << t25
node.tools << t26
node.tools << t28
font = Tag.create(tag:'font')
font.tools << t9
animate = Tag.create(tag:'animation')
animate.tools << t2
animate.tools << t10
animate.tools << t8
animate.tools << t5
animate.tools << t6
animate.tools << t7
animate.tools << t33
animate.tools << t35
animate.tools << t36
frontend = Tag.create({tag:'frontend'})
frontend.tools << t36
frontend.tools << t35
frontend.tools << t33
frontend.tools << t34
frontend.tools << t32
frontend.tools << t31
frontend.tools << t30
frontend.tools << t1
frontend.tools << t2
frontend.tools << t3
frontend.tools << t4
frontend.tools << t5
frontend.tools << t6
frontend.tools << t7
frontend.tools << t8
frontend.tools << t9
frontend.tools << t10
frontend.tools << t11
frontend.tools << t12
frontend.tools << t22
backend = Tag.create({tag:'backend'})
backend.tools << t37
backend.tools << t1
backend.tools << t13
backend.tools << t14
backend.tools << t15
backend.tools << t16
backend.tools << t17
backend.tools << t20
backend.tools << t21
backend.tools << t23
backend.tools << t24
backend.tools << t25
backend.tools << t26
backend.tools << t28
comandline = Tag.create({tag:'commandline'})
comandline.tools << t1
comandline.tools << t18
comandline.tools << t19
comandline.tools << t27
comandline.tools << t29
loading = Tag.create({tag:'loading'})
loading.tools << t36
# Create Categories
# Associate Tools to Categories
library = Category.create({category: 'library'})
library.tools << t37
library.tools << t36
library.tools << t1
library.tools << t2
library.tools << t6
library.tools << t7
library.tools << t8
library.tools << t9
library.tools << t10
library.tools << t11
library.tools << t13
library.tools << t14
library.tools << t15
library.tools << t16
library.tools << t19
library.tools << t20
library.tools << t21
library.tools << t22
library.tools << t24
library.tools << t25
library.tools << t27
library.tools << t28
library.tools << t29
library.tools << t35
framework = Category.create({category: 'framework'})
framework.tools << t1
framework.tools << t31
framework.tools << t32
framework.tools << t34
framework.tools << t33
framework.tools << t30
framework.tools << t12
framework.tools << t17
framework.tools << t23
framework.tools << t26
assets = Category.create({category: 'assets'})
assets.tools << t1
assets.tools << t3
assets.tools << t4
assets.tools << t5
assets.tools << t31
assets.tools << t35
packageManager = Category.create({category: 'package manager'})
packageManager.tools << t18
text = Category.create({category:'text-editory/ide'})
image = Category.create({category:'image editor'})
team = Category.create({category:'team communication'})
project = Category.create({category:'project management'})
prototype = Category.create({category:'prototype builder'})
tv1 = Tvote.create(vote:75)
t1.tvotes << tv1
Cody.tvotes << tv1
tv2 = Tvote.create(vote:1)
t1.tvotes << tv2
Nick.tvotes << tv2
tv3 = Tvote.create(vote:100)
t2.tvotes << tv3
Cody.tvotes << tv3
tv4 = Tvote.create(vote:6)
t3.tvotes << tv4
Nick.tvotes << tv4
tv5 = Tvote.create(vote:15)
t3.tvotes << tv5
Cody.tvotes << tv5
tv6 = Tvote.create(vote:1)
t4.tvotes << tv6
Nick.tvotes << tv6
tv7 = Tvote.create(vote:20)
t5.tvotes << tv7
Nick.tvotes << tv7
tv8 = Tvote.create(vote:75)
t5.tvotes << tv8
Cody.tvotes << tv8
tv9 = Tvote.create(vote:1)
t6.tvotes << tv9
Nick.tvotes << tv9
tv10 = Tvote.create(vote:100)
t7.tvotes << tv10
Cody.tvotes << tv10
tv11 = Tvote.create(vote:6)
t8.tvotes << tv11
Nick.tvotes << tv11
tv12 = Tvote.create(vote:15)
t9.tvotes << tv12
Cody.tvotes << tv12
tv13 = Tvote.create(vote:1)
t10.tvotes << tv13
Nick.tvotes << tv13
tv14 = Tvote.create(vote:20)
t11.tvotes << tv14
Nick.tvotes << tv14
tv15 = Tvote.create(vote:75)
t12.tvotes << tv15
Cody.tvotes << tv15
tv16 = Tvote.create(vote:1)
t13.tvotes << tv16
Nick.tvotes << tv16
tv17 = Tvote.create(vote:100)
t14.tvotes << tv17
Cody.tvotes << tv17
tv18 = Tvote.create(vote:6)
t15.tvotes << tv18
Nick.tvotes << tv18
tv19 = Tvote.create(vote:15)
t16.tvotes << tv19
Cody.tvotes << tv19
tv20 = Tvote.create(vote:1)
t17.tvotes << tv20
Nick.tvotes << tv20
tv21 = Tvote.create(vote:20)
t18.tvotes << tv21
Nick.tvotes << tv21
tv22 = Tvote.create(vote:75)
t19.tvotes << tv22
Cody.tvotes << tv22
tv23 = Tvote.create(vote:1)
t20.tvotes << tv23
Nick.tvotes << tv23
tv24 = Tvote.create(vote:100)
t21.tvotes << tv24
Cody.tvotes << tv24
tv25 = Tvote.create(vote:6)
t22.tvotes << tv25
Nick.tvotes << tv25
tv26 = Tvote.create(vote:15)
t23.tvotes << tv26
Cody.tvotes << tv26
tv27 = Tvote.create(vote:1)
t24.tvotes << tv27
Nick.tvotes << tv27
tv28 = Tvote.create(vote:20)
t25.tvotes << tv28
Nick.tvotes << tv28
tv29 = Tvote.create(vote:6)
t26.tvotes << tv29
Nick.tvotes << tv29
tv30 = Tvote.create(vote:15)
t27.tvotes << tv30
Cody.tvotes << tv30
tv31 = Tvote.create(vote:1)
t28.tvotes << tv31
Nick.tvotes << tv31
tv32 = Tvote.create(vote:20)
t29.tvotes << tv32
Nick.tvotes << tv32
heroku push
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
# Create Tools Template
# t1 = Tool.create({title: '', description: '', language: '', is_free: 1, web_url: '', repo_url: ''})
t1 = Tool.create({title: 'Moment.js', description: 'Parse, validate, manipulate, and display dates in JavaScript.', language: 'javascript', is_free: 1, web_url: 'http://momentjs.com/', repo_url: 'https://github.com/moment/moment/', avg_rating: 5})
t2 = Tool.create({title: 'ramjet', description: 'Ramjet makes it looks as though one DOM element is capable of transforming into another, no matter where the two elements sit in the DOM tree. It does so by making copies of the two elements (and all their children), setting a fixed position on each, then using CSS transforms to morph the two elements in sync.', language: 'CSS', is_free: 1, web_url: 'http://www.rich-harris.co.uk/ramjet/', repo_url: 'https://github.com/rich-harris/ramjet', avg_rating: 5})
t3 = Tool.create({title: 'Nifty Modal Window Effects', description: 'Some inspiration for different modal window appearances', language: 'javascript', is_free: 1, web_url: 'http://tympanus.net/Development/ModalWindowEffects/', repo_url: '', avg_rating: 5})
t4 = Tool.create({title: 'Creative Link Effects', description: 'Subtle and modern effects for links or menu items', language: 'javascript', is_free: 1, web_url: 'http://tympanus.net/Development/CreativeLinkEffects/', repo_url: '', avg_rating: 5})
t5 = Tool.create({title: 'Creative Loading Effects', description: 'Loading animations don\'t have to be restricted to a tiny indicator. Here is some inspiration for some creative loading effects.*', language: 'javascript', is_free: 1, web_url: '', avg_rating: 5, repo_url: 'http://tympanus.net/Development/CreativeLoadingEffects/'})
t6 = Tool.create({title: 'scrollReveal.js', description: 'Easily reveal elements as they enter the viewport.', language: 'javascript', is_free: 1, web_url: 'http://scrollrevealjs.org/', repo_url: 'https://github.com/julianlloyd/scrollReveal.js', avg_rating: 5})
t7 = Tool.create({title: 'jQuery Scoll Path', description: 'It\'s a plugin for defining custom scroll paths.', language: 'javascript', is_free: 1, web_url: 'http://joelb.me/scrollpath/', repo_url: 'https://github.com/JoelBesada/scrollpath', avg_rating: 5})
t8 = Tool.create({title: 'Animate.css', description: 'Just-add-water CSS animations', language: 'css', is_free: 1, web_url: 'http://daneden.github.io/animate.css/', repo_url: 'https://github.com/daneden/animate.css', avg_rating: 5})
t9 = Tool.create({title: 'Lettering.JS', description: 'Web type is exploding all over the web but CSS currently doesn\'t offer complete down-to-the-letter control. So we created a jQuery plugin to give you that control. Here are a few examples of what can easily be done with Lettering.js:', avg_rating: 3, language: 'javascript', is_free: 1, web_url: 'http://letteringjs.com/', repo_url: 'https://github.com/davatron5000/Lettering.js'})
t10 = Tool.create({title: 'Skrollr', description: ' Stand-alone parallax scrolling library for mobile (Android + iOS) and desktop. No jQuery. Just plain JavaScript (and some love).', language: 'javascript', is_free: 1, web_url: 'http://prinzhorn.github.io/skrollr/', repo_url: 'https://github.com/Prinzhorn/skrollr', avg_rating: 5})
t11 = Tool.create({title: 'Scrolldeck', description: 'A jQuery plugin for making scrolling presentation decks', language: 'javascript', is_free: 1, web_url: 'https://johnpolacek.github.io/scrolldeck.js', repo_url: 'https://github.com/johnpolacek/scrolldeck.js', avg_rating: 5})
t12 = Tool.create({title: 'Famous', description: 'Famous abstracts the DOM & WebGL, allowing you to do custom layout and rendering. Centering objects and rotating them can be done with only a few lines of code.', language: 'javascript', is_free: 1, web_url: 'http://famous.org/', repo_url: '', avg_rating: 4})
t13 = Tool.create({title: 'Skipper', description: 'Skipper makes it easy to implement streaming file uploads to disk, S3, or any of its supported file adapters.', language: 'javascript', is_free: 1, web_url: '', repo_url: 'https://github.com/balderdashy/skipper', avg_rating: 2})
t14 = Tool.create({title: 'Waterline', description: 'Waterline is a brand new kind of storage and retrieval engine. It provides a uniform API for accessing stuff from different kinds of databases, protocols, and 3rd party APIs. That means you write the same code to get and store things like users, whether they live in Redis, mySQL, LDAP, MongoDB, or Postgres. Waterline strives to inherit the best parts of ORMs like ActiveRecord, Hibernate, and Mongoose, but with a fresh perspective and emphasis on modularity, testability, and consistency across adapters.', language: 'javascript', is_free: 1, web_url: 'https://github.com/balderdashy/waterline-docs', repo_url: 'https://github.com/balderdashy/waterline'})
t15 = Tool.create({title: 'Mongoose', description: 'Elegant MongoDB object modeling for Node.js', language: 'javascript', is_free: 1, web_url: 'http://mongoosejs.com/', repo_url: 'https://github.com/Automattic/mongoose', avg_rating: 1})
t16 = Tool.create({title: 'bcrypt', description: 'A bcrypt library for NodeJS.', language: 'javascript', is_free: 1, web_url: 'https://www.npmjs.com/package/bcrypt', repo_url: 'https://github.com/ncb000gt/node.bcrypt.js', avg_rating: 4})
t17 = Tool.create({title: 'Ionic', description: ' The beautiful, open source front-end SDK for developing hybrid mobile apps with HTML5.', language: 'javascript', is_free: 1, web_url: 'http://ionicframework.com/', repo_url: '', avg_rating: 5})
t18 = Tool.create({title: 'NPM', description: 'A package manager for javascript and a lot of other stuff.', language: '', is_free: 1, web_url: 'https://www.npmjs.com/', repo_url: '', avg_rating: 1})
t19 = Tool.create({title: 'Foreman', description: 'Manage Procfile-based applications', language: 'ruby', is_free: 1, web_url: 'https://github.com/ddollar/foreman', repo_url: '', avg_rating: 4})
t20 = Tool.create({title: 'Passport', description: 'Passport is authentication middleware for Node.js. Extremely flexible and modular, Passport can be unobtrusively dropped in to any Express-based web application. A comprehensive set of strategies support authentication using a username and password, Facebook, Twitter, and more.', language: 'javascript', is_free: 1, web_url: 'http://passportjs.org', repo_url: 'https://github.com/jaredhanson/passport', avg_rating: 2})
t21 = Tool.create({title: 'Debug', description: "tiny node.js debugging utility modelled after node core's debugging technique.", language: 'javascript', is_free: 1, web_url: 'https://www.npmjs.com/package/debug', repo_url: 'https://github.com/visionmedia/debug', avg_rating: 5})
t22 = Tool.create({title: 'Noty', description: 'NOTY is a jQuery plugin that makes it easy to create alert - success - error - warning - information - confirmation messages as an alternative the standard alert dialog. Each notification is added to a queue. (Optional)', language: 'javascript', is_free: 1, web_url: 'http://ned.im/noty/#/about', repo_url: 'https://github.com/needim/noty/', avg_rating: 5})
t23 = Tool.create({title: 'Sails', description: 'Sails makes it easy to build custom, enterprise-grade Node.js apps. It is designed to emulate the familiar MVC pattern of frameworks like Ruby on Rails, but with support for the requirements of modern apps: data-driven APIs with a scalable, service-oriented architecture. It\'s especially good for building chat, realtime dashboards, or multiplayer games; but you can use it for any web application project - top to bottom.', language: 'javascript', is_free: 1, web_url: 'http://sailsjs.org', repo_url: 'https://github.com/balderdashy/sails/', avg_rating: 5})
t24 = Tool.create({title: 'Async.js', description: 'Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. Although originally designed for use with Node.js and installable via npm install async, it can also be used directly in the browser.', language: 'javascript', is_free: 1, web_url: '', repo_url: 'https://github.com/caolan/async', avg_rating: 3})
t25 = Tool.create({title: 'body-parser', description: 'Node.js body parsing middleware.', language: 'javascript', is_free: 1, web_url: '', repo_url: 'https://github.com/expressjs/body-parser', avg_rating: 2})
t26 = Tool.create({title: 'ExpressJS', description: 'Fast, unopinionated, minimalist web framework for Node.js', language: 'javascript', is_free: 1, web_url: 'http://expressjs.com', repo_url: 'https://github.com/strongloop/expressjs.com', avg_rating: 4})
t27 = Tool.create({title: 'Easy table', description: 'Nice utility for rendering text tables with javascript.', language: 'javascript', is_free: 1, web_url: '', repo_url: 'https://github.com/eldargab/easy-table', avg_rating: 5})
t28 = Tool.create({title: 'Sequelize', description: 'Sequelize is a promise-based ORM for Node.js and io.js. It supports the dialects PostgreSQL, MySQL, MariaDB, SQLite and MSSQL and features solid transaction support, relations, read replication and more.', language: 'javascript', is_free: 1, web_url: 'http://docs.sequelizejs.com', repo_url: 'https://github.com/sequelize/sequelize', avg_rating: 1})
t29 = Tool.create({title: 'sequelize/cli', description: 'The Sequelize Command Line Interface', language: 'javascript', is_free: 1, web_url: '', repo_url: 'https://github.com/sequelize/cli', avg_rating: 5})
t30 = Tool.create({title: 'AngularJS', description: 'HTML is great for declaring static documents, but it falters when we try to use it for declaring dynamic views in web-applications. AngularJS lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop.', language: 'javascript', is_free: 1, web_url: 'https://angularjs.org/', doc_url: 'https://angularjs.org/', repo_url: 'http://cdnjs.com/libraries/angular.js/', avg_rating: 5})
t31 = Tool.create({title: 'UI Bootstrap', description: 'Bootstrap components written in pure AngularJS by the AngularUI Team', language: 'javascript', is_free: 1, web_url: 'http://angular-ui.github.io/bootstrap/', doc_url: 'http://angular-ui.github.io/bootstrap/', repo_url: 'https://github.com/angular-ui/bootstrap', avg_rating: 5})
t32 = Tool.create({title: 'lumx', description: 'The first responsive front-end framework based on AngularJS & Google Material Design specifications.', language: 'javascript', is_free: 1, web_url: 'http://ui.lumapps.com/', doc_url: 'http://ui.lumapps.com/directives/dropdowns', repo_url: 'https://github.com/lumapps/lumX/', avg_rating: 5})
t33 = Tool.create({title: 'ngAnimate', description: 'The ngAnimate module provides support for CSS-based animations (keyframes and transitions) as well as JavaScript-based animations via callback hooks. Animations are not enabled by default, however, by including ngAnimate then the animation hooks are enabled for an Angular app.', language: 'javascript', is_free: 1, web_url: 'https://docs.angularjs.org/api/ngAnimate', doc_url: 'https://docs.angularjs.org/api/ngAnimate', repo_url: '', avg_rating: 5})
t34 = Tool.create({title: 'Angular Material', description: 'The Angular Material project is an implementation of Material Design in Angular.js. This project provides a set of reusable, well-tested, and accessible UI components based on the Material Design system.', language: 'javascript', is_free: 1, web_url: 'https://material.angularjs.org', repo_url: 'https://github.com/angular/material/tree/v0.9.7', doc_url: 'https://material.angularjs.org/latest/#/getting-started', avg_rating: 5})
t35 = Tool.create({title: 'ngInfinite Scroll', description: 'ngInfiniteScroll is a directive that you can use to implement infinite scrolling in your AngularJS applications. Simply declare which function to call when the user gets close to the bottom of the content with the directive and the module will take care of the rest. Of course, you can specify several options to ensure that the behavior is just what you\'re looking for.', language: 'javascript', is_free: 1, web_url: 'https://sroze.github.io/ngInfiniteScroll/', repo_url: 'https://github.com/sroze/ngInfiniteScroll', doc_url: 'https://sroze.github.io/ngInfiniteScroll/documentation.html', avg_rating: 5})
t36 = Tool.create({title: 'spin.js', description: 'Spin.js dynamically creates spinning activity indicators that can be used as resolution-independent replacement for AJAX loading GIFs.', language: 'javascript', is_free: 1, web_url: 'http://fgnass.github.io/spin.js/', repo_url: 'http://github.com/fgnass/spin.js', doc_url: 'http://fgnass.github.io/spin.js/', avg_rating: 5})
t37 = Tool.create({title: 'Typhoeus', description: 'Like a modern code version of the mythical beast with 100 serpent heads, Typhoeus runs HTTP requests in parallel while cleanly encapsulating handling logic.', language: 'ruby', is_free: 1, web_url: 'https://github.com/typhoeus/typhoeus', repo_url: 'https://github.com/typhoeus/typhoeus', doc_url: 'https://github.com/typhoeus/typhoeus', avg_rating: 5})
# Create Tags
terminal = Category.create({category:'terminal'})
terminal.tools << t29
terminal.tools << t27
gems = Tag.create({tag:'gem'})
gems.tools << t37
rails = Tag.create({tag:'rails'})
rails.tools << t37
requests = Tag.create({tag: 'requests'})
requests.tools << t37
angular = Tag.create({tag:'angular.js'})
angular.tools << t30
angular.tools << t31
angular.tools << t32
angular.tools << t33
angular.tools << t34
angular.tools << t35
directive = Tag.create({tag:'directive'})
directive.tools << t31
directive.tools << t32
directive.tools << t33
directive.tools << t34
directive.tools << t35
pagination = Tag.create({tag:'pagination'})
pagination.tools << t35
responsive = Tag.create({tag:'responsive'})
responsive.tools << t31
responsive.tools << t32
responsive.tools << t34
responsive.tools << t35
jquery = Tag.create(tag:'jquery')
jquery.tools << t22
jquery.tools << t36
oauth = Tag.create(tag:'oauth')
oauth.tools << t20
date = Tag.create(tag:'date')
date.tools << t1
time = Tag.create(tag:'time')
time.tools << t1
sails = Tag.create(tag:'sails.js')
sails.tools << t13
node = Tag.create(tag:'node.js')
node.tools << t15
node.tools << t23
node.tools << t20
node.tools << t21
node.tools << t25
node.tools << t26
node.tools << t28
font = Tag.create(tag:'font')
font.tools << t9
animate = Tag.create(tag:'animation')
animate.tools << t2
animate.tools << t10
animate.tools << t8
animate.tools << t5
animate.tools << t6
animate.tools << t7
animate.tools << t33
animate.tools << t35
animate.tools << t36
frontend = Tag.create({tag:'frontend'})
frontend.tools << t36
frontend.tools << t35
frontend.tools << t33
frontend.tools << t34
frontend.tools << t32
frontend.tools << t31
frontend.tools << t30
frontend.tools << t1
frontend.tools << t2
frontend.tools << t3
frontend.tools << t4
frontend.tools << t5
frontend.tools << t6
frontend.tools << t7
frontend.tools << t8
frontend.tools << t9
frontend.tools << t10
frontend.tools << t11
frontend.tools << t12
frontend.tools << t22
backend = Tag.create({tag:'backend'})
backend.tools << t37
backend.tools << t1
backend.tools << t13
backend.tools << t14
backend.tools << t15
backend.tools << t16
backend.tools << t17
backend.tools << t20
backend.tools << t21
backend.tools << t23
backend.tools << t24
backend.tools << t25
backend.tools << t26
backend.tools << t28
comandline = Tag.create({tag:'commandline'})
comandline.tools << t1
comandline.tools << t18
comandline.tools << t19
comandline.tools << t27
comandline.tools << t29
loading = Tag.create({tag:'loading'})
loading.tools << t36
# Create Categories
# Associate Tools to Categories
library = Category.create({category: 'library'})
library.tools << t37
library.tools << t36
library.tools << t1
library.tools << t2
library.tools << t6
library.tools << t7
library.tools << t8
library.tools << t9
library.tools << t10
library.tools << t11
library.tools << t13
library.tools << t14
library.tools << t15
library.tools << t16
library.tools << t19
library.tools << t20
library.tools << t21
library.tools << t22
library.tools << t24
library.tools << t25
library.tools << t27
library.tools << t28
library.tools << t29
library.tools << t35
framework = Category.create({category: 'framework'})
framework.tools << t1
framework.tools << t31
framework.tools << t32
framework.tools << t34
framework.tools << t33
framework.tools << t30
framework.tools << t12
framework.tools << t17
framework.tools << t23
framework.tools << t26
assets = Category.create({category: 'assets'})
assets.tools << t1
assets.tools << t3
assets.tools << t4
assets.tools << t5
assets.tools << t31
assets.tools << t35
packageManager = Category.create({category: 'package manager'})
packageManager.tools << t18
text = Category.create({category:'text-editory/ide'})
image = Category.create({category:'image editor'})
team = Category.create({category:'team communication'})
project = Category.create({category:'project management'})
prototype = Category.create({category:'prototype builder'})
tv1 = Tvote.create(vote:75)
t1.tvotes << tv1
Cody.tvotes << tv1
tv2 = Tvote.create(vote:1)
t1.tvotes << tv2
Nick.tvotes << tv2
tv3 = Tvote.create(vote:100)
t2.tvotes << tv3
Cody.tvotes << tv3
tv4 = Tvote.create(vote:6)
t3.tvotes << tv4
Nick.tvotes << tv4
tv5 = Tvote.create(vote:15)
t3.tvotes << tv5
Cody.tvotes << tv5
tv6 = Tvote.create(vote:1)
t4.tvotes << tv6
Nick.tvotes << tv6
tv7 = Tvote.create(vote:20)
t5.tvotes << tv7
Nick.tvotes << tv7
tv8 = Tvote.create(vote:75)
t5.tvotes << tv8
Cody.tvotes << tv8
tv9 = Tvote.create(vote:1)
t6.tvotes << tv9
Nick.tvotes << tv9
tv10 = Tvote.create(vote:100)
t7.tvotes << tv10
Cody.tvotes << tv10
tv11 = Tvote.create(vote:6)
t8.tvotes << tv11
Nick.tvotes << tv11
tv12 = Tvote.create(vote:15)
t9.tvotes << tv12
Cody.tvotes << tv12
tv13 = Tvote.create(vote:1)
t10.tvotes << tv13
Nick.tvotes << tv13
tv14 = Tvote.create(vote:20)
t11.tvotes << tv14
Nick.tvotes << tv14
tv15 = Tvote.create(vote:75)
t12.tvotes << tv15
Cody.tvotes << tv15
tv16 = Tvote.create(vote:1)
t13.tvotes << tv16
Nick.tvotes << tv16
tv17 = Tvote.create(vote:100)
t14.tvotes << tv17
Cody.tvotes << tv17
tv18 = Tvote.create(vote:6)
t15.tvotes << tv18
Nick.tvotes << tv18
tv19 = Tvote.create(vote:15)
t16.tvotes << tv19
Cody.tvotes << tv19
tv20 = Tvote.create(vote:1)
t17.tvotes << tv20
Nick.tvotes << tv20
tv21 = Tvote.create(vote:20)
t18.tvotes << tv21
Nick.tvotes << tv21
tv22 = Tvote.create(vote:75)
t19.tvotes << tv22
Cody.tvotes << tv22
tv23 = Tvote.create(vote:1)
t20.tvotes << tv23
Nick.tvotes << tv23
tv24 = Tvote.create(vote:100)
t21.tvotes << tv24
Cody.tvotes << tv24
tv25 = Tvote.create(vote:6)
t22.tvotes << tv25
Nick.tvotes << tv25
tv26 = Tvote.create(vote:15)
t23.tvotes << tv26
Cody.tvotes << tv26
tv27 = Tvote.create(vote:1)
t24.tvotes << tv27
Nick.tvotes << tv27
tv28 = Tvote.create(vote:20)
t25.tvotes << tv28
Nick.tvotes << tv28
tv29 = Tvote.create(vote:6)
t26.tvotes << tv29
Nick.tvotes << tv29
tv30 = Tvote.create(vote:15)
t27.tvotes << tv30
Cody.tvotes << tv30
tv31 = Tvote.create(vote:1)
t28.tvotes << tv31
Nick.tvotes << tv31
tv32 = Tvote.create(vote:20)
t29.tvotes << tv32
Nick.tvotes << tv32
|
require 'factory_bot_rails'
include FactoryBot::Syntax::Methods
# Generate a staff user with a known username and password
create(:staff, username: 'staff', password: 'staff')
# Generate activity classifications
create(:diagnostic)
create(:proofreader)
create(:grammar)
create(:connect)
create(:lesson)
# Generate objectives
create(:create_a_classroom)
create(:add_students)
create(:assign_featured_activity_pack)
create(:add_school)
create(:assign_entry_diagnostic)
create(:build_your_own_activity_pack)
# Generate milestones
create(:view_lessons_tutorial_milestone)
create(:complete_diagnostic_milestone)
create(:publish_customized_lesson_milestone)
create(:complete_customized_lesson_milestone)
# Path to SQL seeds files
dir_path = File.dirname(__FILE__) + '/seeds/'
# Import concepts
ActiveRecord::Base.connection.execute(File.read(dir_path + 'concepts.sql'))
# Import activities
ActiveRecord::Base.connection.execute(File.read(dir_path + 'activities.sql'))
# Import categories
ActiveRecord::Base.connection.execute(File.read(dir_path + 'categories.sql'))
# Import activity categories
ActiveRecord::Base.connection.execute(File.read(dir_path + 'activity_categories.sql'))
# Import activity category activities
ActiveRecord::Base.connection.execute(File.read(dir_path + 'activity_category_activities.sql'))
# Import unit templates
ActiveRecord::Base.connection.execute(File.read(dir_path + 'unit_templates.sql'))
# Import unit template categories
ActiveRecord::Base.connection.execute(File.read(dir_path + 'unit_template_categories.sql'))
# Import activities unit templates
ActiveRecord::Base.connection.execute(File.read(dir_path + 'activities_unit_templates.sql'))
# Import topics
ActiveRecord::Base.connection.execute(File.read(dir_path + 'topics.sql'))
# Import activities topic categories
ActiveRecord::Base.connection.execute(File.read(dir_path + 'topic_categories.sql'))
# Generate sections
create(:grade_1_section)
create(:grade_2_section)
create(:grade_3_section)
create(:grade_4_section)
create(:grade_5_section)
create(:grade_6_section)
create(:grade_7_section)
create(:grade_8_section)
create(:grade_9_section)
create(:grade_10_section)
create(:grade_11_section)
create(:grade_12_section)
create(:university_section)
# Generate a teacher with classes and students with activities
create(:teacher, :with_classrooms_students_and_activities, username: 'teacher', password: 'teacher')
# Generate Firebase apps
create(:grammar_firebase_app)
Reindex primary keys after db seeding
require 'factory_bot_rails'
include FactoryBot::Syntax::Methods
# Generate a staff user with a known username and password
create(:staff, username: 'staff', password: 'staff')
# Generate activity classifications
create(:diagnostic)
create(:proofreader)
create(:grammar)
create(:connect)
create(:lesson)
# Generate objectives
create(:create_a_classroom)
create(:add_students)
create(:assign_featured_activity_pack)
create(:add_school)
create(:assign_entry_diagnostic)
create(:build_your_own_activity_pack)
# Generate milestones
create(:view_lessons_tutorial_milestone)
create(:complete_diagnostic_milestone)
create(:publish_customized_lesson_milestone)
create(:complete_customized_lesson_milestone)
# Path to SQL seeds files
dir_path = File.dirname(__FILE__) + '/seeds/'
# Import concepts
ActiveRecord::Base.connection.execute(File.read(dir_path + 'concepts.sql'))
# Import activities
ActiveRecord::Base.connection.execute(File.read(dir_path + 'activities.sql'))
# Import categories
ActiveRecord::Base.connection.execute(File.read(dir_path + 'categories.sql'))
# Import activity categories
ActiveRecord::Base.connection.execute(File.read(dir_path + 'activity_categories.sql'))
# Import activity category activities
ActiveRecord::Base.connection.execute(File.read(dir_path + 'activity_category_activities.sql'))
# Import unit templates
ActiveRecord::Base.connection.execute(File.read(dir_path + 'unit_templates.sql'))
# Import unit template categories
ActiveRecord::Base.connection.execute(File.read(dir_path + 'unit_template_categories.sql'))
# Import activities unit templates
ActiveRecord::Base.connection.execute(File.read(dir_path + 'activities_unit_templates.sql'))
# Import topics
ActiveRecord::Base.connection.execute(File.read(dir_path + 'topics.sql'))
# Import activities topic categories
ActiveRecord::Base.connection.execute(File.read(dir_path + 'topic_categories.sql'))
# Generate sections
create(:grade_1_section)
create(:grade_2_section)
create(:grade_3_section)
create(:grade_4_section)
create(:grade_5_section)
create(:grade_6_section)
create(:grade_7_section)
create(:grade_8_section)
create(:grade_9_section)
create(:grade_10_section)
create(:grade_11_section)
create(:grade_12_section)
create(:university_section)
# Generate a teacher with classes and students with activities
create(:teacher, :with_classrooms_students_and_activities, username: 'teacher', password: 'teacher')
# Generate Firebase apps
create(:grammar_firebase_app)
# Reset primary keys
ActiveRecord::Base.connection.tables.each do |table|
ActiveRecord::Base.connection.reset_pk_sequence!(table)
end
|
# coding: utf-8
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
Skill.first_or_create(
[
{ name: 'HTML' },
{ name: 'CSS' },
{ name: 'JavaScript' },
{ name: 'PHP' },
{ name: 'Ruby' },
{ name: 'Java' },
{ name: 'Python' },
{ name: 'Perl' },
{ name: 'C++' },
{ name: 'C#' }
]
)
[
{ name: '議論' },
{ name: '企画・設計' },
{ name: 'プロトタイプ作成' },
{ name: 'ユーザテスト' },
{ name: '運用' },
{ name: '改善・改修' },
{ name: '参加者募集' },
{ name: 'デザイナー募集' },
{ name: 'エンジニア募集' },
{ name: '議論と調査' },
{ name: '企画と試作中' },
{ name: '運用中' },
{ name: '休止・終了' }
].each do |r|
Stage.where(r).first_or_create
end
ステージを減らした。元レコードは削除し、プロジェクトの値は適当に移植すること。
# coding: utf-8
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
Skill.first_or_create(
[
{ name: 'HTML' },
{ name: 'CSS' },
{ name: 'JavaScript' },
{ name: 'PHP' },
{ name: 'Ruby' },
{ name: 'Java' },
{ name: 'Python' },
{ name: 'Perl' },
{ name: 'C++' },
{ name: 'C#' }
]
)
[
{ id: 10, name: '議論と調査' },
{ id: 11, name: '企画と試作中' },
{ id: 12, name: '運用中' },
{ id: 13, name: '休止・終了' }
].each do |r|
Stage.where(r).first_or_create
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
Interest.destroy_all
User.destroy_all
UserInterest.destroy_all
Itinerary.destroy_all
Activity.destroy_all
Location.destroy_all
gender = ["Male", "Female", "Other"]
numbers_to_sample = [1,2,3,4,5,6,7,8,9,10]
5.times do User.create!(
first_name: Faker::Name.first_name,
last_name: Faker::Name.last_name,
email: Faker::Internet.email,
city: Faker::Address.city,
state_province: Faker::Address.state,
country: Faker::Address.country,
personal_info: Faker::Hipster.paragraph,
language: "English",
password:'password',
gender: gender.sample,
is_host: true
)
end
5.times do User.create!(
first_name: Faker::Name.first_name,
last_name: Faker::Name.last_name,
email: Faker::Internet.email,
city: Faker::Address.city,
state_province: Faker::Address.state,
country: Faker::Address.country,
personal_info: Faker::Hipster.paragraph,
language: "English",
password:'password',
gender: gender.sample,
is_host: false
)
end
Interest.create!(name: "History & Culture")
Interest.create!(name: "Art & Museums")
Interest.create!(name: "Exploration")
Interest.create!(name: "Food & Restaurant")
Interest.create!(name: "Nightlife & Bars")
Interest.create!(name: "Shopping")
Interest.create!(name: "Translation")
UserInterest.create!(interest_id: 1, user_id: 1)
UserInterest.create!(interest_id: 2, user_id: 1)
UserInterest.create!(interest_id: 3, user_id: 1)
UserInterest.create!(interest_id: 1, user_id: 2)
UserInterest.create!(interest_id: 4, user_id: 2)
UserInterest.create!(interest_id: 1, user_id: 3)
UserInterest.create!(interest_id: 2, user_id: 3)
UserInterest.create!(interest_id: 3, user_id: 3)
UserInterest.create!(interest_id: 1, user_id: 4)
UserInterest.create!(interest_id: 2, user_id: 4)
UserInterest.create!(interest_id: 3, user_id: 4)
UserInterest.create!(interest_id: 1, user_id: 5)
UserInterest.create!(interest_id: 4, user_id: 5)
UserInterest.create!(interest_id: 5, user_id: 5)
UserInterest.create!(interest_id: 2, user_id: 6)
UserInterest.create!(interest_id: 6, user_id: 6)
UserInterest.create!(interest_id: 1, user_id: 7)
UserInterest.create!(interest_id: 5, user_id: 7)
UserInterest.create!(interest_id: 6, user_id: 7)
UserInterest.create!(interest_id: 1, user_id: 8)
UserInterest.create!(interest_id: 1, user_id: 9)
UserInterest.create!(interest_id: 7, user_id: 9)
UserInterest.create!(interest_id: 1, user_id: 10)
UserInterest.create!(interest_id: 6, user_id: 10)
10.times do
Itinerary.create!(
name: Faker::Book.genre,
visitor_id: rand(1..10),
host_id: rand(1..10),
date:rand(1..10)
)
end
10.times do
Activity.create!(
description: Faker::Hacker.verb,
itinerary_id: rand(1..10),
location_id: rand(1..10)
)
end
10.times do
Location.create!(
name: Faker::Hacker.abbreviation,
address: Faker::Address.street_address,
city: Faker::Address.city
)
end
Update seeds so users all have city of Chicago for search demo
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
Interest.destroy_all
User.destroy_all
UserInterest.destroy_all
Itinerary.destroy_all
Activity.destroy_all
Location.destroy_all
gender = ["Male", "Female", "Other"]
languages = ["English", "Spanish", "Chinese", "Korean", "Japanese", "Russian"]
numbers_to_sample = [1,2,3,4,5,6,7,8,9,10]
5.times do User.create!(
first_name: Faker::Name.first_name,
last_name: Faker::Name.last_name,
email: Faker::Internet.email,
city: "Chicago",
state_province: "IL",
country: "U.S.A.",
personal_info: Faker::Hipster.paragraph,
language: "English",
password:'password',
gender: gender.sample,
is_host: true
)
end
5.times do User.create!(
first_name: Faker::Name.first_name,
last_name: Faker::Name.last_name,
email: Faker::Internet.email,
city: "Chicago",
state_province: "IL",
country: "U.S.A.",
personal_info: Faker::Hipster.paragraph,
language: "English",
password:'password',
gender: gender.sample,
is_host: false
)
end
Interest.create!(name: "History & Culture")
Interest.create!(name: "Art & Museums")
Interest.create!(name: "Exploration")
Interest.create!(name: "Food & Restaurant")
Interest.create!(name: "Nightlife & Bars")
Interest.create!(name: "Shopping")
Interest.create!(name: "Translation")
UserInterest.create!(interest_id: 1, user_id: 1)
UserInterest.create!(interest_id: 2, user_id: 1)
UserInterest.create!(interest_id: 3, user_id: 1)
UserInterest.create!(interest_id: 1, user_id: 2)
UserInterest.create!(interest_id: 4, user_id: 2)
UserInterest.create!(interest_id: 1, user_id: 3)
UserInterest.create!(interest_id: 2, user_id: 3)
UserInterest.create!(interest_id: 3, user_id: 3)
UserInterest.create!(interest_id: 1, user_id: 4)
UserInterest.create!(interest_id: 2, user_id: 4)
UserInterest.create!(interest_id: 3, user_id: 4)
UserInterest.create!(interest_id: 1, user_id: 5)
UserInterest.create!(interest_id: 4, user_id: 5)
UserInterest.create!(interest_id: 5, user_id: 5)
UserInterest.create!(interest_id: 2, user_id: 6)
UserInterest.create!(interest_id: 6, user_id: 6)
UserInterest.create!(interest_id: 1, user_id: 7)
UserInterest.create!(interest_id: 5, user_id: 7)
UserInterest.create!(interest_id: 6, user_id: 7)
UserInterest.create!(interest_id: 1, user_id: 8)
UserInterest.create!(interest_id: 1, user_id: 9)
UserInterest.create!(interest_id: 7, user_id: 9)
UserInterest.create!(interest_id: 1, user_id: 10)
UserInterest.create!(interest_id: 6, user_id: 10)
10.times do
Itinerary.create!(
name: Faker::Book.genre,
visitor_id: rand(1..10),
host_id: rand(1..10),
date:rand(1..10)
)
end
10.times do
Activity.create!(
description: Faker::Hacker.verb,
itinerary_id: rand(1..10),
location_id: rand(1..10)
)
end
10.times do
Location.create!(
name: Faker::Hacker.abbreviation,
address: Faker::Address.street_address,
city: Faker::Address.city
)
end
|
Thing.create(:city_id => 1, :lng => -157.907267096142, :lat=> 21.3568513726121)
Thing.create(:city_id => 2, :lng => -157.907267096142, :lat=> 21.3568513726121)
Thing.create(:city_id => 3, :lng => -157.897267163587, :lat=> 21.3568510655695)
Thing.create(:city_id => 4, :lng => -157.877267204154, :lat=> 21.366850261096)
Thing.create(:city_id => 5, :lng => -157.887267741275, :lat=> 21.3368519303584)
Thing.create(:city_id => 6, :lng => -158.077262282656, :lat=> 21.4868520584493)
Thing.create(:city_id => 7, :lng => -158.067262044674, :lat=> 21.4968483067078)
Thing.create(:city_id => 8, :lng => -158.057262177695, :lat=> 21.4968475461058)
Thing.create(:city_id => 9, :lng => -158.057262503784, :lat=> 21.4868490333856)
Thing.create(:city_id => 10, :lng => -157.846074437503, :lat=> 21.3437233457758)
Thing.create(:city_id => 11, :lng => -157.872418074894, :lat=> 21.3581978066891)
Thing.create(:city_id => 12, :lng => -157.882708867565, :lat=> 21.3440045045595)
Thing.create(:city_id => 13, :lng => -158.064235161442, :lat=> 21.4616960383057)
Thing.create(:city_id => 14, :lng => -158.050141248608, :lat=> 21.4882858279106)
Thing.create(:city_id => 15, :lng => -158.055323987012, :lat=> 21.481265031463)
Thing.create(:city_id => 16, :lng => -157.931638505683, :lat=> 21.3850469825825)
Thing.create(:city_id => 17, :lng => -157.961560907198, :lat=> 21.4010033983768)
Thing.create(:city_id => 18, :lng => -157.952267812228, :lat=> 21.4258934529549)
Thing.create(:city_id => 19, :lng => -157.999110079138, :lat=> 21.3140104659747)
Thing.create(:city_id => 20, :lng => -158.083498272374, :lat=> 21.3487978286239)
Thing.create(:city_id => 21, :lng => -158.130219529927, :lat=> 21.353018012192)
Thing.create(:city_id => 22, :lng => -158.159685505531, :lat=> 21.3943581603153)
Thing.create(:city_id => 23, :lng => -158.177016220811, :lat=> 21.4044350227556)
Thing.create(:city_id => 24, :lng => -158.177228617578, :lat=> 21.4160366339282)
Thing.create(:city_id => 25, :lng => -158.178535425568, :lat=> 21.4242178698243)
Thing.create(:city_id => 26, :lng => -158.183895972906, :lat=> 21.437319763786)
Thing.create(:city_id => 27, :lng => -158.187492456299, :lat=> 21.4432074006922)
Thing.create(:city_id => 28, :lng => -158.201358293171, :lat=> 21.4569125832838)
Thing.create(:city_id => 29, :lng => -158.199941321184, :lat=> 21.4741947505672)
Thing.create(:city_id => 30, :lng => -158.216558958283, :lat=> 21.4702429867079)
Thing.create(:city_id => 31, :lng => -158.224971980058, :lat=> 21.4799695348904)
Thing.create(:city_id => 32, :lng => -157.754496720723, :lat=> 21.4036887376188)
Thing.create(:city_id => 33, :lng => -157.883493156995, :lat=> 21.5778470495095)
Thing.create(:city_id => 34, :lng => -158.195176071216, :lat=> 21.5807020863157)
Thing.create(:city_id => 35, :lng => -158.179789578807, :lat=> 21.579593625176)
Thing.create(:city_id => 36, :lng => -158.150915022545, :lat=> 21.5735682804467)
Thing.create(:city_id => 37, :lng => -158.132524208094, :lat=> 21.5811608187928)
Thing.create(:city_id => 38, :lng => -158.123358707131, :lat=> 21.574029756352)
Thing.create(:city_id => 39, :lng => -158.103362888033, :lat=> 21.5871508375257)
Thing.create(:city_id => 40, :lng => -158.105626714414, :lat=> 21.6022027204205)
Thing.create(:city_id => 41, :lng => -158.08003653807, :lat=> 21.6224865491224)
Thing.create(:city_id => 42, :lng => -158.092223839596, :lat=> 21.6113630358796)
Thing.create(:city_id => 43, :lng => -158.069160289073, :lat=> 21.6337942533026)
Thing.create(:city_id => 44, :lng => -158.061838443688, :lat=> 21.6508192180787)
Thing.create(:city_id => 45, :lng => -158.047053320362, :lat=> 21.6454826908311)
Thing.create(:city_id => 46, :lng => -158.040028682588, :lat=> 21.6744482575418)
Thing.create(:city_id => 47, :lng => -158.007877427003, :lat=> 21.6956678521218)
Thing.create(:city_id => 48, :lng => -157.947480290329, :lat=> 21.6763269455704)
Thing.create(:city_id => 49, :lng => -157.911982190474, :lat=> 21.6131814031171)
Thing.create(:city_id => 50, :lng => -157.899322442482, :lat=> 21.6032770369995)
Thing.create(:city_id => 51, :lng => -157.87602133967, :lat=> 21.5588180569569)
Thing.create(:city_id => 52, :lng => -157.853034631037, :lat=> 21.5562291398746)
Thing.create(:city_id => 53, :lng => -157.845377672728, :lat=> 21.5444562416597)
Thing.create(:city_id => 54, :lng => -157.834804129931, :lat=> 21.5229002423584)
Thing.create(:city_id => 55, :lng => -157.845073911008, :lat=> 21.4831800830427)
Thing.create(:city_id => 56, :lng => -157.832508760107, :lat=> 21.4599374531661)
Thing.create(:city_id => 57, :lng => -157.832468203867, :lat=> 21.4499428851933)
Thing.create(:city_id => 58, :lng => -157.809794189801, :lat=> 21.4441300067049)
Thing.create(:city_id => 59, :lng => -157.807547420631, :lat=> 21.4285780545948)
Thing.create(:city_id => 60, :lng => -157.809520205436, :lat=> 21.418625345525)
Thing.create(:city_id => 61, :lng => -157.802899929016, :lat=> 21.407740103214)
Thing.create(:city_id => 62, :lng => -157.801970615567, :lat=> 21.3994461693407)
Thing.create(:city_id => 63, :lng => -157.79563293566, :lat=> 21.4040415742976)
Thing.create(:city_id => 64, :lng => -157.771251068831, :lat=> 21.4105019416548)
Thing.create(:city_id => 65, :lng => -157.751155659806, :lat=> 21.426148969717)
Thing.create(:city_id => 66, :lng => -157.749428396245, :lat=> 21.4130321078115)
Thing.create(:city_id => 67, :lng => -157.739716021599, :lat=> 21.3959945164134)
Thing.create(:city_id => 68, :lng => -157.726302137028, :lat=> 21.3965249046891)
Thing.create(:city_id => 69, :lng => -157.713388111014, :lat=> 21.3888021609634)
Thing.create(:city_id => 70, :lng => -157.763383320841, :lat=> 21.3721689919862)
Thing.create(:city_id => 71, :lng => -157.750682372517, :lat=> 21.3782403444234)
Thing.create(:city_id => 72, :lng => -157.729077553964, :lat=> 21.3680463237656)
Thing.create(:city_id => 73, :lng => -157.714297624696, :lat=> 21.3410916177968)
Thing.create(:city_id => 74, :lng => -157.696255041267, :lat=> 21.3318834454688)
Thing.create(:city_id => 75, :lng => -157.661352360952, :lat=> 21.3116671988342)
Thing.create(:city_id => 76, :lng => -157.673417572447, :lat=> 21.2887673721808)
Thing.create(:city_id => 77, :lng => -157.684557381758, :lat=> 21.2934351846836)
Thing.create(:city_id => 78, :lng => -157.683905247981, :lat=> 21.3068530227439)
Thing.create(:city_id => 79, :lng => -157.702655465801, :lat=> 21.2643959750558)
Thing.create(:city_id => 80, :lng => -157.696221122678, :lat=> 21.2746573882003)
Thing.create(:city_id => 81, :lng => -157.716087953583, :lat=> 21.2829120436342)
Thing.create(:city_id => 82, :lng => -157.709030594675, :lat=> 21.2955793579324)
Thing.create(:city_id => 83, :lng => -157.724747294307, :lat=> 21.2949466424837)
Thing.create(:city_id => 84, :lng => -157.736908836642, :lat=> 21.2815542983049)
Thing.create(:city_id => 85, :lng => -157.754491603919, :lat=> 21.2940016641832)
Thing.create(:city_id => 86, :lng => -157.755525907069, :lat=> 21.2778179820173)
Thing.create(:city_id => 87, :lng => -157.784529288031, :lat=> 21.2809625853678)
Thing.create(:city_id => 88, :lng => -157.778285794686, :lat=> 21.26972446448)
Thing.create(:city_id => 89, :lng => -157.794324441533, :lat=> 21.2684001262832)
Thing.create(:city_id => 90, :lng => -157.803937430169, :lat=> 21.2760559793157)
Thing.create(:city_id => 91, :lng => -157.811897816923, :lat=> 21.2562454051683)
Thing.create(:city_id => 92, :lng => -157.792660243298, :lat=> 21.298804122091)
Thing.create(:city_id => 93, :lng => -157.790385934476, :lat=> 21.2951540513122)
Thing.create(:city_id => 94, :lng => -157.817293155113, :lat=> 21.2749898776195)
Thing.create(:city_id => 95, :lng => -157.832061077499, :lat=> 21.2827972288229)
Thing.create(:city_id => 96, :lng => -157.832250065966, :lat=> 21.2891070439355)
Thing.create(:city_id => 97, :lng => -157.821807037601, :lat=> 21.2969393055593)
Thing.create(:city_id => 98, :lng => -157.840310998455, :lat=> 21.282899649438)
Thing.create(:city_id => 99, :lng => -157.845278207666, :lat=> 21.288454417265)
Thing.create(:city_id => 100, :lng => -157.837289674897, :lat=> 21.302463497689)
Thing.create(:city_id => 101, :lng => -157.803239731146, :lat=> 21.3164200871051)
Thing.create(:city_id => 102, :lng => -157.824298672247, :lat=> 21.3104389923515)
Thing.create(:city_id => 103, :lng => -157.843058388852, :lat=> 21.3207064703129)
Thing.create(:city_id => 104, :lng => -157.850182925574, :lat=> 21.2961268064134)
Thing.create(:city_id => 105, :lng => -157.857995092103, :lat=> 21.294793746018)
Thing.create(:city_id => 106, :lng => -157.854930640428, :lat=> 21.3040974384965)
Thing.create(:city_id => 107, :lng => -157.871731739559, :lat=> 21.3034001995518)
Thing.create(:city_id => 108, :lng => -157.868154733438, :lat=> 21.3205413560812)
Thing.create(:city_id => 109, :lng => -157.879066259275, :lat=> 21.3209797333392)
Thing.create(:city_id => 110, :lng => -157.832850448698, :lat=> 21.3424435658155)
Thing.create(:city_id => 111, :lng => -157.861660068444, :lat=> 21.3520056879379)
Thing.create(:city_id => 112, :lng => -157.868908544827, :lat=> 21.3352335118215)
Thing.create(:city_id => 113, :lng => -157.878445854892, :lat=> 21.3278193576302)
Thing.create(:city_id => 114, :lng => -157.887419871867, :lat=> 21.3283454699525)
Thing.create(:city_id => 115, :lng => -157.913538299819, :lat=> 21.3327598723568)
Thing.create(:city_id => 116, :lng => -157.928214280534, :lat=> 21.3313995326117)
Thing.create(:city_id => 117, :lng => -157.907924821034, :lat=> 21.3322848580763)
Thing.create(:city_id => 118, :lng => -157.910761356646, :lat=> 21.3526219490008)
Thing.create(:city_id => 119, :lng => -157.908559798786, :lat=> 21.395368717166)
Thing.create(:city_id => 120, :lng => -157.949216321446, :lat=> 21.3905563544334)
Thing.create(:city_id => 121, :lng => -157.969971174739, :lat=> 21.3935361119825)
Thing.create(:city_id => 122, :lng => -157.994678110428, :lat=> 21.3892392199248)
Thing.create(:city_id => 123, :lng => -158.01940330168, :lat=> 21.5110135292043)
Thing.create(:city_id => 124, :lng => -157.995987219003, :lat=> 21.5089405516982)
Thing.create(:city_id => 125, :lng => -158.012100912007, :lat=> 21.5022406638449)
Thing.create(:city_id => 126, :lng => -158.022572339712, :lat=> 21.499060703223)
Thing.create(:city_id => 127, :lng => -158.015674984231, :lat=> 21.4818414654101)
Thing.create(:city_id => 128, :lng => -158.013218262609, :lat=> 21.4617057479373)
Thing.create(:city_id => 129, :lng => -158.015327848256, :lat=> 21.4513328432601)
Thing.create(:city_id => 130, :lng => -158.013432652738, :lat=> 21.3162648162192)
Thing.create(:city_id => 131, :lng => -158.032946797876, :lat=> 21.3458430251635)
Thing.create(:city_id => 132, :lng => -158.019472970522, :lat=> 21.3800749363346)
Thing.create(:city_id => 133, :lng => -158.028588317644, :lat=> 21.3904855367527)
Thing.create(:city_id => 134, :lng => -158.142699905916, :lat=> 21.3788152965161)
Thing.create(:city_id => 135, :lng => -158.206740360549, :lat=> 21.4599555141009)
Thing.create(:city_id => 136, :lng => -158.099627362502, :lat=> 21.3080901120075)
Thing.create(:city_id => 137, :lng => -158.051404769479, :lat=> 21.6635309510769)
Thing.create(:city_id => 138, :lng => -157.994162049857, :lat=> 21.4089692990589)
Thing.create(:city_id => 139, :lng => -157.890537218142, :lat=> 21.349030830504)
Thing.create(:city_id => 140, :lng => -157.891116835418, :lat=> 21.3699204994857)
Thing.create(:city_id => 141, :lng => -157.928864910531, :lat=> 21.3758165814181)
Thing.create(:city_id => 142, :lng => -157.999354381369, :lat=> 21.4635015680454)
Thing.create(:city_id => 143, :lng => -157.989897067178, :lat=> 21.4712666112177)
Thing.create(:city_id => 144, :lng => -157.996696263749, :lat=> 21.4796946052859)
Thing.create(:city_id => 145, :lng => -158.006160624325, :lat=> 21.4705833778126)
Thing.create(:city_id => 146, :lng => -157.98357796533, :lat=> 21.4789203720479)
Thing.create(:city_id => 147, :lng => -158.018919667596, :lat=> 21.4325009208139)
Thing.create(:city_id => 148, :lng => -157.931716501908, :lat=> 21.655675862578)
Thing.create(:city_id => 149, :lng => -157.924045999699, :lat=> 21.6492730392567)
Thing.create(:city_id => 150, :lng => -157.920224039169, :lat=> 21.6371585365542)
Thing.create(:city_id => 151, :lng => -158.214866265488, :lat=> 21.5787935095528)
update sirens
Thing.create(:city_id => 1, :lng => -157.74898782223062, :lat=> 21.376607020832314)
Thing.create(:city_id => 2, :lng => -157.83260982529868, :lat=> 21.44316202186285)
Thing.create(:city_id => 3, :lng => -157.92847782520883, :lat=> 21.375356017001515)
Thing.create(:city_id => 4, :lng => -157.93160082521447, :lat=> 21.384862017273573)
Thing.create(:city_id => 5, :lng => -157.75111682330962, :lat=> 21.4261480229591)
Thing.create(:city_id => 6, :lng => -157.85067582165888, :lat=> 21.290883014655773)
Thing.create(:city_id => 7, :lng => -157.8321548213673, :lat=> 21.28912701501561)
Thing.create(:city_id => 8, :lng => -157.84043682093125, :lat=> 21.2828820146399)
Thing.create(:city_id => 9, :lng => -157.8461798226548, :lat=> 21.34414801740725)
Thing.create(:city_id => 10, :lng => -157.9101168243043, :lat=> 21.35915801667744)
Thing.create(:city_id => 11, :lng => -157.91368982433966, :lat=> 21.365030016584047)
Thing.create(:city_id => 12, :lng => -158.11012782689667, :lat=> 21.3231000102485)
Thing.create(:city_id => 13, :lng => -157.71133482131077, :lat=> 21.376248021485782)
Thing.create(:city_id => 14, :lng => -157.71622082087887, :lat=> 21.358244020940564)
Thing.create(:city_id => 15, :lng => -157.843143822069, :lat=> 21.32076001619144)
Thing.create(:city_id => 16, :lng => -158.22406683573888, :lat=> 21.577878019617877)
Thing.create(:city_id => 17, :lng => -157.90418582495636, :lat=> 21.388264018119706)
Thing.create(:city_id => 18, :lng => -158.10009782648797, :lat=> 21.308143009715533)
Thing.create(:city_id => 19, :lng => -157.79582882326815, :lat=> 21.40411802098645)
Thing.create(:city_id => 20, :lng => -157.75538982259908, :lat=> 21.40366502201616)
Thing.create(:city_id => 21, :lng => -157.994118826769, :lat=> 21.409028016575462)
Thing.create(:city_id => 22, :lng => -157.81234081986355, :lat=> 21.256238013877024)
Thing.create(:city_id => 23, :lng => -158.21779483543156, :lat=> 21.577765019680786)
Thing.create(:city_id => 24, :lng => -157.79435481970012, :lat=> 21.268150015055905)
Thing.create(:city_id => 25, :lng => -157.82160482136467, :lat=> 21.296877015457156)
Thing.create(:city_id => 26, :lng => -158.01948182682628, :lat=> 21.38003601492668)
Thing.create(:city_id => 27, :lng => -158.01373082505435, :lat=> 21.31599401218161)
Thing.create(:city_id => 28, :lng => -158.03355982594744, :lat=> 21.34514501322552)
Thing.create(:city_id => 29, :lng => -158.02361582970087, :lat=> 21.49873602006822)
Thing.create(:city_id => 30, :lng => -157.8322488210979, :lat=> 21.28242101499991)
Thing.create(:city_id => 31, :lng => -157.79617581994086, :lat=> 21.259485014564294)
Thing.create(:city_id => 32, :lng => -157.88092882305372, :lat=> 21.339637016274896)
Thing.create(:city_id => 33, :lng => -157.87718582357948, :lat=> 21.35031401673813)
Thing.create(:city_id => 34, :lng => -157.7087988189692, :lat=> 21.295935017970496)
Thing.create(:city_id => 35, :lng => -158.1038018339511, :lat=> 21.600452023316592)
Thing.create(:city_id => 36, :lng => -158.10391883350616, :lat=> 21.58411702262625)
Thing.create(:city_id => 37, :lng => -157.6964498181775, :lat=> 21.274650017721303)
Thing.create(:city_id => 38, :lng => -157.91192483045373, :lat=> 21.613120028166456)
Thing.create(:city_id => 39, :lng => -157.809880824759, :lat=> 21.443964022766856)
Thing.create(:city_id => 40, :lng => -157.80985682416656, :lat=> 21.418354021260043)
Thing.create(:city_id => 41, :lng => -158.0187138308728, :lat=> 21.535475022203023)
Thing.create(:city_id => 42, :lng => -157.95290482465077, :lat=> 21.34174101470715)
Thing.create(:city_id => 43, :lng => -157.95586182403216, :lat=> 21.320893013539422)
Thing.create(:city_id => 44, :lng => -157.94165282440127, :lat=> 21.33671701481102)
Thing.create(:city_id => 45, :lng => -157.93241882383276, :lat=> 21.334976014734213)
Thing.create(:city_id => 46, :lng => -157.9608628245134, :lat=> 21.33610801416671)
Thing.create(:city_id => 47, :lng => -157.9616758240671, :lat=> 21.3262770136546)
Thing.create(:city_id => 48, :lng => -157.9356038238304, :lat=> 21.318621014141154)
Thing.create(:city_id => 49, :lng => -158.10570882742553, :lat=> 21.341345011002286)
Thing.create(:city_id => 50, :lng => -157.86818582257328, :lat=> 21.320691015531366)
Thing.create(:city_id => 51, :lng => -157.90697882348084, :lat=> 21.33183801541621)
Thing.create(:city_id => 52, :lng => -157.9135758236346, :lat=> 21.333161015065652)
Thing.create(:city_id => 53, :lng => -157.8549128220964, :lat=> 21.30432101504991)
Thing.create(:city_id => 54, :lng => -158.02778682653891, :lat=> 21.36314001383917)
Thing.create(:city_id => 55, :lng => -157.97687982427408, :lat=> 21.32304301347066)
Thing.create(:city_id => 56, :lng => -157.84150782582262, :lat=> 21.45931802271594)
Thing.create(:city_id => 57, :lng => -157.87634982862264, :lat=> 21.558734026080284)
Thing.create(:city_id => 58, :lng => -158.13000582800763, :lat=> 21.352261011126284)
Thing.create(:city_id => 59, :lng => -157.94790283263714, :lat=> 21.676660030011078)
Thing.create(:city_id => 60, :lng => -157.72633082215856, :lat=> 21.396294022466314)
Thing.create(:city_id => 61, :lng => -157.74026282215934, :lat=> 21.39574502173133)
Thing.create(:city_id => 62, :lng => -157.7300948215248, :lat=> 21.370650021011514)
Thing.create(:city_id => 63, :lng => -157.74954182313948, :lat=> 21.41290902240102)
Thing.create(:city_id => 64, :lng => -157.845896827792, :lat=> 21.544900026440732)
Thing.create(:city_id => 65, :lng => -157.87834582288363, :lat=> 21.32783901583794)
Thing.create(:city_id => 66, :lng => -157.86118982312033, :lat=> 21.351972017133857)
Thing.create(:city_id => 67, :lng => -157.87227382314913, :lat=> 21.334155016363432)
Thing.create(:city_id => 68, :lng => -157.68445981870823, :lat=> 21.293361018510986)
Thing.create(:city_id => 69, :lng => -157.75683082394616, :lat=> 21.447908023669775)
Thing.create(:city_id => 70, :lng => -157.81725482032934, :lat=> 21.27515801483637)
Thing.create(:city_id => 71, :lng => -157.80369282025674, :lat=> 21.27657801503768)
Thing.create(:city_id => 72, :lng => -158.0647048268991, :lat=> 21.349226012593128)
Thing.create(:city_id => 73, :lng => -157.80319182388092, :lat=> 21.407617021281787)
Thing.create(:city_id => 74, :lng => -157.75568381937035, :lat=> 21.278311016489358)
Thing.create(:city_id => 75, :lng => -158.0739128341717, :lat=> 21.62733602534101)
Thing.create(:city_id => 76, :lng => -158.08982483413348, :lat=> 21.613963024208562)
Thing.create(:city_id => 77, :lng => -158.0078448344824, :lat=> 21.695416029877496)
Thing.create(:city_id => 78, :lng => -157.80271582359893, :lat=> 21.399295020525663)
Thing.create(:city_id => 79, :lng => -157.85795282154297, :lat=> 21.294624014740002)
Thing.create(:city_id => 80, :lng => -157.80739882451016, :lat=> 21.427984021889692)
Thing.create(:city_id => 81, :lng => -158.01268682889688, :lat=> 21.460383018619094)
Thing.create(:city_id => 82, :lng => -157.85055582135453, :lat=> 21.297385015068834)
Thing.create(:city_id => 83, :lng => -157.83472282726564, :lat=> 21.526015025442213)
Thing.create(:city_id => 84, :lng => -157.72445281964025, :lat=> 21.295102017846556)
Thing.create(:city_id => 85, :lng => -158.06447182949844, :lat=> 21.461427017522674)
Thing.create(:city_id => 86, :lng => -158.0519738299445, :lat=> 21.475950018505653)
Thing.create(:city_id => 87, :lng => -157.83214482529525, :lat=> 21.45939702289368)
Thing.create(:city_id => 88, :lng => -157.7135378219587, :lat=> 21.388976022461602)
Thing.create(:city_id => 89, :lng => -158.01077982968604, :lat=> 21.498587020417453)
Thing.create(:city_id => 90, :lng => -158.17845583067609, :lat=> 21.424877013505082)
Thing.create(:city_id => 91, :lng => -158.17699783010798, :lat=> 21.404381012424786)
Thing.create(:city_id => 92, :lng => -158.196644832502, :lat=> 21.4752320152021)
Thing.create(:city_id => 93, :lng => -158.0835458272797, :lat=> 21.348993012026142)
Thing.create(:city_id => 94, :lng => -157.83750682147138, :lat=> 21.302775015747844)
Thing.create(:city_id => 95, :lng => -158.20611183223983, :lat=> 21.45979301453494)
Thing.create(:city_id => 96, :lng => -157.79011682079684, :lat=> 21.295470016522497)
Thing.create(:city_id => 97, :lng => -157.71603781878292, :lat=> 21.283257017424443)
Thing.create(:city_id => 98, :lng => -157.76356982235515, :lat=> 21.37254202059158)
Thing.create(:city_id => 99, :lng => -158.01522782827166, :lat=> 21.451293018202275)
Thing.create(:city_id => 100, :lng => -157.98983882843382, :lat=> 21.471167019577646)
Thing.create(:city_id => 101, :lng => -157.99885982831643, :lat=> 21.463277019229132)
Thing.create(:city_id => 102, :lng => -158.00645882895915, :lat=> 21.47088901933723)
Thing.create(:city_id => 103, :lng => -157.99672182900528, :lat=> 21.479559020205272)
Thing.create(:city_id => 104, :lng => -158.01887182820258, :lat=> 21.43231801727201)
Thing.create(:city_id => 105, :lng => -158.0143588290843, :lat=> 21.48198901944057)
Thing.create(:city_id => 106, :lng => -157.8902628236568, :lat=> 21.349338016466824)
Thing.create(:city_id => 107, :lng => -157.88046282397227, :lat=> 21.37424101763897)
Thing.create(:city_id => 108, :lng => -157.77135582325556, :lat=> 21.410547021858594)
Thing.create(:city_id => 109, :lng => -158.19669383494892, :lat=> 21.58087402044294)
Thing.create(:city_id => 110, :lng => -158.1512158341522, :lat=> 21.57340702075577)
Thing.create(:city_id => 111, :lng => -158.18046183454405, :lat=> 21.579834020437964)
Thing.create(:city_id => 112, :lng => -158.1426468289115, :lat=> 21.378572011948677)
Thing.create(:city_id => 113, :lng => -158.15981782945417, :lat=> 21.394275012640936)
Thing.create(:city_id => 114, :lng => -157.9094558251303, :lat=> 21.39477701826225)
Thing.create(:city_id => 115, :lng => -158.07360882546814, :lat=> 21.299189009743564)
Thing.create(:city_id => 116, :lng => -157.8327688223107, :lat=> 21.342877017412988)
Thing.create(:city_id => 117, :lng => -157.9520558266261, :lat=> 21.42574301853092)
Thing.create(:city_id => 118, :lng => -157.79689882075843, :lat=> 21.299517016144886)
Thing.create(:city_id => 119, :lng => -157.9694428262645, :lat=> 21.393374016645687)
Thing.create(:city_id => 120, :lng => -157.96301582625452, :lat=> 21.402912017268495)
Thing.create(:city_id => 121, :lng => -157.95582882669225, :lat=> 21.415251017883918)
Thing.create(:city_id => 122, :lng => -157.8788028225911, :lat=> 21.320769015416566)
Thing.create(:city_id => 123, :lng => -157.92233583137326, :lat=> 21.636515028602346)
Thing.create(:city_id => 124, :lng => -157.99820782452016, :lat=> 21.314119012371098)
Thing.create(:city_id => 125, :lng => -157.87585142246277, :lat=> 21.56928305686768)
Thing.create(:city_id => 126, :lng => -157.88335982928228, :lat=> 21.577647026730236)
Thing.create(:city_id => 127, :lng => -158.04663283393126, :lat=> 21.64552502662107)
Thing.create(:city_id => 128, :lng => -157.8246358213948, :lat=> 21.31030101608435)
Thing.create(:city_id => 129, :lng => -158.1330238339621, :lat=> 21.581169021905904)
Thing.create(:city_id => 130, :lng => -157.89957142357613, :lat=> 21.603323058055302)
Thing.create(:city_id => 131, :lng => -157.91047582414865, :lat=> 21.352961016285786)
Thing.create(:city_id => 132, :lng => -157.88722682321992, :lat=> 21.328377015388227)
Thing.create(:city_id => 133, :lng => -157.87128082224936, :lat=> 21.30311401501926)
Thing.create(:city_id => 134, :lng => -157.67354781829516, :lat=> 21.28831601863615)
Thing.create(:city_id => 135, :lng => -158.05870283034758, :lat=> 21.499077019254226)
Thing.create(:city_id => 136, :lng => -158.04929483019527, :lat=> 21.48773001897003)
Thing.create(:city_id => 137, :lng => -158.06195983032302, :lat=> 21.489631018941324)
Thing.create(:city_id => 138, :lng => -158.080082830953, :lat=> 21.491899018696458)
Thing.create(:city_id => 139, :lng => -158.07019983092889, :lat=> 21.501769019235088)
Thing.create(:city_id => 140, :lng => -157.66153357545718, :lat=> 21.311734787240624)
Thing.create(:city_id => 141, :lng => -157.88982282360212, :lat=> 21.336857015856182)
Thing.create(:city_id => 142, :lng => -158.0631398340273, :lat=> 21.646076026298616)
Thing.create(:city_id => 143, :lng => -158.04004283456464, :lat=> 21.674241028026643)
Thing.create(:city_id => 144, :lng => -158.05160383434702, :lat=> 21.66341002720093)
Thing.create(:city_id => 145, :lng => -157.85265682835822, :lat=> 21.55599902655402)
Thing.create(:city_id => 146, :lng => -157.89665882389028, :lat=> 21.35976001659018)
Thing.create(:city_id => 147, :lng => -157.88473082409124, :lat=> 21.3656500174639)
Thing.create(:city_id => 148, :lng => -157.98661583388738, :lat=> 21.697613030142982)
Thing.create(:city_id => 149, :lng => -158.02784082743034, :lat=> 21.389938014933648)
Thing.create(:city_id => 150, :lng => -157.99563282983857, :lat=> 21.509711021468043)
Thing.create(:city_id => 151, :lng => -157.77757281971574, :lat=> 21.27049301559295)
Thing.create(:city_id => 152, :lng => -158.12391783381614, :lat=> 21.576042021558642)
Thing.create(:city_id => 153, :lng => -158.19220083164953, :lat=> 21.450976014465105)
Thing.create(:city_id => 154, :lng => -158.2011158318622, :lat=> 21.45685601444641)
Thing.create(:city_id => 155, :lng => -158.18469183120425, :lat=> 21.437443013927464)
Thing.create(:city_id => 156, :lng => -157.84521582644632, :lat=> 21.483165023383712)
Thing.create(:city_id => 157, :lng => -157.75456981965175, :lat=> 21.293383017135724)
Thing.create(:city_id => 158, :lng => -157.94906082582506, :lat=> 21.390490017165284)
Thing.create(:city_id => 159, :lng => -157.73942982074732, :lat=> 21.34259401980951)
Thing.create(:city_id => 160, :lng => -157.69488782005618, :lat=> 21.331240019963758)
Thing.create(:city_id => 161, :lng => -157.7149768202957, :lat=> 21.342226020236374)
Thing.create(:city_id => 162, :lng => -158.06830683422734, :lat=> 21.633542025295704)
Thing.create(:city_id => 163, :lng => -157.9947748264404, :lat=> 21.389103015915467)
Thing.create(:city_id => 164, :lng => -157.99972682741034, :lat=> 21.41751801731743)
Thing.create(:city_id => 165, :lng => -158.01945083005862, :lat=> 21.510946021049175)
Thing.create(:city_id => 166, :lng => -157.78429982008112, :lat=> 21.281191015653494)
Thing.create(:city_id => 167, :lng => -157.80305482135455, :lat=> 21.316619017048804)
Thing.create(:city_id => 168, :lng => -157.70420151822051, :lat=> 21.26312934688229)
Thing.create(:city_id => 169, :lng => -157.68383481898852, :lat=> 21.306896019196543)
Thing.create(:city_id => 170, :lng => -158.03283482553962, :lat=> 21.329912682456115)
Thing.create(:city_id => 171, :lng => -158.17710153050268, :lat=> 21.416179343209556)
Thing.create(:city_id => 172, :lng => -158.07565152660166, :lat=> 21.333712681485853)
Thing.create(:city_id => 173, :lng => -158.05665152554553, :lat=> 21.305562680724595)
Thing.create(:city_id => 174, :lng => -157.92276813168795, :lat=> 21.64734602947919)
Thing.create(:city_id => 175, :lng => -158.22261813326296, :lat=> 21.47887601489222)
Thing.create(:city_id => 176, :lng => -158.2162848324896, :lat=> 21.470246014598548)
Thing.create(:city_id => 177, :lng => -158.01736615525047, :lat=> 21.33226754604477)
|
require 'open-uri'
User.delete_all
Group.delete_all
Challenge.delete_all
Comment.delete_all
Participation.delete_all
Membership.delete_all
# Users with photos
alana = User.create!(username: 'alana', password: 'password', email: 'alana@mail.com')
alana.image = open('https://github.com/tomorrow-lauren/lauren-doodle/blob/master/jpg/alana.jpg?raw=true')
alana.save
marshall = User.create!(username: 'marshall', password: 'password', email: 'marshall@mail.com')
marshall.image = open('https://github.com/tomorrow-lauren/lauren-doodle/blob/master/jpg/marshall.jpg?raw=true')
marshall.save
mike = User.create!(username: 'mike', password: 'password', email: 'mike@mail.com')
mike.image = open('https://github.com/tomorrow-lauren/lauren-doodle/blob/master/jpg/mike.jpg?raw=true')
mike.save
lauren = User.create!(username: 'lauren', password: 'password', email: 'lauren@mail.com')
lauren.image = open('https://github.com/tomorrow-lauren/lauren-doodle/blob/master/jpg/lauren.jpg')
lauren.save
# Users without photos
mom = User.create!(username: 'mom', password: 'password', email: 'mom@mail.com')
dad = User.create!(username: 'dad', password: 'password', email: 'dad@mail.com')
jim = User.create!(username: 'jim', password: 'password', email: 'jim@mail.com')
dan = User.create!(username: 'dan', password: 'password', email: 'dan@mail.com')
sabri = User.create!(username: 'sabri', password: 'password', email: 'sabri@mail.com')
tiffany = User.create!(username: 'tiffany', password: 'password', email: 'tiffany@mail.com')
eddie = User.create!(username: 'eddie', password: 'password', email: 'eddie@mail.com')
james = User.create!(username: 'james', password: 'password', email: 'james@mail.com')
meagan = User.create!(username: 'meagan', password: 'password', email: 'meagan@mail.com')
tyler = User.create!(username: 'tyler', password: 'password', email: 'tyler@mail.com')
ray = User.create!(username: 'ray', password: 'password', email: 'ray@mail.com')
catie = User.create!(username: 'catie', password: 'password', email: 'catie@mail.com')
group = marshall.created_groups.create(name: 'Team Grouvie')
group2 = mike.created_groups.create(name: 'Squirrels')
group3 = alana.created_groups.create(name: 'Speed Racers')
group4 = marshall.created_groups.create(name: 'HS Friends')
group5 = lauren.created_groups.create(name: 'La Familia')
group6 = alana.created_groups.create(name: 'College')
group.members << [alana, marshall, mike, lauren]
group2.members << [alana, marshall, lauren, mike, dan, sabri, tiffany, catie, eddie, jim, james, tyler, ray, meagan]
group3.members << [marshall, alana, lauren, sabri, tiffany]
group4.members << [alana, marshall, mike, lauren]
group5.members << [alana, marshall, mike, mom, dad]
group6.members << [mike, alana, lauren, dan, tiffany]
challenge1 = group.challenges.create!(name: 'Learn React Native', description: 'Dive into the docs and learn all there is to know!', start_date: Date.new(2016, 3, 10), end_date: Date.new(2016, 03, 20))
challenge2 = group.challenges.create!(name: 'Build an App', description: 'Create an app using Rails and React Native to help its users reach goals / take selfies', start_date: Date.new(2016, 3, 10), end_date: Date.new(2016, 03, 20))
challenge3 = group.challenges.create!(name: 'Perfect the fast-to-slow clap', description: 'And then add to resume skills.', start_date: Date.new(2016, 3, 10), end_date: Date.new(2016, 03, 20))
challenge4 = group2.challenges.create!(name: 'Vacuum the ROR', description: 'Vacuum the entire room and the chairs', start_date: Date.new(2016, 3, 15), end_date: Date.new(2016, 03, 25))
challenge5 = group.challenges.create!(name: 'Demo App!', description: 'Show your creation to the masses.', start_date: Date.new(2016, 3, 10), end_date: Date.new(2016, 03, 20))
challenge6 = group2.challenges.create!(name: 'Graduate', description: 'But stay in touch.', start_date: Date.new(2016, 1, 18), end_date: Date.new(2016, 03, 25))
challenge7 = group2.challenges.create!(name: 'Do a donut crawl', description: 'Heart donuts', start_date: Date.new(2016, 3, 18), end_date: Date.new(2016, 03, 20))
challenge8 = group2.challenges.create!(name: 'Perfect the fast-to-slow clap', description: 'And then add to resume skills.', start_date: Date.new(2016, 3, 10), end_date: Date.new(2017, 03, 10))
challenge9 = group3.challenges.create!(name: 'Run 3 times this week', description: 'Take a run of 20+ minutes 3 times this week', start_date: Date.new(2016, 3, 16), end_date: Date.new(2016, 03, 23))
challenge10 = group3.challenges.create!(name: 'Swim 100 laps in the pool', description: 'Get fit', start_date: Date.new(2016, 3, 16), end_date: Date.new(2016, 03, 23))
challenge11 = group3.challenges.create!(name: 'Get 100,000 steps on pedometer this week', description: 'Walk a lot', start_date: Date.new(2016, 3, 15), end_date: Date.new(2016, 03, 22))
challenge12 = group4.challenges.create!(name: 'Book tickets to France', description: 'Prices will go up', start_date: Date.new(2016, 3, 01), end_date: Date.new(2016, 05, 01))
challenge13 = group4.challenges.create!(name: 'Reserve Pat Green tickets', description: 'Theyre going to sell out', start_date: Date.new(2016, 3, 10), end_date: Date.new(2016, 03, 31))
challenge14 = group4.challenges.create!(name: 'Read the 2nd chapter of that book', description: 'And then add to resume skills.', start_date: Date.new(2016, 3, 10), end_date: Date.new(2016, 03, 20))
challenge15 = group4.challenges.create!(name: 'Fill out common app', description: 'Its almost due', start_date: Date.new(2016, 3, 10), end_date: Date.new(2016, 04, 01))
challenge16 = group5.challenges.create!(name: 'Get your flu shot', description: 'It actually matters.', start_date: Date.new(2016, 3, 13), end_date: Date.new(2016, 03, 20))
challenge17 = group5.challenges.create!(name: 'Call Grandma this week', description: 'She would really appreciate it', start_date: Date.new(2016, 3, 15), end_date: Date.new(2016, 03, 21))
challenge18 = group5.challenges.create!(name: 'Share a funny picture this week!', description: 'Stay in touch yall', start_date: Date.new(2016, 3, 14), end_date: Date.new(2016, 03, 21))
challenge19 = group5.challenges.create!(name: 'Clean up the bathroom', description: 'It is gross.', start_date: Date.new(2016, 3, 17), end_date: Date.new(2016, 03, 19))
challenge20 = group6.challenges.create!(name: 'Vote in your primary', description: 'It actually matters.', start_date: Date.new(2016, 2, 10), end_date: Date.new(2016, 05, 18))
challenge21 = group6.challenges.create!(name: 'Sign up for Soccer', description: 'Just do it', start_date: Date.new(2016, 3, 10), end_date: Date.new(2016, 03, 31))
challenge1.participants << [alana, marshall, mike, lauren]
challenge2.participants << [lauren, marshall, mike, alana]
challenge3.participants << [lauren, alana, mike]
challenge4.participants << [alana, mike]
challenge5.participants << [alana, mike, marshall, lauren]
challenge6.participants << [lauren, dan, sabri, tiffany, mike]
challenge7.participants << [marshall, alana, lauren, sabri, tiffany]
challenge8.participants << [alana, marshall, lauren, tiffany]
challenge9.participants << [alana, marshall, lauren, sabri]
challenge10.participants << [lauren, alana, marshall, tiffany]
challenge11.participants << [alana, tiffany, sabri]
challenge12.participants << [alana, mike]
challenge13.participants << [marshall, lauren]
challenge14.participants << [marshall, alana, lauren]
challenge15.participants << [alana, marshall, mike, lauren]
challenge16.participants << [alana, marshall, mom, dad]
challenge17.participants << [mom, dad, marshall, mike]
challenge18.participants << [alana, mike, mom]
challenge19.participants << [dad, mike, marshall]
challenge20.participants << [mike, alana, lauren]
challenge21.participants << [dan, alana, lauren]
alana.comments.create!(group: group, content: 'these docs are so confusing!')
marshall.comments.create!(group: group, content: "Is it friday yet?")
lauren.comments.create!(group: group, content: "Errors amiright?")
mike.comments.create!(group: group2, content: "Guys the ROR really needs to be vacuumed")
tiffany.comments.create!(group: group2, content: "Amazing!")
alana.comments.create!(group: group3, content: "Already ran twice. Come on guys")
marshall.comments.create!(group: group3, content: "Swimming tomorrow")
alana.comments.create!(group: group4, content: "Seriously the tickets will sell out just buy them")
marshall.comments.create!(group: group4, content: "Can you just order 2 for me?")
lauren.comments.create!(group: group4, content: "Stop being so lazy marshall")
mom.comments.create!(group: group5, content: "Send pictures please!")
mom.comments.create!(group: group5, content: "I don't want to spoil this movie but you have to see it. It was so good. Whatever you think will happen doesn't actually happen. Don't worry that won't spoil it. But it's really pretty sad because everyone dies at the end. Oh shoot! Sorry!")
marshall.comments.create!(group: group5, content: "Mom!")
mike.comments.create!(group: group6, content: "Sup")
alana.comments.create!(group: group6, content: "Yo")
clip_art = ['http://worldartsme.com/images/fall-squirrel-clipart-1.jpg', 'http://clipartbold.com/wp-content/uploads/2016/02/Cute-squirrel-cartoon-clipart-image-5.png', 'http://clipartion.com/wp-content/uploads/2015/11/running-squirrel-clipart.png', 'http://images.clipartpanda.com/squirrel-clipart-cartoon_squirrel_with_an_acorn_nut_0071-0908-3116-2318_SMU.jpg', 'http://comps.canstockphoto.com/can-stock-photo_csp13648213.jpg', 'http://worldartsme.com/images/fall-squirrel-clipart-1.jpg', 'http://clipartbold.com/wp-content/uploads/2016/02/Cute-squirrel-cartoon-clipart-image-5.png', 'http://clipartion.com/wp-content/uploads/2015/11/running-squirrel-clipart.png', 'http://images.clipartpanda.com/squirrel-clipart-cartoon_squirrel_with_an_acorn_nut_0071-0908-3116-2318_SMU.jpg', 'http://comps.canstockphoto.com/can-stock-photo_csp13648213.jpg']
completed_challenges = Participation.all.sample(10)
completed_challenges.each_with_index do |participation, index|
participation.completed = true
participation.image = open(clip_art[index])
participation.save
end
fix seed again
require 'open-uri'
User.delete_all
Group.delete_all
Challenge.delete_all
Comment.delete_all
Participation.delete_all
Membership.delete_all
# Users with photos
alana = User.create!(username: 'alana', password: 'password', email: 'alana@mail.com')
alana.image = open('https://github.com/tomorrow-lauren/lauren-doodle/blob/master/jpg/alana.jpg?raw=true')
alana.save
marshall = User.create!(username: 'marshall', password: 'password', email: 'marshall@mail.com')
marshall.image = open('https://github.com/tomorrow-lauren/lauren-doodle/blob/master/jpg/marshall.jpg?raw=true')
marshall.save
mike = User.create!(username: 'mike', password: 'password', email: 'mike@mail.com')
mike.image = open('https://github.com/tomorrow-lauren/lauren-doodle/blob/master/jpg/mike.jpg?raw=true')
mike.save
lauren = User.create!(username: 'lauren', password: 'password', email: 'lauren@mail.com')
lauren.image = open('https://github.com/tomorrow-lauren/lauren-doodle/blob/master/jpg/lauren.jpg?raw=true')
lauren.save
# Users without photos
mom = User.create!(username: 'mom', password: 'password', email: 'mom@mail.com')
dad = User.create!(username: 'dad', password: 'password', email: 'dad@mail.com')
jim = User.create!(username: 'jim', password: 'password', email: 'jim@mail.com')
dan = User.create!(username: 'dan', password: 'password', email: 'dan@mail.com')
sabri = User.create!(username: 'sabri', password: 'password', email: 'sabri@mail.com')
tiffany = User.create!(username: 'tiffany', password: 'password', email: 'tiffany@mail.com')
eddie = User.create!(username: 'eddie', password: 'password', email: 'eddie@mail.com')
james = User.create!(username: 'james', password: 'password', email: 'james@mail.com')
meagan = User.create!(username: 'meagan', password: 'password', email: 'meagan@mail.com')
tyler = User.create!(username: 'tyler', password: 'password', email: 'tyler@mail.com')
ray = User.create!(username: 'ray', password: 'password', email: 'ray@mail.com')
catie = User.create!(username: 'catie', password: 'password', email: 'catie@mail.com')
group = marshall.created_groups.create(name: 'Team Grouvie')
group2 = mike.created_groups.create(name: 'Squirrels')
group3 = alana.created_groups.create(name: 'Speed Racers')
group4 = marshall.created_groups.create(name: 'HS Friends')
group5 = lauren.created_groups.create(name: 'La Familia')
group6 = alana.created_groups.create(name: 'College')
group.members << [alana, marshall, mike, lauren]
group2.members << [alana, marshall, lauren, mike, dan, sabri, tiffany, catie, eddie, jim, james, tyler, ray, meagan]
group3.members << [marshall, alana, lauren, sabri, tiffany]
group4.members << [alana, marshall, mike, lauren]
group5.members << [alana, marshall, mike, mom, dad]
group6.members << [mike, alana, lauren, dan, tiffany]
challenge1 = group.challenges.create!(name: 'Learn React Native', description: 'Dive into the docs and learn all there is to know!', start_date: Date.new(2016, 3, 10), end_date: Date.new(2016, 03, 20))
challenge2 = group.challenges.create!(name: 'Build an App', description: 'Create an app using Rails and React Native to help its users reach goals / take selfies', start_date: Date.new(2016, 3, 10), end_date: Date.new(2016, 03, 20))
challenge3 = group.challenges.create!(name: 'Perfect the fast-to-slow clap', description: 'And then add to resume skills.', start_date: Date.new(2016, 3, 10), end_date: Date.new(2016, 03, 20))
challenge4 = group.challenges.create!(name: 'Vacuum the ROR', description: 'Vacuum the entire room and the chairs', start_date: Date.new(2016, 3, 15), end_date: Date.new(2016, 03, 25))
challenge5 = group.challenges.create!(name: 'Demo App!', description: 'Show your creation to the masses.', start_date: Date.new(2016, 3, 10), end_date: Date.new(2016, 03, 20))
challenge6 = group2.challenges.create!(name: 'Graduate', description: 'But stay in touch.', start_date: Date.new(2016, 1, 18), end_date: Date.new(2016, 03, 25))
challenge7 = group2.challenges.create!(name: 'Do a donut crawl', description: 'Heart donuts', start_date: Date.new(2016, 3, 18), end_date: Date.new(2016, 03, 20))
challenge8 = group2.challenges.create!(name: 'Perfect the fast-to-slow clap', description: 'And then add to resume skills.', start_date: Date.new(2016, 3, 10), end_date: Date.new(2017, 03, 10))
challenge9 = group3.challenges.create!(name: 'Run 3 times this week', description: 'Take a run of 20+ minutes 3 times this week', start_date: Date.new(2016, 3, 16), end_date: Date.new(2016, 03, 23))
challenge10 = group3.challenges.create!(name: 'Swim 100 laps in the pool', description: 'Get fit', start_date: Date.new(2016, 3, 16), end_date: Date.new(2016, 03, 23))
challenge11 = group3.challenges.create!(name: 'Get 100,000 steps on pedometer this week', description: 'Walk a lot', start_date: Date.new(2016, 3, 15), end_date: Date.new(2016, 03, 22))
challenge12 = group4.challenges.create!(name: 'Book tickets to France', description: 'Prices will go up', start_date: Date.new(2016, 3, 01), end_date: Date.new(2016, 05, 01))
challenge13 = group4.challenges.create!(name: 'Reserve Pat Green tickets', description: 'Theyre going to sell out', start_date: Date.new(2016, 3, 10), end_date: Date.new(2016, 03, 31))
challenge14 = group4.challenges.create!(name: 'Read the 2nd chapter of that book', description: 'And then add to resume skills.', start_date: Date.new(2016, 3, 10), end_date: Date.new(2016, 03, 20))
challenge15 = group4.challenges.create!(name: 'Fill out common app', description: 'Its almost due', start_date: Date.new(2016, 3, 10), end_date: Date.new(2016, 04, 01))
challenge16 = group5.challenges.create!(name: 'Get your flu shot', description: 'It actually matters.', start_date: Date.new(2016, 3, 13), end_date: Date.new(2016, 03, 20))
challenge17 = group5.challenges.create!(name: 'Call Grandma this week', description: 'She would really appreciate it', start_date: Date.new(2016, 3, 15), end_date: Date.new(2016, 03, 21))
challenge18 = group5.challenges.create!(name: 'Share a funny picture this week!', description: 'Stay in touch yall', start_date: Date.new(2016, 3, 14), end_date: Date.new(2016, 03, 21))
challenge19 = group5.challenges.create!(name: 'Clean up the bathroom', description: 'It is gross.', start_date: Date.new(2016, 3, 17), end_date: Date.new(2016, 03, 19))
challenge20 = group6.challenges.create!(name: 'Vote in your primary', description: 'It actually matters.', start_date: Date.new(2016, 2, 10), end_date: Date.new(2016, 05, 18))
challenge21 = group6.challenges.create!(name: 'Sign up for Soccer', description: 'Just do it', start_date: Date.new(2016, 3, 10), end_date: Date.new(2016, 03, 31))
challenge1.participants << [alana, marshall, mike, lauren]
challenge2.participants << [lauren, marshall, mike, alana]
challenge3.participants << [lauren, alana, mike]
challenge4.participants << [alana, mike]
challenge5.participants << [alana, mike, marshall, lauren]
challenge6.participants << [lauren, dan, sabri, tiffany, mike]
challenge7.participants << [marshall, alana, lauren, sabri, tiffany]
challenge8.participants << [alana, marshall, lauren, tiffany]
challenge9.participants << [alana, marshall, lauren, sabri]
challenge10.participants << [lauren, alana, marshall, tiffany]
challenge11.participants << [alana, tiffany, sabri]
challenge12.participants << [alana, mike]
challenge13.participants << [marshall, lauren]
challenge14.participants << [marshall, alana, lauren]
challenge15.participants << [alana, marshall, mike, lauren]
challenge16.participants << [alana, marshall, mom, dad]
challenge17.participants << [mom, dad, marshall, mike]
challenge18.participants << [alana, mike, mom]
challenge19.participants << [dad, mike, marshall]
challenge20.participants << [mike, alana, lauren]
challenge21.participants << [dan, alana, lauren]
alana.comments.create!(group: group, content: 'these docs are so confusing!')
lauren.comments.create!(group: group, content: "Errors amiright?")
mike.comments.create!(group: group, content: "Guys the ROR really needs to be vacuumed")
tiffany.comments.create!(group: group2, content: "Amazing!")
alana.comments.create!(group: group3, content: "Already ran twice. Come on guys")
marshall.comments.create!(group: group3, content: "Swimming tomorrow")
alana.comments.create!(group: group4, content: "Seriously the tickets will sell out just buy them")
marshall.comments.create!(group: group4, content: "Can you just order 2 for me?")
lauren.comments.create!(group: group4, content: "Stop being so lazy marshall")
mom.comments.create!(group: group5, content: "Send pictures please!")
mom.comments.create!(group: group5, content: "I don't want to spoil this movie but you have to see it. It was so good. Whatever you think will happen doesn't actually happen. Don't worry that won't spoil it. But it's really pretty sad because everyone dies at the end. Oh shoot! Sorry!")
marshall.comments.create!(group: group5, content: "Mom!")
mike.comments.create!(group: group6, content: "Sup")
alana.comments.create!(group: group6, content: "Yo")
clip_art = ['http://worldartsme.com/images/fall-squirrel-clipart-1.jpg', 'http://clipartbold.com/wp-content/uploads/2016/02/Cute-squirrel-cartoon-clipart-image-5.png', 'http://clipartion.com/wp-content/uploads/2015/11/running-squirrel-clipart.png', 'http://images.clipartpanda.com/squirrel-clipart-cartoon_squirrel_with_an_acorn_nut_0071-0908-3116-2318_SMU.jpg', 'http://comps.canstockphoto.com/can-stock-photo_csp13648213.jpg', 'http://worldartsme.com/images/fall-squirrel-clipart-1.jpg', 'http://clipartbold.com/wp-content/uploads/2016/02/Cute-squirrel-cartoon-clipart-image-5.png', 'http://clipartion.com/wp-content/uploads/2015/11/running-squirrel-clipart.png', 'http://images.clipartpanda.com/squirrel-clipart-cartoon_squirrel_with_an_acorn_nut_0071-0908-3116-2318_SMU.jpg', 'http://comps.canstockphoto.com/can-stock-photo_csp13648213.jpg']
completed_challenges = Participation.all.sample(10)
completed_challenges.each_with_index do |participation, index|
participation.completed = true
participation.image = open(clip_art[index])
participation.save
end
|
# coding: utf-8
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
# Division(部署)テーブルに初期値を投入(全件削除して再投入)
Division.delete_all
Division.create(id: 1, code: 'HdO-01', name: '本社')
Division.create(id: 2, code: 'OSK-01', name: '大阪第1')
Division.create(id: 3, code: 'OSK-02', name: '大阪第2')
Division.create(id: 4, code: 'NGY-01', name: '名古屋営業所')
Division.create(id: 5, code: 'TKY-01', name: '東京支社')
# Type(種類)テーブルに初期値を投入(全件削除して再投入)
Type.delete_all
Type.create(id: 1, name: '通常用')
Type.create(id: 2, name: '非常用')
Type.create(id: 3, name: '携帯用')
# Place(場所)テーブルに初期値を投入(全件削除して再投入)
Place.delete_all
Place.create(id: 1, name: '大阪ビル', address: '大阪市なんとか区どこそこ町1−2−3')
Place.create(id: 2, name: '名古屋タワー', address: '名古屋市なんとか区どこそこ町7−5−8')
Place.create(id: 3, name: '東京港ショッピングモール', address: '東京都なんとか区ベイサイドエリア109')
# Status(状況)テーブルに初期値を投入(全件削除して再投入)
Status.delete_all
Status.create(id: 1, name: '担当未割当')
Status.create(id: 2, name: '実施待ち')
Status.create(id: 3, name: '実施中')
Status.create(id: 4, name: '完了')
# Result(結果)テーブルに初期値を投入(全件削除して再投入)
Result.delete_all
Result.create(id: 1, name: '合格')
Result.create(id: 2, name: '不合格')
Result.create(id: 3, name: '状態不明')
Result.create(id: 4, name: '検査前')
# Weather(天気)テーブルに初期値を投入(全件削除して再投入)
Weather.delete_all
Weather.create(id: 1, name: '晴')
Weather.create(id: 2, name: '曇')
Weather.create(id: 3, name: '雨')
Weather.create(id: 4, name: '雪')
# Checkresult(チェック結果)テーブルに初期値を投入(全件削除して再投入)
Checkresult.delete_all
Checkresult.create(id: 1, name: '優')
Checkresult.create(id: 2, name: '良')
Checkresult.create(id: 3, name: '可')
Checkresult.create(id: 4, name: '不可')
##########################
### テスト用にデータを入れる(超暫定)
##########################
# Worker(作業者)テーブルにテスト用初期値を投入(全件削除して再投入)
Worker.delete_all
Worker.create(id: 1, name: "山田 たろこ", division_id: 1)
Worker.create(id: 2, name: "浪速 あきこ", division_id: 2)
Worker.create(id: 3, name: "道頓堀 たろう", division_id: 3)
Worker.create(id: 4, name: "名古屋 じょうたろう", division_id: 4)
Worker.create(id: 5, name: "東京 はとこ", division_id: 5)
# Equipment(設備)テーブルにテスト用初期値を投入(全件削除して再投入)
Equipment.delete_all
Equipment.create(id: 1, name: "屋外特設会場用", type_id: 1, place_id: 1, division_id: 2)
Equipment.create(id: 2, name: "災害対策用", type_id: 2, place_id: 2, division_id: 4)
Equipment.create(id: 3, name: "イベント貸出用", type_id: 3, place_id: 3, division_id: 5)
# Inspection(点検)テーブルにテスト用初期値を投入(全件削除して再投入)
Inspection.delete_all
Inspection.create(id: 1, targetyearmonth: "201503", equipment_id: 1, status_id: 2, worker_id: 2, result_id: 4, processingdate: "2015-03-01")
Inspection.create(id: 2, targetyearmonth: "201503", equipment_id: 2, status_id: 2, worker_id: 4, result_id: 4, processingdate: "2015-03-01")
Inspection.create(id: 3, targetyearmonth: "201503", equipment_id: 3, status_id: 2, worker_id: 5, result_id: 4, processingdate: "2015-03-01")
change seeds.rb
# coding: utf-8
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
# Division(部署)テーブルに初期値を投入(全件削除して再投入)
Division.delete_all
Division.create(id: 1, code: 'HdO-01', name: '本社')
Division.create(id: 2, code: 'OSK-01', name: '大阪第1')
Division.create(id: 3, code: 'OSK-02', name: '大阪第2')
Division.create(id: 4, code: 'NGY-01', name: '名古屋営業所')
Division.create(id: 5, code: 'TKY-01', name: '東京支社')
# Type(種類)テーブルに初期値を投入(全件削除して再投入)
Type.delete_all
Type.create(id: 1, name: '通常用')
Type.create(id: 2, name: '非常用')
Type.create(id: 3, name: '携帯用')
# Place(場所)テーブルに初期値を投入(全件削除して再投入)
Place.delete_all
Place.create(id: 1, name: '大阪ビル', address: '大阪市なんとか区どこそこ町1−2−3')
Place.create(id: 2, name: '名古屋タワー', address: '名古屋市なんとか区どこそこ町7−5−8')
Place.create(id: 3, name: '東京港ショッピングモール', address: '東京都なんとか区ベイサイドエリア109')
# Status(状況)テーブルに初期値を投入(全件削除して再投入)
Status.delete_all
Status.create(id: 1, name: '担当未割当')
Status.create(id: 2, name: '実施待ち')
Status.create(id: 3, name: '実施中')
Status.create(id: 4, name: '完了')
# Result(結果)テーブルに初期値を投入(全件削除して再投入)
Result.delete_all
Result.create(id: 1, name: '合格')
Result.create(id: 2, name: '不合格')
Result.create(id: 3, name: '状態不明')
Result.create(id: 4, name: '検査前')
# Weather(天気)テーブルに初期値を投入(全件削除して再投入)
Weather.delete_all
Weather.create(id: 1, name: '晴')
Weather.create(id: 2, name: '曇')
Weather.create(id: 3, name: '雨')
Weather.create(id: 4, name: '雪')
# Checkresult(チェック結果)テーブルに初期値を投入(全件削除して再投入)
Checkresult.delete_all
Checkresult.create(id: 1, name: '優')
Checkresult.create(id: 2, name: '良')
Checkresult.create(id: 3, name: '可')
Checkresult.create(id: 4, name: '不可')
##########################
### テスト用にデータを入れる(超暫定)
##########################
# Worker(作業者)テーブルにテスト用初期値を投入(全件削除して再投入)
Worker.delete_all
if Rails.env.development?
Worker.connection.execute("delete from sqlite_sequence where name='Worker'")
else
Worker.connection.execute("SELECT SETVAL('Worker_id_seq',1,FALSE)")
end
Worker.create(id: 1, name: "山田 たろこ", division_id: 1)
Worker.create(id: 2, name: "浪速 あきこ", division_id: 2)
Worker.create(id: 3, name: "道頓堀 たろう", division_id: 3)
Worker.create(id: 4, name: "名古屋 じょうたろう", division_id: 4)
Worker.create(id: 5, name: "東京 はとこ", division_id: 5)
# Equipment(設備)テーブルにテスト用初期値を投入(全件削除して再投入)
Equipment.delete_all
Equipment.create(id: 1, name: "屋外特設会場用", type_id: 1, place_id: 1, division_id: 2)
Equipment.create(id: 2, name: "災害対策用", type_id: 2, place_id: 2, division_id: 4)
Equipment.create(id: 3, name: "イベント貸出用", type_id: 3, place_id: 3, division_id: 5)
# Inspection(点検)テーブルにテスト用初期値を投入(全件削除して再投入)
Inspection.delete_all
Inspection.create(id: 1, targetyearmonth: "201503", equipment_id: 1, status_id: 2, worker_id: 2, result_id: 4, processingdate: "2015-03-01")
Inspection.create(id: 2, targetyearmonth: "201503", equipment_id: 2, status_id: 2, worker_id: 4, result_id: 4, processingdate: "2015-03-01")
Inspection.create(id: 3, targetyearmonth: "201503", equipment_id: 3, status_id: 2, worker_id: 5, result_id: 4, processingdate: "2015-03-01") |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Daley', :city => cities.first)
# Create our admin user
user = User.find_by_email('admin@example.com') || User.new(:email => 'admin@example.com')
user.login = 'admin' # Not used anymore
user.password = 'secret'
user.password_confirmation = 'secret'
user.admin = true
user.save!
user.confirm!
# Create an example zone template
zone_template = ZoneTemplate.find_by_name('Example Template') || ZoneTemplate.new(:name => 'Example Template')
zone_template.ttl = 86400
zone_template.save!
# Clean and re-populate the zone template
zone_template.record_templates.clear
# SOA
RecordTemplate.create!({
:zone_template => zone_template,
:record_type => 'SOA',
:primary_ns => 'ns1.%ZONE%',
:contact => 'template@example.com',
:refresh => 10800,
:retry => 7200,
:expire => 604800,
:minimum => 10800
})
# NS records
RecordTemplate.create!({
:zone_template => zone_template,
:record_type => 'NS',
:content => 'ns1.%ZONE%'
})
RecordTemplate.create!({
:zone_template => zone_template,
:record_type => 'NS',
:content => 'ns2.%ZONE%'
})
# Assorted A records
RecordTemplate.create!({
:zone_template => zone_template,
:record_type => 'A',
:name => 'ns1',
:content => '10.0.0.1'
})
RecordTemplate.create!({
:zone_template => zone_template,
:record_type => 'A',
:name => 'ns2',
:content => '10.0.0.2'
})
RecordTemplate.create!({
:zone_template => zone_template,
:record_type => 'A',
:content => '10.0.0.3'
})
RecordTemplate.create!({
:zone_template => zone_template,
:record_type => 'A',
:name => 'mail',
:content => '10.0.0.4'
})
RecordTemplate.create!({
:zone_template => zone_template,
:record_type => 'MX',
:content => 'mail',
:prio => 10
})
# And add our example.com records
domain = Domain.find_by_name('example.com') || Domain.new(:name => 'example.com')
domain.ttl = 84600
domain.primary_ns = 'ns1.example.com'
domain.contact = 'admin@example.com'
domain.refresh = 10800
domain.retry = 7200
domain.expire = 604800
domain.minimum = 10800
domain.save!
# Clear the records and start fresh
domain.records_without_soa.each(&:destroy)
# NS records
NS.create!({
:domain => domain,
:content => 'ns1.%ZONE%'
})
NS.create!({
:domain => domain,
:content => 'ns2.%ZONE%'
})
# Assorted A records
A.create!({
:domain => domain,
:name => 'ns1',
:content => '10.0.0.1'
})
A.create!({
:domain => domain,
:name => 'ns2',
:content => '10.0.0.2'
})
A.create!({
:domain => domain,
:content => '10.0.0.3'
})
A.create!({
:domain => domain,
:name => 'mail',
:content => '10.0.0.4'
})
MX.create!({
:domain => domain,
:content => 'mail',
:prio => 10
})
puts <<-EOF
-------------------------------------------------------------------------------
Congratulations on setting up your PowerDNS on Rails database. You can now
start the server by running the command below, and then pointing your browser
to http://localhost:3000/
$ ./script/rails s
You can then login with "admin@example.com" using the password "secret".
Thanks for trying out PowerDNS on Rails!
-------------------------------------------------------------------------------
EOF
Admin user created during 'rake db:seed' should be confirmed, closes #37
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Daley', :city => cities.first)
# Create our admin user
user = User.find_by_email('admin@example.com') || User.new(:email => 'admin@example.com')
user.login = 'admin' # Not used anymore
user.password = 'secret'
user.password_confirmation = 'secret'
user.admin = true
user.confirmed_at = true
user.save!
user.confirm!
# Create an example zone template
zone_template = ZoneTemplate.find_by_name('Example Template') || ZoneTemplate.new(:name => 'Example Template')
zone_template.ttl = 86400
zone_template.save!
# Clean and re-populate the zone template
zone_template.record_templates.clear
# SOA
RecordTemplate.create!({
:zone_template => zone_template,
:record_type => 'SOA',
:primary_ns => 'ns1.%ZONE%',
:contact => 'template@example.com',
:refresh => 10800,
:retry => 7200,
:expire => 604800,
:minimum => 10800
})
# NS records
RecordTemplate.create!({
:zone_template => zone_template,
:record_type => 'NS',
:content => 'ns1.%ZONE%'
})
RecordTemplate.create!({
:zone_template => zone_template,
:record_type => 'NS',
:content => 'ns2.%ZONE%'
})
# Assorted A records
RecordTemplate.create!({
:zone_template => zone_template,
:record_type => 'A',
:name => 'ns1',
:content => '10.0.0.1'
})
RecordTemplate.create!({
:zone_template => zone_template,
:record_type => 'A',
:name => 'ns2',
:content => '10.0.0.2'
})
RecordTemplate.create!({
:zone_template => zone_template,
:record_type => 'A',
:content => '10.0.0.3'
})
RecordTemplate.create!({
:zone_template => zone_template,
:record_type => 'A',
:name => 'mail',
:content => '10.0.0.4'
})
RecordTemplate.create!({
:zone_template => zone_template,
:record_type => 'MX',
:content => 'mail',
:prio => 10
})
# And add our example.com records
domain = Domain.find_by_name('example.com') || Domain.new(:name => 'example.com')
domain.ttl = 84600
domain.primary_ns = 'ns1.example.com'
domain.contact = 'admin@example.com'
domain.refresh = 10800
domain.retry = 7200
domain.expire = 604800
domain.minimum = 10800
domain.save!
# Clear the records and start fresh
domain.records_without_soa.each(&:destroy)
# NS records
NS.create!({
:domain => domain,
:content => 'ns1.%ZONE%'
})
NS.create!({
:domain => domain,
:content => 'ns2.%ZONE%'
})
# Assorted A records
A.create!({
:domain => domain,
:name => 'ns1',
:content => '10.0.0.1'
})
A.create!({
:domain => domain,
:name => 'ns2',
:content => '10.0.0.2'
})
A.create!({
:domain => domain,
:content => '10.0.0.3'
})
A.create!({
:domain => domain,
:name => 'mail',
:content => '10.0.0.4'
})
MX.create!({
:domain => domain,
:content => 'mail',
:prio => 10
})
puts <<-EOF
-------------------------------------------------------------------------------
Congratulations on setting up your PowerDNS on Rails database. You can now
start the server by running the command below, and then pointing your browser
to http://localhost:3000/
$ ./script/rails s
You can then login with "admin@example.com" using the password "secret".
Thanks for trying out PowerDNS on Rails!
-------------------------------------------------------------------------------
EOF
|
# frozen_string_literal: true
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
User.create(email: 'root@root.com', password: 'ChangeMe123', admin: true)
# default game
game = Game.create!(name: 'Test Game', start: Time.now.utc + 3.months, stop: Time.now.utc + 3.months + 2.days)
high_school = Division.create!(name: 'High School', game: game, min_year_in_school: 9, max_year_in_school: 12)
college = Division.create!(name: 'College', game: game, min_year_in_school: 9, max_year_in_school: 16)
Division.create!(name: 'Professional', game: game, min_year_in_school: 0, max_year_in_school: 16)
# players
team1 = Team.create(team_name: 'pwnies', affiliation: 'PwnPwnPwn', division: high_school, eligible: false)
user = User.create!(
email: 'ctf@mitre.org',
password: 'Test123456',
team: team1,
full_name: 'I Pwn',
affiliation: 'PwnPwnPwn',
year_in_school: 12,
gender: 'Male',
age: 16,
area_of_study: 'Robotics',
state: 'FL'
)
team1.reload.save! # This will trigger set_team_captain so that the user declared above will become team captain
Team.create!(team_name: 'n00bs', affiliation: "We're n00bs", division: college, eligible: true)
# crypto
category = Category.create!(name: 'Crypto', game: game)
Challenge.create!(
name: 'Challenge A',
point_value: 100,
flags: [Flag.create(flag: 'flag')],
state: 'open',
category: category
)
Challenge.create!(
name: 'Challenge B',
point_value: 200,
flags: [Flag.create(flag: 'flag')],
state: 'closed',
category: category
)
Challenge.create!(
name: 'Challenge C',
point_value: 300,
flags: [Flag.create(flag: 'flag')],
state: 'closed',
category: category
)
Challenge.create!(
name: 'Challenge D',
point_value: 400,
flags: [Flag.create(flag: 'flag')],
state: 'closed',
category: category
)
category = Category.create!(name: 'Forensics', game: game)
Challenge.create!(
name: 'Challenge E',
point_value: 100,
flags: [Flag.create(flag: 'flag')],
state: 'open',
category: category
)
Challenge.create!(
name: 'Challenge F',
point_value: 200,
flags: [Flag.create(flag: 'flag')],
state: 'closed',
category: category
)
Challenge.create!(
name: 'Challenge G',
point_value: 300,
flags: [Flag.create(flag: 'flag')],
state: 'closed',
category: category
)
Challenge.create!(
name: 'Challenge H',
point_value: 400,
flags: [Flag.create(flag: 'flag')],
state: 'closed',
category: category
)
Message.create!(
game: game,
text: 'Message',
title: 'Neat message'
)
FeedItem.create!(
team: team1,
user: user,
division: high_school,
challenge: Challenge.first,
text: 'Achievement',
type: Achievement
)
Use an example.com domain in seeds file
# frozen_string_literal: true
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
User.create(email: 'root@example.com', password: 'ChangeMe123', admin: true)
# default game
game = Game.create!(name: 'Test Game', start: Time.now.utc + 3.months, stop: Time.now.utc + 3.months + 2.days)
high_school = Division.create!(name: 'High School', game: game, min_year_in_school: 9, max_year_in_school: 12)
college = Division.create!(name: 'College', game: game, min_year_in_school: 9, max_year_in_school: 16)
Division.create!(name: 'Professional', game: game, min_year_in_school: 0, max_year_in_school: 16)
# players
team1 = Team.create(team_name: 'pwnies', affiliation: 'PwnPwnPwn', division: high_school, eligible: false)
user = User.create!(
email: 'ctf@mitre.org',
password: 'Test123456',
team: team1,
full_name: 'I Pwn',
affiliation: 'PwnPwnPwn',
year_in_school: 12,
gender: 'Male',
age: 16,
area_of_study: 'Robotics',
state: 'FL'
)
team1.reload.save! # This will trigger set_team_captain so that the user declared above will become team captain
Team.create!(team_name: 'n00bs', affiliation: "We're n00bs", division: college, eligible: true)
# crypto
category = Category.create!(name: 'Crypto', game: game)
Challenge.create!(
name: 'Challenge A',
point_value: 100,
flags: [Flag.create(flag: 'flag')],
state: 'open',
category: category
)
Challenge.create!(
name: 'Challenge B',
point_value: 200,
flags: [Flag.create(flag: 'flag')],
state: 'closed',
category: category
)
Challenge.create!(
name: 'Challenge C',
point_value: 300,
flags: [Flag.create(flag: 'flag')],
state: 'closed',
category: category
)
Challenge.create!(
name: 'Challenge D',
point_value: 400,
flags: [Flag.create(flag: 'flag')],
state: 'closed',
category: category
)
category = Category.create!(name: 'Forensics', game: game)
Challenge.create!(
name: 'Challenge E',
point_value: 100,
flags: [Flag.create(flag: 'flag')],
state: 'open',
category: category
)
Challenge.create!(
name: 'Challenge F',
point_value: 200,
flags: [Flag.create(flag: 'flag')],
state: 'closed',
category: category
)
Challenge.create!(
name: 'Challenge G',
point_value: 300,
flags: [Flag.create(flag: 'flag')],
state: 'closed',
category: category
)
Challenge.create!(
name: 'Challenge H',
point_value: 400,
flags: [Flag.create(flag: 'flag')],
state: 'closed',
category: category
)
Message.create!(
game: game,
text: 'Message',
title: 'Neat message'
)
FeedItem.create!(
team: team1,
user: user,
division: high_school,
challenge: Challenge.first,
text: 'Achievement',
type: Achievement
)
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
Setting.create!(name: "competition_name", value: "HackTheArch", setting_type: "text")
Setting.create!(name: "max_members_per_team", value: "5", setting_type: "text")
Setting.create!(name: "subtract_hint_points_before_solve", value: "true", setting_type: "boolean")
Setting.create!(name: "scoreboard_on", value: "true", setting_type: "boolean")
Setting.create!(name: "send_activation_emails", value: "true", setting_type: "boolean")
Setting.create!(name: "max_submissions_per_team", value: "0", setting_type: "text")
Setting.create!(name: "start_time", value: Time.zone.now.to_s, setting_type: "date")
Setting.create!(name: "end_time", value: (Time.zone.now + 24.hours).to_s, setting_type: "date")
bracket = Bracket.create!(name: "Professional", priority: "10")
Bracket.create!(name: "College", priority: "5")
Bracket.create!(name: "High School", priority: "1")
team = Team.create!(name: "admins",
passphrase: "password",
bracket_id: bracket.id)
user = User.create!(id: Random.rand(10000),
fname: "admin",
lname: "user",
email: "admin@gmail.com",
password: "password",
password_confirmation: "password",
admin: true,
activated: true,
team_id: team.id,
activated_at: Time.zone.now)
team.add(user)
hint = Hint.create!(hint: "The test was named after him",
points: "25",
priority: "1")
problem = Problem.create!(name: "Who's that scientist?",
points: "100",
category: "Trivia",
description: "What's the name of the scientist that invented the test to determine the ability of a machine to exhibit intelligent behavior equivalent to, or indistinguishable from, that of a human?",
solution: "Alan Turing",
correct_message: "Very good!",
false_message: "Try again!",
solution_case_sensitive: "1",
visible: "1")
problem.add(hint.id)
Problem.create!(name: "Google Foo",
points: "100",
category: "Network Exploitation",
description: "What is the name of the site that indexes varios IoT devices like web cams and ethernet enabled thermostats?",
solution: "Shodan",
correct_message: "Scary, right!?",
false_message: "Try again!",
visible: "1")
Updating seed values
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
Setting.create!(name: "competition_name", value: "HackTheArch", setting_type: "text")
Setting.create!(name: "max_members_per_team", value: "5", setting_type: "text")
Setting.create!(name: "subtract_hint_points_before_solve", value: "true", setting_type: "boolean")
Setting.create!(name: "scoreboard_on", value: "true", setting_type: "boolean")
Setting.create!(name: "send_activation_emails", value: "true", setting_type: "boolean")
Setting.create!(name: "max_submissions_per_team", value: "0", setting_type: "text")
Setting.create!(name: "start_time", value: Time.zone.now.to_s, setting_type: "date")
Setting.create!(name: "end_time", value: (Time.zone.now + 24.hours).to_s, setting_type: "date")
bracket = Bracket.create!(name: "Professional", priority: "10")
Bracket.create!(name: "College", priority: "5")
Bracket.create!(name: "High School", priority: "1")
team = Team.create!(name: "admins",
passphrase: "password",
bracket_id: bracket.id)
user = User.create!(id: Random.rand(10000),
fname: "admin",
lname: "user",
email: "admin@gmail.com",
password: "password",
password_confirmation: "password",
admin: true,
activated: true,
team_id: team.id,
activated_at: Time.zone.now)
team.add(user)
hint = Hint.create!(hint: "The test was named after him",
points: "25",
priority: "1")
problem = Problem.create!(name: "Who's that scientist?",
points: "100",
category: "Trivia",
description: "What's the name of the scientist that invented the test to determine the ability of a machine to exhibit intelligent behavior equivalent to, or indistinguishable from, that of a human?",
solution: "Alan Turing",
correct_message: "Very good!",
false_message: "Try again!",
solution_case_sensitive: "1",
visible: "1")
problem.add(hint.id)
Problem.create!(name: "Google Foo",
points: "100",
category: "Network Exploitation",
description: "What is the name of the site that indexes varios IoT devices like web cams and ethernet enabled thermostats?",
solution: "Shodan",
correct_message: "Scary, right!?",
false_message: "Try again!",
solution_case_sensitive: "1",
visible: "1")
|
10.times do
User.create(name: TubularFaker.name, password: '123')
end
10.times do
question = Question.create(title: TubularFaker.company, content: TubularFaker.lingo, user: User.find(User.pluck(:id).sample))
3.times do
Answer.create(content: TubularFaker.city, user: User.find(User.pluck(:id).sample), question_id: question.id)
end
end
Fix merge conflict
10.times do
User.create(name: TubularFaker.name, password: '123')
end
10.times do
question = Question.create(title: TubularFaker.company, content: TubularFaker.lingo, user: User.find(User.pluck(:id).sample))
3.times do
Answer.create(content: TubularFaker.city, user: User.find(User.pluck(:id).sample), question_id: question.id)
end
end
|
if Rails.env.development?
unless Dir.exist?("../government-service-design-manual")
print "Cloning repository..."
sh "cd ../ && git clone https://github.com/alphagov/government-service-design-manual"
puts " [done]"
end
objects = Dir.glob("../government-service-design-manual/service-manual/**/*.md")
.map do |path|
url = path.gsub("../government-service-design-manual", "")
url = url.gsub(".md", "")
url = url.gsub(/\/index$/, '')
{
path: path,
url: url,
}
end
# https://github.com/jekyll/jekyll/blob/2807b8a012ead8b8fe7ed30f1a8ad1f6f9de7ba4/lib/jekyll/document.rb
YAML_FRONT_MATTER_REGEXP = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
author = User.first || User.create!(name: "Unknown")
objects.each do |object|
content = File.read(object[:path])
title = ""
if content =~ YAML_FRONT_MATTER_REGEXP
body = $POSTMATCH
data_file = YAML.load($1)
title = data_file["title"]
state = data_file["status"]
if Guide.find_by_slug(object[:url]).present?
next
puts "Ignoring '#{title}'"
end
puts "Creating '#{title}'"
next if body.blank?
edition = Edition.new(
title: title,
state: state.present? ? state : "draft",
phase: "beta",
description: "Description",
update_type: "minor",
body: body,
publisher_title: Edition::PUBLISHERS.keys.first,
user: author
)
guide = Guide.create!(slug: object[:url], content_id: nil, latest_edition: edition)
GuidePublisher.new(guide: guide).put_draft
if state == "published"
GuidePublisher.new(guide: guide).publish
end
end
end
end
Use /tmp for db:seed script
We're going to be running this script in a staging environment, so it
would be safer if we only used tmp directories. We don't want to
overwrite anything.
if Rails.env.development?
directory = File.join(Dir.mktmpdir("government-service-design-manual"), "git")
unless Dir.exist?(directory)
print "Cloning repository..."
sh "git clone https://github.com/alphagov/government-service-design-manual #{directory}"
puts " [done]"
end
objects = Dir.glob("#{directory}/service-manual/**/*.md")
.map do |path|
url = path.gsub(directory, "")
url = url.gsub(".md", "")
url = url.gsub(/\/index$/, '')
{
path: path,
url: url,
}
end
# https://github.com/jekyll/jekyll/blob/2807b8a012ead8b8fe7ed30f1a8ad1f6f9de7ba4/lib/jekyll/document.rb
YAML_FRONT_MATTER_REGEXP = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
author = User.first || User.create!(name: "Unknown")
objects.each do |object|
content = File.read(object[:path])
title = ""
if content =~ YAML_FRONT_MATTER_REGEXP
body = $POSTMATCH
data_file = YAML.load($1)
title = data_file["title"]
state = data_file["status"]
if Guide.find_by_slug(object[:url]).present?
next
puts "Ignoring '#{title}'"
end
puts "Creating '#{title}'"
next if body.blank?
edition = Edition.new(
title: title,
state: state.present? ? state : "draft",
phase: "beta",
description: "Description",
update_type: "minor",
body: body,
publisher_title: Edition::PUBLISHERS.keys.first,
user: author
)
guide = Guide.create!(slug: object[:url], content_id: nil, latest_edition: edition)
GuidePublisher.new(guide: guide).put_draft
if state == "published"
GuidePublisher.new(guide: guide).publish
end
end
end
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
add seeds for streams
# Seed Streams
streams = {
0 => "Everything",
1 => "Alternative",
2 => "Electronic",
3 => "Jazz",
4 => "Pop",
5 => "Rock",
6 => "Jazz + Electronic",
7 => "Jazz + Rock",
8 => "Electronic + Pop",
9 => "Rock + Alternative"
}
streams.each do |mountId, title|
Stream.create!(title: title,
mount: "/live#{mountId}",
server: "http://stream.creativecommons.gr:8000/")
end
|
class SandboxEvent < ActiveRecord::Base
self.table_name = "atomic.events"
establish_connection("redshift_sandbox")
end
Support overriding of sandbox database via ENV var
class SandboxEvent < ActiveRecord::Base
self.table_name = "atomic.events"
establish_connection(ENV['SANDBOX_DATABASE_URL'] || "redshift_sandbox")
end
|
require "savon/logger"
module Savon
class Options
def initialize(options = {})
@options = {}
assign options
end
def [](option)
@options[option]
end
def []=(option, value)
value = [value].flatten
self.send(option, *value)
end
def include?(option)
@options.key? option
end
def select(&block)
@options.select(&block)
end
private
def assign(options)
options.each do |option, value|
self.send(option, value)
end
end
end
class GlobalOptions < Options
def initialize(options = {})
defaults = {
:encoding => "UTF-8",
:soap_version => 1,
:logger => Logger.new,
:pretty_print_xml => false,
:raise_errors => true,
:strip_namespaces => true,
:convert_tags_to => lambda { |tag| tag.snakecase.to_sym }
}
super defaults.merge(options)
end
# Location of the local or remote WSDL document.
def wsdl(wsdl_address)
@options[:wsdl] = wsdl_address
end
# SOAP endpoint.
def endpoint(endpoint)
@options[:endpoint] = endpoint
end
# Target namespace.
def namespace(namespace)
@options[:namespace] = namespace
end
# The namespace identifer.
def namespace_identifier(identifier)
@options[:namespace_identifier] = identifier
end
# Proxy server to use for all requests.
def proxy(proxy)
@options[:proxy] = proxy
end
# A Hash of HTTP headers.
def headers(headers)
@options[:headers] = headers
end
# Open timeout in seconds.
def open_timeout(open_timeout)
@options[:open_timeout] = open_timeout
end
# Read timeout in seconds.
def read_timeout(read_timeout)
@options[:read_timeout] = read_timeout
end
# The encoding to use. Defaults to "UTF-8".
def encoding(encoding)
@options[:encoding] = encoding
end
# The global SOAP header. Expected to be a Hash.
def soap_header(header)
@options[:soap_header] = header
end
# Sets whether elements should be :qualified or unqualified.
# If you need to use this option, please open an issue and make
# sure to add your WSDL document for debugging.
def element_form_default(element_form_default)
@options[:element_form_default] = element_form_default
end
# Can be used to change the SOAP envelope namespace identifier.
# If you need to use this option, please open an issue and make
# sure to add your WSDL document for debugging.
def env_namespace(env_namespace)
@options[:env_namespace] = env_namespace
end
# Changes the SOAP version to 1 or 2.
def soap_version(soap_version)
@options[:soap_version] = soap_version
end
# Whether or not to raise SOAP fault and HTTP errors.
def raise_errors(raise_errors)
@options[:raise_errors] = raise_errors
end
# The logger to use. Defaults to a Savon::Logger instance.
def logger(logger)
@options[:logger] = logger
end
# Whether to pretty print request and response XML log messages.
def pretty_print_xml(pretty_print_xml)
@options[:pretty_print_xml] = pretty_print_xml
end
# Used by Savon to store the last response to pass
# its cookies to the next request.
def last_response(last_response)
@options[:last_response] = last_response
end
# HTTP basic auth credentials.
def basic_auth(*credentials)
@options[:basic_auth] = credentials
end
# HTTP digest auth credentials.
def digest_auth(*credentials)
@options[:digest_auth] = credentials
end
# WSSE auth credentials for Akami.
def wsse_auth(*credentials)
@options[:wsse_auth] = credentials.flatten
end
# Instruct Nori whether to strip namespaces from XML nodes.
def strip_namespaces(strip_namespaces)
@options[:strip_namespaces] = strip_namespaces
end
# Tell Nori how to convert XML tags. Expects a lambda which receives an XML tag and returns
# the conversion result. Defaults to convert tags to snakecase Symbols.
def convert_tags_to(converter)
@options[:convert_tags_to] = converter
end
end
class LocalOptions < Options
def initialize(options = {})
defaults = {
:advanced_typecasting => true,
:response_parser => :nokogiri
}
super defaults.merge(options)
end
# The SOAP message to send. Expected to be a Hash or a String.
def message(message)
@options[:message] = message
end
# SOAP message tag (formerly known as SOAP input tag). If it's not set, Savon retrieves the name from
# the WSDL document (if available). Otherwise, Gyoku converts the operation name into an XML element.
def message_tag(message_tag)
@options[:message_tag] = message_tag
end
# Value of the SOAPAction HTTP header.
def soap_action(soap_action)
@options[:soap_action] = soap_action
end
# The SOAP request XML to send. Expected to be a String.
def xml(xml)
@options[:xml] = xml
end
# Instruct Nori to use advanced typecasting.
def advanced_typecasting(advanced)
@options[:advanced_typecasting] = advanced
end
# Instruct Nori to use :rexml or :nokogiri to parse the response.
def response_parser(parser)
@options[:response_parser] = parser
end
end
end
flatten basic/digest auth arguments
require "savon/logger"
module Savon
class Options
def initialize(options = {})
@options = {}
assign options
end
def [](option)
@options[option]
end
def []=(option, value)
value = [value].flatten
self.send(option, *value)
end
def include?(option)
@options.key? option
end
def select(&block)
@options.select(&block)
end
private
def assign(options)
options.each do |option, value|
self.send(option, value)
end
end
end
class GlobalOptions < Options
def initialize(options = {})
defaults = {
:encoding => "UTF-8",
:soap_version => 1,
:logger => Logger.new,
:pretty_print_xml => false,
:raise_errors => true,
:strip_namespaces => true,
:convert_tags_to => lambda { |tag| tag.snakecase.to_sym }
}
super defaults.merge(options)
end
# Location of the local or remote WSDL document.
def wsdl(wsdl_address)
@options[:wsdl] = wsdl_address
end
# SOAP endpoint.
def endpoint(endpoint)
@options[:endpoint] = endpoint
end
# Target namespace.
def namespace(namespace)
@options[:namespace] = namespace
end
# The namespace identifer.
def namespace_identifier(identifier)
@options[:namespace_identifier] = identifier
end
# Proxy server to use for all requests.
def proxy(proxy)
@options[:proxy] = proxy
end
# A Hash of HTTP headers.
def headers(headers)
@options[:headers] = headers
end
# Open timeout in seconds.
def open_timeout(open_timeout)
@options[:open_timeout] = open_timeout
end
# Read timeout in seconds.
def read_timeout(read_timeout)
@options[:read_timeout] = read_timeout
end
# The encoding to use. Defaults to "UTF-8".
def encoding(encoding)
@options[:encoding] = encoding
end
# The global SOAP header. Expected to be a Hash.
def soap_header(header)
@options[:soap_header] = header
end
# Sets whether elements should be :qualified or unqualified.
# If you need to use this option, please open an issue and make
# sure to add your WSDL document for debugging.
def element_form_default(element_form_default)
@options[:element_form_default] = element_form_default
end
# Can be used to change the SOAP envelope namespace identifier.
# If you need to use this option, please open an issue and make
# sure to add your WSDL document for debugging.
def env_namespace(env_namespace)
@options[:env_namespace] = env_namespace
end
# Changes the SOAP version to 1 or 2.
def soap_version(soap_version)
@options[:soap_version] = soap_version
end
# Whether or not to raise SOAP fault and HTTP errors.
def raise_errors(raise_errors)
@options[:raise_errors] = raise_errors
end
# The logger to use. Defaults to a Savon::Logger instance.
def logger(logger)
@options[:logger] = logger
end
# Whether to pretty print request and response XML log messages.
def pretty_print_xml(pretty_print_xml)
@options[:pretty_print_xml] = pretty_print_xml
end
# Used by Savon to store the last response to pass
# its cookies to the next request.
def last_response(last_response)
@options[:last_response] = last_response
end
# HTTP basic auth credentials.
def basic_auth(*credentials)
@options[:basic_auth] = credentials.flatten
end
# HTTP digest auth credentials.
def digest_auth(*credentials)
@options[:digest_auth] = credentials.flatten
end
# WSSE auth credentials for Akami.
def wsse_auth(*credentials)
@options[:wsse_auth] = credentials.flatten
end
# Instruct Nori whether to strip namespaces from XML nodes.
def strip_namespaces(strip_namespaces)
@options[:strip_namespaces] = strip_namespaces
end
# Tell Nori how to convert XML tags. Expects a lambda which receives an XML tag and returns
# the conversion result. Defaults to convert tags to snakecase Symbols.
def convert_tags_to(converter)
@options[:convert_tags_to] = converter
end
end
class LocalOptions < Options
def initialize(options = {})
defaults = {
:advanced_typecasting => true,
:response_parser => :nokogiri
}
super defaults.merge(options)
end
# The SOAP message to send. Expected to be a Hash or a String.
def message(message)
@options[:message] = message
end
# SOAP message tag (formerly known as SOAP input tag). If it's not set, Savon retrieves the name from
# the WSDL document (if available). Otherwise, Gyoku converts the operation name into an XML element.
def message_tag(message_tag)
@options[:message_tag] = message_tag
end
# Value of the SOAPAction HTTP header.
def soap_action(soap_action)
@options[:soap_action] = soap_action
end
# The SOAP request XML to send. Expected to be a String.
def xml(xml)
@options[:xml] = xml
end
# Instruct Nori to use advanced typecasting.
def advanced_typecasting(advanced)
@options[:advanced_typecasting] = advanced
end
# Instruct Nori to use :rexml or :nokogiri to parse the response.
def response_parser(parser)
@options[:response_parser] = parser
end
end
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Emanuel', :city => cities.first)
puts 'SEEDING USERS'
users = [
{
:_id => 'jpale',
:first_name => 'Jean',
:last_name => 'PALE',
:email => 'jpale@example.com',
:password => 'iloveactivities',
:password_confirmation => 'iloveactivities',
:fake => true,
},
{
:_id => 'anne',
:first_name => 'Anne',
:last_name => 'CHTITEGOUTE',
:email => 'anne@example.com',
:password => 'iloveactivities',
:password_confirmation => 'iloveactivities',
:fake => true,
},
{
:_id => 'corinne',
:first_name => 'Corinne',
:last_name => 'CHTITEGOUTE',
:email => 'corinne@example.com',
:password => 'iloveactivities',
:password_confirmation => 'iloveactivities',
:fake => true,
},
{
:_id => 'justine',
:first_name => 'Justine',
:last_name => 'CHTITEGOUTE',
:email => 'justine@example.com',
:password => 'iloveactivities',
:password_confirmation => 'iloveactivities',
:fake => true,
},
]
users.each do |user_hash|
user = User.create!(user_hash)
puts "Fake user created: #{user.fullname}"
end
Cleanup db seeds
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Emanuel', :city => cities.first)
puts 'SEEDING USERS'
users = [
{
:first_name => 'Jean',
:last_name => 'PALE',
:email => 'jpale@example.com',
:password => 'iloveactivities',
:password_confirmation => 'iloveactivities',
:fake => true,
},
{
:first_name => 'Anne',
:last_name => 'CHTITEGOUTE',
:email => 'anne@example.com',
:password => 'iloveactivities',
:password_confirmation => 'iloveactivities',
:fake => true,
},
{
:first_name => 'Corinne',
:last_name => 'CHTITEGOUTE',
:email => 'corinne@example.com',
:password => 'iloveactivities',
:password_confirmation => 'iloveactivities',
:fake => true,
},
{
:first_name => 'Justine',
:last_name => 'CHTITEGOUTE',
:email => 'justine@example.com',
:password => 'iloveactivities',
:password_confirmation => 'iloveactivities',
:fake => true,
},
]
users.each do |user_hash|
user = User.create!(user_hash)
puts "Fake user created: #{user.fullname}"
end
|
controller para projetos#28
class ProjetosController < ApplicationController
def index
@projetos = Projeto.all
end
def create
@projeto = Projeto.new(params[:projeto])
end
#------------------------------------------------------------------
def show
end
def new
@pesquisadores = Pesquisador.all
@tematicas = Tematica.all
@projeto = Projeto.new
end
end
|
add callback example
require 'active_support/callbacks'
$:.unshift("~/studio/source_route/lib")
require 'source_route'
SourceRoute.enable do
event :call, :return
defined_class 'ActiveSupport::Callbacks', 'PersonRecord'
method_id :base_save, :saving_message, :callback
result_config.import_return_to_call = true
end
class Record
include ActiveSupport::Callbacks
define_callbacks :save
def base_save
run_callbacks :save do
puts "- save"
end
end
end
class PersonRecord < Record
set_callback :save, :before, :saving_message
def saving_message
puts "saving..."
end
end
person = PersonRecord.new
person.base_save
SourceRoute.build_html_output
|
Dir[File.dirname(__FILE__) + "/clio_client/api/*.rb"].each {|file| require file }
require 'net/http'
require 'json'
module ClioClient
autoload :Record, 'clio_client/record'
autoload :Activity, 'clio_client/activity'
autoload :TimeEntry, 'clio_client/time_entry'
autoload :ExpenseEntry, 'clio_client/expense_entry'
autoload :User, 'clio_client/user'
autoload :ActivityDescription, 'clio_client/activity_description'
autoload :Communication, 'clio_client/communication'
autoload :Matter, 'clio_client/matter'
module Api
autoload :Activity, 'clio_client/api/activity'
autoload :Crud, 'clio_client/api/crud'
autoload :TimeEntry, 'clio_client/api/time_entry'
autoload :ExpenseEntry, 'clio_client/api/expense_entry'
autoload :Base, 'clio_client/api/base'
end
end
Removing the block require
require 'net/http'
require 'json'
module ClioClient
autoload :Record, 'clio_client/record'
autoload :Activity, 'clio_client/activity'
autoload :TimeEntry, 'clio_client/time_entry'
autoload :ExpenseEntry, 'clio_client/expense_entry'
autoload :User, 'clio_client/user'
autoload :ActivityDescription, 'clio_client/activity_description'
autoload :Communication, 'clio_client/communication'
autoload :Matter, 'clio_client/matter'
module Api
autoload :Activity, 'clio_client/api/activity'
autoload :Crud, 'clio_client/api/crud'
autoload :TimeEntry, 'clio_client/api/time_entry'
autoload :ExpenseEntry, 'clio_client/api/expense_entry'
autoload :Base, 'clio_client/api/base'
end
end
|
require 'net/https'
require 'uri'
# @return [Net::HTTPResponse]
# @params [String] uri_string URI string
# @params [String] authtoken
def https_get(uri_string, authtoken)
uri = URI.parse uri_string
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
req = Net::HTTP::Get.new(uri.path)
req['Content-Type'] = 'application/json'
req['Accept'] = 'application/json'
req['X-Auth-Token'] = authtoken
https.request(req)
end
# @return [Net::HTTPResponse]
# @params [String] uri_string URI string
# @params [Hash] payload HTTP request body
# @params [String|nil] authtoken
# Authtoken string or `nil`.
# Can pass `nil` only on authenticating with username and password.
def https_post(uri_string, payload, authtoken)
uri = URI.parse uri_string
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
req = Net::HTTP::Post.new(uri.request_uri)
req['Content-Type'] = 'application/json'
req['Accept'] = 'application/json'
req['X-Auth-Token'] = authtoken
req.body = payload.to_json
https.request(req)
end
# @return [Net::HTTPResponse]
# @params [String] uri_string URI string
# @params [String] authtoken
def https_delete(uri_string, authtoken)
uri = URI.parse uri_string
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
req = Net::HTTP::Delete.new(uri.request_uri)
req['Content-Type'] = 'application/json'
req['Accept'] = 'application/json'
req['X-Auth-Token'] = authtoken
https.request(req)
end
# @params [Array<String>]
# The return value of `ip_address_of` method. It is either
#
# ["111.111.111.111", "1111:1111:1111:1111:1111:1111:1111:1111"]
#
# or
#
# ["1111:1111:1111:1111:1111:1111:1111:1111", "111.111.111.111"]
#
# @return [String] IPv4 address (e.g. "111.111.111.111")
def ipv4(ip_address)
ip_address.select { |e| e =~ /\d+\.\d+\.\d+\.\d+/ }.first
end
# @return [String] UUID of image
# @params [String] os OS name
# @raise [StandardError] When the OS name isn't contained.
def image_ref_from_os(os)
dictionary = {
'ubuntu' => '793be3e1-3c33-4ab3-9779-f4098ea90eb5', # Ubuntu 14.04 amd64
'debian' => 'c14d5dd5-debc-464c-9cc3-ada6e48f5d0c', # Debian 8 amd64
'fedora23' => 'ed6364b8-9fb2-479c-a5a8-bde9ba1101f3', # Fedora 23 amd64
'centos67' => 'cd13a8b9-6b57-467b-932e-eee5edcd8d6c', # CentOS 6.7
'centos72' => 'e141fc06-632e-42a9-9c2d-eec9201427ec', # CentOS 7.2
'arch' => 'f5e5b475-ebec-4973-99c7-bc8add5d16c4', # Arch
}
if dictionary.keys.include? os
dictionary[os]
else
raise StandardError.new <<EOS
"#{os}" doesn't exist.
Select os name from the following list:
#{dictionary.keys.join("\n")}
EOS
end
end
# @return [String] Image name tag
# @params [String] os OS name
# @raise [StandardError] When the OS name isn't included in the dictionary.
def image_tag_dictionary(os)
dictionary = {
'ubuntu' => 'vmi-ubuntu-14.04-amd64', # Ubuntu 14.04 amd64
'debian' => 'vmi-debian-8-amd64', # Debian 8 amd64
'fedora23' => 'vmi-fedora-23-amd64', # Fedora 23 amd64
'centos67' => 'vmi-centos-6.7-amd64', # CentOS 6.7
'centos72' => 'vmi-centos-7.2-amd64', # CentOS 7.2
'arch' => 'vmi-arch-amd64', # Arch
}
# 'opensuse' => 'vmi-opensuse-42.1-amd64' # openSUSE
# 'openbsd' => 'vmi-openbsd-5.8-amd64', # OpenBSD
# 'netbsd' => 'vmi-netbsd-7.0-amd64', # NetBSD
# 'freebsd' => 'vmi-freebsd-10.1-x86_64', # FreeBSD
if dictionary.keys.include? os
dictionary[os]
else
raise StandardError.new <<EOS
"#{os}" doesn't exist.
Select os name from the following list:
#{dictionary.keys.join("\n")}
EOS
end
end
Remove image_ref_from_os method from util.rb
require 'net/https'
require 'uri'
# @return [Net::HTTPResponse]
# @params [String] uri_string URI string
# @params [String] authtoken
def https_get(uri_string, authtoken)
uri = URI.parse uri_string
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
req = Net::HTTP::Get.new(uri.path)
req['Content-Type'] = 'application/json'
req['Accept'] = 'application/json'
req['X-Auth-Token'] = authtoken
https.request(req)
end
# @return [Net::HTTPResponse]
# @params [String] uri_string URI string
# @params [Hash] payload HTTP request body
# @params [String|nil] authtoken
# Authtoken string or `nil`.
# Can pass `nil` only on authenticating with username and password.
def https_post(uri_string, payload, authtoken)
uri = URI.parse uri_string
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
req = Net::HTTP::Post.new(uri.request_uri)
req['Content-Type'] = 'application/json'
req['Accept'] = 'application/json'
req['X-Auth-Token'] = authtoken
req.body = payload.to_json
https.request(req)
end
# @return [Net::HTTPResponse]
# @params [String] uri_string URI string
# @params [String] authtoken
def https_delete(uri_string, authtoken)
uri = URI.parse uri_string
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
req = Net::HTTP::Delete.new(uri.request_uri)
req['Content-Type'] = 'application/json'
req['Accept'] = 'application/json'
req['X-Auth-Token'] = authtoken
https.request(req)
end
# @params [Array<String>]
# The return value of `ip_address_of` method. It is either
#
# ["111.111.111.111", "1111:1111:1111:1111:1111:1111:1111:1111"]
#
# or
#
# ["1111:1111:1111:1111:1111:1111:1111:1111", "111.111.111.111"]
#
# @return [String] IPv4 address (e.g. "111.111.111.111")
def ipv4(ip_address)
ip_address.select { |e| e =~ /\d+\.\d+\.\d+\.\d+/ }.first
end
# @return [String] Image name tag
# @params [String] os OS name
# @raise [StandardError] When the OS name isn't included in the dictionary.
def image_tag_dictionary(os)
dictionary = {
'ubuntu' => 'vmi-ubuntu-14.04-amd64', # Ubuntu 14.04 amd64
'debian' => 'vmi-debian-8-amd64', # Debian 8 amd64
'fedora23' => 'vmi-fedora-23-amd64', # Fedora 23 amd64
'centos67' => 'vmi-centos-6.7-amd64', # CentOS 6.7
'centos72' => 'vmi-centos-7.2-amd64', # CentOS 7.2
'arch' => 'vmi-arch-amd64', # Arch
}
# 'opensuse' => 'vmi-opensuse-42.1-amd64' # openSUSE
# 'openbsd' => 'vmi-openbsd-5.8-amd64', # OpenBSD
# 'netbsd' => 'vmi-netbsd-7.0-amd64', # NetBSD
# 'freebsd' => 'vmi-freebsd-10.1-x86_64', # FreeBSD
if dictionary.keys.include? os
dictionary[os]
else
raise StandardError.new <<EOS
"#{os}" doesn't exist.
Select os name from the following list:
#{dictionary.keys.join("\n")}
EOS
end
end
|
require 'controls'
module Controls
module ID
def self.get(i=nil)
i ||= 1
first_octet = (i).to_s.rjust(8, '0')
third_prefix = ['8', '9', 'A', 'B'].sample
"#{first_octet}-4000-#{third_prefix}000-0000-000000000000"
# NOTE This should become: Identifier::UUID::Controls::Incrementing.example(i) [Scott, Mon Oct 12 2015]
end
end
end
Swap second and third octets
require 'controls'
module Controls
module ID
def self.get(i=nil)
i ||= 1
first_octet = (i).to_s.rjust(8, '0')
third_prefix = ['8', '9', 'A', 'B'].sample
"#{first_octet}-0000-4000-#{third_prefix}000-000000000000"
# NOTE This should become: Identifier::UUID::Controls::Incrementing.example(i) [Scott, Mon Oct 12 2015]
end
end
end
|
module Serenity
class Line
attr_reader :text
def initialize text
@text = text
end
def to_s
@text
end
def self.text txt
TextLine.new txt
end
def self.code txt
CodeLine.new txt
end
def self.string txt
StringLine.new txt
end
def self.literal txt
LiteralLine.new txt
end
end
class TextLine < Line
def to_buf
" _buf << '" << escape_text(@text) << "';"
end
def escape_text text
text.gsub(/['\\]/, '\\\\\&')
end
end
class CodeLine < Line
def to_buf
escape_code(@text) << ';'
end
def escape_code code
code.mgsub! [[/'/, "'"], [/>/, '>'], [/</, '<'], [/"/, '"'], [/&/, '&']]
end
end
class StringLine < CodeLine
def to_buf
" _buf << (" << escape_code(@text) << ").to_s.escape_xml.convert_newlines;"
end
def convert_newlines text
text.gsub("First line", '<text:line-break>')
end
end
class LiteralLine < CodeLine
def to_buf
" _buf << (" << escape_code(@text) << ").to_s;"
end
end
end
Encapsulate eval code in begin-rescue to raise error in output file
module Serenity
class Line
attr_reader :text
def initialize text
@text = text
end
def to_s
@text
end
def self.text txt
TextLine.new txt
end
def self.code txt
CodeLine.new txt
end
def self.string txt
StringLine.new txt
end
def self.literal txt
LiteralLine.new txt
end
end
class TextLine < Line
def to_buf
" _buf << '" << escape_text(@text) << "';"
end
def escape_text text
text.gsub(/['\\]/, '\\\\\&')
end
end
class CodeLine < Line
def to_buf
escape_code(@text) << ';'
end
def escape_code code
code.mgsub! [[/'/, "'"], [/>/, '>'], [/</, '<'], [/"/, '"'], [/&/, '&']]
end
end
class StringLine < CodeLine
def to_buf
code = "begin;#{@text};rescue Exception => e; e.inspect;end"
" _buf << (" << escape_code(code) << ").to_s.escape_xml.convert_newlines;"
end
def convert_newlines text
text.gsub("First line", '<text:line-break>')
end
end
class LiteralLine < CodeLine
def to_buf
code = "begin;#{@text};rescue Exception => e; e.inspect;end"
" _buf << (" << escape_code(code) << ").to_s;"
end
end
end
|
# encoding: UTF-8
#
# Provides version as a contsant for the serf gem
module Serfx
VERSION = '0.1.1'
end
bump to v0.1.2
This includes the enhancement which ensures that errors that are either `nil` or empty will not be treated as errors.
# encoding: UTF-8
#
# Provides version as a contsant for the serf gem
module Serfx
VERSION = '0.1.2'
end
|
Veewee::Definition.declare_yaml('definition.yml', '8.4.yml')
Use Debian 8.5 instead of Debian 8.4
8.4 url currently returns a 404
Veewee::Definition.declare_yaml('definition.yml', '8.5.yml')
|
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{moonshado-sms}
s.version = "0.5.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Kevin Patel"]
s.date = %q{2010-08-06}
s.email = %q{tech@moonshado.com}
s.extra_rdoc_files = [
"LICENSE",
"README.rdoc"
]
s.files = [
".document",
".gitignore",
"LICENSE",
"README.rdoc",
"Rakefile",
"VERSION.yml",
"gems/moonshado-sms-0.0.1/.gitignore",
"lib/moonshado-sms.rb",
"lib/moonshado/configuration.rb",
"lib/moonshado/keywords.rb",
"lib/moonshado/sender.rb",
"lib/moonshado/sms.rb",
"moonshado-sms.gemspec",
"test/configuration_test.rb",
"test/helper.rb",
"test/keywords_test.rb",
"test/sms_test.rb"
]
s.homepage = %q{http://github.com/moonshado/moonshado-sms}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.7}
s.summary = %q{Moonshado SMS gem}
s.test_files = [
"test/configuration_test.rb",
"test/helper.rb",
"test/keywords_test.rb",
"test/sms_test.rb"
]
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_development_dependency(%q<shoulda>, [">= 0"])
s.add_development_dependency(%q<webmock>, [">= 0"])
s.add_runtime_dependency(%q<rest-client>, ["= 1.5.1"])
s.add_runtime_dependency(%q<yajl-ruby>, ["= 0.7.6"])
else
s.add_dependency(%q<shoulda>, [">= 0"])
s.add_dependency(%q<webmock>, [">= 0"])
s.add_dependency(%q<rest-client>, ["= 1.5.1"])
s.add_dependency(%q<yajl-ruby>, ["= 0.7.6"])
end
else
s.add_dependency(%q<shoulda>, [">= 0"])
s.add_dependency(%q<webmock>, [">= 0"])
s.add_dependency(%q<rest-client>, ["= 1.5.1"])
s.add_dependency(%q<yajl-ruby>, ["= 0.7.6"])
end
end
Regenerated gemspec for version 1.0.0
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{moonshado-sms}
s.version = "1.0.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Kevin Patel"]
s.date = %q{2010-08-26}
s.email = %q{tech@moonshado.com}
s.extra_rdoc_files = [
"LICENSE",
"README.rdoc"
]
s.files = [
".document",
".gitignore",
"LICENSE",
"README.rdoc",
"Rakefile",
"VERSION.yml",
"gems/moonshado-sms-0.0.1/.gitignore",
"lib/moonshado-sms.rb",
"lib/moonshado/configuration.rb",
"lib/moonshado/keywords.rb",
"lib/moonshado/sender.rb",
"lib/moonshado/sms.rb",
"moonshado-sms.gemspec",
"test/configuration_test.rb",
"test/helper.rb",
"test/keywords_test.rb",
"test/sms_test.rb"
]
s.homepage = %q{http://github.com/moonshado/moonshado-sms}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.7}
s.summary = %q{Moonshado SMS gem}
s.test_files = [
"test/configuration_test.rb",
"test/helper.rb",
"test/keywords_test.rb",
"test/sms_test.rb"
]
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_development_dependency(%q<shoulda>, [">= 0"])
s.add_development_dependency(%q<webmock>, [">= 0"])
s.add_runtime_dependency(%q<rest-client>, ["= 1.6.0"])
s.add_runtime_dependency(%q<yajl-ruby>, ["= 0.7.7"])
else
s.add_dependency(%q<shoulda>, [">= 0"])
s.add_dependency(%q<webmock>, [">= 0"])
s.add_dependency(%q<rest-client>, ["= 1.6.0"])
s.add_dependency(%q<yajl-ruby>, ["= 0.7.7"])
end
else
s.add_dependency(%q<shoulda>, [">= 0"])
s.add_dependency(%q<webmock>, [">= 0"])
s.add_dependency(%q<rest-client>, ["= 1.6.0"])
s.add_dependency(%q<yajl-ruby>, ["= 0.7.7"])
end
end
|
# Scrapes a Gatherer search page for a given set to return a list of card details
# pages for that set
module MTGExtractor
class SetExtractor
require 'restclient'
require 'uri'
attr_accessor :name, :url
CARDS_FOR_SET_URL = 'http://gatherer.wizards.com/Pages/Search/Default.aspx?output=checklist&set=["escaped_set_name"]'
def initialize(name)
@name = name
@url = URI.encode(CARDS_FOR_SET_URL.gsub("escaped_set_name", name))
end
def get_card_detail_urls
ids = []
response = RestClient.get(@url)
extract_card_detail_urls(response)
end
def extract_card_detail_urls(html)
match_data = /Card\/Details\.aspx\?multiverseid=(\d+)/
multiverse_ids = html.scan(match_data).flatten.uniq
multiverse_ids.collect {|id| "http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=#{id}" }
end
def self.get_all_sets
response = RestClient.get('http://gatherer.wizards.com/Pages/Default.aspx')
set_select_regex = /<select name="ctl00\$ctl00\$MainContent\$Content\$SearchControls\$setAddText" id="ctl00_ctl00_MainContent_Content_SearchControls_setAddText">\s*(<option[^>]*>[^>]*<\/option>\s*)+<\/select>/
set_regex = /value="([^"]+)"/
set_select = response.match(set_select_regex)[0]
set_select.scan(set_regex).flatten
end
end
end
Fix spacing issue
# Scrapes a Gatherer search page for a given set to return a list of card details
# pages for that set
module MTGExtractor
class SetExtractor
require 'restclient'
require 'uri'
attr_accessor :name, :url
CARDS_FOR_SET_URL = 'http://gatherer.wizards.com/Pages/Search/Default.aspx?output=checklist&set=["escaped_set_name"]'
def initialize(name)
@name = name
@url = URI.encode(CARDS_FOR_SET_URL.gsub("escaped_set_name", name))
end
def get_card_detail_urls
ids = []
response = RestClient.get(@url)
extract_card_detail_urls(response)
end
def extract_card_detail_urls(html)
match_data = /Card\/Details\.aspx\?multiverseid=(\d+)/
multiverse_ids = html.scan(match_data).flatten.uniq
multiverse_ids.collect {|id| "http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=#{id}" }
end
def self.get_all_sets
response = RestClient.get('http://gatherer.wizards.com/Pages/Default.aspx')
set_select_regex = /<select name="ctl00\$ctl00\$MainContent\$Content\$SearchControls\$setAddText" id="ctl00_ctl00_MainContent_Content_SearchControls_setAddText">\s*(<option[^>]*>[^>]*<\/option>\s*)+<\/select>/
set_regex = /value="([^"]+)"/
set_select = response.match(set_select_regex)[0]
set_select.scan(set_regex).flatten
end
end
end
|
module Sgcop
VERSION = "0.0.1".freeze
end
v0.0.2
module Sgcop
VERSION = "0.0.2".freeze
end
|
class ShareCounter
# require 'share-counter/common'
# require 'json'
require 'rest-client'
require 'nokogiri'
require 'open-uri'
# def self.twitter url, raise_exceptions = false
# try("twitter", url, raise_exceptions) {
# extract_count from_json( "http://urls.api.twitter.com/1/urls/count.json", :url => url),
# :selector => "count"
# }
# end
# def self.facebook url, raise_exceptions = false
# try("facebook", url, raise_exceptions) {
# extract_count from_json("http://api.facebook.com/restserver.php", :v => "1.0", :method => "links.getStats",
# :urls => url, :callback => "fb_sharepro_render", :format => "json" ), :selector => "total_count"
# }
# end
# def self.linkedin url, raise_exceptions = false
# try("linkedin", url, raise_exceptions) {
# extract_count from_json("http://www.linkedin.com/cws/share-count",
# :url => url, :callback => "IN.Tags.Share.handleCount" ), :selector => "count"
# }
# end
def self.googleplus url
begin
url = "https://plusone.google.com/_/+1/fastbutton?url=" + URI::encode(url)
html = RestClient.get url
return Nokogiri::HTML.parse(html).xpath('//*[@id="aggregateCount"]').text.to_i
rescue Exception => e
puts e
end
end
# def self.all url
# supported_networks.inject({}) { |r, c| r[c.to_sym] = ShareCounts.send(c, url); r }
# end
# def self.selected url, selections
# selections.map{|name| name.downcase}.select{|name| supported_networks.include? name.to_s}.inject({}) {
# |r, c| r[c.to_sym] = ShareCounts.send(c, url); r }
# end
end
linkedin, twitter and facebook
class ShareCounter
# require 'share-counter/common'
# require 'json'
require 'rest-client'
require 'nokogiri'
require 'open-uri'
def self.twitter url
url = "http://urls.api.twitter.com/1/urls/count.json?url=" + URI::encode(url)
html = RestClient.get url
return JSON.parse(html)['count']
end
def self.facebook url
url = 'https://api.facebook.com/method/fql.query?format=json&query=select like_count from link_stat where url="' + url + '"'
url = URI::encode(url)
html = RestClient.get url
return JSON.parse(html)[0]['like_count']
end
def self.linkedin url
url = "http://www.linkedin.com/countserv/count/share?url=" + URI::encode(url)
html = RestClient.get url
callback = "IN.Tags.Share.handleCount"
html = html.gsub(/\A\/\*\*\/\s+/, "").gsub(/^(.*);+\n*$/, "\\1").gsub(/^#{callback}\((.*)\)$/, "\\1")
return JSON.parse(html)['count']
end
def self.googleplus url
begin
url = "https://plusone.google.com/_/+1/fastbutton?url=" + URI::encode(url)
html = RestClient.get url
return Nokogiri::HTML.parse(html).xpath('//*[@id="aggregateCount"]').text.to_i
rescue Exception => e
puts e
end
end
# def self.all url
# supported_networks.inject({}) { |r, c| r[c.to_sym] = ShareCounts.send(c, url); r }
# end
# def self.selected url, selections
# selections.map{|name| name.downcase}.select{|name| supported_networks.include? name.to_s}.inject({}) {
# |r, c| r[c.to_sym] = ShareCounts.send(c, url); r }
# end
end
# url = "http://makeshift.io/"
# puts ShareCounter.googleplus url
# puts ShareCounter.linkedin url
# puts ShareCounter.twitter url
# puts ShareCounter.facebook url
|
require "shield_square/version"
require 'cgi'
require 'rest-client'
require 'addressable/uri'
module ShieldSquare
class URI::Parser
def split url
a = Addressable::URI::parse url
[a.scheme, a.userinfo, a.host, a.port, nil, a.path, nil, a.query, a.fragment]
end
end
class << self
def setup
yield config
end
def config
@config ||= Configuration.new
end
#Request Variables
$ShieldsquareRequest_zpsbd0 = false
$ShieldsquareRequest_zpsbd1 = ""
$ShieldsquareRequest_zpsbd2 = ""
$ShieldsquareRequest_zpsbd3 = ""
$ShieldsquareRequest_zpsbd4 = ""
$ShieldsquareRequest_zpsbd5 = ""
$ShieldsquareRequest_zpsbd6 = ""
$ShieldsquareRequest_zpsbd7 = ""
$ShieldsquareRequest_zpsbd8 = ""
$ShieldsquareRequest_zpsbd9 = ""
$ShieldsquareRequest_zpsbda = ""
$ShieldsquareRequest__uzma = ""
$ShieldsquareRequest__uzmb = 0
$ShieldsquareRequest__uzmc = ""
$ShieldsquareRequest__uzmd = 0
#Curl Response Variables
$ShieldsquareCurlResponseCode_error_string = ""
$ShieldsquareCurlResponseCode_responsecode = 0
#Response Variables
$ShieldsquareResponse_pid = ""
$ShieldsquareResponse_responsecode= 0
$ShieldsquareResponse_url = ""
$ShieldsquareResponse_reason =""
#Codes Variables
$ShieldsquareCodes_ALLOW = 0
$ShieldsquareCodes_MONITOR = 1
$ShieldsquareCodes_CAPTCHA = 2
$ShieldsquareCodes_BLOCK = 3
$ShieldsquareCodes_FFD = 4
$ShieldsquareCodes_ALLOW_EXP = -1
$IP_ADDRESS
def self.shieldsquare_ValidateRequest( shieldsquare_username, shieldsquare_calltype, request, cookies )
shieldsquare_low = 10000
shieldsquare_high = 99999
shieldsquare_a = 1
shieldsquare_b = 3
shieldsquare_c = 7
shieldsquare_d = 1
shieldsquare_e = 5
shieldsquare_f = 10
shieldsquare_service_url = "http://" + config.$_ss2_domain + "/getRequestData"
$IP_ADDRESS = request.remote_ip
if config.$_timeout_value > 1000
puts "Content-type: text/html"
puts ''
puts 'ShieldSquare Timeout cant be greater then 1000 Milli seconds'
exit
end
if shieldsquare_calltype == 1
shieldsquare_pid = shieldsquare_generate_pid config.$_sid
else
if shieldsquare_pid.length == 0
puts "Content-type: text/html"
puts ''
puts 'PID Cant be null'
exit
end
end
if cookies['__uzma']!="" and (cookies['__uzma'].to_s).length > 3
shieldsquare_lastaccesstime = cookies['__uzmd']
shieldsquare_uzmc=0
shieldsquare_uzmc= cookies['__uzmc']
shieldsquare_uzmc=shieldsquare_uzmc[shieldsquare_e..shieldsquare_e+1]
shieldsquare_a = ((shieldsquare_uzmc.to_i-shieldsquare_c)/shieldsquare_b) + shieldsquare_d
shieldsquare_uzmc= rand(shieldsquare_low..shieldsquare_high).to_s + (shieldsquare_c+shieldsquare_a*shieldsquare_b).to_s + rand(shieldsquare_low..shieldsquare_high).to_s
cookies[:__uzmc] = { :value => shieldsquare_uzmc, :expires => Time.now + 3600*24*365*10}
cookies[:__uzmd] = { :value => Time.now.to_i.to_s, :expires => Time.now + 3600*24*365*10}
$ShieldsquareRequest__uzma = cookies["__uzma"]
$ShieldsquareRequest__uzmb = cookies["__uzmb"]
$ShieldsquareRequest__uzmc = shieldsquare_uzmc
$ShieldsquareRequest__uzmd = shieldsquare_lastaccesstime
else
id = DateTime.now.strftime('%Q')# Get current date to the milliseconds
# Reverse it
shieldsquare_uzma = id.to_i(36).to_s
shieldsquare_lastaccesstime = Time.now.to_i
shieldsquare_uzmc= rand(shieldsquare_low..shieldsquare_high).to_s + (shieldsquare_c+shieldsquare_a*shieldsquare_b).to_s + rand(shieldsquare_low..shieldsquare_high).to_s
cookies[:__uzma] = { :value => shieldsquare_uzma, :expires => Time.now + 3600*24*365*10}
cookies[:__uzmb] = { :value => Time.now.to_i.to_s, :expires => Time.now + 3600*24*365*10}
cookies[:__uzmc] = { :value => shieldsquare_uzmc, :expires => Time.now + 3600*24*365*10}
cookies[:__uzmd] = { :value => Time.now.to_i.to_s, :expires => Time.now + 3600*24*365*10}
$ShieldsquareRequest__uzma = shieldsquare_uzma
$ShieldsquareRequest__uzmb = Time.now.to_i
$ShieldsquareRequest__uzmc = shieldsquare_uzmc
$ShieldsquareRequest__uzmd = shieldsquare_lastaccesstime
end
if $_mode == 'Active'
$ShieldsquareRequest_zpsbd0 = true;
else
$ShieldsquareRequest_zpsbd0 = false;
end
$ShieldsquareRequest_zpsbd1 = config.$_sid
$ShieldsquareRequest_zpsbd2 = shieldsquare_pid
$ShieldsquareRequest_zpsbd3 = request.headers['HTTP_REFERER']
$ShieldsquareRequest_zpsbd4 = request.headers['REQUEST_URI']
$ShieldsquareRequest_zpsbd5 = request.session_options[:id]
$ShieldsquareRequest_zpsbd6 = $IP_ADDRESS
$ShieldsquareRequest_zpsbd7 = request.headers['HTTP_USER_AGENT']
$ShieldsquareRequest_zpsbd8 = shieldsquare_calltype
$ShieldsquareRequest_zpsbd9 = shieldsquare_username
$ShieldsquareRequest_zpsbda = Time.now.to_i
my_hash = {:_zpsbd0 => $ShieldsquareRequest_zpsbd0,:_zpsbd1 => $ShieldsquareRequest_zpsbd1,:_zpsbd2 => $ShieldsquareRequest_zpsbd2,:_zpsbd3 => $ShieldsquareRequest_zpsbd3,:_zpsbd4 => $ShieldsquareRequest_zpsbd4,:_zpsbd5 => $ShieldsquareRequest_zpsbd5,:_zpsbd6 => $ShieldsquareRequest_zpsbd6,:_zpsbd7 => $ShieldsquareRequest_zpsbd7,:_zpsbd8 => $ShieldsquareRequest_zpsbd8,:_zpsbd9 => $ShieldsquareRequest_zpsbd9,:_zpsbda => $ShieldsquareRequest_zpsbda,:__uzma => $ShieldsquareRequest__uzma,:__uzmb => $ShieldsquareRequest__uzmb,:__uzmc => $ShieldsquareRequest__uzmc,:__uzmd => $ShieldsquareRequest__uzmd }
shieldsquare_json_obj = JSON.generate(my_hash)
$ShieldsquareResponse_pid = shieldsquare_pid
$ShieldsquareResponse_url = config.$_js_url
if config.$_mode == 'Active'
shieldsquareCurlResponseCode=shieldsquare_post_sync shieldsquare_service_url, shieldsquare_json_obj,config.$_timeout_value
if shieldsquareCurlResponseCode['response'] != 200
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_ALLOW_EXP
$ShieldsquareResponse_reason = shieldsquareCurlResponseCode['output']
else
shieldsquareResponse_from_ss = JSON.parse(shieldsquareCurlResponseCode['output'])
$ShieldsquareResponse_dynamic_JS = shieldsquareResponse_from_ss['dynamic_JS']
n=shieldsquareResponse_from_ss['ssresp'].to_i
if n==0
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_ALLOW
elsif n==1
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_MONITOR
elsif n==2
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_CAPTCHA
elsif n==3
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_BLOCK
elsif n==4
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_FFD
else
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_ALLOW_EXP
$ShieldsquareResponse_reason = shieldsquareCurlResponseCode['output']
end
end
else
if $_async_http_post == true
asyncresponse=shieldsquare_post_async shieldsquare_service_url, shieldsquare_json_obj,config.$_timeout_value.to_s
if asyncresponse['response'] == false
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_ALLOW_EXP
$ShieldsquareResponse_reason = "Request Timed Out/Server Not Reachable"
else
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_ALLOW
end
else
syncresponse=shieldsquare_post_sync shieldsquare_service_url, shieldsquare_json_obj,config.$_timeout_value
if syncresponse['response'] != 200
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_ALLOW_EXP
$ShieldsquareResponse_reason = syncresponse['output']
else
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_ALLOW
end
end
$ShieldsquareResponse_dynamic_JS = "var __uzdbm_c = 2+2"
end
shieldsquareResponse = Hash["pid" => $ShieldsquareResponse_pid, "responsecode" => $ShieldsquareResponse_responsecode,"url" => $ShieldsquareResponse_url,"reason" => $ShieldsquareResponse_reason,"dynamic_JS" =>$ShieldsquareResponse_dynamic_JS]
return shieldsquareResponse
end
def self.shieldsquare_post_sync(url, payload, timeout)
# Sendind the Data to the ShieldSquare Server
params=payload
headers={}
headers['Content-Type']='application/json'
headers['Accept']='application/json'
begin
response = RestClient::Request.execute(:method => :post, :url => url, :headers => headers, :timeout => timeout, :payload => params)
# c.http_post(params)
# response=Hash["response"=>c.response_code,"output"=>c.body_str]
rescue RestClient::Exception => e
response=Hash["response"=>0,"output"=>"Request Timed Out/Server Not Reachable"]
end
return response
end
def self.microtime()
epoch_mirco = Time.now.to_f
epoch_full = Time.now.to_i
epoch_fraction = epoch_mirco - epoch_full
return epoch_fraction.to_s + ' ' + epoch_full.to_s
end
def self.shieldsquare_generate_pid(shieldsquare_sid)
t=microtime
dt=t.split(" ")
p = config.$_sid.split("-")
sid_min = p[3].to_i(16)
rmstr1=("00000000"+(dt[1].to_i).to_s(16)).split(//).last(4).join("").to_s
rmstr2=("0000" + ((dt[0].to_f * 65536).round).to_s(16)).split(//).last(4).join("").to_s
return sprintf('%08s-%04x-%04s-%04s-%04x%04x%04x', shieldsquare_IP2Hex(),sid_min,rmstr1,rmstr2,(rand() * 0xffff).to_i,(rand() * 0xffff).to_i,(rand() * 0xffff).to_i)
end
def self.shieldsquare_IP2Hex()
hexx=""
ip=$IP_ADDRESS
part=ip.split('.')
hexx=''
for i in 0..part.count-1
hexx= hexx + ("0"+(part[i].to_i).to_s(16)).split(//).last(2).join("").to_s
end
return hexx
end
end
end
fixed syntax error
require "shield_square/version"
require 'cgi'
require 'rest-client'
require 'addressable/uri'
module ShieldSquare
class URI::Parser
def split url
a = Addressable::URI::parse url
[a.scheme, a.userinfo, a.host, a.port, nil, a.path, nil, a.query, a.fragment]
end
end
class << self
def setup
yield config
end
def config
@config ||= Configuration.new
end
#Request Variables
$ShieldsquareRequest_zpsbd0 = false
$ShieldsquareRequest_zpsbd1 = ""
$ShieldsquareRequest_zpsbd2 = ""
$ShieldsquareRequest_zpsbd3 = ""
$ShieldsquareRequest_zpsbd4 = ""
$ShieldsquareRequest_zpsbd5 = ""
$ShieldsquareRequest_zpsbd6 = ""
$ShieldsquareRequest_zpsbd7 = ""
$ShieldsquareRequest_zpsbd8 = ""
$ShieldsquareRequest_zpsbd9 = ""
$ShieldsquareRequest_zpsbda = ""
$ShieldsquareRequest__uzma = ""
$ShieldsquareRequest__uzmb = 0
$ShieldsquareRequest__uzmc = ""
$ShieldsquareRequest__uzmd = 0
#Curl Response Variables
$ShieldsquareCurlResponseCode_error_string = ""
$ShieldsquareCurlResponseCode_responsecode = 0
#Response Variables
$ShieldsquareResponse_pid = ""
$ShieldsquareResponse_responsecode= 0
$ShieldsquareResponse_url = ""
$ShieldsquareResponse_reason =""
#Codes Variables
$ShieldsquareCodes_ALLOW = 0
$ShieldsquareCodes_MONITOR = 1
$ShieldsquareCodes_CAPTCHA = 2
$ShieldsquareCodes_BLOCK = 3
$ShieldsquareCodes_FFD = 4
$ShieldsquareCodes_ALLOW_EXP = -1
$IP_ADDRESS
def self.shieldsquare_ValidateRequest( shieldsquare_username, shieldsquare_calltype, request, cookies )
shieldsquare_low = 10000
shieldsquare_high = 99999
shieldsquare_a = 1
shieldsquare_b = 3
shieldsquare_c = 7
shieldsquare_d = 1
shieldsquare_e = 5
shieldsquare_f = 10
shieldsquare_service_url = "http://" + ShieldSquare.config.$_ss2_domain + "/getRequestData"
$IP_ADDRESS = request.remote_ip
if ShieldSquare.config.$_timeout_value > 1000
puts "Content-type: text/html"
puts ''
puts 'ShieldSquare Timeout cant be greater then 1000 Milli seconds'
exit
end
if shieldsquare_calltype == 1
shieldsquare_pid = shieldsquare_generate_pid ShieldSquare.config.$_sid
else
if shieldsquare_pid.length == 0
puts "Content-type: text/html"
puts ''
puts 'PID Cant be null'
exit
end
end
if cookies['__uzma']!="" and (cookies['__uzma'].to_s).length > 3
shieldsquare_lastaccesstime = cookies['__uzmd']
shieldsquare_uzmc=0
shieldsquare_uzmc= cookies['__uzmc']
shieldsquare_uzmc=shieldsquare_uzmc[shieldsquare_e..shieldsquare_e+1]
shieldsquare_a = ((shieldsquare_uzmc.to_i-shieldsquare_c)/shieldsquare_b) + shieldsquare_d
shieldsquare_uzmc= rand(shieldsquare_low..shieldsquare_high).to_s + (shieldsquare_c+shieldsquare_a*shieldsquare_b).to_s + rand(shieldsquare_low..shieldsquare_high).to_s
cookies[:__uzmc] = { :value => shieldsquare_uzmc, :expires => Time.now + 3600*24*365*10}
cookies[:__uzmd] = { :value => Time.now.to_i.to_s, :expires => Time.now + 3600*24*365*10}
$ShieldsquareRequest__uzma = cookies["__uzma"]
$ShieldsquareRequest__uzmb = cookies["__uzmb"]
$ShieldsquareRequest__uzmc = shieldsquare_uzmc
$ShieldsquareRequest__uzmd = shieldsquare_lastaccesstime
else
id = DateTime.now.strftime('%Q')# Get current date to the milliseconds
# Reverse it
shieldsquare_uzma = id.to_i(36).to_s
shieldsquare_lastaccesstime = Time.now.to_i
shieldsquare_uzmc= rand(shieldsquare_low..shieldsquare_high).to_s + (shieldsquare_c+shieldsquare_a*shieldsquare_b).to_s + rand(shieldsquare_low..shieldsquare_high).to_s
cookies[:__uzma] = { :value => shieldsquare_uzma, :expires => Time.now + 3600*24*365*10}
cookies[:__uzmb] = { :value => Time.now.to_i.to_s, :expires => Time.now + 3600*24*365*10}
cookies[:__uzmc] = { :value => shieldsquare_uzmc, :expires => Time.now + 3600*24*365*10}
cookies[:__uzmd] = { :value => Time.now.to_i.to_s, :expires => Time.now + 3600*24*365*10}
$ShieldsquareRequest__uzma = shieldsquare_uzma
$ShieldsquareRequest__uzmb = Time.now.to_i
$ShieldsquareRequest__uzmc = shieldsquare_uzmc
$ShieldsquareRequest__uzmd = shieldsquare_lastaccesstime
end
if $_mode == 'Active'
$ShieldsquareRequest_zpsbd0 = true;
else
$ShieldsquareRequest_zpsbd0 = false;
end
$ShieldsquareRequest_zpsbd1 = ShieldSquare.config.$_sid
$ShieldsquareRequest_zpsbd2 = shieldsquare_pid
$ShieldsquareRequest_zpsbd3 = request.headers['HTTP_REFERER']
$ShieldsquareRequest_zpsbd4 = request.headers['REQUEST_URI']
$ShieldsquareRequest_zpsbd5 = request.session_options[:id]
$ShieldsquareRequest_zpsbd6 = $IP_ADDRESS
$ShieldsquareRequest_zpsbd7 = request.headers['HTTP_USER_AGENT']
$ShieldsquareRequest_zpsbd8 = shieldsquare_calltype
$ShieldsquareRequest_zpsbd9 = shieldsquare_username
$ShieldsquareRequest_zpsbda = Time.now.to_i
my_hash = {:_zpsbd0 => $ShieldsquareRequest_zpsbd0,:_zpsbd1 => $ShieldsquareRequest_zpsbd1,:_zpsbd2 => $ShieldsquareRequest_zpsbd2,:_zpsbd3 => $ShieldsquareRequest_zpsbd3,:_zpsbd4 => $ShieldsquareRequest_zpsbd4,:_zpsbd5 => $ShieldsquareRequest_zpsbd5,:_zpsbd6 => $ShieldsquareRequest_zpsbd6,:_zpsbd7 => $ShieldsquareRequest_zpsbd7,:_zpsbd8 => $ShieldsquareRequest_zpsbd8,:_zpsbd9 => $ShieldsquareRequest_zpsbd9,:_zpsbda => $ShieldsquareRequest_zpsbda,:__uzma => $ShieldsquareRequest__uzma,:__uzmb => $ShieldsquareRequest__uzmb,:__uzmc => $ShieldsquareRequest__uzmc,:__uzmd => $ShieldsquareRequest__uzmd }
shieldsquare_json_obj = JSON.generate(my_hash)
$ShieldsquareResponse_pid = shieldsquare_pid
$ShieldsquareResponse_url = ShieldSquare.config.$_js_url
if ShieldSquare.config.$_mode == 'Active'
shieldsquareCurlResponseCode=shieldsquare_post_sync shieldsquare_service_url, shieldsquare_json_obj,ShieldSquare.config.$_timeout_value
if shieldsquareCurlResponseCode['response'] != 200
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_ALLOW_EXP
$ShieldsquareResponse_reason = shieldsquareCurlResponseCode['output']
else
shieldsquareResponse_from_ss = JSON.parse(shieldsquareCurlResponseCode['output'])
$ShieldsquareResponse_dynamic_JS = shieldsquareResponse_from_ss['dynamic_JS']
n=shieldsquareResponse_from_ss['ssresp'].to_i
if n==0
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_ALLOW
elsif n==1
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_MONITOR
elsif n==2
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_CAPTCHA
elsif n==3
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_BLOCK
elsif n==4
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_FFD
else
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_ALLOW_EXP
$ShieldsquareResponse_reason = shieldsquareCurlResponseCode['output']
end
end
else
if $_async_http_post == true
asyncresponse=shieldsquare_post_async shieldsquare_service_url, shieldsquare_json_obj,ShieldSquare.config.$_timeout_value.to_s
if asyncresponse['response'] == false
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_ALLOW_EXP
$ShieldsquareResponse_reason = "Request Timed Out/Server Not Reachable"
else
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_ALLOW
end
else
syncresponse=shieldsquare_post_sync shieldsquare_service_url, shieldsquare_json_obj,ShieldSquare.config.$_timeout_value
if syncresponse['response'] != 200
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_ALLOW_EXP
$ShieldsquareResponse_reason = syncresponse['output']
else
$ShieldsquareResponse_responsecode = $ShieldsquareCodes_ALLOW
end
end
$ShieldsquareResponse_dynamic_JS = "var __uzdbm_c = 2+2"
end
shieldsquareResponse = Hash["pid" => $ShieldsquareResponse_pid, "responsecode" => $ShieldsquareResponse_responsecode,"url" => $ShieldsquareResponse_url,"reason" => $ShieldsquareResponse_reason,"dynamic_JS" =>$ShieldsquareResponse_dynamic_JS]
return shieldsquareResponse
end
def self.shieldsquare_post_sync(url, payload, timeout)
# Sendind the Data to the ShieldSquare Server
params=payload
headers={}
headers['Content-Type']='application/json'
headers['Accept']='application/json'
begin
response = RestClient::Request.execute(:method => :post, :url => url, :headers => headers, :timeout => timeout, :payload => params)
# c.http_post(params)
# response=Hash["response"=>c.response_code,"output"=>c.body_str]
rescue RestClient::Exception => e
response=Hash["response"=>0,"output"=>"Request Timed Out/Server Not Reachable"]
end
return response
end
def self.microtime()
epoch_mirco = Time.now.to_f
epoch_full = Time.now.to_i
epoch_fraction = epoch_mirco - epoch_full
return epoch_fraction.to_s + ' ' + epoch_full.to_s
end
def self.shieldsquare_generate_pid(shieldsquare_sid)
t=microtime
dt=t.split(" ")
p = ShieldSquare.config.$_sid.split("-")
sid_min = p[3].to_i(16)
rmstr1=("00000000"+(dt[1].to_i).to_s(16)).split(//).last(4).join("").to_s
rmstr2=("0000" + ((dt[0].to_f * 65536).round).to_s(16)).split(//).last(4).join("").to_s
return sprintf('%08s-%04x-%04s-%04s-%04x%04x%04x', shieldsquare_IP2Hex(),sid_min,rmstr1,rmstr2,(rand() * 0xffff).to_i,(rand() * 0xffff).to_i,(rand() * 0xffff).to_i)
end
def self.shieldsquare_IP2Hex()
hexx=""
ip=$IP_ADDRESS
part=ip.split('.')
hexx=''
for i in 0..part.count-1
hexx= hexx + ("0"+(part[i].to_i).to_s(16)).split(//).last(2).join("").to_s
end
return hexx
end
end
end
|
require 'cfpropertylist'
require 'ostruct'
require 'simctl/device_path'
require 'simctl/device_settings'
require 'simctl/object'
require 'timeout'
module SimCtl
class Device < Object
attr_reader :availability, :name, :os, :state, :udid
# Boots the device
#
# @return [void]
def boot
SimCtl.boot_device(self)
end
# Deletes the device
#
# @return [void]
def delete
SimCtl.delete_device(self)
end
# Returns the device type
#
# @return [SimCtl::DeviceType]
def devicetype
@devicetype ||= SimCtl.devicetype(identifier: plist.deviceType)
end
# Erases the device
#
# @return [void]
def erase
SimCtl.erase_device(self)
end
# Installs an app on a device
#
# @param path Absolute path to the app that should be installed
# @return [void]
def install(path)
SimCtl.install_app(self, path)
end
# Uninstall an app from a device
#
# @param app_id App identifier of the app that should be uninstalled
# @return [void]
def uninstall(app_id)
SimCtl.uninstall_app(self, app_id)
end
# Kills the device
#
# @return [void]
def kill
SimCtl.kill_device(self)
end
# Launches the Simulator
#
# @return [void]
def launch(scale=1.0, opts={})
SimCtl.launch_device(self, scale, opts)
end
# Launches an app in the given device
#
# @param opts [Hash] options hash - `{ wait_for_debugger: true/false }`
# @param identifier [String] the app identifier
# @param args [Array] optional launch arguments
# @return [void]
def launch_app(identifier, args=[], opts={})
SimCtl.launch_app(self, identifier, args, opts)
end
# Opens the url on the device
#
# @param url [String] The url to be opened on the device
# @return [void]
def open_url(url)
SimCtl.open_url(self, url)
end
def path
@path ||= DevicePath.new(self)
end
# Reloads the device information
#
# @return [void]
def reload
device = SimCtl.device(udid: udid)
device.instance_variables.each do |ivar|
instance_variable_set(ivar, device.instance_variable_get(ivar))
end
end
# Renames the device
#
# @return [void]
def rename(name)
SimCtl.rename_device(self, name)
@name = name
end
# Resets the device
#
# @return [void]
def reset
SimCtl.reset_device name, devicetype, runtime
end
# Resets the runtime
#
# @return [SimCtl::Runtime]
def runtime
@runtime ||= SimCtl.runtime(identifier: plist.runtime)
end
# Saves a screenshot to a file
#
# @param file Path where the screenshot should be saved to
# @param opts Optional hash that supports two keys:
# * type: Can be png, tiff, bmp, gif, jpeg (default is png)
# * display: Can be main or tv for iOS, tv for tvOS and main for watchOS
# @return [void]
def screenshot(file, opts={})
SimCtl.screenshot(self, file, opts)
end
# Returns the settings object
#
# @ return [SimCtl::DeviceSettings]
def settings
@settings ||= DeviceSettings.new(path)
end
# Shuts down the runtime
#
# @return [void]
def shutdown
SimCtl.shutdown_device(self)
end
# Returns the state of the device
#
# @return [sym]
def state
@state.downcase.to_sym
end
# Reloads the device until the given block returns true
#
# @return [void]
def wait(timeout=SimCtl.default_timeout)
Timeout::timeout(timeout) do
loop do
break if yield SimCtl.device(udid: udid)
end
end
reload
end
def ==(other)
return false if other.nil?
return false unless other.kind_of? Device
other.udid == udid
end
def method_missing(method_name, *args, &block)
if method_name[-1] == '!'
new_method_name = method_name.to_s.chop.to_sym
if respond_to?(new_method_name)
warn "[#{Kernel.caller.first}] `#{method_name}` is deprecated. Please use `#{new_method_name}` instead."
return send(new_method_name, &block)
end
end
super
end
private
def plist
@plist ||= OpenStruct.new(CFPropertyList.native_types(CFPropertyList::List.new(file: path.device_plist).value))
end
end
end
Add available method
require 'cfpropertylist'
require 'ostruct'
require 'simctl/device_path'
require 'simctl/device_settings'
require 'simctl/object'
require 'timeout'
module SimCtl
class Device < Object
attr_reader :availability, :name, :os, :state, :udid
# Returns true/false if the device is available
#
# @return [Bool]
def available?
availability !~ /unavailable/i
end
# Boots the device
#
# @return [void]
def boot
SimCtl.boot_device(self)
end
# Deletes the device
#
# @return [void]
def delete
SimCtl.delete_device(self)
end
# Returns the device type
#
# @return [SimCtl::DeviceType]
def devicetype
@devicetype ||= SimCtl.devicetype(identifier: plist.deviceType)
end
# Erases the device
#
# @return [void]
def erase
SimCtl.erase_device(self)
end
# Installs an app on a device
#
# @param path Absolute path to the app that should be installed
# @return [void]
def install(path)
SimCtl.install_app(self, path)
end
# Uninstall an app from a device
#
# @param app_id App identifier of the app that should be uninstalled
# @return [void]
def uninstall(app_id)
SimCtl.uninstall_app(self, app_id)
end
# Kills the device
#
# @return [void]
def kill
SimCtl.kill_device(self)
end
# Launches the Simulator
#
# @return [void]
def launch(scale=1.0, opts={})
SimCtl.launch_device(self, scale, opts)
end
# Launches an app in the given device
#
# @param opts [Hash] options hash - `{ wait_for_debugger: true/false }`
# @param identifier [String] the app identifier
# @param args [Array] optional launch arguments
# @return [void]
def launch_app(identifier, args=[], opts={})
SimCtl.launch_app(self, identifier, args, opts)
end
# Opens the url on the device
#
# @param url [String] The url to be opened on the device
# @return [void]
def open_url(url)
SimCtl.open_url(self, url)
end
def path
@path ||= DevicePath.new(self)
end
# Reloads the device information
#
# @return [void]
def reload
device = SimCtl.device(udid: udid)
device.instance_variables.each do |ivar|
instance_variable_set(ivar, device.instance_variable_get(ivar))
end
end
# Renames the device
#
# @return [void]
def rename(name)
SimCtl.rename_device(self, name)
@name = name
end
# Resets the device
#
# @return [void]
def reset
SimCtl.reset_device name, devicetype, runtime
end
# Resets the runtime
#
# @return [SimCtl::Runtime]
def runtime
@runtime ||= SimCtl.runtime(identifier: plist.runtime)
end
# Saves a screenshot to a file
#
# @param file Path where the screenshot should be saved to
# @param opts Optional hash that supports two keys:
# * type: Can be png, tiff, bmp, gif, jpeg (default is png)
# * display: Can be main or tv for iOS, tv for tvOS and main for watchOS
# @return [void]
def screenshot(file, opts={})
SimCtl.screenshot(self, file, opts)
end
# Returns the settings object
#
# @ return [SimCtl::DeviceSettings]
def settings
@settings ||= DeviceSettings.new(path)
end
# Shuts down the runtime
#
# @return [void]
def shutdown
SimCtl.shutdown_device(self)
end
# Returns the state of the device
#
# @return [sym]
def state
@state.downcase.to_sym
end
# Reloads the device until the given block returns true
#
# @return [void]
def wait(timeout=SimCtl.default_timeout)
Timeout::timeout(timeout) do
loop do
break if yield SimCtl.device(udid: udid)
end
end
reload
end
def ==(other)
return false if other.nil?
return false unless other.kind_of? Device
other.udid == udid
end
def method_missing(method_name, *args, &block)
if method_name[-1] == '!'
new_method_name = method_name.to_s.chop.to_sym
if respond_to?(new_method_name)
warn "[#{Kernel.caller.first}] `#{method_name}` is deprecated. Please use `#{new_method_name}` instead."
return send(new_method_name, &block)
end
end
super
end
private
def plist
@plist ||= OpenStruct.new(CFPropertyList.native_types(CFPropertyList::List.new(file: path.device_plist).value))
end
end
end
|
require 'simple-daemon/version'
require 'fileutils'
module SimpleDaemon
class Base
def self.classname
underscore(name.split("::").last)
end
def self.pid_fn
File.join(SimpleDaemon::WORKING_DIRECTORY, "#{classname}.pid")
end
def self.daemonize
Controller.daemonize(self)
end
private
def underscore(camel_cased_word)
camel_cased_word.to_s.
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr("-", "_").
downcase
end
end
module PidFile
def self.store(daemon, pid)
File.open(daemon.pid_fn, 'w') {|f| f << pid}
end
def self.recall(daemon)
IO.read(daemon.pid_fn).to_i rescue nil
end
end
module Controller
def self.daemonize(daemon)
case !ARGV.empty? && ARGV[0]
when 'start'
start(daemon)
when 'stop'
stop(daemon)
when 'restart'
stop(daemon)
start(daemon)
else
puts "Invalid command. Please specify start, stop or restart."
exit
end
end
def self.start(daemon)
fork do
Process.setsid
exit if fork
PidFile.store(daemon, Process.pid)
Dir.chdir SimpleDaemon::WORKING_DIRECTORY
File.umask 0000
log = File.new("#{daemon.classname}.log", "a")
STDIN.reopen "/dev/null"
STDOUT.reopen log
STDERR.reopen STDOUT
trap("TERM") {daemon.stop; exit}
daemon.start
end
puts "Daemon started."
end
def self.stop(daemon)
if !File.file?(daemon.pid_fn)
puts "Pid file not found. Is the daemon started?"
exit
end
pid = PidFile.recall(daemon)
FileUtils.rm(daemon.pid_fn)
pid && Process.kill("TERM", pid)
rescue Errno::ESRCH
puts "Pid file found, but process was not running. The daemon may have died."
end
end
end
it is a private class method
require 'simple-daemon/version'
require 'fileutils'
module SimpleDaemon
class Base
def self.classname
underscore(name.split("::").last)
end
def self.pid_fn
File.join(SimpleDaemon::WORKING_DIRECTORY, "#{classname}.pid")
end
def self.daemonize
Controller.daemonize(self)
end
private
def self.underscore(camel_cased_word)
camel_cased_word.to_s.
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr("-", "_").
downcase
end
end
module PidFile
def self.store(daemon, pid)
File.open(daemon.pid_fn, 'w') {|f| f << pid}
end
def self.recall(daemon)
IO.read(daemon.pid_fn).to_i rescue nil
end
end
module Controller
def self.daemonize(daemon)
case !ARGV.empty? && ARGV[0]
when 'start'
start(daemon)
when 'stop'
stop(daemon)
when 'restart'
stop(daemon)
start(daemon)
else
puts "Invalid command. Please specify start, stop or restart."
exit
end
end
def self.start(daemon)
fork do
Process.setsid
exit if fork
PidFile.store(daemon, Process.pid)
Dir.chdir SimpleDaemon::WORKING_DIRECTORY
File.umask 0000
log = File.new("#{daemon.classname}.log", "a")
STDIN.reopen "/dev/null"
STDOUT.reopen log
STDERR.reopen STDOUT
trap("TERM") {daemon.stop; exit}
daemon.start
end
puts "Daemon started."
end
def self.stop(daemon)
if !File.file?(daemon.pid_fn)
puts "Pid file not found. Is the daemon started?"
exit
end
pid = PidFile.recall(daemon)
FileUtils.rm(daemon.pid_fn)
pid && Process.kill("TERM", pid)
rescue Errno::ESRCH
puts "Pid file found, but process was not running. The daemon may have died."
end
end
end
|
require 'compass'
require 'breakpoint'
Compass::Frameworks.register("singularitygs", :path => "#{File.dirname(__FILE__)}/..")
module SingularityGS
VERSION = "1.0.8"
DATE = "2013-04-25"
end
Updated Version Number
require 'compass'
require 'breakpoint'
Compass::Frameworks.register("singularitygs", :path => "#{File.dirname(__FILE__)}/..")
module SingularityGS
VERSION = "1.1.0"
DATE = "2013-07-18"
end |
require 'social_stream-base'
require 'social_stream-documents'
require 'social_stream-events'
module SocialStream
class Engine < ::Rails::Engine #:nodoc:
config.app_generators.base 'social_stream:base'
config.app_generators.documents 'social_stream:documents'
config.app_generators.events 'social_stream:events'
end
end
Modify activity_form order
require 'social_stream-base'
require 'social_stream-documents'
require 'social_stream-events'
module SocialStream
# Put :group at the end of activity_forms
activity_forms.delete(:group)
activity_forms.push(:group)
class Engine < ::Rails::Engine #:nodoc:
config.app_generators.base 'social_stream:base'
config.app_generators.documents 'social_stream:documents'
config.app_generators.events 'social_stream:events'
end
end
|
# This class is used to transform a Song object into an equivalent Song object whose
# sample data will be generated faster by the audio engine.
#
# The primary method is optimize(). Currently, it performs two optimizations:
#
# 1.) Breaks patterns into shorter patterns. Generating one long Pattern is generally
# slower than generating several short Patterns with the same combined length.
# 2.) Replaces Patterns which are equivalent (i.e. they have the same tracks with the
# same rhythms) with one canonical Pattern. This allows for better caching, by
# preventing the audio engine from generating the same sample data more than once.
#
# Note that step #1 actually performs double duty, because breaking Patterns into smaller
# pieces increases the likelihood there will be duplicates that can be combined.
class SongOptimizer
def initialize()
end
# Returns a Song that will produce the same output as original_song, but should be
# generated faster.
def optimize(original_song, max_pattern_length)
# 1.) Create a new song, cloned from the original
optimized_song = original_song.copy_ignoring_patterns_and_flow()
# 2.) Subdivide patterns
optimized_song = subdivide_song_patterns(original_song, optimized_song, max_pattern_length)
# 3.) Prune duplicate patterns
optimized_song = prune_duplicate_patterns(optimized_song)
return optimized_song
end
protected
# Splits the patterns of a Song into smaller patterns, each one with at most
# max_pattern_length steps. For example, if max_pattern_length is 4, then
# the following pattern:
#
# track1: X...X...X.
# track2: ..X.....X.
# track3: X.X.X.X.X.
#
# will be converted into the following 3 patterns:
#
# track1: X...
# track2: ..X.
# track3: X.X.
#
# track1: X...
# track3: X.X.
#
# track1: X.
# track2: X.
# track3: X.
#
# Note that if a track in a sub-divided pattern has no triggers (such as track2 in the
# 2nd pattern above), it will not be included in the new pattern.
def subdivide_song_patterns(original_song, optimized_song, max_pattern_length)
blank_track_pattern = '.' * max_pattern_length
# For each pattern, add a new pattern to new song every max_pattern_length steps
optimized_flow = {}
original_song.patterns.values.each do |pattern|
step_index = 0
optimized_flow[pattern.name] = []
while(pattern.tracks.values.first.rhythm[step_index] != nil) do
# TODO: Is this pattern 100% sufficient to prevent collisions between subdivided
# pattern names and existing patterns with numeric suffixes?
new_pattern = optimized_song.pattern("#{pattern.name}_#{step_index}".to_sym)
optimized_flow[pattern.name] << new_pattern.name
pattern.tracks.values.each do |track|
sub_track_pattern = track.rhythm[step_index...(step_index + max_pattern_length)]
if sub_track_pattern != blank_track_pattern
new_pattern.track(track.name, sub_track_pattern)
end
end
# If no track has a trigger during this step pattern, add a blank track.
# Otherwise, this pattern will have no steps, and no sound will be generated,
# causing the pattern to be "compacted away".
if new_pattern.tracks.empty?
new_pattern.track("placeholder", blank_track_pattern)
end
step_index += max_pattern_length
end
end
# Replace the Song's flow to reference the new sub-divided patterns
# instead of the old patterns.
optimized_flow = original_song.flow.map do |original_pattern|
optimized_flow[original_pattern]
end
optimized_song.flow = optimized_flow.flatten
return optimized_song
end
# Replaces any Patterns that are duplicates (i.e., each track uses the same sound and has
# the same rhythm) with a single canonical pattern.
#
# The benefit of this is that it allows more effective caching. For example, suppose Pattern A
# and Pattern B are equivalent. If Pattern A gets generated first, it will be cached. When
# Pattern B gets generated, it will be generated from scratch instead of using Pattern A's
# cached data. Consolidating duplicates into one prevents this from happening.
#
# Duplicate Patterns are more likely to occur after calling subdivide_song_patterns().
def prune_duplicate_patterns(song)
seen_patterns = []
replacements = {}
# Pattern names are sorted to ensure predictable pattern replacement. Makes tests easier to write.
# Sort function added manually because Ruby 1.8 doesn't know how to sort symbols...
pattern_names = song.patterns.keys.sort {|x, y| x.to_s <=> y.to_s }
# Detect duplicates
pattern_names.each do |pattern_name|
pattern = song.patterns[pattern_name]
found_duplicate = false
seen_patterns.each do |seen_pattern|
if !found_duplicate && pattern.same_tracks_as?(seen_pattern)
replacements[pattern.name.to_sym] = seen_pattern.name.to_sym
found_duplicate = true
end
end
if !found_duplicate
seen_patterns << pattern
end
end
# Update flow to remove references to duplicates
new_flow = song.flow
replacements.each do |duplicate, replacement|
new_flow = new_flow.map do |pattern_name|
(pattern_name == duplicate) ? replacement : pattern_name
end
end
song.flow = new_flow
# Remove unused Patterns. Not strictly necessary, but makes resulting songs
# easier to read for debugging purposes.
song.remove_unused_patterns()
return song
end
end
Moving some code to a new method to make the parent method shorter.
# This class is used to transform a Song object into an equivalent Song object whose
# sample data will be generated faster by the audio engine.
#
# The primary method is optimize(). Currently, it performs two optimizations:
#
# 1.) Breaks patterns into shorter patterns. Generating one long Pattern is generally
# slower than generating several short Patterns with the same combined length.
# 2.) Replaces Patterns which are equivalent (i.e. they have the same tracks with the
# same rhythms) with one canonical Pattern. This allows for better caching, by
# preventing the audio engine from generating the same sample data more than once.
#
# Note that step #1 actually performs double duty, because breaking Patterns into smaller
# pieces increases the likelihood there will be duplicates that can be combined.
class SongOptimizer
def initialize()
end
# Returns a Song that will produce the same output as original_song, but should be
# generated faster.
def optimize(original_song, max_pattern_length)
# 1.) Create a new song, cloned from the original
optimized_song = original_song.copy_ignoring_patterns_and_flow()
# 2.) Subdivide patterns
optimized_song = subdivide_song_patterns(original_song, optimized_song, max_pattern_length)
# 3.) Prune duplicate patterns
optimized_song = prune_duplicate_patterns(optimized_song)
return optimized_song
end
protected
# Splits the patterns of a Song into smaller patterns, each one with at most
# max_pattern_length steps. For example, if max_pattern_length is 4, then
# the following pattern:
#
# track1: X...X...X.
# track2: ..X.....X.
# track3: X.X.X.X.X.
#
# will be converted into the following 3 patterns:
#
# track1: X...
# track2: ..X.
# track3: X.X.
#
# track1: X...
# track3: X.X.
#
# track1: X.
# track2: X.
# track3: X.
#
# Note that if a track in a sub-divided pattern has no triggers (such as track2 in the
# 2nd pattern above), it will not be included in the new pattern.
def subdivide_song_patterns(original_song, optimized_song, max_pattern_length)
blank_track_pattern = '.' * max_pattern_length
# For each pattern, add a new pattern to new song every max_pattern_length steps
optimized_flow = {}
original_song.patterns.values.each do |pattern|
step_index = 0
optimized_flow[pattern.name] = []
while(pattern.tracks.values.first.rhythm[step_index] != nil) do
# TODO: Is this pattern 100% sufficient to prevent collisions between subdivided
# pattern names and existing patterns with numeric suffixes?
new_pattern = optimized_song.pattern("#{pattern.name}_#{step_index}".to_sym)
optimized_flow[pattern.name] << new_pattern.name
pattern.tracks.values.each do |track|
sub_track_pattern = track.rhythm[step_index...(step_index + max_pattern_length)]
if sub_track_pattern != blank_track_pattern
new_pattern.track(track.name, sub_track_pattern)
end
end
# If no track has a trigger during this step pattern, add a blank track.
# Otherwise, this pattern will have no steps, and no sound will be generated,
# causing the pattern to be "compacted away".
if new_pattern.tracks.empty?
new_pattern.track("placeholder", blank_track_pattern)
end
step_index += max_pattern_length
end
end
# Replace the Song's flow to reference the new sub-divided patterns
# instead of the old patterns.
optimized_flow = original_song.flow.map do |original_pattern|
optimized_flow[original_pattern]
end
optimized_song.flow = optimized_flow.flatten
return optimized_song
end
# Replaces any Patterns that are duplicates (i.e., each track uses the same sound and has
# the same rhythm) with a single canonical pattern.
#
# The benefit of this is that it allows more effective caching. For example, suppose Pattern A
# and Pattern B are equivalent. If Pattern A gets generated first, it will be cached. When
# Pattern B gets generated, it will be generated from scratch instead of using Pattern A's
# cached data. Consolidating duplicates into one prevents this from happening.
#
# Duplicate Patterns are more likely to occur after calling subdivide_song_patterns().
def prune_duplicate_patterns(song)
pattern_replacements = determine_pattern_replacements(song.patterns)
# Update flow to remove references to duplicates
new_flow = song.flow
pattern_replacements.each do |duplicate, replacement|
new_flow = new_flow.map do |pattern_name|
(pattern_name == duplicate) ? replacement : pattern_name
end
end
song.flow = new_flow
# Remove unused Patterns. Not strictly necessary, but makes resulting songs
# easier to read for debugging purposes.
song.remove_unused_patterns()
return song
end
# Examines a set of patterns definitions, determining which ones have the same tracks with the same
# rhythms. Then constructs a hash of pattern => pattern indicating that all occurances in the flow
# of the key should be replaced with the value, so that the other equivalent definitions can be pruned
# from the song (and hence their sample data doesn't need to be generated).
def determine_pattern_replacements(patterns)
seen_patterns = []
replacements = {}
# Pattern names are sorted to ensure predictable pattern replacement. Makes tests easier to write.
# Sort function added manually because Ruby 1.8 doesn't know how to sort symbols...
pattern_names = patterns.keys.sort {|x, y| x.to_s <=> y.to_s }
# Detect duplicates
pattern_names.each do |pattern_name|
pattern = patterns[pattern_name]
found_duplicate = false
seen_patterns.each do |seen_pattern|
if !found_duplicate && pattern.same_tracks_as?(seen_pattern)
replacements[pattern.name.to_sym] = seen_pattern.name.to_sym
found_duplicate = true
end
end
if !found_duplicate
seen_patterns << pattern
end
end
return replacements
end
end
|
# encoding: UTF-8
# $HeadURL$
# $Id$
#
# Copyright (c) 2009-2012 by Public Library of Science, a non-profit corporation
# http://www.plos.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'faraday'
require 'faraday_middleware'
require 'faraday-cookie_jar'
require 'typhoeus'
require 'typhoeus/adapters/faraday'
module SourceHelper
DEFAULT_TIMEOUT = 60
SourceHelperExceptions = [Faraday::Error::ClientError, Delayed::WorkerTimeout].freeze
# Errno::EPIPE, Errno::ECONNRESET
def get_json(url, options = { timeout: DEFAULT_TIMEOUT })
conn = conn_json
conn.basic_auth(options[:username], options[:password]) if options[:username]
conn.authorization :Bearer, options[:bearer] if options[:bearer]
conn.options[:timeout] = options[:timeout]
response = conn.get url
response.body
rescue *SourceHelperExceptions => e
rescue_faraday_error(url, e, options.merge(json: true))
end
def get_xml(url, options = { timeout: DEFAULT_TIMEOUT })
conn = conn_xml
conn.basic_auth(options[:username], options[:password]) if options[:username]
conn.options[:timeout] = options[:timeout]
if options[:data]
response = conn.post url do |request|
request.body = options[:data]
end
else
response = conn.get url
end
# We have issues with the Faraday XML parsing
Nokogiri::XML(response.body)
rescue *SourceHelperExceptions => e
rescue_faraday_error(url, e, options.merge(xml: true))
end
def post_xml(url, options = { data: nil, timeout: DEFAULT_TIMEOUT })
get_xml(url, options)
end
def get_alm_data(id = "")
get_json("#{couchdb_url}#{id}")
end
def get_alm_rev(id, options={})
head_alm_data("#{couchdb_url}#{id}", options)
end
def head_alm_data(url, options = { timeout: DEFAULT_TIMEOUT })
conn = conn_json
conn.basic_auth(options[:username], options[:password]) if options[:username]
conn.options[:timeout] = options[:timeout]
response = conn.head url
# CouchDB revision is in etag header. We need to remove extra double quotes
rev = response.env[:response_headers][:etag][1..-2]
rescue *SourceHelperExceptions => e
rescue_faraday_error(url, e, options.merge(head: true))
end
def save_alm_data(id, options = { data: nil })
data_rev = get_alm_rev(id)
unless data_rev.blank?
options[:data][:_id] = "#{id}"
options[:data][:_rev] = data_rev
end
put_alm_data("#{couchdb_url}#{id}", options)
end
def put_alm_data(url, options = { data: nil })
return nil unless options[:data] || Rails.env.test?
conn = conn_json
conn.options[:timeout] = DEFAULT_TIMEOUT
response = conn.put url do |request|
request.body = options[:data]
end
(response.body["ok"] ? response.body["rev"] : nil)
rescue *SourceHelperExceptions => e
rescue_faraday_error(url, e, options)
end
def remove_alm_data(id, data_rev)
params = {'rev' => data_rev }
delete_alm_data("#{couchdb_url}#{id}?#{params.to_query}")
end
def delete_alm_data(url, options={})
return nil unless url != couchdb_url || Rails.env.test?
response = conn_json.delete url
(response.body["ok"] ? response.body["rev"] : nil)
rescue *SourceHelperExceptions => e
rescue_faraday_error(url, e, options)
end
def get_alm_database
get_alm_data
end
def put_alm_database
put_alm_data(couchdb_url)
filter = Faraday::UploadIO.new('design_doc/filter.json', 'application/json')
put_alm_data("#{couchdb_url}_design/filter", { data: filter })
end
def delete_alm_database
delete_alm_data(couchdb_url)
end
def get_canonical_url(url, options = { timeout: DEFAULT_TIMEOUT })
conn = conn_doi
# disable ssl verification
conn.options[:ssl] = { verify: false }
conn.options[:timeout] = options[:timeout]
response = conn.get url
# Priority to find URL:
# 1. <link rel=canonical />
# 2. <meta property="og:url" />
# 3. URL from header
body = Nokogiri::HTML(response.body)
body_url = body.at('link[rel="canonical"]')['href'] if body.at('link[rel="canonical"]')
if !body_url && body.at('meta[property="og:url"]')
body_url = body.at('meta[property="og:url"]')['content']
end
url = response.env[:url].to_s
if url
# remove jsessionid used by J2EE servers
url = url.gsub(/(.*);jsessionid=.*/,'\1')
# remove parameter used by IEEE
url = url.sub("reload=true&", "")
# make url lowercase
end
# we will raise an error if 1. or 2. doesn't match with 3. as this confuses Facebook
if body_url.present? and body_url.casecmp(url) != 0
raise Faraday::Error::ClientError, "Canonical URL mismatch: #{body_url}"
end
url
rescue *SourceHelperExceptions => e
rescue_faraday_error(url, e, options)
end
def save_to_file(url, filename = "tmpdata", options = { timeout: DEFAULT_TIMEOUT })
conn = conn_xml
conn.basic_auth(options[:username], options[:password]) if options[:username]
conn.options[:timeout] = options[:timeout]
response = conn.get url
File.open("#{Rails.root}/data/#{filename}", 'w') { |file| file.write(response.body) }
filename
rescue *SourceHelperExceptions => e
rescue_faraday_error(url, e, options.merge(:xml => true))
rescue => exception
Alert.create(:exception => exception, :class_name => exception.class.to_s,
:message => exception.message,
:status => 500,
:source_id => options[:source_id])
nil
end
def conn_json
Faraday.new do |c|
c.headers['Accept'] = 'application/json'
c.headers['User-agent'] = "#{CONFIG[:useragent]} - http://#{CONFIG[:hostname]}"
c.use Faraday::HttpCache, store: Rails.cache
c.use FaradayMiddleware::FollowRedirects, :limit => 10
c.request :multipart
c.request :json
c.response :json, :content_type => /\bjson$/
c.use Faraday::Response::RaiseError
c.adapter :typhoeus
end
end
def conn_xml
Faraday.new do |c|
c.headers['Accept'] = 'application/xml'
c.headers['User-agent'] = "#{CONFIG[:useragent]} - http://#{CONFIG[:hostname]}"
c.use Faraday::HttpCache, store: Rails.cache
c.use FaradayMiddleware::FollowRedirects, :limit => 10
c.use Faraday::Response::RaiseError
c.adapter :typhoeus
end
end
def conn_doi
Faraday.new do |c|
c.headers['User-agent'] = "#{CONFIG[:useragent]} - http://#{CONFIG[:hostname]}"
c.use Faraday::HttpCache, store: Rails.cache
c.use FaradayMiddleware::FollowRedirects, :limit => 10
c.use :cookie_jar
c.use Faraday::Response::RaiseError
c.adapter :typhoeus
end
end
def couchdb_url
CONFIG[:couchdb_url]
end
def rescue_faraday_error(url, error, options={})
if error.kind_of?(Faraday::Error::ResourceNotFound)
if error.response.blank? && error.response[:body].blank?
nil
elsif options[:json]
error.response[:body]
elsif options[:xml]
Nokogiri::XML(error.response[:body])
else
error.response[:body]
end
# malformed JSON is treated as ResourceNotFound
elsif error.message.include?("unexpected token")
nil
else
details = nil
if error.kind_of?(Faraday::Error::TimeoutError)
status = 408
elsif error.respond_to?('status')
status = error[:status]
elsif error.response
status = error.response[:status]
details = error.response[:body]
else
status = 400
end
if error.respond_to?('exception')
exception = error.exception
else
exception = ""
end
class_name = error.class
message = "#{error.message} for #{url}"
case status
when 400
class_name = Net::HTTPBadRequest
when 401
class_name = Net::HTTPUnauthorized
when 403
class_name = Net::HTTPForbidden
when 406
class_name = Net::HTTPNotAcceptable
when 408
class_name = Net::HTTPRequestTimeOut
when 409
class_name = Net::HTTPConflict
message = "#{error.message} with rev #{options[:data][:rev]}"
when 417
class_name = Net::HTTPExpectationFailed
when 429
class_name = Net::HTTPClientError
when 500
class_name = Net::HTTPInternalServerError
when 502
class_name = Net::HTTPBadGateway
when 503
class_name = Net::HTTPServiceUnavailable
end
Alert.create(exception: exception,
class_name: class_name.to_s,
message: message,
details: details,
status: status,
target_url: url,
source_id: options[:source_id])
nil
end
end
end
require accept header with charset UTF-8
# encoding: UTF-8
# $HeadURL$
# $Id$
#
# Copyright (c) 2009-2012 by Public Library of Science, a non-profit corporation
# http://www.plos.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'faraday'
require 'faraday_middleware'
require 'faraday-cookie_jar'
require 'typhoeus'
require 'typhoeus/adapters/faraday'
module SourceHelper
DEFAULT_TIMEOUT = 60
SourceHelperExceptions = [Faraday::Error::ClientError, Delayed::WorkerTimeout].freeze
# Errno::EPIPE, Errno::ECONNRESET
def get_json(url, options = { timeout: DEFAULT_TIMEOUT })
conn = conn_json
conn.basic_auth(options[:username], options[:password]) if options[:username]
conn.authorization :Bearer, options[:bearer] if options[:bearer]
conn.options[:timeout] = options[:timeout]
response = conn.get url
response.body
rescue *SourceHelperExceptions => e
rescue_faraday_error(url, e, options.merge(json: true))
end
def get_xml(url, options = { timeout: DEFAULT_TIMEOUT })
conn = conn_xml
conn.basic_auth(options[:username], options[:password]) if options[:username]
conn.options[:timeout] = options[:timeout]
if options[:data]
response = conn.post url do |request|
request.body = options[:data]
end
else
response = conn.get url
end
# We have issues with the Faraday XML parsing
Nokogiri::XML(response.body)
rescue *SourceHelperExceptions => e
rescue_faraday_error(url, e, options.merge(xml: true))
end
def post_xml(url, options = { data: nil, timeout: DEFAULT_TIMEOUT })
get_xml(url, options)
end
def get_alm_data(id = "")
get_json("#{couchdb_url}#{id}")
end
def get_alm_rev(id, options={})
head_alm_data("#{couchdb_url}#{id}", options)
end
def head_alm_data(url, options = { timeout: DEFAULT_TIMEOUT })
conn = conn_json
conn.basic_auth(options[:username], options[:password]) if options[:username]
conn.options[:timeout] = options[:timeout]
response = conn.head url
# CouchDB revision is in etag header. We need to remove extra double quotes
rev = response.env[:response_headers][:etag][1..-2]
rescue *SourceHelperExceptions => e
rescue_faraday_error(url, e, options.merge(head: true))
end
def save_alm_data(id, options = { data: nil })
data_rev = get_alm_rev(id)
unless data_rev.blank?
options[:data][:_id] = "#{id}"
options[:data][:_rev] = data_rev
end
put_alm_data("#{couchdb_url}#{id}", options)
end
def put_alm_data(url, options = { data: nil })
return nil unless options[:data] || Rails.env.test?
conn = conn_json
conn.options[:timeout] = DEFAULT_TIMEOUT
response = conn.put url do |request|
request.body = options[:data]
end
(response.body["ok"] ? response.body["rev"] : nil)
rescue *SourceHelperExceptions => e
rescue_faraday_error(url, e, options)
end
def remove_alm_data(id, data_rev)
params = {'rev' => data_rev }
delete_alm_data("#{couchdb_url}#{id}?#{params.to_query}")
end
def delete_alm_data(url, options={})
return nil unless url != couchdb_url || Rails.env.test?
response = conn_json.delete url
(response.body["ok"] ? response.body["rev"] : nil)
rescue *SourceHelperExceptions => e
rescue_faraday_error(url, e, options)
end
def get_alm_database
get_alm_data
end
def put_alm_database
put_alm_data(couchdb_url)
filter = Faraday::UploadIO.new('design_doc/filter.json', 'application/json')
put_alm_data("#{couchdb_url}_design/filter", { data: filter })
end
def delete_alm_database
delete_alm_data(couchdb_url)
end
def get_canonical_url(url, options = { timeout: DEFAULT_TIMEOUT })
conn = conn_doi
# disable ssl verification
conn.options[:ssl] = { verify: false }
conn.options[:timeout] = options[:timeout]
response = conn.get url
# Priority to find URL:
# 1. <link rel=canonical />
# 2. <meta property="og:url" />
# 3. URL from header
body = Nokogiri::HTML(response.body)
body_url = body.at('link[rel="canonical"]')['href'] if body.at('link[rel="canonical"]')
if !body_url && body.at('meta[property="og:url"]')
body_url = body.at('meta[property="og:url"]')['content']
end
url = response.env[:url].to_s
if url
# remove jsessionid used by J2EE servers
url = url.gsub(/(.*);jsessionid=.*/,'\1')
# remove parameter used by IEEE
url = url.sub("reload=true&", "")
# make url lowercase
end
# we will raise an error if 1. or 2. doesn't match with 3. as this confuses Facebook
if body_url.present? and body_url.casecmp(url) != 0
raise Faraday::Error::ClientError, "Canonical URL mismatch: #{body_url}"
end
url
rescue *SourceHelperExceptions => e
rescue_faraday_error(url, e, options)
end
def save_to_file(url, filename = "tmpdata", options = { timeout: DEFAULT_TIMEOUT })
conn = conn_xml
conn.basic_auth(options[:username], options[:password]) if options[:username]
conn.options[:timeout] = options[:timeout]
response = conn.get url
File.open("#{Rails.root}/data/#{filename}", 'w') { |file| file.write(response.body) }
filename
rescue *SourceHelperExceptions => e
rescue_faraday_error(url, e, options.merge(:xml => true))
rescue => exception
Alert.create(:exception => exception, :class_name => exception.class.to_s,
:message => exception.message,
:status => 500,
:source_id => options[:source_id])
nil
end
def conn_json
Faraday.new do |c|
c.headers['Accept'] = 'application/json'
c.headers['User-agent'] = "#{CONFIG[:useragent]} - http://#{CONFIG[:hostname]}"
c.use Faraday::HttpCache, store: Rails.cache
c.use FaradayMiddleware::FollowRedirects, :limit => 10
c.request :multipart
c.request :json
c.response :json, :content_type => /\bjson$/
c.use Faraday::Response::RaiseError
c.adapter :typhoeus
end
end
def conn_xml
Faraday.new do |c|
c.headers['Accept'] = 'application/xml'
c.headers['User-agent'] = "#{CONFIG[:useragent]} - http://#{CONFIG[:hostname]}"
c.use Faraday::HttpCache, store: Rails.cache
c.use FaradayMiddleware::FollowRedirects, :limit => 10
c.use Faraday::Response::RaiseError
c.adapter :typhoeus
end
end
def conn_doi
Faraday.new do |c|
c.headers['Accept'] = 'text/html;charset=UTF-8'
c.headers['User-agent'] = "#{CONFIG[:useragent]} - http://#{CONFIG[:hostname]}"
c.use Faraday::HttpCache, store: Rails.cache
c.use FaradayMiddleware::FollowRedirects, :limit => 10
c.use :cookie_jar
c.use Faraday::Response::RaiseError
c.adapter :typhoeus
end
end
def couchdb_url
CONFIG[:couchdb_url]
end
def rescue_faraday_error(url, error, options={})
if error.kind_of?(Faraday::Error::ResourceNotFound)
if error.response.blank? && error.response[:body].blank?
nil
elsif options[:json]
error.response[:body]
elsif options[:xml]
Nokogiri::XML(error.response[:body])
else
error.response[:body]
end
# malformed JSON is treated as ResourceNotFound
elsif error.message.include?("unexpected token")
nil
else
details = nil
if error.kind_of?(Faraday::Error::TimeoutError)
status = 408
elsif error.respond_to?('status')
status = error[:status]
elsif error.response
status = error.response[:status]
details = error.response[:body]
else
status = 400
end
if error.respond_to?('exception')
exception = error.exception
else
exception = ""
end
class_name = error.class
message = "#{error.message} for #{url}"
case status
when 400
class_name = Net::HTTPBadRequest
when 401
class_name = Net::HTTPUnauthorized
when 403
class_name = Net::HTTPForbidden
when 406
class_name = Net::HTTPNotAcceptable
when 408
class_name = Net::HTTPRequestTimeOut
when 409
class_name = Net::HTTPConflict
message = "#{error.message} with rev #{options[:data][:rev]}"
when 417
class_name = Net::HTTPExpectationFailed
when 429
class_name = Net::HTTPClientError
when 500
class_name = Net::HTTPInternalServerError
when 502
class_name = Net::HTTPBadGateway
when 503
class_name = Net::HTTPServiceUnavailable
end
Alert.create(exception: exception,
class_name: class_name.to_s,
message: message,
details: details,
status: status,
target_url: url,
source_id: options[:source_id])
nil
end
end
end
|
module CQL
# The current version of the gem
VERSION = '1.4.1'
end
Bump gem version
Incrementing the version for the upcoming release.
module CQL
# The current version of the gem
VERSION = '1.4.2'
end
|
require 'spark_toolkit/version'
Dir.glob("/usr/local/spark-2.1.0-bin-hadoop2.7/jars/*.jar").each { |jar| require jar }
# Set up log4j
org.apache.log4j.basicconfigrator.configure
#require_relative 'spark-assembly-1.5.2-hadoop2.6.0.jar'
require 'spark_toolkit/hadoop'
require 'spark_toolkit/spark'
Remove code for developing
require 'spark_toolkit/version'
# Set up log4j
org.apache.log4j.basicconfigrator.configure
require 'spark_toolkit/hadoop'
require 'spark_toolkit/spark'
|
module Spidr
VERSION = '0.1.8'
end
Version bump.
module Spidr
VERSION = '0.1.9'
end
|
module Spine
VERSION = '0.0.5'
end
0.1.0
module Spine
VERSION = '0.1.0'
end
|
require 'thread'
module Splib
class Monitor
def initialize
@threads = []
@locks = []
@lock_owner = nil
@timers = {}
end
# timeout:: Wait for given amount of time
# Park a thread here
def wait(timeout=nil)
if(timeout)
timout = timeout.to_f
@timers[Thread.current] = Thread.new(Thread.current) do |t|
sleep(timeout)
t.wakeup
end
end
@threads << Thread.current
Thread.stop
@threads.delete(Thread.current)
if(timeout)
if(@timers[Thread.current].alive?)
@timers[Thread.current].kill
end
@timers.delete(Thread.current)
end
true
end
# Park thread while block is true
def wait_while
while yield
wait
end
end
# Park thread until block is true
def wait_until
until yield
wait
end
end
# Wake up earliest thread
def signal
synchronize do
t = @threads.shift
t.wakeup if t.alive?
end
end
# Wake up all threads
def broadcast
synchronize do
@threads.each do |t|
t.wakeup if t.alive?
end
@threads.clear
end
end
# Number of threads waiting
def waiters
@threads.size
end
# Lock the monitor
def lock
Thread.stop if Thread.exclusive{ do_lock }
end
# Unlock the monitor
def unlock
Thread.exclusive{ do_unlock }
end
# Lock the monitor, execute block and unlock the monitor
def synchronize
result = nil
Thread.exclusive do
do_lock
result = yield
do_unlock
end
result
end
private
def do_lock
stop = false
unless(@locks.empty?)
@locks << Thread.current
stop = true
else
@lock_owner = Thread.current
end
stop
end
def do_unlock
unless(@lock_owner == Thread.current)
raise ThreadError.new("Thread #{Thread.current} is not the current owner: #{@lock_owner}")
end
unless(@locks.empty?)
@locks.delete{|t|!t.alive?}
@lock_owner = @locks.shift
@lock_owner.wakeup
else
@lock_owner = nil
end
end
end
end
make sure we have a thread before we wake it up. add locked? method
require 'thread'
module Splib
class Monitor
def initialize
@threads = []
@locks = []
@lock_owner = nil
@timers = {}
end
# timeout:: Wait for given amount of time
# Park a thread here
def wait(timeout=nil)
if(timeout)
timout = timeout.to_f
@timers[Thread.current] = Thread.new(Thread.current) do |t|
sleep(timeout)
t.wakeup
end
end
@threads << Thread.current
Thread.stop
@threads.delete(Thread.current)
if(timeout)
if(@timers[Thread.current].alive?)
@timers[Thread.current].kill
end
@timers.delete(Thread.current)
end
true
end
# Park thread while block is true
def wait_while
while yield
wait
end
end
# Park thread until block is true
def wait_until
until yield
wait
end
end
# Wake up earliest thread
def signal
synchronize do
t = @threads.shift
t.wakeup if t && t.alive?
end
end
# Wake up all threads
def broadcast
synchronize do
@threads.each do |t|
t.wakeup if t.alive?
end
@threads.clear
end
end
# Number of threads waiting
def waiters
@threads.size
end
# Lock the monitor
def lock
Thread.stop if Thread.exclusive{ do_lock }
end
# Unlock the monitor
def unlock
Thread.exclusive{ do_unlock }
end
# Is monitor locked
def locked?
@locks.size > 0
end
# Lock the monitor, execute block and unlock the monitor
def synchronize
result = nil
Thread.exclusive do
do_lock
result = yield
do_unlock
end
result
end
private
def do_lock
stop = false
unless(@locks.empty?)
@locks << Thread.current
stop = true
else
@lock_owner = Thread.current
end
stop
end
def do_unlock
unless(@lock_owner == Thread.current)
raise ThreadError.new("Thread #{Thread.current} is not the current owner: #{@lock_owner}")
end
unless(@locks.empty?)
@locks.delete{|t|!t.alive?}
@lock_owner = @locks.shift
@lock_owner.wakeup
else
@lock_owner = nil
end
end
end
end |
module Spotify
# A generic error class for Spotify errors.
class Error < StandardError
end
# @abstract Generic error class, extended by all libspotify errors.
class APIError < Spotify::Error
extend FFI::DataConverter
native_type :int
@@code_to_class = { 0 => nil }
class << self
# Returns an error if applicable.
#
# @param [Integer] error
# @return [Error, nil] an error, unless error symbol was OK
def from_native(error, context)
error_class = code_to_class.fetch(error) do
raise ArgumentError, "unknown error code: #{error}"
end
error_class.new if error_class
end
# From an error, retrieve it's native value.
#
# @param [Error] error
# @return [Symbol]
def to_native(error, context)
if error
error.to_i
else
0
end
end
# @return [Integer] error code
attr_reader :to_i
private
def code_to_class
@@code_to_class
end
end
# @param [String] message only to be supplied if overridden
def initialize(message = "#{Spotify::API.error_message(self)} (#{to_i})")
super
end
# @return (see .to_i)
def to_i
self.class.to_i
end
end
class << self
private
# @!macro [attach] define_error
# @!parse class $1 < Spotify::APIError; end
def define_error(name, number)
const_set(name, Class.new(Spotify::APIError) do
code_to_class[number] = self
@to_i = number
end)
end
end
define_error("BadAPIVersionError", 1)
define_error("APIInitializationFailedError", 2)
define_error("TrackNotPlayableError", 3)
define_error("BadApplicationKeyError", 5)
define_error("BadUsernameOrPasswordError", 6)
define_error("UserBannedError", 7)
define_error("UnableToContactServerError", 8)
define_error("ClientTooOldError", 9)
define_error("OtherPermanentError", 10)
define_error("BadUserAgentError", 11)
define_error("MissingCallbackError", 12)
define_error("InvalidIndataError", 13)
define_error("IndexOutOfRangeError", 14)
define_error("UserNeedsPremiumError", 15)
define_error("OtherTransientError", 16)
define_error("IsLoadingError", 17)
define_error("NoStreamAvailableError", 18)
define_error("PermissionDeniedError", 19)
define_error("InboxIsFullError", 20)
define_error("NoCacheError", 21)
define_error("NoSuchUserError", 22)
define_error("NoCredentialsError", 23)
define_error("NetworkDisabledError", 24)
define_error("InvalidDeviceIdError", 25)
define_error("CantOpenTraceFileError", 26)
define_error("ApplicationBannedError", 27)
define_error("OfflineTooManyTracksError", 31)
define_error("OfflineDiskCacheError", 32)
define_error("OfflineExpiredError", 33)
define_error("OfflineNotAllowedError", 34)
define_error("OfflineLicenseLostError", 35)
define_error("OfflineLicenseError", 36)
define_error("LastfmAuthError", 39)
define_error("InvalidArgumentError", 40)
define_error("SystemFailureError", 41)
end
Define proper classes for all errors instead of using metaprogramming
module Spotify
# A generic error class for Spotify errors.
class Error < StandardError
end
# @abstract Generic error class, extended by all libspotify errors.
class APIError < Spotify::Error
extend FFI::DataConverter
native_type :int
@@code_to_class = { 0 => nil }
class << self
# Returns an error if applicable.
#
# @param [Integer] error
# @return [Error, nil] an error, unless error symbol was OK
def from_native(error, context)
error_class = @@code_to_class.fetch(error) do
raise ArgumentError, "unknown error code: #{error}"
end
error_class.new if error_class
end
# From an error, retrieve it's native value.
#
# @param [Error] error
# @return [Symbol]
def to_native(error, context)
if error
error.to_i
else
0
end
end
# @return [Integer] error code
attr_reader :to_i
private
def error_code(number)
@to_i = number
@@code_to_class[number] = self
end
end
# @param [String] message only to be supplied if overridden
def initialize(message = "#{Spotify::API.error_message(self)} (#{to_i})")
super
end
# @return (see .to_i)
def to_i
self.class.to_i
end
end
class BadAPIVersionError < APIError
error_code 1
end
class APIInitializationFailedError < APIError
error_code 2
end
class TrackNotPlayableError < APIError
error_code 3
end
class BadApplicationKeyError < APIError
error_code 5
end
class BadUsernameOrPasswordError < APIError
error_code 6
end
class UserBannedError < APIError
error_code 7
end
class UnableToContactServerError < APIError
error_code 8
end
class ClientTooOldError < APIError
error_code 9
end
class OtherPermanentError < APIError
error_code 10
end
class BadUserAgentError < APIError
error_code 11
end
class MissingCallbackError < APIError
error_code 12
end
class InvalidIndataError < APIError
error_code 13
end
class IndexOutOfRangeError < APIError
error_code 14
end
class UserNeedsPremiumError < APIError
error_code 15
end
class OtherTransientError < APIError
error_code 16
end
class IsLoadingError < APIError
error_code 17
end
class NoStreamAvailableError < APIError
error_code 18
end
class PermissionDeniedError < APIError
error_code 19
end
class InboxIsFullError < APIError
error_code 20
end
class NoCacheError < APIError
error_code 21
end
class NoSuchUserError < APIError
error_code 22
end
class NoCredentialsError < APIError
error_code 23
end
class NetworkDisabledError < APIError
error_code 24
end
class InvalidDeviceIdError < APIError
error_code 25
end
class CantOpenTraceFileError < APIError
error_code 26
end
class ApplicationBannedError < APIError
error_code 27
end
class OfflineTooManyTracksError < APIError
error_code 31
end
class OfflineDiskCacheError < APIError
error_code 32
end
class OfflineExpiredError < APIError
error_code 33
end
class OfflineNotAllowedError < APIError
error_code 34
end
class OfflineLicenseLostError < APIError
error_code 35
end
class OfflineLicenseError < APIError
error_code 36
end
class LastfmAuthError < APIError
error_code 39
end
class InvalidArgumentError < APIError
error_code 40
end
class SystemFailureError < APIError
error_code 41
end
end
|
require 'spree_core'
module SpreeVatFix
class Engine < Rails::Engine
config.autoload_paths += %W(#{config.root}/lib)
def self.activate
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
Rails.env.production? ? require(c) : load(c)
end
end
config.to_prepare &method(:activate).to_proc
end
end
removes require
module SpreeVatFix
class Engine < Rails::Engine
config.autoload_paths += %W(#{config.root}/lib)
def self.activate
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
Rails.env.production? ? require(c) : load(c)
end
end
config.to_prepare &method(:activate).to_proc
end
end
|
module Spyme
VERSION = "0.1.1"
end
updated version
module Spyme
VERSION = "0.1.2"
end
|
require "cryptsy/api/version"
require "httparty"
require "uri"
require "openssl"
require "json"
module Cryptsy
module API
class PublicMethod
include HTTParty
base_uri "http://pubapi.cryptsy.com"
def execute_method(all_markets, single_market, marketid)
api_method = marketid.nil? ? all_markets : single_market
query = {method: api_method}
query["marketid"] = marketid if marketid
response = self.class.get("/api.php", query: query)
JSON.parse(response.body)
end
end
class PrivateMethod
include HTTParty
base_uri "https://www.cryptsy.com"
def initialize(key=nil, secret=nil)
@key = key
@secret = secret
end
def execute_method(method_name, params)
post_data = {method: method_name, nonce: nonce}.merge(params)
post_body = URI.encode_www_form(post_data)
response = self.class.post("/api",
headers: { "User-Agent" => "Mozilla/4.0 (compatible; Cryptsy API ruby client)",
"Sign" => signed_message(post_body),
"Key" => @key,
},
body: post_data)
JSON.parse(response.body)
end
def auth_changed?(key, secret)
return @key == key && @secret == secret
end
private
def nonce
Time.now.to_i
end
def signed_message(msg)
OpenSSL::HMAC.hexdigest('sha512', @secret, msg)
end
end
class Client
def initialize(key=nil, secret=nil)
@key = key
@secret = secret
@private_caller = nil
end
# Public APIs
# We don't bother to support deprecated v1 api
def marketdata(marketid=nil)
call_public_api("marketdata", "singlemarketdata", marketid)
end
def orderdata(marketid=nil)
call_public_api("orderdata", "singleorderdata", marketid)
end
# Private APIs
def getinfo
call_private_api("getinfo", {})
end
def getmarkets
call_private_api("getmarkets", {})
end
def mytransactions
call_private_api("mytransactions", {})
end
def markettrades(marketid)
call_private_api("markettrades", {marketid: marketid})
end
def marketorders(marketid)
call_private_api("marketorders", {marketid: marketid})
end
def mytrades(marketid, limit=nil)
params = {marketid: marketid}
params.merge({limit: limit}) if limit
call_private_api("mytrades", params)
end
def allmytrades
call_private_api("allmytrades", {})
end
def myorders(marketid)
call_private_api("myorders", {marketid: marketid})
end
def allmyorders
call_private_api("allmyorders", {})
end
def createorder(marketid, ordertype, quantity, price)
call_private_api("createorder",
{marketid: marketid,
ordertype: ordertype,
quantity: quantity,
price: price})
end
def cancelorder(orderid)
call_private_api("cancelorder", {orderid: orderid})
end
def cancelmarketorders(marketid)
call_private_api("cancelmarketorders", {marketid: marketid})
end
def cancelallorders
call_private_api("cancelallorders", {})
end
def calculatefees(ordertype, quantity, price)
call_private_api("calculatefees",
{ordertype: ordertype,
quantity: quantity,
price: price})
end
def generatenewaddress(currency)
# if integer - it is currency id
if currency.is_a? Integer or !!(currency =~ /^[-+]?[0-9]+$/) then
call_private_api("generatenewaddress", {currencyid: currency})
else
call_private_api("generatenewaddress", {currencycode: currency})
end
end
private
def call_public_api(all_markets, single_market, marketid=nil)
Cryptsy::API::PublicMethod.new.execute_method(all_markets, single_market, marketid)
end
def call_private_api(method_name, params={})
if @private_caller.nil? || @private_caller.auth_changed?(@key, @secret)
@private_caller = Cryptsy::API::PrivateMethod.new(@key,@secret)
end
@private_caller.execute_method(method_name, params)
end
end
end
end
Added support for cryptsys "depth" method that returns market depth for selected market id
require "cryptsy/api/version"
require "httparty"
require "uri"
require "openssl"
require "json"
module Cryptsy
module API
class PublicMethod
include HTTParty
base_uri "http://pubapi.cryptsy.com"
def execute_method(all_markets, single_market, marketid)
api_method = marketid.nil? ? all_markets : single_market
query = {method: api_method}
query["marketid"] = marketid if marketid
response = self.class.get("/api.php", query: query)
JSON.parse(response.body)
end
end
class PrivateMethod
include HTTParty
base_uri "https://www.cryptsy.com"
def initialize(key=nil, secret=nil)
@key = key
@secret = secret
end
def execute_method(method_name, params)
post_data = {method: method_name, nonce: nonce}.merge(params)
post_body = URI.encode_www_form(post_data)
response = self.class.post("/api",
headers: { "User-Agent" => "Mozilla/4.0 (compatible; Cryptsy API ruby client)",
"Sign" => signed_message(post_body),
"Key" => @key,
},
body: post_data)
JSON.parse(response.body)
end
def auth_changed?(key, secret)
return @key == key && @secret == secret
end
private
def nonce
Time.now.to_i
end
def signed_message(msg)
OpenSSL::HMAC.hexdigest('sha512', @secret, msg)
end
end
class Client
def initialize(key=nil, secret=nil)
@key = key
@secret = secret
@private_caller = nil
end
# Public APIs
# We don't bother to support deprecated v1 api
def marketdata(marketid=nil)
call_public_api("marketdata", "singlemarketdata", marketid)
end
def orderdata(marketid=nil)
call_public_api("orderdata", "singleorderdata", marketid)
end
# Private APIs
def getinfo
call_private_api("getinfo", {})
end
def getmarkets
call_private_api("getmarkets", {})
end
def mytransactions
call_private_api("mytransactions", {})
end
def markettrades(marketid)
call_private_api("markettrades", {marketid: marketid})
end
def marketorders(marketid)
call_private_api("marketorders", {marketid: marketid})
end
def depth(marketid)
call_private_api("depth", {marketid: marketid})
end
def mytrades(marketid, limit=nil)
params = {marketid: marketid}
params.merge({limit: limit}) if limit
call_private_api("mytrades", params)
end
def allmytrades
call_private_api("allmytrades", {})
end
def myorders(marketid)
call_private_api("myorders", {marketid: marketid})
end
def allmyorders
call_private_api("allmyorders", {})
end
def createorder(marketid, ordertype, quantity, price)
call_private_api("createorder",
{marketid: marketid,
ordertype: ordertype,
quantity: quantity,
price: price})
end
def cancelorder(orderid)
call_private_api("cancelorder", {orderid: orderid})
end
def cancelmarketorders(marketid)
call_private_api("cancelmarketorders", {marketid: marketid})
end
def cancelallorders
call_private_api("cancelallorders", {})
end
def calculatefees(ordertype, quantity, price)
call_private_api("calculatefees",
{ordertype: ordertype,
quantity: quantity,
price: price})
end
def generatenewaddress(currency)
# if integer - it is currency id
if currency.is_a? Integer or !!(currency =~ /^[-+]?[0-9]+$/) then
call_private_api("generatenewaddress", {currencyid: currency})
else
call_private_api("generatenewaddress", {currencycode: currency})
end
end
private
def call_public_api(all_markets, single_market, marketid=nil)
Cryptsy::API::PublicMethod.new.execute_method(all_markets, single_market, marketid)
end
def call_private_api(method_name, params={})
if @private_caller.nil? || @private_caller.auth_changed?(@key, @secret)
@private_caller = Cryptsy::API::PrivateMethod.new(@key,@secret)
end
@private_caller.execute_method(method_name, params)
end
end
end
end
|
require 'mustache'
module Dali
module Engine
extend self
def render(template, content)
output_text = Mustache.render(template, content)
output = File.new("#{content['title']}.html", 'w')
output << output_text
output.close
end
end
end
add success message
require 'mustache'
module Dali
module Engine
extend self
def render(template, content)
output_text = Mustache.render(template, content)
output = File.new("#{content['title']}.html", 'w')
output << output_text
output.close
puts "Success! #{content['title']}.html has been created"
end
end
end
|
require 'state_pattern/state'
require 'state_pattern/invalid_transition_exception'
module StatePattern
def self.included(base)
base.instance_eval do
def state_classes
@state_classes ||= []
end
def initial_state_class
@initial_state_class
end
def set_initial_state(state_class)
@initial_state_class = state_class
end
def add_states(*state_classes)
state_classes.each do |state_class|
add_state_class(state_class)
end
end
def add_state_class(state_class)
state_classes << state_class
end
def valid_transitions(transitions_hash)
@transitions_hash = transitions_hash
end
def transitions_hash
@transitions_hash
end
def delegate_all_state_events
state_methods.each do |state_method|
define_method state_method do |*args|
delegate_to_event(state_method)
end
end
end
def state_methods
state_classes.map{|state_class| state_class.public_instance_methods(false)}.flatten.uniq
end
end
end
attr_accessor :current_state, :current_event
def initialize(*args)
super(*args)
set_state(self.class.initial_state_class)
self.class.delegate_all_state_events
end
def set_state(state_class)
self.current_state = state_class.new(self)
end
def delegate_to_event(method_name, *args)
self.current_event = method_name.to_sym
self.current_state.send(current_event, *args)
end
def transition_to(state_class)
raise InvalidTransitionException.new(self.current_state.class, state_class, self.current_event) unless self.valid_transition?(self.current_state.class, state_class)
set_state(state_class)
end
def valid_transition?(from_module, to_module)
trans = self.class.transitions_hash
return true if trans.nil?
#TODO: ugly
trans.has_key?(from_module) &&
(trans[from_module] == to_module ||
trans[from_module].include?(to_module)) ||
trans.has_key?([from_module, current_event]) &&
(trans[[from_module, current_event]] == to_module || trans[[from_module, current_event]].include?(to_module))
end
def state
self.current_state.state
end
end
This should have been obvious, what was I thinking?
require 'state_pattern/state'
require 'state_pattern/invalid_transition_exception'
module StatePattern
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def state_classes
@state_classes ||= []
end
def initial_state_class
@initial_state_class
end
def set_initial_state(state_class)
@initial_state_class = state_class
end
def add_states(*state_classes)
state_classes.each do |state_class|
add_state_class(state_class)
end
end
def add_state_class(state_class)
state_classes << state_class
end
def valid_transitions(transitions_hash)
@transitions_hash = transitions_hash
end
def transitions_hash
@transitions_hash
end
def delegate_all_state_events
state_methods.each do |state_method|
define_method state_method do |*args|
delegate_to_event(state_method)
end
end
end
def state_methods
state_classes.map{|state_class| state_class.public_instance_methods(false)}.flatten.uniq
end
end
attr_accessor :current_state, :current_event
def initialize(*args)
super(*args)
set_state(self.class.initial_state_class)
self.class.delegate_all_state_events
end
def set_state(state_class)
self.current_state = state_class.new(self)
end
def delegate_to_event(method_name, *args)
self.current_event = method_name.to_sym
self.current_state.send(current_event, *args)
end
def transition_to(state_class)
raise InvalidTransitionException.new(self.current_state.class, state_class, self.current_event) unless self.valid_transition?(self.current_state.class, state_class)
set_state(state_class)
end
def valid_transition?(from_module, to_module)
trans = self.class.transitions_hash
return true if trans.nil?
#TODO: ugly
trans.has_key?(from_module) &&
(trans[from_module] == to_module ||
trans[from_module].include?(to_module)) ||
trans.has_key?([from_module, current_event]) &&
(trans[[from_module, current_event]] == to_module || trans[[from_module, current_event]].include?(to_module))
end
def state
self.current_state.state
end
end
|
require 'stream_helper'
class StreamReader
class << self
def logger
@logger ||= Logger.new(STDOUT)
end
end
# Assume only one shard for now
BATCH_SIZE = 10
def initialize(stream_name:, prefix: '')
@stream_name = stream_name
@prefix = prefix
@tracker = SequenceNumberTracker.new(key_prefix: [ stream_name, prefix ].compact.join('-'))
@logger = StreamReader.logger
trap('SIGTERM') { @stop_processing = true; puts 'Exiting...' }
end
attr_reader :stop_processing
def run!(&block)
LibratoReporter.run! if send_to_librato?
# Locate a shard id to iterate through - we only have one for now
loop do
break if stop_processing
begin
iterator_opts = { stream_name: @stream_name, shard_id: shard_id }
if seq = @tracker.last_sequence_number
iterator_opts[:shard_iterator_type] = 'AFTER_SEQUENCE_NUMBER'
iterator_opts[:starting_sequence_number] = seq
else
iterator_opts[:shard_iterator_type] = 'TRIM_HORIZON'
end
@logger.debug "Getting shard iterator for #{@stream_name} / #{seq}"
resp = client.get_shard_iterator(iterator_opts)
shard_iterator = resp.shard_iterator
# Iterate!
loop do
break if stop_processing
sleep 1
@logger.debug "Getting records for #{shard_iterator}"
resp = client.get_records({
shard_iterator: shard_iterator,
limit: BATCH_SIZE,
})
resp.records.each do |record|
ActiveSupport::Notifications.instrument('stream_reader.process_record',
stream_name: @stream_name,
prefix: @prefix,
shard_id: shard_id,
ms_behind: resp.millis_behind_latest) do
AvroParser.new(record.data).each_with_schema_name(&block)
@tracker.last_sequence_number = record.sequence_number
end
end
shard_iterator = resp.next_shard_iterator
end
rescue Aws::Kinesis::Errors::ExpiredIteratorException
@logger.debug "Iterator expired! Fetching a new one."
end
end
end
private
def client
@client ||= Aws::Kinesis::Client.new
end
def shard_id
@shard_id ||= begin
resp = client.describe_stream(stream_name: @stream_name, limit: 1)
resp.stream_description.shards[0].shard_id
end
end
def send_to_librato?
!!(ENV['LIBRATO_USER'] && ENV['LIBRATO_TOKEN'])
end
end
Allow a reader to customize the batch_size
Default it to 100 as well.
require 'stream_helper'
class StreamReader
class << self
def logger
@logger ||= Logger.new(STDOUT)
end
end
# Assume only one shard for now
DEFAULT_BATCH_SIZE = 100
def initialize(stream_name:, prefix: '')
@stream_name = stream_name
@prefix = prefix
@tracker = SequenceNumberTracker.new(key_prefix: [ stream_name, prefix ].compact.join('-'))
@logger = StreamReader.logger
trap('SIGTERM') { @stop_processing = true; puts 'Exiting...' }
end
attr_reader :stop_processing
def run!(batch_size: DEFAULT_BATCH_SIZE, &block)
LibratoReporter.run! if send_to_librato?
# Locate a shard id to iterate through - we only have one for now
loop do
break if stop_processing
begin
iterator_opts = { stream_name: @stream_name, shard_id: shard_id }
if seq = @tracker.last_sequence_number
iterator_opts[:shard_iterator_type] = 'AFTER_SEQUENCE_NUMBER'
iterator_opts[:starting_sequence_number] = seq
else
iterator_opts[:shard_iterator_type] = 'TRIM_HORIZON'
end
@logger.debug "Getting shard iterator for #{@stream_name} / #{seq}"
resp = client.get_shard_iterator(iterator_opts)
shard_iterator = resp.shard_iterator
# Iterate!
loop do
break if stop_processing
sleep 1
@logger.debug "Getting records for #{shard_iterator}"
resp = client.get_records({
shard_iterator: shard_iterator,
limit: batch_size,
})
resp.records.each do |record|
ActiveSupport::Notifications.instrument('stream_reader.process_record',
stream_name: @stream_name,
prefix: @prefix,
shard_id: shard_id,
ms_behind: resp.millis_behind_latest) do
AvroParser.new(record.data).each_with_schema_name(&block)
@tracker.last_sequence_number = record.sequence_number
end
end
shard_iterator = resp.next_shard_iterator
end
rescue Aws::Kinesis::Errors::ExpiredIteratorException
@logger.debug "Iterator expired! Fetching a new one."
end
end
end
private
def client
@client ||= Aws::Kinesis::Client.new
end
def shard_id
@shard_id ||= begin
resp = client.describe_stream(stream_name: @stream_name, limit: 1)
resp.stream_description.shards[0].shard_id
end
end
def send_to_librato?
!!(ENV['LIBRATO_USER'] && ENV['LIBRATO_TOKEN'])
end
end
|
# coding: utf-8
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "mpesa_connect/version"
Gem::Specification.new do |spec|
spec.name = "mpesa_connect"
spec.version = MpesaConnect::VERSION
spec.authors = ["mboya"]
spec.email = ["mboyaberry@gmail.com"]
spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.}
spec.description = %q{TODO: Write a longer description or delete this line.}
spec.homepage = "TODO: Put your gem's website or public repo URL here."
spec.license = "MIT"
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
if spec.respond_to?(:metadata)
spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
else
raise "RubyGems 2.0 or newer is required to protect against " \
"public gem pushes."
end
spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 1.15"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "minitest", "~> 5.0"
end
dependencies for the gem
# coding: utf-8
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "mpesa_connect/version"
Gem::Specification.new do |spec|
spec.name = "mpesa_connect"
spec.version = MpesaConnect::VERSION
spec.authors = ["mboya"]
spec.email = ["mboyaberry@gmail.com"]
spec.summary = %q{connect to Mpesa API}
spec.description = %q{connect to Mpesa API to perform available transactions}
spec.homepage = ""
spec.license = "MIT"
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
# if spec.respond_to?(:metadata)
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
# else
# raise "RubyGems 2.0 or newer is required to protect against " \
# "public gem pushes."
# end
spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.add_dependency "httparty"
spec.add_development_dependency "bundler", "~> 1.15"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "minitest", "~> 5.0"
spec.add_development_dependency "pry"
spec.add_development_dependency "pry-nav"
spec.add_development_dependency "webmock"
end
|
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'msgpack_rails/version'
Gem::Specification.new do |spec|
spec.name = "msgpack_rails"
spec.version = MsgpackRails::VERSION
spec.authors = ["Jingwen Owen Ou"]
spec.email = ["jingweno@gmail.com"]
spec.description = %q{Message Pack for Rails.}
spec.summary = %q{The Rails way to serialize/deserialize with Message Pack.}
spec.homepage = "https://github.com/jingweno/msgpack_rails"
spec.license = "MIT"
spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.add_runtime_dependency "activesupport", ">= 3.0"
spec.add_runtime_dependency "msgpack"
end
Use msgpack-jruby for jruby
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'msgpack_rails/version'
Gem::Specification.new do |spec|
spec.name = "msgpack_rails"
spec.version = MsgpackRails::VERSION
spec.authors = ["Jingwen Owen Ou"]
spec.email = ["jingweno@gmail.com"]
spec.description = %q{Message Pack for Rails.}
spec.summary = %q{The Rails way to serialize/deserialize with Message Pack.}
spec.homepage = "https://github.com/jingweno/msgpack_rails"
spec.license = "MIT"
spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.add_runtime_dependency "activesupport", ">= 3.0"
if RUBY_ENGINE == "jruby"
spec.add_runtime_dependency "msgpack-jruby"
else
spec.add_runtime_dependency "msgpack"
end
end
|
namespace :admin do
desc "TODO"
task reset_counters: :environment do
puts "Likes counter reset"
Comment.find_each { |comment| Comment.reset_counters(comment.id, :likes) }
puts "Counters reset done"
end
end
Update tasks
namespace :admin do
task reset_counters: :environment do
puts "Likes counter reset"
Comment.find_each { |comment| Comment.reset_counters(comment.id, :likes) }
puts "Counters reset done"
end
task update_sprint_system: :environment do
puts "Sprint update system (Task)"
Project.update_sprint_system
puts "Sprint update done"
end
end
|
require 'csv'
# gonna start asserting that everything is as expected.
# will slow down import, but I want to make sure I get it right.
def assert(expression,message = 'Assertion failed.')
raise "#{message} :\n #{caller[0]}" unless expression
end
def total_lines(csv_file_name)
f = CSV.open(csv_file_name,'rb')
total_lines = f.readlines.size # includes header, but so does f.lineno
f.close
total_lines
end
def childid_cdcid
unless @childid_cdcid
@childid_cdcid = HWIA.new
CSV.open( 'anand/2010-12-06_MaternalBiospecimenIDLink.csv',
'rb',{ :headers => true }).each do |line|
@childid_cdcid[line['CHILDID'].to_i] = line['CDC_ID'].to_i
end
end
@childid_cdcid
end
#
# NOTE
# CDC\ Maternal\ Inventory\ 11_10_08.csv
# Child ID of 09299 changed to 09229 as this subject had samples with the
# corresponding CDC ID of 318
#
#
# One-off tasks written for Anand
#
namespace :anand do
# 1 "LabelID","AstroID","subjectid","sampleid","sex","sample_type","collected_date","Box","Position"
# "20130405_CDC_GEGL_lastbatch.csv" 1635L, 105981C
task :verify_maternal_last_batch => :environment do
total_lines = total_lines('anand/20130405_CDC_GEGL_lastbatch.csv')
error_file = File.open('anand/20130405_CDC_GEGL_lastbatch.txt','w')
( csv_in = CSV.open( 'anand/20130405_CDC_GEGL_lastbatch.csv',
'rb',{ :headers => true })).each do |line|
puts "Processing #{csv_in.lineno}/#{total_lines}"
# verify subjectid exists
# verify sampleid exists
# verify subject with subjectid is same subject with cdcid/childid
# verify subject sex
# verify subject is mother
# verify sample sample type
cdcid = line['LabelID'].gsub(/^05-57-/,'').gsub(/-\w+$/,'').to_i
childid = childid_cdcid.invert[cdcid]
cdc_mother = StudySubject.with_childid(childid).first.mother
subject = nil
if line['subjectid'].present?
subject = StudySubject.with_subjectid(line['subjectid']).first
if subject.nil?
error_file.puts "No subject found with #{line['subjectid']}"
error_file.puts line
error_file.puts
end
else
puts "SubjectID is blank"
puts line
puts "CDC mother subjectid would be #{cdc_mother.subjectid}"
puts
end
#
# Do we want these samples attached to the child or the mother?
# Assuming mother since all but one are attached to mothers,
# even though the LabelID contains the child's childid.
#
if subject and !subject.is_mother?
error_file.puts "subject is not a mother"
error_file.puts line
if subject.mother.nil? # DOESN'T HAPPEN
error_file.puts "And subject has no mother in database. could create."
else
puts "Mother: #{subject.mother.childid}, #{subject.mother.subjectid}"
end
error_file.puts
#
# only happens for one subjectid
#
# create mother?
# subject.create_mother
# reassign it to subject?
# subject = subject.mother
#
end
if subject and subject.childid != cdc_mother.childid
error_file.puts "childid mismatch #{subject.childid} : #{cdc_mother.childid}"
error_file.puts line
error_file.puts
end
sample = nil
if line['sampleid'].present?
sample = Sample.where(:id => line['sampleid'].to_i).first
if sample.nil? # DOESN'T HAPPEN
error_file.puts "No sample found with #{line['sampleid']}"
error_file.puts line
error_file.puts
end
else
error_file.puts "SampleID is blank."
error_file.puts line
samples = Sample.where(
Sample.arel_table[:external_id].matches("%#{line['LabelID']}%") )
if samples.empty?
error_file.puts "And no samples match external_id #{line['LabelID']}"
else
error_file.puts "BUT #{samples.length} samples DO match external_id #{line['LabelID']}"
error_file.puts samples.collect(&:sampleid)
end
error_file.puts
end
if subject and sample
if !subject.samples.include?( sample ) # DOESN'T HAPPEN
# puts "Sample belongs to subject"
# else
error_file.puts "Sample does not belong to subject"
error_file.puts line
error_file.puts
end
elsif cdc_mother and sample
if !cdc_mother.samples.include?( sample ) # DOESN'T HAPPEN
# puts "Sample belongs to subject"
# else
error_file.puts "Sample does not belong to cdc_mother"
error_file.puts line
error_file.puts
end
end
end
error_file.close
end # task :verify_maternal_last_batch => :environment do
# 20130402
task :output_mothers_with_their_own_childids => :environment do
csv_out = CSV.open('anand/mothers_with_their_own_childids.csv','w')
csv_out << %w( mother_subjectid mother_childid child_subjectid child_childid )
StudySubject.mothers.where(StudySubject.arel_table[:childid].not_eq(nil)).each do |mother|
out = []
out << mother.subjectid
out << mother.childid
child = mother.child
out << child.subjectid
out << child.childid
puts out.join(',')
csv_out << out
end
csv_out.close
end
# 20130402
task :verify_childid_subjectid_in_original_samples_is_same_subject => :environment do
total_lines = total_lines('anand/ODMS_samples_xxxxxx.csv')
error_file = File.open('anand/ODMS_samples_xxxxxx.txt','w')
( csv_in = CSV.open( 'anand/ODMS_samples_xxxxxx.csv',
'rb',{ :headers => true })).each do |line|
puts "Processing #{csv_in.lineno}/#{total_lines}"
subject = StudySubject.with_subjectid(line['subjectID']).first
if subject.nil?
error_file.puts "No subject found with #{line['subjectID']}"
error_file.puts line
error_file.puts
next
end
#
# The subjectids and childids don't always match.
# Sometimes they were subjectid for the mother and childid of the child???
# When I imported these samples, I was only going by the subjectid.
# This file confirms the mismatch at import of the 0196 samples.
#
if subject.childid != line['childid'].to_i &&
subject.child.childid != line['childid'].to_i
error_file.puts "Childid Subjectid mismatch"
error_file.puts "Expected #{line['childid']}"
error_file.puts "Has #{subject.childid}"
error_file.puts line
error_file.puts
next
end
end
error_file.close
end # task :verify_childid_subjectid_in_original_samples_is_same_subject => :environment do
# 20130401
# check that all samples with an external_id matching the cdcid
# belong to the subject with the given childid
task :verify_cdcid_childid_sample_link => :environment do
error_file = File.open('anand/2010-12-06_MaternalBiospecimenIDLink.txt','w')
childid_cdcid.each do |childid, cdcid|
cdcid = sprintf('%04d',cdcid.to_i)
puts "Checking childid #{childid} against cdcid #{cdcid}"
samples = Sample.where(
Sample.arel_table[:external_id].matches("05-57-#{cdcid}%") )
samples.each do |sample|
puts "DB:#{sample.study_subject.child.childid} CSV:#{childid}"
unless ( sample.study_subject.child.childid == childid ) #.to_i )
error_file.puts "Childid Mismatch"
error_file.puts "CDC ID #{cdcid}"
error_file.puts "DB:#{sample.study_subject.child.childid} CSV:#{childid}"
error_file.puts
end
end
end
# ensure that the cdcids are unique
if childid_cdcid.keys.length != childid_cdcid.invert.keys.length
error_file.puts "ChildIDs #{childid_cdcid.keys.length}"
error_file.puts "CDC IDs #{childid_cdcid.invert.keys.length}"
end
error_file.close
end # task :verify_cdcid_childid_sample_link => :environment do
# 20130402
#
task :import_cdc_biospecimens_inventory_not_on_gegl_manifest => :environment do
raise "This task has been disabled."
csv_out = CSV.open('anand/20111114_CDC_UrinePlasmaRBC_SampleInventory.NotOnGeglManifest-OUTPUT.csv','w')
csv_out << ['LabelID','SubjectID','SampleID','ProjectID','Gender','smp_type','Amount (mL)',
'Box','Group','Pos','Container']
total_lines = total_lines('anand/20111114_CDC_UrinePlasmaRBC_SampleInventory.NotOnGeglManifest.csv')
(csv_in = CSV.open( 'anand/20111114_CDC_UrinePlasmaRBC_SampleInventory.NotOnGeglManifest.csv',
'rb',{ :headers => true })).each do |line|
puts "Processing line #{csv_in.lineno}/#{total_lines}"
# ,"DLSSampleID","AstroID","smp_type","Box","Group","Pos","Amount (mL)",
# "Amount Full","Container","Sample Type"
#1,"05-57-0042-R1","0019UJNP","RBC",,"NCCLS07C11",1,0.75,,"2.0 mL cryo","R1 RBC Folate"
cdcid = line['DLSSampleID'].gsub(/^05-57-/,'').gsub(/-\w+$/,'').to_i
childid = childid_cdcid.invert[cdcid]
subject = StudySubject.where(:childid => childid).first.mother
sample = subject.samples.create!(
:project_id => Project[:ccls].id,
:sample_type_id => 1003,
:external_id_source => '20111114_CDC_UrinePlasmaRBC_SampleInventory.NotOnGeglManifest.csv',
:external_id => line['DLSSampleID'],
:notes => "Imported from 20111114_CDC_UrinePlasmaRBC_SampleInventory.NotOnGeglManifest.csv\n" <<
"DLSSampleID #{line['DLSSampleID']},\n" <<
"AstroID #{line['AstroID']},\n" <<
"smp_type #{line['smp_type']},\n" <<
"Box #{line['Box']},\n" <<
"Group #{line['Group']},\n" <<
"Pos #{line['Pos']},\n" <<
"Amount (mL) #{line['Amount (mL)']},\n" <<
"Amount Full #{line['Amount Full']},\n" <<
"Container #{line['Container']}" )
out = []
out << line['DLSSampleID']
out << subject.subjectid
out << sample.sampleid
out << 'CCLS'
out << 'F'
out << sample.sample_type.gegl_sample_type_id
out << line['Amount (mL)']
out << line['Box']
out << line['Group']
out << line['Pos']
out << line['Container']
puts out.join(',')
csv_out << out
end # CSV.open( '20111114_CDC_UrinePlasmaRBC_SampleInventory.NotOnGeglManifest.csv',
csv_out.close
puts "Commiting to Sunspot index."
Sunspot.commit
end # task :import_cdc_biospecimens_inventory_not_on_gegl_manifest => :environment do
# 20130401
# check if samples with the given external_id exist
task :verify_cdc_biospecimens_inventory_not_on_gegl_manifest => :environment do
CSV.open( 'anand/20111114_CDC_UrinePlasmaRBC_SampleInventory.NotOnGeglManifest.csv',
'rb',{ :headers => true }).each do |line|
# ,"DLSSampleID","AstroID","smp_type","Box","Group","Pos","Amount (mL)",
# "Amount Full","Container","Sample Type"
#1,"05-57-0042-R1","0019UJNP","RBC",,"NCCLS07C11",1,0.75,,"2.0 mL cryo","R1 RBC Folate"
# DLSSampleID ... external_id
## sample = Sample.where(:external_id => line['DLSSampleID']).first
## sample = Sample.where(:external_id => line['DLSSampleID'].gsub(/-??$/,'')).first
##external_id = line['DLSSampleID'].gsub(/-..$/,'%')
#external_id = line['DLSSampleID']
##external_id = line['DLSSampleID'].gsub(/-R1$/,'-P1')
##puts external_id
# samples = Sample.where(
# Sample.arel_table[:external_id].matches(external_id) )
# if samples.empty?
# raise "No sample found with external_id #{line['DLSSampleID']}"
# else
# puts "-- sample found with external_id #{line['DLSSampleID']}"
# puts samples.collect(&:external_id)
# end
cdcid = line['DLSSampleID'].gsub(/^05-57-/,'').gsub(/-\w+$/,'').to_i
childid = childid_cdcid.invert[cdcid]
raise "CDCID Not Found. #{cdcid}" if childid.nil?
end # CSV.open( '20111114_CDC_UrinePlasmaRBC_SampleInventory.NotOnGeglManifest.csv',
end # task :verify_cdc_biospecimens_inventory_not_on_gegl_manifest => :environment do
# 20130328
task :verify_cdc_biospecimens_inventory => :environment do
error_file = File.open('anand/20111114_CDC_UrinePlasmaRBC_SampleInventory.txt','w')
(i=CSV.open( 'anand/20111114_CDC_UrinePlasmaRBC_SampleInventory.csv',
'rb',{ :headers => true })).each do |line|
#"external_id","astroid","SubjectID","SampleID","sex","type","collected_on","Box","Position",,1
sample = nil
if line['SubjectID'].blank?
puts "Blank subjectid."
puts line
error_file.puts i.lineno
error_file.puts line
error_file.puts "Blank SubjectID"
error_file.puts
sample = Sample.find(line['SampleID'].to_i)
# actually, find would raise an error so this will never happen
raise "No sample found with sampleid #{line['SampleID']}" if sample.nil?
puts "Found sample with #{line['SampleID']}"
else
subject = StudySubject.with_subjectid(line['SubjectID']).first
raise "No subject found with subjectid #{line['SubjectID']}" if subject.nil?
puts "Found subject with #{line['SubjectID']}"
unless subject.is_mother?
error_file.puts i.lineno
error_file.puts line
error_file.puts "Subject is not a Mother"
error_file.puts subject.subject_type
error_file.puts
end
sample = subject.samples.find(line['SampleID'].to_i)
# actually, find would raise an error so this will never happen
raise "No sample found with sampleid #{line['SampleID']}" if sample.nil?
puts "Found subject's sample with #{line['SampleID']}"
end
puts "Types: DB: #{sample.sample_type.gegl_sample_type_id} CSV: #{line['type']}"
puts "ExtID: DB: #{sample.external_id} CSV: #{line['external_id']}"
puts "Sex: DB: #{sample.study_subject.sex} CSV: #{line['sex']}"
# Our gegl sample type codes aren't always the same
# raise "Type mismatch" if sample.sample_type.gegl_sample_type_id != line['type']
raise "ExtID Mismatch" if sample.external_id != line['external_id']
if sample.study_subject.sex != line['sex'].upcase
error_file.puts i.lineno
error_file.puts line
error_file.puts "Sex Mismatch"
error_file.puts "Sex: DB: #{sample.study_subject.sex} CSV: #{line['sex']}"
error_file.puts
end
end # CSV.open
error_file.close
end # task :check_maternal_biospecimens_inventory
# 20130401
task :import_maternal_biospecimens_inventory => :environment do
raise "This task has been disabled."
error_file = File.open('anand/CDC Maternal Inventory 11_10_08.txt','w')
csv_out = CSV.open('anand/UCSF Maternal Samples.csv','w')
csv_out << ['LabelID','SubjectID','SampleID','ProjectID','Gender','smp_type',
'Date Collected','Date Received','Vol(ml)','Freezer','Rack','Box','Position']
total_lines = total_lines('anand/CDC Maternal Inventory 11_10_08.csv')
childid_cdcid_out = HWIA.new
(csv_in = CSV.open( 'anand/CDC Maternal Inventory 11_10_08.csv',
'rb',{ :headers => true })).each do |line|
puts "Processing line #{csv_in.lineno}/#{total_lines}"
if line['Assigned Location'] != '1 Wiencke Lab'
puts "Location is not Wiencke Lab. It is '#{line['Assigned Location']}'. Skipping."
next
end
if line['Spec Type'] == 'VOC(gray top)' # irrelevant as only location '11 CDC'
puts "Spec Type is VOC(gray top). Skipping."
next
end
if line['Spec Type'] == 'VOC(gray tube)' # irrelevant as only location '11 CDC'
puts "Spec Type is VOC(gray tube). Skipping."
next
end
puts line
#
# "Item#","Assigned Location","Child ID","CDC ID","2-Digit CDC ID","Spec Type",
# "Freezer","Rack","Box","Position","Vol (ml)","Date Collected","Date Received",
# "Date Shipped to CDC","Studycode","Comments","UsedUp?","Hematocrit",
# "First Morning Void?"
#
subject = StudySubject.where(:childid => line['Child ID']).first.mother
raise "No subject found with childid #{line['Child ID']}" if subject.nil?
cdcid = line['CDC ID'].gsub(/05-57-/,'').to_i
if childid_cdcid_out.has_key? line['Child ID'].to_i
if childid_cdcid_out[line['Child ID'].to_i] != cdcid # line['CDC ID'].to_i
puts "Child ID CDC ID Mismatch"
puts "Have CDC ID :#{childid_cdcid_out[line['Child ID'].to_i]}:"
puts "This CDC ID :#{cdcid}:" # line['CDC ID'].to_i}:"
raise "Child ID CDC ID Mismatch"
end
else
childid_cdcid_out[line['Child ID'].to_i] = cdcid # line['CDC ID'].to_i
end
cdcid = childid_cdcid[line['Child ID'].to_i]
if cdcid.blank?
error_file.puts line['CDC ID']
error_file.puts line['Child ID']
error_file.puts "No comparison cdc id"
error_file.puts
elsif line['CDC ID'] != "05-57-#{sprintf('%04d',cdcid)}"
error_file.puts "CDC ID Mismatch"
error_file.puts line['CDC ID']
error_file.puts "05-57-#{sprintf('%04d',cdcid)}"
error_file.puts
end
sample_type = case line['Spec Type']
when 'Serum Cotinine' then SampleType.find 1002
when 'Plasma Folate' then SampleType.find 1000
when 'RBC Folate' then SampleType.find 1003
when 'Urine Cup' then SampleType.find 25
when 'SAA' then SampleType.find 1002
when 'SE' then SampleType.find 1002
when 'PL' then SampleType.find 1000
when 'RBC' then SampleType.find 1003
when 'CL' then SampleType.find 1001
when 'Urine Archive' then SampleType.find 25
when 'Clot' then SampleType.find 1001
when 'PA' then SampleType.find 1000
else
raise "All hell. Unexpected spec type :#{line['Spec Type']}:"
end
labelid = "#{line['CDC ID']}-#{line['2-Digit CDC ID']}"
sample = subject.samples.create!(
:project_id => Project[:ccls].id,
:sample_type_id => sample_type.id,
:external_id_source => 'CDC Maternal Inventory 11_10_08.csv',
:external_id => labelid,
:collected_from_subject_at => line['Date Collected'],
:received_by_ccls_at => line['Date Received'],
:notes => "Imported from CDC Maternal Inventory 11_10_08.csv\n" <<
"Child ID #{line['Child ID']},\n" <<
"CDC ID #{line['CDC ID']},\n" <<
"2-Digit CDC ID #{line['2-Digit CDC ID']},\n" <<
"Spec Type #{line['Spec Type']},\n" <<
"Freezer #{line['Freezer']},\n" <<
"Rack #{line['Rack']},\n" <<
"Box #{line['Box']},\n" <<
"Position #{line['Position']},\n" <<
"Vol (ml) #{line['Vol (ml)']},\n" <<
"UsedUp? #{line['UsedUp?']},\n" <<
"Hematocrit #{line['Hematocrit']},\n" <<
"First Morning Void? #{line['First Morning Void?']}" )
out = []
out << labelid
out << subject.subjectid
out << sample.sampleid
out << 'CCLS'
out << 'F'
out << sample.sample_type.gegl_sample_type_id
out << line['Date Collected']
out << line['Date Received']
out << line['Vol (ml)']
out << line['Freezer']
out << line['Rack']
out << line['Box']
out << line['Position']
puts out.join(',')
csv_out << out
end # CSV.open
csv_out.close
error_file.close
childid_cdcid_csv_out = CSV.open('anand/CDC Maternal Inventory 11_10_08-childid-cdcid.csv','w')
childid_cdcid_csv_out << ["CHILDID","CDC_ID"]
childid_cdcid_out.each { |childid,cdcid| childid_cdcid_csv_out << [childid,cdcid] }
childid_cdcid_csv_out.close
puts "Commiting to Sunspot index."
Sunspot.commit
end # task :import_maternal_biospecimens_inventory
# 20130321
# Just confirm that the childids in this csv file exist.
task :check_maternal_biospecimens_inventory => :environment do
(i=CSV.open( 'anand/CDC Maternal Inventory 11_10_08.csv',
'rb',{ :headers => true })).each do |line|
puts line
#
# "Item#","Assigned Location","Child ID","CDC ID","2-Digit CDC ID","Spec Type",
# "Freezer","Rack","Box","Position","Vol (ml)","Date Collected","Date Received",
# "Date Shipped to CDC","Studycode","Comments","UsedUp?","Hematocrit",
# "First Morning Void?"
#
subject = StudySubject.where(:childid => line['Child ID']).first
raise "No subject found with childid #{line['Child ID']}" if subject.nil?
end # CSV.open
end # task :check_maternal_biospecimens_inventory
# 20130321
# Loop over the guthrie card inventory and create new samples
# and then output a combination of the input and the new sample data.
task :import_guthrie_card_inventory => :environment do
raise "This task has been disabled."
csv_out = CSV.open('anand/Guthrie cards inventory 02_05_13- OUTPUT.csv','w')
csv_out << %w(
guthrieid subjectid sampleid projectid gender smp_type book page pocket
)
total_lines = total_lines('anand/Guthrie cards inventory 02_05_13-APC CHECKED- for import.csv')
(csv_in = CSV.open( 'anand/Guthrie cards inventory 02_05_13-APC CHECKED- for import.csv',
'rb',{ :headers => true })).each do |line|
puts "Processing line #{csv_in.lineno}/#{total_lines}"
#
# "SubjectID","GuthrieID","Book","Page","Pocket"
#
out = []
subject = StudySubject.with_subjectid(line['SubjectID']).first
raise "No subject found with #{line['SubjectID']}" if subject.nil?
#
# Create Sample and get sampleid
# sample_type = Blood Spot ( id: 16 ... archive newborn blood )
# external_id_source = 'Guthrie' ( perhaps with book, page and pocket? )
# external_id = line['GuthrieID']
#
sample = subject.samples.create!(
:project_id => Project[:ccls].id,
:sample_type_id => 16,
:sample_format_id => SampleFormat[:guthrie].id,
:external_id_source => "Guthrie cards inventory 02_05_13-APC CHECKED- for import",
:external_id => line['GuthrieID'],
:notes => "Imported from Guthrie cards inventory 02_05_13-APC CHECKED- for import\n" <<
"SubjectID #{line['SubjectID']},\n" <<
"GuthrieID #{line['GuthrieID']},\n" <<
"Book #{line['Book']},\n" <<
"Page #{line['Page']},\n" <<
"Pocket #{line['Pocket']}" )
out << line['GuthrieID']
out << line['SubjectID']
out << sample.sampleid
out << 'CCLS'
out << subject.sex
out << 'bg'
out << line['Book']
out << line['Page']
out << line['Pocket']
puts out.join(', ')
csv_out << out
end # CSV.open( 'Guthrie cards in
csv_out.close
puts "Commiting to Sunspot index."
Sunspot.commit
end # task :import_guthrie_card_inventory
# 20130321
# Loop over guthrie card inventory and confirm that any samples with an
# external_id equal to the given GuthrieID belong to the given Subject.
task :check_guthrie_card_inventory => :environment do
raise "This task has been disabled."
(i=CSV.open( 'anand/Guthrie cards inventory 02_05_13-APC CHECKED- for import.csv',
'rb',{ :headers => true })).each do |line|
# "SubjectID","GuthrieID","Book","Page","Pocket"
subject = StudySubject.with_subjectid(line['SubjectID']).first
raise "No subject found with #{line['SubjectID']}" if subject.nil?
samples = Sample.where(:external_id => line['GuthrieID'])
if samples.empty?
puts "No samples with guthrieid #{line['GuthrieID']}"
else
samples.each do |sample|
puts "Found sample with guthrieid #{line['GuthrieID']}"
if sample.study_subject_id == subject.id
puts "Sample and Subject match"
else
puts "WARNING ..... Sample and Subject DO NOT match"
end
end
end
end # CSV.open
end # task :check_guthrie_card_inventory
# 20130313
task :add_sample_external_ids_to_csv => :environment do
raise "This task has been disabled."
f=CSV.open('anand/subjects_with_blood_spot.csv', 'rb')
in_columns = f.gets
f.close
CSV.open('anand/subjects_with_blood_spot_and_external_ids.csv','w') do |csv_out|
csv_out << in_columns + ['external_ids']
(i=CSV.open( 'anand/subjects_with_blood_spot.csv',
'rb',{ :headers => true })).each do |line|
out = in_columns.collect{|c| line[c] }
subject = StudySubject.with_subjectid(line['subjectid']).first
external_ids = subject.samples.where(:sample_type_id => 16).where("external_id LIKE '%G'").collect(&:external_id).compact.join(', ')
external_ids = nil if external_ids.blank?
out << external_ids
puts out
csv_out << out
end
end
end # task :add_sample_external_ids_to_csv => :environment do
end
Deving Anand's last batch of samples task.
require 'csv'
# gonna start asserting that everything is as expected.
# will slow down import, but I want to make sure I get it right.
def assert(expression,message = 'Assertion failed.')
raise "#{message} :\n #{caller[0]}" unless expression
end
def total_lines(csv_file_name)
f = CSV.open(csv_file_name,'rb')
total_lines = f.readlines.size # includes header, but so does f.lineno
f.close
total_lines
end
def childid_cdcid
unless @childid_cdcid
@childid_cdcid = HWIA.new
CSV.open( 'anand/2010-12-06_MaternalBiospecimenIDLink.csv',
'rb',{ :headers => true }).each do |line|
@childid_cdcid[line['CHILDID'].to_i] = line['CDC_ID'].to_i
end
end
@childid_cdcid
end
#
# NOTE
# CDC\ Maternal\ Inventory\ 11_10_08.csv
# Child ID of 09299 changed to 09229 as this subject had samples with the
# corresponding CDC ID of 318
#
#
# One-off tasks written for Anand
#
namespace :anand do
#
# For this task, I wanted the output quoting to match the input quoting
# so that I can compare. By default, any attempt to quote the fields
# will result in triplicate quoting as the quotes get quoted. Irritating.
# However, I read a response to a post online
# http://stackoverflow.com/questions/4854900
# that sets the quote char to null and then manually quote the fields.
# Doing it this way doesn't quote the quotes. Clever.
#
task :verify_maternal_last_batch => :environment do
total_lines = total_lines('anand/20130405_CDC_GEGL_lastbatch.csv')
error_file = File.open('anand/20130405_CDC_GEGL_lastbatch.txt','w')
csv_out = CSV.open( 'anand/20130405_CDC_GEGL_lastbatch_OUTPUT.csv', 'w',
{ :quote_char => "\0" } )
csv_out << %w(LabelID AstroID subjectid sampleid sex sample_type collected_date Box
Position).collect{|c| "\"#{c}\""}
sampleids_in_csv = []
CSV.open( 'anand/20130405_CDC_GEGL_lastbatch.csv',
'rb',{ :headers => true }).each do |line|
sampleids_in_csv << line['sampleid'] if line['sampleid'].present?
end
( csv_in = CSV.open( 'anand/20130405_CDC_GEGL_lastbatch.csv',
'rb',{ :headers => true })).each do |line|
# "LabelID","AstroID","subjectid","sampleid","sex","sample_type",
# "collected_date","Box","Position"
puts "Processing #{csv_in.lineno}/#{total_lines}"
# subjectid sampleid sex sample_type collected_date Box Position)
outline = ["\"#{line['LabelID']}\"", "\"#{line['AstroID']}\""]
# verify subjectid exists
# verify sampleid exists
# verify subject with subjectid is same subject with cdcid/childid
# verify subject sex
# verify subject is mother
# verify sample sample type
cdcid = line['LabelID'].gsub(/^05-57-/,'').gsub(/-\w+$/,'').to_i
childid = childid_cdcid.invert[cdcid]
cdc_mother = StudySubject.with_childid(childid).first.mother
subject = nil
outline << if line['subjectid'].present?
subject = StudySubject.with_subjectid(line['subjectid']).first
if subject.nil?
raise "No subject found with #{line['subjectid']}"
# DOESN'T HAPPEN
# error_file.puts "No subject found with #{line['subjectid']}"
# error_file.puts line
# error_file.puts
end
line['subjectid'].presence
else
# error_file.puts "SubjectID is blank"
# error_file.puts line
# error_file.puts "CDC mother subjectid would be #{cdc_mother.subjectid}"
# error_file.puts
puts "SubjectID is blank."
puts "Assigning the subjectid of mother matching CDCID.#{cdc_mother.subjectid}"
cdc_mother.subjectid
end
#
# Do we want these samples attached to the child or the mother?
# Assuming mother since all but one are attached to mothers,
# even though the LabelID contains the child's childid.
#
if subject and !subject.is_mother?
raise "subject is not a mother"
# FIXED SO WON'T HAPPEN
# error_file.puts "subject is not a mother"
# error_file.puts line
# if subject.mother.nil? # DOESN'T HAPPEN
# error_file.puts "And subject has no mother in database. could create."
# else
# puts "Mother: #{subject.mother.childid}, #{subject.mother.subjectid}"
# end
# error_file.puts
#
# only happens for one subjectid
#
# create mother?
# subject.create_mother
# reassign it to subject?
# subject = subject.mother
#
end
if subject and subject.childid != cdc_mother.childid
raise "childid mismatch #{subject.childid} : #{cdc_mother.childid}"
# FIXED SO WON'T HAPPEN
# error_file.puts "childid mismatch #{subject.childid} : #{cdc_mother.childid}"
# error_file.puts line
# error_file.puts
end
# 2 samples required reassignment to a different subject
# to match CDCID/CHILDID relationship
sample = nil
outline << if line['sampleid'].present?
sample = Sample.where(:id => line['sampleid'].to_i).first
if sample.nil? # DOESN'T HAPPEN
raise "No sample found with #{line['sampleid']}"
# error_file.puts "No sample found with #{line['sampleid']}"
# error_file.puts line
# error_file.puts
end
line['sampleid'].presence
else
puts "SampleID is blank."
# error_file.puts "SampleID is blank."
# error_file.puts line
samples = Sample.where(
Sample.arel_table[:external_id].matches("%#{line['LabelID']}%") )
assumed_sampleid = nil
if samples.empty?
raise "And no samples match external_id #{line['LabelID']}"
# DOESN'T HAPPEN
# error_file.puts "And no samples match external_id #{line['LabelID']}"
else
# error_file.puts "BUT #{samples.length} samples DO match external_id #{line['LabelID']}"
# error_file.puts samples.collect(&:sampleid)
# csv doesn't have leading 0's so just use id, AND they are strings
sampleids = samples.collect(&:id).collect(&:to_s)
puts "Matching sampleids #{sampleids.join(',')}"
unused_sampleids = sampleids - sampleids_in_csv
if unused_sampleids.length == 1
assumed_sampleid = unused_sampleids.first
else
raise "More that one left over matching sampleid? #{sampleids.join(',')}"
end
end
# error_file.puts
assumed_sampleid
end
if subject and sample
if !subject.samples.include?( sample ) # DOESN'T HAPPEN
raise "Sample does not belong to subject"
# FIXED SO WON'T HAPPEN
# error_file.puts "Sample does not belong to subject"
# error_file.puts line
# error_file.puts
end
elsif cdc_mother and sample
if !cdc_mother.samples.include?( sample ) # DOESN'T HAPPEN
raise "Sample does not belong to cdc_mother"
# FIXED SO WON'T HAPPEN
# error_file.puts "Sample does not belong to cdc_mother"
# error_file.puts line
# error_file.puts
end
end
outline << "\"#{line['sex']}\""
outline << "\"#{line['sample_type']}\""
outline << line['collected_date']
outline << if line['Box'].to_s.match(/^NCL/)
"\"#{line['Box']}\""
else
line['Box']
end
outline << line['Position']
csv_out << outline
end # ( csv_in = CSV.open( 'anand/20130405_CDC_GEGL_lastbatch.csv', 'rb'
error_file.close
csv_out.close
end # task :verify_maternal_last_batch => :environment do
# 20130402
task :output_mothers_with_their_own_childids => :environment do
csv_out = CSV.open('anand/mothers_with_their_own_childids.csv','w')
csv_out << %w( mother_subjectid mother_childid child_subjectid child_childid )
StudySubject.mothers.where(StudySubject.arel_table[:childid].not_eq(nil)).each do |mother|
out = []
out << mother.subjectid
out << mother.childid
child = mother.child
out << child.subjectid
out << child.childid
puts out.join(',')
csv_out << out
end
csv_out.close
end
# 20130402
task :verify_childid_subjectid_in_original_samples_is_same_subject => :environment do
total_lines = total_lines('anand/ODMS_samples_xxxxxx.csv')
error_file = File.open('anand/ODMS_samples_xxxxxx.txt','w')
( csv_in = CSV.open( 'anand/ODMS_samples_xxxxxx.csv',
'rb',{ :headers => true })).each do |line|
puts "Processing #{csv_in.lineno}/#{total_lines}"
subject = StudySubject.with_subjectid(line['subjectID']).first
if subject.nil?
error_file.puts "No subject found with #{line['subjectID']}"
error_file.puts line
error_file.puts
next
end
#
# The subjectids and childids don't always match.
# Sometimes they were subjectid for the mother and childid of the child???
# When I imported these samples, I was only going by the subjectid.
# This file confirms the mismatch at import of the 0196 samples.
#
if subject.childid != line['childid'].to_i &&
subject.child.childid != line['childid'].to_i
error_file.puts "Childid Subjectid mismatch"
error_file.puts "Expected #{line['childid']}"
error_file.puts "Has #{subject.childid}"
error_file.puts line
error_file.puts
next
end
end
error_file.close
end # task :verify_childid_subjectid_in_original_samples_is_same_subject => :environment do
# 20130401
# check that all samples with an external_id matching the cdcid
# belong to the subject with the given childid
task :verify_cdcid_childid_sample_link => :environment do
error_file = File.open('anand/2010-12-06_MaternalBiospecimenIDLink.txt','w')
childid_cdcid.each do |childid, cdcid|
cdcid = sprintf('%04d',cdcid.to_i)
puts "Checking childid #{childid} against cdcid #{cdcid}"
samples = Sample.where(
Sample.arel_table[:external_id].matches("05-57-#{cdcid}%") )
samples.each do |sample|
puts "DB:#{sample.study_subject.child.childid} CSV:#{childid}"
unless ( sample.study_subject.child.childid == childid ) #.to_i )
error_file.puts "Childid Mismatch"
error_file.puts "CDC ID #{cdcid}"
error_file.puts "DB:#{sample.study_subject.child.childid} CSV:#{childid}"
error_file.puts
end
end
end
# ensure that the cdcids are unique
if childid_cdcid.keys.length != childid_cdcid.invert.keys.length
error_file.puts "ChildIDs #{childid_cdcid.keys.length}"
error_file.puts "CDC IDs #{childid_cdcid.invert.keys.length}"
end
error_file.close
end # task :verify_cdcid_childid_sample_link => :environment do
# 20130402
#
task :import_cdc_biospecimens_inventory_not_on_gegl_manifest => :environment do
raise "This task has been disabled."
csv_out = CSV.open('anand/20111114_CDC_UrinePlasmaRBC_SampleInventory.NotOnGeglManifest-OUTPUT.csv','w')
csv_out << ['LabelID','SubjectID','SampleID','ProjectID','Gender','smp_type','Amount (mL)',
'Box','Group','Pos','Container']
total_lines = total_lines('anand/20111114_CDC_UrinePlasmaRBC_SampleInventory.NotOnGeglManifest.csv')
(csv_in = CSV.open( 'anand/20111114_CDC_UrinePlasmaRBC_SampleInventory.NotOnGeglManifest.csv',
'rb',{ :headers => true })).each do |line|
puts "Processing line #{csv_in.lineno}/#{total_lines}"
# ,"DLSSampleID","AstroID","smp_type","Box","Group","Pos","Amount (mL)",
# "Amount Full","Container","Sample Type"
#1,"05-57-0042-R1","0019UJNP","RBC",,"NCCLS07C11",1,0.75,,"2.0 mL cryo","R1 RBC Folate"
cdcid = line['DLSSampleID'].gsub(/^05-57-/,'').gsub(/-\w+$/,'').to_i
childid = childid_cdcid.invert[cdcid]
subject = StudySubject.where(:childid => childid).first.mother
sample = subject.samples.create!(
:project_id => Project[:ccls].id,
:sample_type_id => 1003,
:external_id_source => '20111114_CDC_UrinePlasmaRBC_SampleInventory.NotOnGeglManifest.csv',
:external_id => line['DLSSampleID'],
:notes => "Imported from 20111114_CDC_UrinePlasmaRBC_SampleInventory.NotOnGeglManifest.csv\n" <<
"DLSSampleID #{line['DLSSampleID']},\n" <<
"AstroID #{line['AstroID']},\n" <<
"smp_type #{line['smp_type']},\n" <<
"Box #{line['Box']},\n" <<
"Group #{line['Group']},\n" <<
"Pos #{line['Pos']},\n" <<
"Amount (mL) #{line['Amount (mL)']},\n" <<
"Amount Full #{line['Amount Full']},\n" <<
"Container #{line['Container']}" )
out = []
out << line['DLSSampleID']
out << subject.subjectid
out << sample.sampleid
out << 'CCLS'
out << 'F'
out << sample.sample_type.gegl_sample_type_id
out << line['Amount (mL)']
out << line['Box']
out << line['Group']
out << line['Pos']
out << line['Container']
puts out.join(',')
csv_out << out
end # CSV.open( '20111114_CDC_UrinePlasmaRBC_SampleInventory.NotOnGeglManifest.csv',
csv_out.close
puts "Commiting to Sunspot index."
Sunspot.commit
end # task :import_cdc_biospecimens_inventory_not_on_gegl_manifest => :environment do
# 20130401
# check if samples with the given external_id exist
task :verify_cdc_biospecimens_inventory_not_on_gegl_manifest => :environment do
CSV.open( 'anand/20111114_CDC_UrinePlasmaRBC_SampleInventory.NotOnGeglManifest.csv',
'rb',{ :headers => true }).each do |line|
# ,"DLSSampleID","AstroID","smp_type","Box","Group","Pos","Amount (mL)",
# "Amount Full","Container","Sample Type"
#1,"05-57-0042-R1","0019UJNP","RBC",,"NCCLS07C11",1,0.75,,"2.0 mL cryo","R1 RBC Folate"
# DLSSampleID ... external_id
## sample = Sample.where(:external_id => line['DLSSampleID']).first
## sample = Sample.where(:external_id => line['DLSSampleID'].gsub(/-??$/,'')).first
##external_id = line['DLSSampleID'].gsub(/-..$/,'%')
#external_id = line['DLSSampleID']
##external_id = line['DLSSampleID'].gsub(/-R1$/,'-P1')
##puts external_id
# samples = Sample.where(
# Sample.arel_table[:external_id].matches(external_id) )
# if samples.empty?
# raise "No sample found with external_id #{line['DLSSampleID']}"
# else
# puts "-- sample found with external_id #{line['DLSSampleID']}"
# puts samples.collect(&:external_id)
# end
cdcid = line['DLSSampleID'].gsub(/^05-57-/,'').gsub(/-\w+$/,'').to_i
childid = childid_cdcid.invert[cdcid]
raise "CDCID Not Found. #{cdcid}" if childid.nil?
end # CSV.open( '20111114_CDC_UrinePlasmaRBC_SampleInventory.NotOnGeglManifest.csv',
end # task :verify_cdc_biospecimens_inventory_not_on_gegl_manifest => :environment do
# 20130328
task :verify_cdc_biospecimens_inventory => :environment do
error_file = File.open('anand/20111114_CDC_UrinePlasmaRBC_SampleInventory.txt','w')
(i=CSV.open( 'anand/20111114_CDC_UrinePlasmaRBC_SampleInventory.csv',
'rb',{ :headers => true })).each do |line|
#"external_id","astroid","SubjectID","SampleID","sex","type","collected_on","Box","Position",,1
sample = nil
if line['SubjectID'].blank?
puts "Blank subjectid."
puts line
error_file.puts i.lineno
error_file.puts line
error_file.puts "Blank SubjectID"
error_file.puts
sample = Sample.find(line['SampleID'].to_i)
# actually, find would raise an error so this will never happen
raise "No sample found with sampleid #{line['SampleID']}" if sample.nil?
puts "Found sample with #{line['SampleID']}"
else
subject = StudySubject.with_subjectid(line['SubjectID']).first
raise "No subject found with subjectid #{line['SubjectID']}" if subject.nil?
puts "Found subject with #{line['SubjectID']}"
unless subject.is_mother?
error_file.puts i.lineno
error_file.puts line
error_file.puts "Subject is not a Mother"
error_file.puts subject.subject_type
error_file.puts
end
sample = subject.samples.find(line['SampleID'].to_i)
# actually, find would raise an error so this will never happen
raise "No sample found with sampleid #{line['SampleID']}" if sample.nil?
puts "Found subject's sample with #{line['SampleID']}"
end
puts "Types: DB: #{sample.sample_type.gegl_sample_type_id} CSV: #{line['type']}"
puts "ExtID: DB: #{sample.external_id} CSV: #{line['external_id']}"
puts "Sex: DB: #{sample.study_subject.sex} CSV: #{line['sex']}"
# Our gegl sample type codes aren't always the same
# raise "Type mismatch" if sample.sample_type.gegl_sample_type_id != line['type']
raise "ExtID Mismatch" if sample.external_id != line['external_id']
if sample.study_subject.sex != line['sex'].upcase
error_file.puts i.lineno
error_file.puts line
error_file.puts "Sex Mismatch"
error_file.puts "Sex: DB: #{sample.study_subject.sex} CSV: #{line['sex']}"
error_file.puts
end
end # CSV.open
error_file.close
end # task :check_maternal_biospecimens_inventory
# 20130401
task :import_maternal_biospecimens_inventory => :environment do
raise "This task has been disabled."
error_file = File.open('anand/CDC Maternal Inventory 11_10_08.txt','w')
csv_out = CSV.open('anand/UCSF Maternal Samples.csv','w')
csv_out << ['LabelID','SubjectID','SampleID','ProjectID','Gender','smp_type',
'Date Collected','Date Received','Vol(ml)','Freezer','Rack','Box','Position']
total_lines = total_lines('anand/CDC Maternal Inventory 11_10_08.csv')
childid_cdcid_out = HWIA.new
(csv_in = CSV.open( 'anand/CDC Maternal Inventory 11_10_08.csv',
'rb',{ :headers => true })).each do |line|
puts "Processing line #{csv_in.lineno}/#{total_lines}"
if line['Assigned Location'] != '1 Wiencke Lab'
puts "Location is not Wiencke Lab. It is '#{line['Assigned Location']}'. Skipping."
next
end
if line['Spec Type'] == 'VOC(gray top)' # irrelevant as only location '11 CDC'
puts "Spec Type is VOC(gray top). Skipping."
next
end
if line['Spec Type'] == 'VOC(gray tube)' # irrelevant as only location '11 CDC'
puts "Spec Type is VOC(gray tube). Skipping."
next
end
puts line
#
# "Item#","Assigned Location","Child ID","CDC ID","2-Digit CDC ID","Spec Type",
# "Freezer","Rack","Box","Position","Vol (ml)","Date Collected","Date Received",
# "Date Shipped to CDC","Studycode","Comments","UsedUp?","Hematocrit",
# "First Morning Void?"
#
subject = StudySubject.where(:childid => line['Child ID']).first.mother
raise "No subject found with childid #{line['Child ID']}" if subject.nil?
cdcid = line['CDC ID'].gsub(/05-57-/,'').to_i
if childid_cdcid_out.has_key? line['Child ID'].to_i
if childid_cdcid_out[line['Child ID'].to_i] != cdcid # line['CDC ID'].to_i
puts "Child ID CDC ID Mismatch"
puts "Have CDC ID :#{childid_cdcid_out[line['Child ID'].to_i]}:"
puts "This CDC ID :#{cdcid}:" # line['CDC ID'].to_i}:"
raise "Child ID CDC ID Mismatch"
end
else
childid_cdcid_out[line['Child ID'].to_i] = cdcid # line['CDC ID'].to_i
end
cdcid = childid_cdcid[line['Child ID'].to_i]
if cdcid.blank?
error_file.puts line['CDC ID']
error_file.puts line['Child ID']
error_file.puts "No comparison cdc id"
error_file.puts
elsif line['CDC ID'] != "05-57-#{sprintf('%04d',cdcid)}"
error_file.puts "CDC ID Mismatch"
error_file.puts line['CDC ID']
error_file.puts "05-57-#{sprintf('%04d',cdcid)}"
error_file.puts
end
sample_type = case line['Spec Type']
when 'Serum Cotinine' then SampleType.find 1002
when 'Plasma Folate' then SampleType.find 1000
when 'RBC Folate' then SampleType.find 1003
when 'Urine Cup' then SampleType.find 25
when 'SAA' then SampleType.find 1002
when 'SE' then SampleType.find 1002
when 'PL' then SampleType.find 1000
when 'RBC' then SampleType.find 1003
when 'CL' then SampleType.find 1001
when 'Urine Archive' then SampleType.find 25
when 'Clot' then SampleType.find 1001
when 'PA' then SampleType.find 1000
else
raise "All hell. Unexpected spec type :#{line['Spec Type']}:"
end
labelid = "#{line['CDC ID']}-#{line['2-Digit CDC ID']}"
sample = subject.samples.create!(
:project_id => Project[:ccls].id,
:sample_type_id => sample_type.id,
:external_id_source => 'CDC Maternal Inventory 11_10_08.csv',
:external_id => labelid,
:collected_from_subject_at => line['Date Collected'],
:received_by_ccls_at => line['Date Received'],
:notes => "Imported from CDC Maternal Inventory 11_10_08.csv\n" <<
"Child ID #{line['Child ID']},\n" <<
"CDC ID #{line['CDC ID']},\n" <<
"2-Digit CDC ID #{line['2-Digit CDC ID']},\n" <<
"Spec Type #{line['Spec Type']},\n" <<
"Freezer #{line['Freezer']},\n" <<
"Rack #{line['Rack']},\n" <<
"Box #{line['Box']},\n" <<
"Position #{line['Position']},\n" <<
"Vol (ml) #{line['Vol (ml)']},\n" <<
"UsedUp? #{line['UsedUp?']},\n" <<
"Hematocrit #{line['Hematocrit']},\n" <<
"First Morning Void? #{line['First Morning Void?']}" )
out = []
out << labelid
out << subject.subjectid
out << sample.sampleid
out << 'CCLS'
out << 'F'
out << sample.sample_type.gegl_sample_type_id
out << line['Date Collected']
out << line['Date Received']
out << line['Vol (ml)']
out << line['Freezer']
out << line['Rack']
out << line['Box']
out << line['Position']
puts out.join(',')
csv_out << out
end # CSV.open
csv_out.close
error_file.close
childid_cdcid_csv_out = CSV.open('anand/CDC Maternal Inventory 11_10_08-childid-cdcid.csv','w')
childid_cdcid_csv_out << ["CHILDID","CDC_ID"]
childid_cdcid_out.each { |childid,cdcid| childid_cdcid_csv_out << [childid,cdcid] }
childid_cdcid_csv_out.close
puts "Commiting to Sunspot index."
Sunspot.commit
end # task :import_maternal_biospecimens_inventory
# 20130321
# Just confirm that the childids in this csv file exist.
task :check_maternal_biospecimens_inventory => :environment do
(i=CSV.open( 'anand/CDC Maternal Inventory 11_10_08.csv',
'rb',{ :headers => true })).each do |line|
puts line
#
# "Item#","Assigned Location","Child ID","CDC ID","2-Digit CDC ID","Spec Type",
# "Freezer","Rack","Box","Position","Vol (ml)","Date Collected","Date Received",
# "Date Shipped to CDC","Studycode","Comments","UsedUp?","Hematocrit",
# "First Morning Void?"
#
subject = StudySubject.where(:childid => line['Child ID']).first
raise "No subject found with childid #{line['Child ID']}" if subject.nil?
end # CSV.open
end # task :check_maternal_biospecimens_inventory
# 20130321
# Loop over the guthrie card inventory and create new samples
# and then output a combination of the input and the new sample data.
task :import_guthrie_card_inventory => :environment do
raise "This task has been disabled."
csv_out = CSV.open('anand/Guthrie cards inventory 02_05_13- OUTPUT.csv','w')
csv_out << %w(
guthrieid subjectid sampleid projectid gender smp_type book page pocket
)
total_lines = total_lines('anand/Guthrie cards inventory 02_05_13-APC CHECKED- for import.csv')
(csv_in = CSV.open( 'anand/Guthrie cards inventory 02_05_13-APC CHECKED- for import.csv',
'rb',{ :headers => true })).each do |line|
puts "Processing line #{csv_in.lineno}/#{total_lines}"
#
# "SubjectID","GuthrieID","Book","Page","Pocket"
#
out = []
subject = StudySubject.with_subjectid(line['SubjectID']).first
raise "No subject found with #{line['SubjectID']}" if subject.nil?
#
# Create Sample and get sampleid
# sample_type = Blood Spot ( id: 16 ... archive newborn blood )
# external_id_source = 'Guthrie' ( perhaps with book, page and pocket? )
# external_id = line['GuthrieID']
#
sample = subject.samples.create!(
:project_id => Project[:ccls].id,
:sample_type_id => 16,
:sample_format_id => SampleFormat[:guthrie].id,
:external_id_source => "Guthrie cards inventory 02_05_13-APC CHECKED- for import",
:external_id => line['GuthrieID'],
:notes => "Imported from Guthrie cards inventory 02_05_13-APC CHECKED- for import\n" <<
"SubjectID #{line['SubjectID']},\n" <<
"GuthrieID #{line['GuthrieID']},\n" <<
"Book #{line['Book']},\n" <<
"Page #{line['Page']},\n" <<
"Pocket #{line['Pocket']}" )
out << line['GuthrieID']
out << line['SubjectID']
out << sample.sampleid
out << 'CCLS'
out << subject.sex
out << 'bg'
out << line['Book']
out << line['Page']
out << line['Pocket']
puts out.join(', ')
csv_out << out
end # CSV.open( 'Guthrie cards in
csv_out.close
puts "Commiting to Sunspot index."
Sunspot.commit
end # task :import_guthrie_card_inventory
# 20130321
# Loop over guthrie card inventory and confirm that any samples with an
# external_id equal to the given GuthrieID belong to the given Subject.
task :check_guthrie_card_inventory => :environment do
raise "This task has been disabled."
(i=CSV.open( 'anand/Guthrie cards inventory 02_05_13-APC CHECKED- for import.csv',
'rb',{ :headers => true })).each do |line|
# "SubjectID","GuthrieID","Book","Page","Pocket"
subject = StudySubject.with_subjectid(line['SubjectID']).first
raise "No subject found with #{line['SubjectID']}" if subject.nil?
samples = Sample.where(:external_id => line['GuthrieID'])
if samples.empty?
puts "No samples with guthrieid #{line['GuthrieID']}"
else
samples.each do |sample|
puts "Found sample with guthrieid #{line['GuthrieID']}"
if sample.study_subject_id == subject.id
puts "Sample and Subject match"
else
puts "WARNING ..... Sample and Subject DO NOT match"
end
end
end
end # CSV.open
end # task :check_guthrie_card_inventory
# 20130313
task :add_sample_external_ids_to_csv => :environment do
raise "This task has been disabled."
f=CSV.open('anand/subjects_with_blood_spot.csv', 'rb')
in_columns = f.gets
f.close
CSV.open('anand/subjects_with_blood_spot_and_external_ids.csv','w') do |csv_out|
csv_out << in_columns + ['external_ids']
(i=CSV.open( 'anand/subjects_with_blood_spot.csv',
'rb',{ :headers => true })).each do |line|
out = in_columns.collect{|c| line[c] }
subject = StudySubject.with_subjectid(line['subjectid']).first
external_ids = subject.samples.where(:sample_type_id => 16).where("external_id LIKE '%G'").collect(&:external_id).compact.join(', ')
external_ids = nil if external_ids.blank?
out << external_ids
puts out
csv_out << out
end
end
end # task :add_sample_external_ids_to_csv => :environment do
end
|
# Allow the cache to be cleared by rake task
namespace :cache do
desc "Clears the application cache"
task :clear => :environment do
if Rails.cache.is_a? ActiveSupport::Cache::MemoryStore
message = 'Unable to clear cache, using :memory_store so different process from rake (you should try restarting the app server)'
if defined? Airbrake
Airbrake.notify message
else
raise message
end
else
Rails.cache.clear
end
end
end
use :error_message for airbrake notify
# Allow the cache to be cleared by rake task
namespace :cache do
desc "Clears the application cache"
task :clear => :environment do
if Rails.cache.is_a? ActiveSupport::Cache::MemoryStore
message = 'Unable to clear cache, using :memory_store so different process from rake (you should try restarting the app server)'
if defined? Airbrake
Airbrake.notify :error_message => message
else
raise message
end
else
Rails.cache.clear
end
end
end
|
namespace :soniverse_artists
namespace :candy do
desc 'Load the seed data from db/seeds.rb'
task :seed => 'db:abort_if_pending_migrations' do
seed_file = File.join(#{root}, 'db', 'seeds.rb')
load(seed_file) if File.exist?(seed_file)
end
end
end
good times with namespacing
namespace :soniverse do
namespace :artists do
namespace :candy do
desc 'Load the seed data from db/seeds.rb'
task :seed => 'db:abort_if_pending_migrations' do
seed_file = File.join("#{root}", 'db', 'seeds.rb')
load(seed_file) if File.exist?(seed_file)
end
end
end
end |
require 'yaml'
require 'tmpdir'
require File.expand_path('../../thrust', __FILE__)
@thrust = Thrust::Config.make(Dir.getwd, File.join(Dir.getwd, 'thrust.yml'))
@xcode_tools_provider = Thrust::IOS::XCodeToolsProvider.new
@executor = Thrust::Executor.new
desc 'Trim whitespace'
task :trim do
awk_statement = <<-AWK
{
if ($1 == "RM" || $1 == "R")
print $4;
else if ($1 != "D")
print $2;
}
AWK
awk_statement.gsub!(%r{\s+}, " ")
@executor.system_or_exit %Q[git status --porcelain | awk '#{awk_statement}' | grep -e '.*\.[cmh]$' | xargs sed -i '' -e 's/ / /g;s/ *$//g;']
end
desc 'Remove any focus from specs'
task :nof do
substitutions = focused_methods.map do |method|
unfocused_method = method.sub(/^f/, '')
"-e 's/#{method}/#{unfocused_method}/g;'"
end
@executor.system_or_exit %Q[ rake focused_specs | xargs -I filename sed -i '' #{substitutions.join(' ')} "filename" ]
end
desc 'Print out names of files containing focused specs'
task :focused_specs do
pattern = focused_methods.join("\\|")
directories = @thrust.app_config['ios_spec_targets'].values.map {|h| h['target']}.join(' ')
@executor.system_or_exit %Q[ grep -l -r -e "\\(#{pattern}\\)" #{directories} | grep -v 'Frameworks' ; exit 0 ]
end
desc 'Clean all targets'
task :clean do
xcode_tools_instance(nil).clean_build
end
desc 'Clean all targets (deprecated, use "clean")'
task :clean_build => :clean
(@thrust.app_config['ios_spec_targets'] || []).each do |task_name, target_info|
desc "Run the #{target_info['target'].inspect} target with scheme #{(target_info['scheme'] || target_info['target']).inspect}"
task task_name do
build_configuration = target_info['build_configuration']
target = target_info['target']
scheme = target_info['scheme']
build_sdk = target_info['build_sdk'] || 'iphonesimulator' #build sdk - version you compile the code with
runtime_sdk = target_info['runtime_sdk'] #runtime sdk
xcode_tools = xcode_tools_instance(build_configuration)
xcode_tools.build_scheme_or_target(scheme || target, build_sdk, 'i386')
cedar_success = Thrust::IOS::Cedar.new.run($stdout, build_configuration, target, runtime_sdk, build_sdk, target_info['device'], @thrust.build_dir, @thrust.app_config['ios_sim_binary'])
exit(cedar_success ? 0 : 1)
end
end
def focused_methods
%w(fit fcontext fdescribe).map { |method| "#{method}(@" }
end
def xcode_tools_instance(build_configuration)
tools_options = { project_name: @thrust.app_config['project_name'], workspace_name: @thrust.app_config['workspace_name'] }
@xcode_tools_provider.instance($stdout, build_configuration, @thrust.build_dir, tools_options)
end
Allow setting Specs target runtime_sdk via rake argument
Allows overriding the value specified in the thrust.yml, useful for parameterizing builds on ci
require 'yaml'
require 'tmpdir'
require File.expand_path('../../thrust', __FILE__)
@thrust = Thrust::Config.make(Dir.getwd, File.join(Dir.getwd, 'thrust.yml'))
@xcode_tools_provider = Thrust::IOS::XCodeToolsProvider.new
@executor = Thrust::Executor.new
desc 'Trim whitespace'
task :trim do
awk_statement = <<-AWK
{
if ($1 == "RM" || $1 == "R")
print $4;
else if ($1 != "D")
print $2;
}
AWK
awk_statement.gsub!(%r{\s+}, " ")
@executor.system_or_exit %Q[git status --porcelain | awk '#{awk_statement}' | grep -e '.*\.[cmh]$' | xargs sed -i '' -e 's/ / /g;s/ *$//g;']
end
desc 'Remove any focus from specs'
task :nof do
substitutions = focused_methods.map do |method|
unfocused_method = method.sub(/^f/, '')
"-e 's/#{method}/#{unfocused_method}/g;'"
end
@executor.system_or_exit %Q[ rake focused_specs | xargs -I filename sed -i '' #{substitutions.join(' ')} "filename" ]
end
desc 'Print out names of files containing focused specs'
task :focused_specs do
pattern = focused_methods.join("\\|")
directories = @thrust.app_config['ios_spec_targets'].values.map {|h| h['target']}.join(' ')
@executor.system_or_exit %Q[ grep -l -r -e "\\(#{pattern}\\)" #{directories} | grep -v 'Frameworks' ; exit 0 ]
end
desc 'Clean all targets'
task :clean do
xcode_tools_instance(nil).clean_build
end
desc 'Clean all targets (deprecated, use "clean")'
task :clean_build => :clean
(@thrust.app_config['ios_spec_targets'] || []).each do |task_name, target_info|
desc "Run the #{target_info['target'].inspect} target with scheme #{(target_info['scheme'] || target_info['target']).inspect}"
task task_name, :runtime_sdk do |_, args|
build_configuration = target_info['build_configuration']
target = target_info['target']
scheme = target_info['scheme']
build_sdk = target_info['build_sdk'] || 'iphonesimulator' #build sdk - version you compile the code with
runtime_sdk = args[:runtime_sdk] || target_info['runtime_sdk'] #runtime sdk
xcode_tools = xcode_tools_instance(build_configuration)
xcode_tools.build_scheme_or_target(scheme || target, build_sdk, 'i386')
cedar_success = Thrust::IOS::Cedar.new.run($stdout, build_configuration, target, runtime_sdk, build_sdk, target_info['device'], @thrust.build_dir, @thrust.app_config['ios_sim_binary'])
exit(cedar_success ? 0 : 1)
end
end
def focused_methods
%w(fit fcontext fdescribe).map { |method| "#{method}(@" }
end
def xcode_tools_instance(build_configuration)
tools_options = { project_name: @thrust.app_config['project_name'], workspace_name: @thrust.app_config['workspace_name'] }
@xcode_tools_provider.instance($stdout, build_configuration, @thrust.build_dir, tools_options)
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.