automatic rubocop updates

This commit is contained in:
Devin Howard 2016-09-24 11:00:46 +08:00
parent 0a62eb3299
commit 0ace202ace
158 changed files with 239 additions and 93 deletions

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'https://rubygems.org' source 'https://rubygems.org'
ruby '2.3.0' ruby '2.3.0'

View file

@ -1,4 +1,5 @@
#!/usr/bin/env rake #!/usr/bin/env rake
# frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake, # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

3
Vagrantfile vendored
View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# -*- mode: ruby -*- # -*- mode: ruby -*-
# vi: set ft=ruby : # vi: set ft=ruby :
@ -31,7 +32,7 @@ sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '3112';"
SCRIPT SCRIPT
VAGRANTFILE_API_VERSION = '2'.freeze VAGRANTFILE_API_VERSION = '2'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'trusty64' config.vm.box = 'trusty64'

View file

@ -1,8 +1,9 @@
# frozen_string_literal: true
module Api module Api
module V1 module V1
class DeprecatedController < ApplicationController class DeprecatedController < ApplicationController
def method_missing def method_missing
render json: { error: "/api/v1 is deprecated! Please use /api/v2 instead." } render json: { error: '/api/v1 is deprecated! Please use /api/v2 instead.' }
end end
end end
end end

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Api module Api
module V1 module V1
class MappingsController < DeprecatedController class MappingsController < DeprecatedController

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Api module Api
module V1 module V1
class MapsController < DeprecatedController class MapsController < DeprecatedController

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Api module Api
module V1 module V1
class SynapsesController < DeprecatedController class SynapsesController < DeprecatedController

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Api module Api
module V1 module V1
class TokensController < DeprecatedController class TokensController < DeprecatedController

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Api module Api
module V1 module V1
class TopicsController < DeprecatedController class TopicsController < DeprecatedController

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class MappingsController < RestfulController class MappingsController < RestfulController

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class MapsController < RestfulController class MapsController < RestfulController

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class RestfulController < ActionController::Base class RestfulController < ActionController::Base
@ -101,9 +102,9 @@ module Api
next_page = current_page < total_pages ? current_page + 1 : 0 next_page = current_page < total_pages ? current_page + 1 : 0
base_url = request.base_url + request.path base_url = request.base_url + request.path
nxt = request.query_parameters.merge(page: next_page).map{|x| x.join('=')}.join('&') nxt = request.query_parameters.merge(page: next_page).map { |x| x.join('=') }.join('&')
prev = request.query_parameters.merge(page: prev_page).map{|x| x.join('=')}.join('&') prev = request.query_parameters.merge(page: prev_page).map { |x| x.join('=') }.join('&')
last = request.query_parameters.merge(page: total_pages).map{|x| x.join('=')}.join('&') last = request.query_parameters.merge(page: total_pages).map { |x| x.join('=') }.join('&')
response.headers['Link'] = [ response.headers['Link'] = [
%(<#{base_url}?#{nxt}>; rel="next"), %(<#{base_url}?#{nxt}>; rel="next"),
%(<#{base_url}?#{prev}>; rel="prev"), %(<#{base_url}?#{prev}>; rel="prev"),
@ -163,7 +164,7 @@ module Api
builder = builder.order(sort => direction) builder = builder.order(sort => direction)
end end
end end
return builder builder
end end
def visible_records def visible_records

View file

@ -1,9 +1,10 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class SessionsController < ApplicationController class SessionsController < ApplicationController
def create def create
@user = User.find_by(email: params[:email]) @user = User.find_by(email: params[:email])
if @user && @user.valid_password(params[:password]) if @user&.valid_password(params[:password])
sign_in(@user) sign_in(@user)
render json: @user render json: @user
else else

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class SynapsesController < RestfulController class SynapsesController < RestfulController

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class TokensController < RestfulController class TokensController < RestfulController

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class TopicsController < RestfulController class TopicsController < RestfulController

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
include ApplicationHelper include ApplicationHelper
include Pundit include Pundit
@ -60,10 +61,9 @@ class ApplicationController < ActionController::Base
end end
def require_admin def require_admin
unless authenticated? && admin? return true if authenticated? && admin?
redirect_to root_url, notice: 'You need to be an admin for that.' redirect_to root_url, notice: 'You need to be an admin for that.'
return false false
end
end end
def user def user

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class MainController < ApplicationController class MainController < ApplicationController
include TopicsHelper include TopicsHelper
include MapsHelper include MapsHelper
@ -12,13 +13,13 @@ class MainController < ApplicationController
def home def home
@maps = policy_scope(Map).order('updated_at DESC').page(1).per(20) @maps = policy_scope(Map).order('updated_at DESC').page(1).per(20)
respond_to do |format| respond_to do |format|
format.html { format.html do
if !authenticated? if !authenticated?
render 'main/home' render 'main/home'
else else
render 'maps/activemaps' render 'maps/activemaps'
end end
} end
end end
end end
@ -163,8 +164,8 @@ class MainController < ApplicationController
@synapses = [] @synapses = []
end end
#limit to 5 results # limit to 5 results
@synapses = @synapses.to_a.slice(0,5) @synapses = @synapses.to_a.slice(0, 5)
render json: autocomplete_synapse_array_json(@synapses) render json: autocomplete_synapse_array_json(@synapses)
end end

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class MappingsController < ApplicationController class MappingsController < ApplicationController
before_action :require_user, only: [:create, :update, :destroy] before_action :require_user, only: [:create, :update, :destroy]
after_action :verify_authorized, except: :index after_action :verify_authorized, except: :index

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class MapsController < ApplicationController class MapsController < ApplicationController
before_action :require_user, only: [:create, :update, :access, :star, :unstar, :screenshot, :events, :destroy] before_action :require_user, only: [:create, :update, :access, :star, :unstar, :screenshot, :events, :destroy]
after_action :verify_authorized, except: [:activemaps, :featuredmaps, :mymaps, :sharedmaps, :starredmaps, :usermaps] after_action :verify_authorized, except: [:activemaps, :featuredmaps, :mymaps, :sharedmaps, :starredmaps, :usermaps]
@ -107,7 +108,7 @@ class MapsController < ApplicationController
# GET maps/new # GET maps/new
def new def new
@map = Map.new(name: "Untitled Map", permission: "public", arranged: true) @map = Map.new(name: 'Untitled Map', permission: 'public', arranged: true)
authorize @map authorize @map
respond_to do |format| respond_to do |format|
@ -305,9 +306,7 @@ class MapsController < ApplicationController
@map = Map.find(params[:id]) @map = Map.find(params[:id])
authorize @map authorize @map
star = Star.find_by_map_id_and_user_id(@map.id, current_user.id) star = Star.find_by_map_id_and_user_id(@map.id, current_user.id)
if not star star = Star.create(map_id: @map.id, user_id: current_user.id) unless star
star = Star.create(map_id: @map.id, user_id: current_user.id)
end
respond_to do |format| respond_to do |format|
format.json do format.json do
@ -321,9 +320,7 @@ class MapsController < ApplicationController
@map = Map.find(params[:id]) @map = Map.find(params[:id])
authorize @map authorize @map
star = Star.find_by_map_id_and_user_id(@map.id, current_user.id) star = Star.find_by_map_id_and_user_id(@map.id, current_user.id)
if star star&.delete
star.delete
end
respond_to do |format| respond_to do |format|
format.json do format.json do

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class MessagesController < ApplicationController class MessagesController < ApplicationController
before_action :require_user, except: [:show] before_action :require_user, except: [:show]
after_action :verify_authorized after_action :verify_authorized

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class MetacodeSetsController < ApplicationController class MetacodeSetsController < ApplicationController
before_action :require_admin before_action :require_admin

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class SynapsesController < ApplicationController class SynapsesController < ApplicationController
include TopicsHelper include TopicsHelper

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class TopicsController < ApplicationController class TopicsController < ApplicationController
include TopicsHelper include TopicsHelper

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Users::PasswordsController < Devise::PasswordsController class Users::PasswordsController < Devise::PasswordsController
protected protected
@ -5,7 +6,7 @@ class Users::PasswordsController < Devise::PasswordsController
signed_in_root_path(resource) signed_in_root_path(resource)
end end
def after_sending_reset_password_instructions_path_for(resource_name) def after_sending_reset_password_instructions_path_for(_resource_name)
new_user_session_path if is_navigational_format? new_user_session_path if is_navigational_format?
end end
end end

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Users::RegistrationsController < Devise::RegistrationsController class Users::RegistrationsController < Devise::RegistrationsController
before_action :configure_sign_up_params, only: [:create] before_action :configure_sign_up_params, only: [:create]
before_action :configure_account_update_params, only: [:update] before_action :configure_account_update_params, only: [:update]

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class UsersController < ApplicationController class UsersController < ApplicationController
before_action :require_user, only: [:edit, :update, :updatemetacodes] before_action :require_user, only: [:edit, :update, :updatemetacodes]

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module ApplicationHelper module ApplicationHelper
def get_metacodeset def get_metacodeset
@m = current_user.settings.metacodes @m = current_user.settings.metacodes

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module ContentHelper module ContentHelper
def resource_name def resource_name
:user :user

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module DeviseHelper module DeviseHelper
def devise_error_messages! def devise_error_messages!
resource.errors.to_a[0] resource.errors.to_a[0]

View file

@ -1,2 +1,3 @@
# frozen_string_literal: true
module InMetacodeSetsHelper module InMetacodeSetsHelper
end end

View file

@ -1,2 +1,3 @@
# frozen_string_literal: true
module MainHelper module MainHelper
end end

View file

@ -1,2 +1,3 @@
# frozen_string_literal: true
module MappingHelper module MappingHelper
end end

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module MapsHelper module MapsHelper
## this one is for building our custom JSON autocomplete format for typeahead ## this one is for building our custom JSON autocomplete format for typeahead
def autocomplete_map_array_json(maps) def autocomplete_map_array_json(maps)
@ -16,7 +17,7 @@ module MapsHelper
contributorTip = '' contributorTip = ''
firstContributorImage = 'https://s3.amazonaws.com/metamaps-assets/site/user.png' firstContributorImage = 'https://s3.amazonaws.com/metamaps-assets/site/user.png'
if m.contributors.count > 0 if m.contributors.count.positive?
firstContributorImage = m.contributors[0].image.url(:thirtytwo) firstContributorImage = m.contributors[0].image.url(:thirtytwo)
m.contributors.each_with_index do |c, _index| m.contributors.each_with_index do |c, _index|
userImage = c.image.url(:thirtytwo) userImage = c.image.url(:thirtytwo)

View file

@ -1,2 +1,3 @@
# frozen_string_literal: true
module MetacodeSetsHelper module MetacodeSetsHelper
end end

View file

@ -1,2 +1,3 @@
# frozen_string_literal: true
module MetacodesHelper module MetacodesHelper
end end

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module SynapsesHelper module SynapsesHelper
## this one is for building our custom JSON autocomplete format for typeahead ## this one is for building our custom JSON autocomplete format for typeahead
def autocomplete_synapse_generic_json(unique) def autocomplete_synapse_generic_json(unique)

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module TopicsHelper module TopicsHelper
## this one is for building our custom JSON autocomplete format for typeahead ## this one is for building our custom JSON autocomplete format for typeahead
def autocomplete_array_json(topics) def autocomplete_array_json(topics)
@ -7,7 +8,7 @@ module TopicsHelper
topic['id'] = t.id topic['id'] = t.id
topic['label'] = t.name topic['label'] = t.name
topic['value'] = t.name topic['value'] = t.name
topic['description'] = t.desc ? t.desc.truncate(70) : '' # make this return matched results topic['description'] = t.desc ? t.desc&.truncate(70) # make this return matched results
topic['type'] = t.metacode.name topic['type'] = t.metacode.name
topic['typeImageURL'] = t.metacode.icon topic['typeImageURL'] = t.metacode.icon
topic['permission'] = t.permission topic['permission'] = t.permission
@ -34,7 +35,7 @@ module TopicsHelper
# add the node to the array # add the node to the array
array.push(node) array.push(node)
return array if count == 0 return array if count.zero?
count -= 1 count -= 1

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module UsersHelper module UsersHelper
# build custom json autocomplete for typeahead # build custom json autocomplete for typeahead
def autocomplete_user_array_json(users) def autocomplete_user_array_json(users)

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class ApplicationMailer < ActionMailer::Base class ApplicationMailer < ActionMailer::Base
default from: 'team@metamaps.cc' default from: 'team@metamaps.cc'
layout 'mailer' layout 'mailer'

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class MapMailer < ApplicationMailer class MapMailer < ApplicationMailer
default from: 'team@metamaps.cc' default from: 'team@metamaps.cc'

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true self.abstract_class = true
end end

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Routing module Routing
extend ActiveSupport::Concern extend ActiveSupport::Concern
include Rails.application.routes.url_helpers include Rails.application.routes.url_helpers

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Event < ApplicationRecord class Event < ApplicationRecord
KINDS = %w(user_present_on_map conversation_started_on_map topic_added_to_map synapse_added_to_map).freeze KINDS = %w(user_present_on_map conversation_started_on_map topic_added_to_map synapse_added_to_map).freeze

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Events::ConversationStartedOnMap < Event class Events::ConversationStartedOnMap < Event
# after_create :notify_users! # after_create :notify_users!

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Events::NewMapping < Event class Events::NewMapping < Event
# after_create :notify_users! # after_create :notify_users!

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Events::UserPresentOnMap < Event class Events::UserPresentOnMap < Event
# after_create :notify_users! # after_create :notify_users!

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class InMetacodeSet < ApplicationRecord class InMetacodeSet < ApplicationRecord
belongs_to :metacode, class_name: 'Metacode', foreign_key: 'metacode_id' belongs_to :metacode, class_name: 'Metacode', foreign_key: 'metacode_id'
belongs_to :metacode_set, class_name: 'MetacodeSet', foreign_key: 'metacode_set_id' belongs_to :metacode_set, class_name: 'MetacodeSet', foreign_key: 'metacode_set_id'

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Map < ApplicationRecord class Map < ApplicationRecord
belongs_to :user belongs_to :user
@ -19,7 +20,7 @@ class Map < ApplicationRecord
thumb: ['188x126#', :png] thumb: ['188x126#', :png]
#:full => ['940x630#', :png] #:full => ['940x630#', :png]
}, },
default_url: 'https://s3.amazonaws.com/metamaps-assets/site/missing-map-white.png' default_url: 'https://s3.amazonaws.com/metamaps-assets/site/missing-map-white.png'
validates :name, presence: true validates :name, presence: true
validates :arranged, inclusion: { in: [true, false] } validates :arranged, inclusion: { in: [true, false] }

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Mapping < ApplicationRecord class Mapping < ApplicationRecord
scope :topicmapping, -> { where(mappable_type: :Topic) } scope :topicmapping, -> { where(mappable_type: :Topic) }
scope :synapsemapping, -> { where(mappable_type: :Synapse) } scope :synapsemapping, -> { where(mappable_type: :Synapse) }

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Message < ApplicationRecord class Message < ApplicationRecord
belongs_to :user belongs_to :user
belongs_to :resource, polymorphic: true belongs_to :resource, polymorphic: true

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Metacode < ApplicationRecord class Metacode < ApplicationRecord
has_many :in_metacode_sets has_many :in_metacode_sets
has_many :metacode_sets, through: :in_metacode_sets has_many :metacode_sets, through: :in_metacode_sets

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class MetacodeSet < ApplicationRecord class MetacodeSet < ApplicationRecord
belongs_to :user belongs_to :user
has_many :in_metacode_sets has_many :in_metacode_sets

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class PermittedParams < Struct.new(:params) class PermittedParams < Struct.new(:params)
%w(map synapse topic mapping token).each do |kind| %w(map synapse topic mapping token).each do |kind|
define_method(kind) do define_method(kind) do

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Star < ActiveRecord::Base class Star < ActiveRecord::Base
belongs_to :user belongs_to :user
belongs_to :map belongs_to :map

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Synapse < ApplicationRecord class Synapse < ApplicationRecord
belongs_to :user belongs_to :user
belongs_to :defer_to_map, class_name: 'Map', foreign_key: 'defer_to_map_id' belongs_to :defer_to_map, class_name: 'Map', foreign_key: 'defer_to_map_id'
@ -44,10 +45,7 @@ class Synapse < ApplicationRecord
# :nocov: # :nocov:
def calculated_permission def calculated_permission
if defer_to_map if defer_to_map
defer_to_map.permission defer_to_map&.permission
else
permission
end
end end
# :nocov: # :nocov:

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Token < ApplicationRecord class Token < ApplicationRecord
belongs_to :user belongs_to :user

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Topic < ApplicationRecord class Topic < ApplicationRecord
include TopicsHelper include TopicsHelper
@ -74,10 +75,7 @@ class Topic < ApplicationRecord
def calculated_permission def calculated_permission
if defer_to_map if defer_to_map
defer_to_map.permission defer_to_map&.permission
else
permission
end
end end
def as_json(_options = {}) def as_json(_options = {})

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'open-uri' require 'open-uri'
class User < ApplicationRecord class User < ApplicationRecord
@ -41,7 +42,7 @@ class User < ApplicationRecord
default_url: 'https://s3.amazonaws.com/metamaps-assets/site/user.png' default_url: 'https://s3.amazonaws.com/metamaps-assets/site/user.png'
# Validate the attached image is image/jpg, image/png, etc # Validate the attached image is image/jpg, image/png, etc
validates_attachment_content_type :image, content_type: %r(\Aimage/.*\Z) validates_attachment_content_type :image, content_type: %r{\Aimage/.*\Z}
# override default as_json # override default as_json
def as_json(_options = {}) def as_json(_options = {})
@ -80,7 +81,7 @@ class User < ApplicationRecord
end end
def starred_map?(map) def starred_map?(map)
return self.stars.where(map_id: map.id).exists? stars.where(map_id: map.id).exists?
end end
def settings def settings

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class UserMap < ApplicationRecord class UserMap < ApplicationRecord
belongs_to :map belongs_to :map
belongs_to :user belongs_to :user

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class UserPreference class UserPreference
attr_accessor :metacodes attr_accessor :metacodes
@ -9,7 +10,7 @@ class UserPreference
array.push(metacode.id.to_s) if metacode array.push(metacode.id.to_s) if metacode
rescue ActiveRecord::StatementInvalid rescue ActiveRecord::StatementInvalid
if m == 'Action' if m == 'Action'
Rails.logger.warn("TODO: remove this travis workaround in user_preference.rb") Rails.logger.warn('TODO: remove this travis workaround in user_preference.rb')
end end
end end
end end

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Webhook < ApplicationRecord class Webhook < ApplicationRecord
belongs_to :hookable, polymorphic: true belongs_to :hookable, polymorphic: true

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
Webhooks::Slack::Base = Struct.new(:event) do Webhooks::Slack::Base = Struct.new(:event) do
include Routing include Routing

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Webhooks::Slack::ConversationStartedOnMap < Webhooks::Slack::Base class Webhooks::Slack::ConversationStartedOnMap < Webhooks::Slack::Base
def text def text
"There is a live conversation starting on map *#{event.map.name}*. #{view_map_on_metamaps('Join in!')}" "There is a live conversation starting on map *#{event.map.name}*. #{view_map_on_metamaps('Join in!')}"

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Webhooks::Slack::SynapseAddedToMap < Webhooks::Slack::Base class Webhooks::Slack::SynapseAddedToMap < Webhooks::Slack::Base
def text def text
"\"*#{eventable.mappable.topic1.name}* #{eventable.mappable.desc || '->'} *#{eventable.mappable.topic2.name}*\" was added as a connection to the map *#{view_map_on_metamaps}*" "\"*#{eventable.mappable.topic1.name}* #{eventable.mappable.desc || '->'} *#{eventable.mappable.topic2.name}*\" was added as a connection to the map *#{view_map_on_metamaps}*"

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Webhooks::Slack::TopicAddedToMap < Webhooks::Slack::Base class Webhooks::Slack::TopicAddedToMap < Webhooks::Slack::Base
def text def text
"New #{eventable.mappable.metacode.name} topic *#{eventable.mappable.name}* was added to the map *#{view_map_on_metamaps}*" "New #{eventable.mappable.metacode.name} topic *#{eventable.mappable.name}* was added to the map *#{view_map_on_metamaps}*"

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Webhooks::Slack::UserPresentOnMap < Webhooks::Slack::Base class Webhooks::Slack::UserPresentOnMap < Webhooks::Slack::Base
def text def text
"Mapper *#{event.user.name}* has joined the map *#{event.map.name}*. #{view_map_on_metamaps('Map with them')}" "Mapper *#{event.user.name}* has joined the map *#{event.map.name}*. #{view_map_on_metamaps('Map with them')}"

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class ApplicationPolicy class ApplicationPolicy
attr_reader :user, :record attr_reader :user, :record
@ -39,7 +40,7 @@ class ApplicationPolicy
# explicitly say they want to (E.g. seeing/editing/deleting private # explicitly say they want to (E.g. seeing/editing/deleting private
# maps - they should be able to, but not by accident) # maps - they should be able to, but not by accident)
def admin_override def admin_override
user && user.admin user&.admin
end end
def scope def scope

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class MainPolicy < ApplicationPolicy class MainPolicy < ApplicationPolicy
def initialize(user, _record) def initialize(user, _record)
@user = user @user = user

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class MapPolicy < ApplicationPolicy class MapPolicy < ApplicationPolicy
class Scope < Scope class Scope < Scope
def resolve def resolve

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class MappingPolicy < ApplicationPolicy class MappingPolicy < ApplicationPolicy
class Scope < Scope class Scope < Scope
def resolve def resolve

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class MessagePolicy < ApplicationPolicy class MessagePolicy < ApplicationPolicy
class Scope < Scope class Scope < Scope
def resolve def resolve

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class SynapsePolicy < ApplicationPolicy class SynapsePolicy < ApplicationPolicy
class Scope < Scope class Scope < Scope
def resolve def resolve

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class TokenPolicy < ApplicationPolicy class TokenPolicy < ApplicationPolicy
class Scope < Scope class Scope < Scope
def resolve def resolve

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class TopicPolicy < ApplicationPolicy class TopicPolicy < ApplicationPolicy
class Scope < Scope class Scope < Scope
def resolve def resolve

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class ApplicationSerializer < ActiveModel::Serializer class ApplicationSerializer < ActiveModel::Serializer

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class EventSerializer < ApplicationSerializer class EventSerializer < ApplicationSerializer

View file

@ -1,13 +1,14 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class MapSerializer < ApplicationSerializer class MapSerializer < ApplicationSerializer
attributes :id, attributes :id,
:name, :name,
:desc, :desc,
:permission, :permission,
:screenshot, :screenshot,
:created_at, :created_at,
:updated_at :updated_at
def self.embeddable def self.embeddable
{ {
@ -20,7 +21,7 @@ module Api
} }
end end
self.class_eval do class_eval do
embed_dat embed_dat
end end
end end

View file

@ -1,11 +1,12 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class MappingSerializer < ApplicationSerializer class MappingSerializer < ApplicationSerializer
attributes :id, attributes :id,
:created_at, :created_at,
:updated_at, :updated_at,
:mappable_id, :mappable_id,
:mappable_type :mappable_type
attribute :xloc, if: -> { object.mappable_type == 'Topic' } attribute :xloc, if: -> { object.mappable_type == 'Topic' }
attribute :yloc, if: -> { object.mappable_type == 'Topic' } attribute :yloc, if: -> { object.mappable_type == 'Topic' }
@ -17,7 +18,7 @@ module Api
} }
end end
self.class_eval do class_eval do
embed_dat embed_dat
end end
end end

View file

@ -1,11 +1,12 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class MetacodeSerializer < ApplicationSerializer class MetacodeSerializer < ApplicationSerializer
attributes :id, attributes :id,
:name, :name,
:manual_icon, :manual_icon,
:color, :color,
:aws_icon :aws_icon
end end
end end
end end

View file

@ -1,12 +1,13 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class SynapseSerializer < ApplicationSerializer class SynapseSerializer < ApplicationSerializer
attributes :id, attributes :id,
:desc, :desc,
:category, :category,
:permission, :permission,
:created_at, :created_at,
:updated_at :updated_at
def self.embeddable def self.embeddable
{ {
@ -16,7 +17,7 @@ module Api
} }
end end
self.class_eval do class_eval do
embed_dat embed_dat
end end
end end

View file

@ -1,10 +1,11 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class TokenSerializer < ApplicationSerializer class TokenSerializer < ApplicationSerializer
attributes :id, attributes :id,
:token, :token,
:description, :description,
:created_at :created_at
end end
end end
end end

View file

@ -1,13 +1,14 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class TopicSerializer < ApplicationSerializer class TopicSerializer < ApplicationSerializer
attributes :id, attributes :id,
:name, :name,
:desc, :desc,
:link, :link,
:permission, :permission,
:created_at, :created_at,
:updated_at :updated_at
def self.embeddable def self.embeddable
{ {
@ -16,7 +17,7 @@ module Api
} }
end end
self.class_eval do class_eval do
embed_dat embed_dat
end end
end end

View file

@ -1,11 +1,12 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class UserSerializer < ApplicationSerializer class UserSerializer < ApplicationSerializer
attributes :id, attributes :id,
:name, :name,
:avatar, :avatar,
:is_admin, :is_admin,
:generation :generation
def avatar def avatar
object.image.url(:sixtyfour) object.image.url(:sixtyfour)

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Api module Api
module V2 module V2
class WebhookSerializer < ApplicationSerializer class WebhookSerializer < ApplicationSerializer

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class MapExportService < Struct.new(:user, :map) class MapExportService < Struct.new(:user, :map)
def json def json
# marshal_dump turns OpenStruct into a Hash # marshal_dump turns OpenStruct into a Hash

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class Perm class Perm
# e.g. Perm::ISSIONS # e.g. Perm::ISSIONS
ISSIONS = [:commons, :public, :private].freeze ISSIONS = [:commons, :public, :private].freeze

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class WebhookService class WebhookService
def self.publish!(webhook:, event:) def self.publish!(webhook:, event:)
return false unless webhook.event_types.include? event.kind return false unless webhook.event_types.include? event.kind

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# This file is used by Rack-based servers to start the application. # This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__) require ::File.expand_path('../config/environment', __FILE__)

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative 'boot' require_relative 'boot'
require 'csv' require 'csv'

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems' require 'rubygems'
require 'rails/commands/server' require 'rails/commands/server'

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Load the Rails application. # Load the Rails application.
require_relative 'application' require_relative 'application'

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
Metamaps::Application.configure do Metamaps::Application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
Metamaps::Application.configure do Metamaps::Application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
$codes = [] $codes = []
if ActiveRecord::Base.connection.data_source_exists? 'users' if ActiveRecord::Base.connection.data_source_exists? 'users'
$codes = ActiveRecord::Base.connection.execute('SELECT code FROM users').map { |user| user['code'] } $codes = ActiveRecord::Base.connection.execute('SELECT code FROM users').map { |user| user['code'] }

View file

@ -1 +1,2 @@
# frozen_string_literal: true
ActiveModelSerializers.config.adapter = :json ActiveModelSerializers.config.adapter = :json

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# ApplicationController.renderer.defaults.merge!( # ApplicationController.renderer.defaults.merge!(

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets. # Version of your assets, change this if you want to expire all your assets.
@ -9,4 +10,4 @@ Rails.application.config.assets.quiet = true
# Precompile additional assets. # Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
Rails.application.config.assets.precompile += %w( webpacked/metamaps.bundle.js ) Rails.application.config.assets.precompile += %w(webpacked/metamaps.bundle.js)

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.

Some files were not shown because too many files have changed in this diff Show more