repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
petertseng/adventofcode-rb-2019
04_password.rb
<reponame>petertseng/adventofcode-rb-2019<gh_stars>10-100 def increasing_between(min, max) max_digits = max.digits.reverse digits = min.digits.reverse _, decrease = digits.each_cons(2).with_index.find { |(a, b), i| a > b } # If min doesn't already meet criteria, # construct the first number that does. ...
petertseng/adventofcode-rb-2019
satadd.rb
(0..3).each { |x| (0..3).each { |y| expected = [x + y, 3].min a = x & 0xa b = x & 0x5 c = y & 0xa d = y & 0x5 bd = b & d upper_bits = a | c | (bd << 1) al = a >> 1 cl = c >> 1 lower_bits = (b ^ d) | (al & cl) | (bd & (al | cl)) #lower_bits = ((b | d) & (al | cl | ~bd)) | ...
zivolution921/meobox
app/controllers/users_controller.rb
class UsersController < ApplicationController before_action :require_signin, except: [:new, :create] before_action :require_correct_user, only: [:edit, :update, :destroy] before_action :set_plan, only: [:show, :history] def new @user = User.new end def create @user = User.new(user_params) i...
zivolution921/meobox
app/models/user.rb
<reponame>zivolution921/meobox<gh_stars>0 class User < ActiveRecord::Base attr_accessor :reset_token after_create :create_reset_digest has_secure_password has_one :registration has_one :plan, through: :registration has_many :boxes, through: :plan has_attached_file :avatar, default_url: ':style/default.p...
zivolution921/meobox
config/routes.rb
<reponame>zivolution921/meobox Rails.application.routes.draw do resources :password_resets, only: [:new, :create, :edit, :update] resources :boxes do put 'ship' => 'boxes#ship' end # get 'items/index' # get 'items/new' # get 'items/show' resources :items # get 'history' => 'users#history' ...
zivolution921/meobox
app/models/box.rb
class Box < ActiveRecord::Base validates :theme_title, :plan_id, presence: true has_many :items belongs_to :plan paginates_per 5 # custom writer, receives array of hash (attributes) for all items def item_attributes=(item_attributes) item_attributes.each do |attributes| items.find_or_create_by(...
zivolution921/meobox
db/migrate/20160629171847_add_columns_for_box.rb
<reponame>zivolution921/meobox<filename>db/migrate/20160629171847_add_columns_for_box.rb<gh_stars>0 class AddColumnsForBox < ActiveRecord::Migration def change remove_column :boxes, :date, :integer add_column :boxes, :theme_title, :string add_column :boxes, :starts_at, :datetime add_column :boxes, :pl...
zivolution921/meobox
config/initializers/stripe.rb
<reponame>zivolution921/meobox<filename>config/initializers/stripe.rb Rails.configuration.stripe = { :publishable_key => Rails.application.secrets.PUBLISHABLE_KEY, :secret_key => Rails.application.secrets.SECRET_KEY } Stripe.api_key = Rails.application.secrets.SECRET_KEY
zivolution921/meobox
app/models/item.rb
class Item < ActiveRecord::Base belongs_to :box validates :title, :description, :size, presence: true validates :description, length: { minimum: 5 } do_not_validate_attachment_file_type :image has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" }, default_url: "/images/missing....
zivolution921/meobox
config/initializers/omniauth.rb
OmniAuth.config.logger = Rails.logger Rails.application.config.middleware.use OmniAuth::Builder do provider :facebook, '153892268362744 ', 'bf0843ea1f0d7d966c499e4926356d61' end
zivolution921/meobox
app/controllers/boxes_controller.rb
class BoxesController < ApplicationController before_action :set_plan before_action :set_box, except: [:index, :new, :create, :ship] before_action :require_admin, except: [:index, :show] # index action to fetch all the boxes from the database. # boxes for admin do not require a plan def index if @p...
zivolution921/meobox
app/serializers/api/v1/box_serializer.rb
class Api::V1::BoxSerializer < ActiveModel::Serializer # attributes that want to return as JSON attributes :plan_name, :title, :theme_title, :shipped has_many :items, serializer: Api::V1::ItemSerializer end
zivolution921/meobox
app/controllers/api/v1/users_controller.rb
class Api::V1::UsersController < ApplicationController # skip to make sure the request came from the correct user and it is safe skip_before_filter :verify_authenticity_token def index users = User.all render json: users, status: :ok end def show user = User.find(params[:id]) render json: us...
zivolution921/meobox
db/migrate/20160629223936_add_shipped_to_box.rb
class AddShippedToBox < ActiveRecord::Migration def change add_column :boxes, :shipped, :boolean, default: false end end
zivolution921/meobox
app/controllers/items_controller.rb
<gh_stars>0 class ItemsController < ApplicationController before_action :set_item, only: [:show, :edit, :update, :destroy] before_action :set_box, except: [:index, :destroy] before_action :set_plan, except: [:index, :show] before_action :require_admin, except: [:index, :show] def index @items = Item...
zivolution921/meobox
app/controllers/api/v1/items_controller.rb
<gh_stars>0 class Api::V1::ItemsController < ApplicationController def index items = Item.search(params[:search]) # rednering and specifying specific serializer render json: items, root: false, each_serializer: Api::V1::ItemSerializer end def show item = Item.find(params[:id]) render( ...
zivolution921/meobox
app/controllers/sessions_controller.rb
<filename>app/controllers/sessions_controller.rb<gh_stars>0 class SessionsController < ApplicationController def new end def create @user = User.find_by_email(params[:email]) # call the authenticate method, # use bcrypt to match the password entered in the sign in form # the password_digest s...
zivolution921/meobox
app/controllers/api/v1/boxes_controller.rb
<reponame>zivolution921/meobox class Api::V1::BoxesController < ApplicationController def index boxes = Box.all # rednering and specifying specific serializer render json: boxes, root: false, each_serializer: Api::V1::BoxSerializer end def show box = Box.find(params[:id]) render( ...
zivolution921/meobox
app/controllers/api/v1/plans_controller.rb
class Api::V1::PlansController < ApplicationController skip_before_action :verify_authenticity_token def index plans = Plan.all render( root: false, status: :ok, json: plans, each_serializer: Api::V1::PlanSerializer ) end def show plan = Plan.find(params[:id]) rende...
zivolution921/meobox
app/controllers/pages_controller.rb
<filename>app/controllers/pages_controller.rb class PagesController < ApplicationController def home @plan_1 = Plan.find_by_name("Basic Membership") @plan_2 = Plan.find_by_name("Silver Membership") @plan_3 = Plan.find_by_name("Gold Membership") end def about end end
zivolution921/meobox
app/models/registration.rb
<reponame>zivolution921/meobox<filename>app/models/registration.rb<gh_stars>0 class Registration < ActiveRecord::Base belongs_to :plan belongs_to :user validates :plan, :uniqueness => {:scope => :user} end
zivolution921/meobox
app/serializers/api/v1/plan_serializer.rb
class Api::V1::PlanSerializer < ActiveModel::Serializer attributes :name, :description, :price, :active, :user_id has_many :boxes, serializer: Api::V1::BoxSerializer end
zivolution921/meobox
app/serializers/api/v1/item_serializer.rb
<reponame>zivolution921/meobox<filename>app/serializers/api/v1/item_serializer.rb class Api::V1::ItemSerializer < ActiveModel::Serializer attributes :id, :description, :title, :size, :url, :price, :edit_url, :formatted_price # define custom method for the object def edit_url edit_item_url(object) end def...
zivolution921/meobox
app/controllers/registrations_controller.rb
class RegistrationsController < ApplicationController def create @plan = Plan.find_by_name(params[:plan_name]) @user = User.find(params[:user_id]) # attach the plan to the user if @user.already_registered_for_any_plan? flash[:notice] = "You are already subscribed to #{current_user.plan.na...
zivolution921/meobox
app/models/plan.rb
<filename>app/models/plan.rb class Plan < ActiveRecord::Base has_many :registrations has_many :users, through: :registrations has_many :boxes validates_presence_of :name, :description, :price validates :price, numericality: { greater_than: 0 } def rounded_price self.price.round end end
zivolution921/meobox
db/migrate/20160625152638_remove_columns_from_registration.rb
class RemoveColumnsFromRegistration < ActiveRecord::Migration def change remove_column :registrations, :name, :string remove_column :registrations, :email, :string end end
zivolution921/meobox
app/controllers/application_controller.rb
<filename>app/controllers/application_controller.rb class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # Cross Site Forgery request # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception include CanCan::ControllerAddition...
zivolution921/meobox
test/controllers/plans_controller_test.rb
<gh_stars>0 require 'test_helper' class PlansControllerTest < ActionController::TestCase setup do @plan = plans(:one) end test "should get index" do get :index assert_response :success assert_not_nil assigns(:plans) end test "should get new" do get :new assert_response :success en...
zivolution921/meobox
db/migrate/20160627202826_change_uid_limit_of_user.rb
<reponame>zivolution921/meobox<gh_stars>0 class ChangeUidLimitOfUser < ActiveRecord::Migration def change remove_column :users, :uid, :intger add_column :users, :uid, :text end end
zivolution921/meobox
app/serializers/api/v1/user_serializer.rb
<filename>app/serializers/api/v1/user_serializer.rb class Api::V1::UserSerializer < ActiveModel::Serializer attributes :first_name, :last_name, :email, :password, :password_confirmation, :avatar end
skoba/fhir-ruby
spec/spec_helper.rb
<reponame>skoba/fhir-ruby require 'fhir' require 'open-uri' FHIR_URI = 'http://www.hl7.org/implement/standards/fhir/profiles-resources.xml' FHIR_FILE = "#{File.dirname(__FILE__)}/tmp/cache.xml" unless File.exists?(FHIR_FILE) f = open(FHIR_URI) FileUtils.mkdir_p(File.dirname(FHIR_FILE)) File.open(FHIR_FILE, 'w'...
skoba/fhir-ruby
lib/fhir/resource.rb
require 'nokogiri' module Fhir #Follow xml definition structure class Resource < Fhir::ActiveXml class Element < Fhir::ActiveXml def path value_from_path('path').split('.') end def definition @definition ||= Definition.new(node.xpath('./definition').first) end de...
skoba/fhir-ruby
spec/node_functions_spec.rb
require 'spec_helper' describe 'NodeFunctions' do let(:graph) do Fhir::Graph.new.tap do |g| g.add([1]) g.add([1, 2]) g.add([1, 2, 3]) g.add([1, 2, 3, 4]) g.add([1, 2, 3, 4, 5]) g.add([1, 6]) end end let(:selection) { graph.selection } let(:node) { selection.select {...
skoba/fhir-ruby
example_project/gen/expand_graph.rb
<filename>example_project/gen/expand_graph.rb class ExpandGraph def initialize(graph) @graph = graph end def expand @graph.selection.by_attr(:embed, true).each do |node| res = node.referenced_resource res.descendants.each do |dsc| path = node.path.to_a + dsc.path.to_a[1..-1] @...
skoba/fhir-ruby
lib/fhir/node_functions.rb
<reponame>skoba/fhir-ruby<gh_stars>1-10 module Fhir module NodeFunctions def children(node, selection) selection.select do |n| node.path.child?(n) end end def parent(node, selection) selection.to_a.find do |n| n.path.child?(node) end end def ancestors(node...
skoba/fhir-ruby
example_project/spec/condition_spec.rb
<reponame>skoba/fhir-ruby<gh_stars>1-10 require 'spec_helper' describe 'Condition' do example do codeable_concept_attributes = { text: 'code text' } date = Time.now evidence_attrs = {code_attributes: codeable_concept_attributes} location_attrs = {detail: 'detail', code_attributes: codeabl...
skoba/fhir-ruby
example_project/gen/rules.rb
class Rules def self.apply(graph) graph.rule(%w[MedicationStatement dosage site coding], max: '1') graph.rule(%w[MedicationStatement dosage route coding], max: '1') graph.rule(%w[MedicationStatement dosage method coding], max: '1') graph.rule(%w[MedicationStatement identifier], max: '1') graph.ru...
skoba/fhir-ruby
lib/fhir/graph.rb
module Fhir class Graph attr :modules attr :node_modules def initialize(options = {}) @index = {} @options = options @modules = Array(options[:modules]) @node_modules = Array(options[:node_modules]) end def nodes @nodes ||= [] end def path_exists?(path) ...
skoba/fhir-ruby
lib/fhir/datatype.rb
<gh_stars>1-10 require 'nokogiri' module Fhir class Datatype class << self def load(path) @document = Nokogiri::XML(open(path).readlines.join("")) @document.remove_namespaces! end def all types end def find(name) types.select do |type| typ...
skoba/fhir-ruby
example_project/gen/node_functions.rb
<gh_stars>1-10 module NodeFunctions def class_name(node, _) node.path.to_a.map(&:camelize).join end def table_name(node, _) node.path.to_a.map(&:underscore).join('_').tableize end def class_file_name(node, _) node.class_name.underscore end def references(node, selection) node.children ...
skoba/fhir-ruby
lib/fhir/template_functions.rb
module Fhir module TemplateFunctions def template(selection, opts = {}, &block) opts = {attr_to_write: :template_result}.merge(opts) path = opts[:path] template_str = block_given? ? block.call : File.read(path) template = ERB.new(template_str, nil, '%<>-') template.filename = path if...
skoba/fhir-ruby
example_project/spec/spec_helper.rb
<filename>example_project/spec/spec_helper.rb system "bundle exec ../bin/fhir Fhirfile" unless ENV['NOGEN'] require 'active_support' require 'active_record' require 'active_support/core_ext' require 'active_support/dependencies' ::FHIR_PATH = File.expand_path(File.dirname(__FILE__)) $:.unshift(File.expand_path('../...
skoba/fhir-ruby
example_project/spec/node_functions_spec.rb
require 'spec_helper' describe NodeFunctions do let(:selection) { Fhir.graph.selection } let(:condition) { selection.node(['Condition']) } let(:medstatement) { selection.node(['MedicationStatement']) } let(:medication) { selection.node(['Medication']) } let(:dose) { selection.node(['MedicationStatement','do...
skoba/fhir-ruby
lib/fhir/path.rb
<filename>lib/fhir/path.rb module Fhir class Path include Comparable def initialize(path) @array = uniform(path).freeze end def inspect to_a.join('.') end def to_a @array end def to_s to_a.join('.') end def subpath?(subpath) subpath = uniform...
skoba/fhir-ruby
lib/fhir/active_xml.rb
module Fhir class ActiveXml attr :node def initialize(node) @node = node end def self.value_attr(path, name = nil) name ||= path.split('/').last self.send :define_method, name do value_from_path(path) end end def value_from_path(path) (node.xpath("./#{pa...
skoba/fhir-ruby
lib/fhir/node.rb
<gh_stars>1-10 module Fhir class Node attr :graph attr :path attr :attributes def initialize(graph, path, attrs) @graph, @path, @attributes = graph, Fhir::Path.new(path), attrs end def name path.last end def max attributes[:max] || '1' end def min at...
skoba/fhir-ruby
spec/node_spec.rb
require 'spec_helper' describe 'Fhir::Node' do module NodeRole def children(node, selection, *args) node end end example do graph = Object.new graph.stub(:node_modules).and_return([NodeRole]) graph.stub(:selection).and_return([NodeRole]) node = Fhir::Node.new(graph, ['a','b'], pro...
skoba/fhir-ruby
lib/fhir.rb
$:.unshift(File.expand_path(File.dirname(__FILE__))) unless $:.include?(File.dirname(__FILE__)) require 'ostruct' require 'active_support/core_ext' module Fhir autoload :Cli, 'fhir/cli' autoload :Resource, 'fhir/resource' autoload :ActiveXml, 'fhir/active_xml' autoload :Datatype, 'fhir/datatype' autoload :P...
skoba/fhir-ruby
example_project/lib/fhir/composite.rb
<gh_stars>1-10 # Composite, allow object to compose group of attributes prefixed with composing name: <composing>__<attr_name> # Similar to http://apidock.com/rails/ActiveRecord/Aggregations/ClassMethods/composed_of module Fhir::Composite extend ActiveSupport::Concern module ClassMethods def composing(composin...
skoba/fhir-ruby
example_project/lib/fhir/composing.rb
# Part of composite # Allow to use model as part of another object delegating attribute accessors by convention: <composing>__<attr_name> module Fhir::Composing extend ActiveSupport::Concern attr_accessor :composite, :composing_name def initialize(attrs = {}) composite = attrs.fetch(:composite) composin...
skoba/fhir-ruby
example_project/lib/fhir/migration_helpers.rb
module Fhir module MigrationHelpers def identifier_table(entity_name) create_table("certification_#{entity_name}_identifiers") do |t| t.integer "#{entity_name}_id" t.string :use # enum t.string :label t.string :system_name t.string :key t.string :assigner_id #...
skoba/fhir-ruby
spec/selection_functions_spec.rb
<reponame>skoba/fhir-ruby<gh_stars>1-10 require 'spec_helper' describe Fhir::SelecionFunctions do let(:graph) do Fhir::Graph.new.tap do |g| g.add([1]) g.add([1, 2]) g.add([1, 2, 3]) g.add([1, 4]) end end let(:selection) { graph.selection } it 'should debug' do selection.sh...
skoba/fhir-ruby
lib/fhir/selection_functions.rb
module Fhir module SelecionFunctions def debug(selection, title = nil, attr = nil) puts puts "DEBUG: #{title}" if title puts '-'*20 puts "\n " + selection.to_a.map(&(attr || :inspect)).join("\n ") selection end def select(selection, &block) selection.selection(sele...
skoba/fhir-ruby
example_project/spec/medication_statement_spec.rb
<filename>example_project/spec/medication_statement_spec.rb require 'spec_helper' describe 'Medication Statement' do example do codings_attributes = [ { system_name: 'rxnorm.info', code: '312961' }, { system_name: 'ndc', code: '52959-989' } ] medication_attributes = { ...
skoba/fhir-ruby
example_project/spec/selection_functions_spec.rb
require 'spec_helper' describe SelectionFunctions do let(:selection) { Fhir.graph.selection } it "#value objects" do selection .branch(['MedicationStatement']) .value_objects end it 'should select tables' do selection .branch(['AllergyIntolerance']) .tables .to_a .map(&:table_...
skoba/fhir-ruby
example_project/lib/fhir/base.rb
<reponame>skoba/fhir-ruby<filename>example_project/lib/fhir/base.rb class Fhir::Base < ActiveRecord::Base self.table_name_prefix = 'fhir.' self.abstract_class = true end
skoba/fhir-ruby
spec/datatype_spec.rb
require 'spec_helper' describe Fhir::Datatype do before :all do Fhir::Datatype.load(DATATYPES_FILE) end it 'should detect simple types' do Fhir::Datatype.find('integer').should be_simple Fhir::Datatype.find('id').should be_simple Fhir::Datatype.find('Element').should be_simple Fhir::Datatype...
skoba/fhir-ruby
example_project/spec/allergy_intolerance_spec.rb
<reponame>skoba/fhir-ruby require 'spec_helper' describe 'AllergyIntolerance' do example do allergy = Fhir::AllergyIntolerance.create!( criticality: 'fatal', sensitivity_type: 'allergy', recorded_date: Time.now, status: 'status', substance_attributes: { name: 'substance name...
skoba/fhir-ruby
lib/fhir/selection.rb
<filename>lib/fhir/selection.rb module Fhir class Selection attr :graph def initialize(graph, selection) @graph = graph @selection = selection end def +(other) if other.graph != graph raise "Could not sum selections with different graphs" end if other.respond_to...
skoba/fhir-ruby
spec/path_spec.rb
require 'spec_helper' describe Fhir::Path do let(:p) { Fhir::Path } example do path = p.new(%w[a b c]) subpath = p.new(%w[a b c d e]) relative_path = p.new(%w[d e]) path.to_s.should == 'a.b.c' path.subpath?(subpath).should be_true path.include?(subpath).should be_true (subpath < pat...
skoba/fhir-ruby
spec/sources_spec.rb
require 'spec_helper' describe 'Graph sources' do let(:graph) { Fhir.graph } let(:selection) { Fhir.graph.selection } it 'should parse xml data' do node = selection.node(['Condition']) node.max.should == '1' node.min.should == '1' node.attributes[:comment].should_not be_empty node.children....
skoba/fhir-ruby
spec/selection_spec.rb
require 'spec_helper' describe 'Fhir::Selection' do module TestSelection def my_selection(selection) selection end end let(:graph) do Object.new.tap do |g| g.stub(:modules).and_return([TestSelection]) end end example do initial_selection = Object.new selection = Fhir::Se...
skoba/fhir-ruby
lib/fhir/cli.rb
<gh_stars>1-10 require 'ostruct' module Fhir class Cli def initialize(file) raise "Could not find configuratin file - #{file}" unless File.exists?(file) self.instance_eval File.read(file), file end def configure(&block) Fhir.configure(&block) end def generate(&block) Fhi...
skoba/fhir-ruby
spec/templates_spec.rb
require 'spec_helper' describe 'Fhir::TemplateFunctions' do let(:graph) do Fhir::Graph.new.tap do |g| g.add([1]) g.add([1, 2]) end end let(:selection) { graph.selection } it 'should render template' do selection .template { "item: <%= node.path -%>" } .render .should == "i...
skoba/fhir-ruby
spec/graph_spec.rb
<reponame>skoba/fhir-ruby require 'spec_helper' describe Fhir::Graph do subject { Fhir::Graph.new(modules: Module.new, node_modules: Module.new) } it 'should add nodes' do subject.add(['one', 'two', 'three']) node = subject.nodes.first node.should be_a(Fhir::Node) node.path.should == ['one', 'two...
skoba/fhir-ruby
example_project/gen/selection_functions.rb
module SelectionFunctions def reject_idrefs(selection) selection.select do |n| n.type != 'xmlIdRef' end end def reject_contained(selection) selection.select do |n| n.name != 'contained' end end def simple_types(selection) selection.select do |n| n.type =~ /^[a-z].*/ ...
shirasagi/opendata
lib/opendata/api.rb
<reponame>shirasagi/opendata<gh_stars>1-10 module Opendata::Api public def check_num(num, messages) if num if integer?(num) if num.to_i < 0 messages << "Must be a natural number" end else messages << "Invalid integer" end e...
shirasagi/opendata
spec/models/chorg/test_runner_spec.rb
<reponame>shirasagi/opendata require 'spec_helper' describe Chorg::TestRunner, dbscope: :example do let(:root_group) { create(:revision_root_group) } let(:site) { create(:cms_site, group_ids: [root_group.id]) } context "with add" do let(:revision) { create(:revision, site_id: site.id) } let(:changeset) ...
shirasagi/opendata
app/models/concerns/ss/user_permission.rb
module SS::UserPermission extend ActiveSupport::Concern public def allowed?(action, user, opts = {}) return true if new_record? user_id == user.id end module ClassMethods public def allowed?(action, user, opts = {}) self.new.allowed?(action, user, opts) end def...
shirasagi/opendata
app/models/ezine/sent_log.rb
class Ezine::SentLog include SS::Document field :email, type: String, metadata: { from: :email } belongs_to :page, class_name: "Ezine::Page" belongs_to :node, class_name: "Cms::Node" end
shirasagi/opendata
app/models/voice/synthesis_job.rb
<gh_stars>1-10 require 'bson' require 'open-uri' class Voice::SynthesisJob include Job::Worker self.job_options = { 'pool' => 'voice_synthesis' } public def call(id_or_url, force = false) voice_file = Voice::File.find(id_or_url) rescue nil voice_file ||= Voice::File.find_or_create_by_url(id_or_...
shirasagi/opendata
app/controllers/cms/node/import_controller.rb
<reponame>shirasagi/opendata class Cms::Node::ImportController < ApplicationController include Cms::BaseFilter include Cms::CrudFilter model Cms::Node::ImportNode navi_view "cms/node/import_pages/navi" menu_view nil before_action :set_item public def import @item.attributes = get_params ...
shirasagi/opendata
spec/features/cms/groups_spec.rb
require 'spec_helper' describe "cms_groups" do subject(:site) { cms_site } subject(:item) { Cms::Group.last } subject(:index_path) { cms_groups_path site.host } subject(:new_path) { new_cms_group_path site.host } subject(:show_path) { cms_group_path site.host, item } subject(:edit_path) { edit_cms_group_pa...
shirasagi/opendata
spec/models/opendata/dataset_spec.rb
<reponame>shirasagi/opendata<gh_stars>1-10 require 'spec_helper' describe Opendata::Dataset, dbscope: :example do let!(:node_category) { create(:opendata_node_category) } let!(:node_search_dataset) { create(:opendata_node_search_dataset) } let(:node) { create(:opendata_node_dataset) } context "check attribute...
shirasagi/opendata
app/helpers/cms/node_helper.rb
<reponame>shirasagi/opendata module Cms::NodeHelper def contents_path(node) route = node.view_route.present? ? node.view_route : node.route "/.#{node.site.host}/" + route.pluralize.sub("/", "#{node.id}/") rescue StandardError => e raise(e) unless Rails.env.production? node_nodes_path(cid: node) e...
shirasagi/opendata
app/models/ezine/member.rb
class Ezine::Member include SS::Document include SS::Reference::User include SS::Reference::Site include Cms::SitePermission include Ezine::MemberSearchable include Ezine::Addon::Data field :email, type: String, metadata: { from: :email } field :email_type, type: String field :state, type: String, de...
shirasagi/opendata
spec/features/cms/files_spec.rb
<filename>spec/features/cms/files_spec.rb<gh_stars>1-10 require 'spec_helper' describe "cms_files" do let(:site) { cms_site } let(:item) { Cms::File.last } let(:index_path) { cms_files_path site.host } let(:new_path) { new_cms_file_path site.host } let(:show_path) { cms_file_path site.host, item } let(:edi...
shirasagi/opendata
config/routes/facility/routes.rb
<filename>config/routes/facility/routes.rb SS::Application.routes.draw do Facility::Initializer concern :deletion do get :delete, on: :member end concern :download do get :download, :on => :collection end concern :import do get :import, :on => :collection post :import, :on => :collection...
shirasagi/opendata
app/controllers/concerns/cms/base_filter.rb
module Cms::BaseFilter extend ActiveSupport::Concern include SS::BaseFilter included do cattr_accessor(:user_class) { Cms::User } helper Cms::NodeHelper helper Cms::FormHelper helper Cms::PathHelper before_action :set_site before_action :set_node before_action :set_group before_a...
shirasagi/opendata
app/controllers/facility/agents/nodes/page_controller.rb
class Facility::Agents::Nodes::PageController < ApplicationController include Cms::NodeFilter::View public def map_pages Facility::Map.site(@cur_site).public. where(filename: /^#{@cur_node.filename}\//, depth: @cur_node.depth + 1).order_by(order: 1) end def image_pages Facility::Im...
shirasagi/opendata
app/controllers/workflow/wizard_controller.rb
class Workflow::WizardController < ApplicationController include Cms::ApiFilter before_action :set_route, only: [:approver_setting] before_action :set_item, only: [:approver_setting] private def set_model @model = Cms::Page end def fix_params { cur_user: @cur_user, cur_site: @cur_site...
shirasagi/opendata
spec/features/opendata/dataset/csv2rdf_settings_spec.rb
<gh_stars>1-10 require 'spec_helper' describe "opendata_csv2rdf_settings", type: :feature, dbscope: :example do let(:site) { cms_site } let!(:node_search_dataset) { create(:opendata_node_search_dataset) } let(:node) { create(:opendata_node_dataset) } let(:dataset) { create(:opendata_dataset, node: node) } le...
shirasagi/opendata
config/routes/opendata/app/routes.rb
<reponame>shirasagi/opendata SS::Application.routes.draw do Opendata::Initializer concern :deletion do get :delete, on: :member end content "opendata" do resources :app_categories, concerns: :deletion, module: :app resources :search_apps, concerns: :deletion, module: :app resources :apps, con...
shirasagi/opendata
app/helpers/event/event_helper.rb
<filename>app/helpers/event/event_helper.rb<gh_stars>1-10 module Event::EventHelper require "holiday_japan" def t_date(name) t("datetime.prompts.#{name}") end def t_wday(date) t("date.abbr_day_names")[date.wday] end def t_wdays t("date.abbr_day_names") end def event_h1_class(month) %...
shirasagi/opendata
app/models/concerns/inquiry/addon/release_plan.rb
module Inquiry::Addon module ReleasePlan extend ActiveSupport::Concern extend SS::Addon included do field :release_date, type: DateTime field :close_date, type: DateTime permit_params :release_date, :close_date validate :validate_release_date end module ClassMethods ...
shirasagi/opendata
app/controllers/opendata/agents/nodes/app/appfile_controller.rb
<gh_stars>1-10 class Opendata::Agents::Nodes::App::AppfileController < ApplicationController include Cms::NodeFilter::View include Opendata::UrlHelper before_action :accept_cors_request before_action :set_app private def set_app @app_path = @cur_path.sub(/\/appfile\/.*/, ".html") @app = Ope...
shirasagi/opendata
app/controllers/rdf/vocabs_controller.rb
<reponame>shirasagi/opendata<filename>app/controllers/rdf/vocabs_controller.rb class Rdf::VocabsController < ApplicationController include Cms::BaseFilter include Cms::CrudFilter helper Opendata::FormHelper model Rdf::Vocab navi_view "cms/main/navi" before_action :set_extra_crumbs, only: [:show, :edit, :...
shirasagi/opendata
app/models/chorg/context.rb
module Chorg::Context attr_reader :cur_site, :cur_user, :adds_group_to_site, :item attr_reader :results, :substituter, :validation_substituter, :delete_group_ids def init_context @results = { "add" => { "success" => 0, "failed" => 0 }, "move" => { "success" => 0, "failed" => 0 }, ...
shirasagi/opendata
spec/factories/opendata/member.rb
<reponame>shirasagi/opendata<gh_stars>1-10 FactoryGirl.define do factory :opendata_member, class: Opendata::Member do transient do site nil icon_file nil end site_id { site.present? ? site.id : cms_site.id } name { "#{unique_id}" } email { <EMAIL>" } in_password "<PASSWORD>" i...
shirasagi/opendata
app/models/cms/site.rb
class Cms::Site include SS::Model::Site include Cms::SitePermission include Cms::Addon::PageSetting include Opendata::Addon::SiteSetting set_permission_name "cms_sites" end
shirasagi/opendata
app/controllers/opendata/agents/nodes/mypage/mypage_controller.rb
class Opendata::Agents::Nodes::Mypage::MypageController < ApplicationController include Cms::NodeFilter::View include Member::LoginFilter include Opendata::MemberFilter helper Opendata::UrlHelper before_action :get_member_notice, only: [:show_notice, :confirm_notice] private def get_member_notice ...
shirasagi/opendata
app/controllers/ads/agents/parts/banner_controller.rb
class Ads::Agents::Parts::BannerController < ApplicationController include Cms::PartFilter::View public def index @node = @cur_part.parent return render nothing: true unless @node cond = {} if @cur_part.with_category == "enabled" if cur_page && cur_page.categories.size > 0 ...
shirasagi/opendata
app/models/ckan/node.rb
<reponame>shirasagi/opendata module Ckan::Node class Page include Cms::Model::Node include Cms::Addon::NodeSetting include Cms::Addon::Meta include Cms::Addon::PageList include Ckan::Addon::Server include Cms::Addon::Release include Cms::Addon::GroupPermission include History::Addon::B...
shirasagi/opendata
lib/voice/command.rb
<gh_stars>1-10 class Voice::Command class << self public def run_with_logging(cmd, prompt) require "open3" Rails.logger.debug("popen3: #{cmd}") stdout, stderr, status = Open3.capture3(cmd) Rails.logger.debug("[#{prompt} stdout] #{stdout}") if stdout.present? Rails.log...
shirasagi/opendata
app/models/concerns/contact/addon/page.rb
<gh_stars>1-10 module Contact::Addon module Page extend ActiveSupport::Concern extend SS::Addon included do field :contact_state, type: String field :contact_charge, type: String field :contact_tel, type: String field :contact_fax, type: String field :contact_email, type: St...
shirasagi/opendata
app/models/opendata/dataset_group.rb
<gh_stars>1-10 class Opendata::DatasetGroup include SS::Document include SS::Reference::User include SS::Reference::Site include Cms::Addon::Release include Cms::Addon::GroupPermission include Opendata::Addon::Category set_permission_name :opendata_datasets seqid :id field :state, type: String, defa...
shirasagi/opendata
app/models/workflow/route.rb
class Workflow::Route include Workflow::Model::Route include Cms::SitePermission set_permission_name "cms_users", :edit scope :site, ->(site) { self.in(group_ids: Cms::Group.site(site).pluck(:id)) } validate :validate_groups class << self public def route_options(user) ret = [ [ t("my_...
shirasagi/opendata
app/models/concerns/cms/model/member.rb
module Cms::Model::Member extend ActiveSupport::Concern extend SS::Translation include SS::Document include SS::Reference::Site include Cms::SitePermission attr_accessor :in_password OAUTH_PROVIDER_TWITTER = 'twitter'.freeze OAUTH_PROVIDER_FACEBOOK = 'facebook'.freeze OAUTH_PROVIDER_YAHOOJP = 'yahoo...
shirasagi/opendata
app/helpers/cms/path_helper.rb
module Cms::PathHelper public def cms_mobile_preview_path(params = {}) if params[:path] params[:path] = ::File.join(SS.config.mobile.location, params[:path]) params[:path].sub!(/^\/+/, "") end cms_preview_path(params) end end
shirasagi/opendata
app/models/concerns/opendata/addon/my_app_list.rb
<filename>app/models/concerns/opendata/addon/my_app_list.rb module Opendata::Addon::MyAppList extend SS::Addon extend ActiveSupport::Concern include Cms::Addon::PageList public def template_variable_get(item, name) if name.start_with?('app_') if name == 'app_name' ERB::Util.html_escape item...