source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
Empact/roxml
https://github.com/Empact/roxml
spec/xml/encoding_spec.rb
Ruby
mit
225
master
1,763
# encoding: utf-8 require 'spec_helper' describe ROXML, "encoding" do class TestResult include ROXML xml_accessor :message end context "when provided non-latin characters" do it "should output those characters as input via methods" do res = TestResult.new res.message = "sadfk одловыа j...
github
Empact/roxml
https://github.com/Empact/roxml
spec/xml/namespace_spec.rb
Ruby
mit
225
master
13,681
require_relative './../spec_helper.rb' describe ROXML, "with namespaces" do describe "for writing" do before do @xml = <<EOS <?xml version="1.0" encoding="UTF-8"?> <gronk:VApp name="My new vApp" status="1" href="https://vcloud.example.com/vapp/833" type="application/vnd.vmware.vcloud.vapp+xml" xmlns:vmw="h...
github
Empact/roxml
https://github.com/Empact/roxml
spec/xml/namespaces_spec.rb
Ruby
mit
225
master
2,115
require_relative './../spec_helper.rb' describe ROXML, "#xml_namespaces" do describe "for reading" do class Tires include ROXML xml_namespaces \ :bobsbike => 'http://bobsbikes.example.com', :alicesauto => 'http://alicesautosupply.example.com/' xml_reader :bike_tires, :as ...
github
Empact/roxml
https://github.com/Empact/roxml
spec/xml/text_spec.rb
Ruby
mit
225
master
2,097
require 'spec_helper' describe ROXML::XMLTextRef do before do @xml = ROXML::XML.parse_string %( <myxml> <node> <name>first</name> <name>second</name> <name>third</name> </node> </myxml>) end context "plain vanilla" do before do @ref = ROXML::XMLTextRef.new(OpenStruct.new(:name => '...
github
Empact/roxml
https://github.com/Empact/roxml
spec/examples/search_query_spec.rb
Ruby
mit
225
master
740
require 'spec_helper' require_relative './../../examples/search_query' describe SearchQuery do before do @search = SearchQuery.new @search.query = 'This is a random search query.' @saved_search = SearchQuery.from_xml("<searchquery><query>Search for something</query></searchquery>") end it 'should return t...
github
Empact/roxml
https://github.com/Empact/roxml
spec/examples/person_spec.rb
Ruby
mit
225
master
979
require 'spec_helper' require_relative './../../examples/person' describe Person do before do @person = Person.new @person.name = 'John Doe' @person.lat = '40.715224' @person.long = '-74.005966' @person.street = 'Evergreen Terrace' @person.city = 'Springfield' @person.zip = '2342' end ...
github
Empact/roxml
https://github.com/Empact/roxml
spec/examples/amazon_spec.rb
Ruby
mit
225
master
1,615
require 'spec_helper' require_relative './../../examples/amazon' describe PITA::ItemSearchResponse do before do @response = PITA::ItemSearchResponse.from_xml(xml_for('amazon')) end describe "#total_results" do it "should be parsed as a number" do expect(@response.total_results).to be > 0 end ...
github
Empact/roxml
https://github.com/Empact/roxml
spec/examples/current_weather_spec.rb
Ruby
mit
225
master
966
require 'spec_helper' require_relative './../../examples/current_weather' describe Weather do before do @weather = Weather.from_xml(xml_for('current_weather')) end it "should extract observations" do expect(@weather.observation).to be_an_instance_of(WeatherObservation) end end describe WeatherObserva...
github
Empact/roxml
https://github.com/Empact/roxml
spec/examples/library_spec.rb
Ruby
mit
225
master
1,890
require 'spec_helper' require_relative './../../examples/library' describe Library do before :all do book = Novel.new book.isbn = "0201710897" book.title = "The PickAxe" book.description = "Best Ruby book out there!" book.author = "David Thomas, Andrew Hunt, Dave Thomas" book.publisher = Publ...
github
Empact/roxml
https://github.com/Empact/roxml
spec/examples/post_spec.rb
Ruby
mit
225
master
601
require 'spec_helper' require 'date' require_relative './../../examples/posts' describe Post do before do @posts = Posts.from_xml(xml_for('posts')).posts end it "should extract description" do @posts.each {|post| expect(post.description).to_not be_empty } end it "should extract href" do @posts....
github
Empact/roxml
https://github.com/Empact/roxml
spec/examples/dashed_elements_spec.rb
Ruby
mit
225
master
448
require 'spec_helper' require_relative './../../examples/dashed_elements' describe GitHub::Commit do before do @commit = GitHub::Commit.from_xml(xml_for('dashed_elements')) end it "should extract committed date" do expect(@commit.committed_date).to be_an_instance_of(Date) end it "should extract url...
github
Empact/roxml
https://github.com/Empact/roxml
spec/examples/twitter_spec.rb
Ruby
mit
225
master
705
require 'spec_helper' require_relative './../../examples/twitter' describe Statuses do before do @statuses = Statuses.from_xml(xml_for('twitter')).statuses end it "should extract text" do @statuses.each {|status| expect(status.text).to_not be_empty } end it "should extract source" do @statuses....
github
Empact/roxml
https://github.com/Empact/roxml
spec/examples/library_with_fines_spec.rb
Ruby
mit
225
master
1,085
require_relative './../spec_helper' require_relative './../../examples/library_with_fines' describe LibraryWithFines do let(:xml) { File.read(xml_for('library_with_fines')) } let(:library) { LibraryWithFines.from_xml(xml) } it "should read nested elements" do expect(library.fines).to be_a(Hash) library...
github
Empact/roxml
https://github.com/Empact/roxml
spec/examples/active_record_spec.rb
Ruby
mit
225
master
1,087
require 'fileutils' require 'spec_helper' require_relative '../../examples/rails' describe ROXML, "under ActiveRecord" do before do @route = Route.from_xml(xml_for('active_record')) end it "should be parsed" do expect(@route).to_not eq(nil) expect(@route).to be_an_instance_of(Route) end describ...
github
Empact/roxml
https://github.com/Empact/roxml
test/test_helper.rb
Ruby
mit
225
master
937
require 'rubygems' require 'roxml/utils' require_relative './mocks/mocks' require_relative './mocks/dictionaries' require_relative './support/fixtures' def to_xml_test(*names) names = names.first if names.size == 1 && names.first.is_a?(Hash) names.each do |name, xml_name| xml_name ||= name define_method "...
github
Empact/roxml
https://github.com/Empact/roxml
test/mocks/dictionaries.rb
Ruby
mit
225
master
1,326
require_relative "./../../lib/roxml" class DictionaryOfAttrs include ROXML xml_name :dictionary xml_reader :definitions, :as => {:key => '@dt', :value => '@dd'}, :in => :definitions end class DictionaryOfTexts include ROXML xml_name :dictionary xml_reader :definitions,...
github
Empact/roxml
https://github.com/Empact/roxml
test/mocks/mocks.rb
Ruby
mit
225
master
5,458
require_relative "./../../lib/roxml" class Muffins include ROXML xml_reader(:count, :from => 'bakers_dozens') {|val| val.to_i * 13 } end class MuffinsWithStackedBlocks include ROXML xml_reader(:count, :from => 'bakers_dozens', :as => Integer) {|val| val * 13 } end class Numerology include ROXML xml_re...
github
Empact/roxml
https://github.com/Empact/roxml
test/unit/xml_name_test.rb
Ruby
mit
225
master
3,973
require_relative './../test_helper' require 'minitest/autorun' # Parent | Child # :from | no :from | # -------------------|-------------- # :from | xml_name | xml_name-d # value | value | # -------------------|-------------- # :from | parent's | # value | accessor | un-xml_name-d # ...
github
Empact/roxml
https://github.com/Empact/roxml
test/unit/xml_attribute_test.rb
Ruby
mit
225
master
1,212
require_relative './../test_helper' require 'minitest/autorun' class TestXMLAttribute < Minitest::Test def test_attr_from # :attr => * book = Book.from_xml(fixture(:book_text_with_attribute)) assert_equal '0201710897', book.isbn # :attr, :from => * book = BookWithAttrFrom.from_xml(fixture(:book_...
github
Empact/roxml
https://github.com/Empact/roxml
test/unit/xml_block_test.rb
Ruby
mit
225
master
1,943
require_relative './../test_helper' require 'minitest/autorun' class ArrayWithBlockShorthand include ROXML xml_reader :array, :as => [Integer], :from => 'number' end class ArrayWithBlock include ROXML xml_reader :array, :as => [], :from => 'number' do |arr| arr.map(&:to_i).reverse end end class TestX...
github
Empact/roxml
https://github.com/Empact/roxml
test/unit/to_xml_test.rb
Ruby
mit
225
master
2,167
require_relative './../test_helper' require 'minitest/autorun' class TestHashToXml < Minitest::Test to_xml_test :dictionary_of_attrs, :dictionary_of_mixeds, :dictionary_of_texts, :dictionary_of_names, :dictionary_of_guarded_names, :dictionary_of_n...
github
Empact/roxml
https://github.com/Empact/roxml
test/unit/definition_test.rb
Ruby
mit
225
master
9,364
require 'date' require 'time' require_relative './../test_helper' require 'minitest/autorun' class TestDefinition < Minitest::Test def assert_hash(opts, kvp) assert opts.hash_definition? assert !opts.array? assert_equal kvp, {opts.hash_definition.key.sought_type => opts.hash_definition.key.name, ...
github
Empact/roxml
https://github.com/Empact/roxml
test/unit/xml_object_test.rb
Ruby
mit
225
master
6,861
# encoding: utf-8 require_relative './../test_helper' require 'minitest/autorun' class EmptyCart include ROXML xml_reader :id def empty? true end end class CartHolder include ROXML xml_reader :cart, :as => EmptyCart, :required => true end class TestXMLObject < Minitest::Test # Test book with tex...
github
Empact/roxml
https://github.com/Empact/roxml
test/unit/xml_initialize_test.rb
Ruby
mit
225
master
1,479
require_relative './../test_helper' require 'minitest/autorun' class InheritedBookWithDepth < Book xml_reader :depth, :as => Measurement end class BookWithXmlInitialize < BookWithDepth attr_reader :created_at, :creator def initialize(created_at, creator = "Unknown") @created_at = created_at @creator = ...
github
Empact/roxml
https://github.com/Empact/roxml
test/unit/deprecations_test.rb
Ruby
mit
225
master
1,390
require_relative './../test_helper' require 'minitest/autorun' require 'active_support/testing/deprecation' class TestDeprecation < Minitest::Test include ActiveSupport::Testing::Deprecation def test_as_array_not_deprecated assert_not_deprecated ActiveSupport::Deprecation.new do opts = ROXML::Definition...
github
Empact/roxml
https://github.com/Empact/roxml
test/unit/xml_text_test.rb
Ruby
mit
225
master
2,215
require_relative './../test_helper' require 'minitest/autorun' class TestXMLText < Minitest::Test # Test a simple mapping with no composition def test_valid_simple book = Book.from_xml(fixture(:book_valid)) assert_equal("The PickAxe", book.title) assert_equal("David Thomas, Andrew Hunt & Dave Thomas", ...
github
Empact/roxml
https://github.com/Empact/roxml
test/unit/xml_namespace_test.rb
Ruby
mit
225
master
1,248
require_relative './../test_helper' require 'minitest/autorun' class TestDefaultXMLNamespaces < Minitest::Test def setup @book = BookWithContributions.from_xml(fixture(:book_with_default_namespace)) end def test_default_namespace_doesnt_interfere_with_normal_operation assert_equal("Programming Ruby - 2n...
github
Empact/roxml
https://github.com/Empact/roxml
test/unit/xml_bool_test.rb
Ruby
mit
225
master
3,313
require_relative './../test_helper' require 'minitest/autorun' PROC_TRUE = proc {|val| val ? 'TRUE' : 'FALSE'} PROC_True = proc {|val| val ? 'True' : 'False'} PROC_true = proc {|val| val.to_s} PROC_1 = proc {|val| val ? 1 : 0} class XmlBool include ROXML xml_name 'xml_bool' xml_reader :true_from_TRUE?, :to_...
github
Empact/roxml
https://github.com/Empact/roxml
test/unit/xml_required_test.rb
Ruby
mit
225
master
2,241
require_relative './../test_helper' require 'minitest/autorun' class TestXMLRequired < Minitest::Test def setup @full_book = <<BOOK <book ISBN="1234"> <title>This &amp; that</title> <contributor_array> <contributor role="Author"> <name>Johnny</name> </contributor> </contributor_...
github
Empact/roxml
https://github.com/Empact/roxml
test/unit/xml_hash_test.rb
Ruby
mit
225
master
3,317
require_relative './../test_helper' require 'minitest/autorun' class BookWithContributorHash include ROXML xml_reader :contributors, :as => {:key => '@role', :value => 'name'} end class TestXMLHash < Minitest::Test def setup @contents = {'quaquaversally' => 'adjective: (of a ge...
github
Empact/roxml
https://github.com/Empact/roxml
test/unit/xml_convention_test.rb
Ruby
mit
225
master
3,926
require_relative './../test_helper' require 'minitest/autorun' XML_CAMELLOWER = %{ <bookCase name="Jonas' Books"> <bookCount>12</bookCount> <bigBooks> <bigBook>GED</bigBook> <bigBook>House of Leaves</bigBook> </bigBooks> </bookCase> } XML_CAMELCASE = %{ <BookCase Name="Jonas' Books"> ...
github
Empact/roxml
https://github.com/Empact/roxml
lib/roxml.rb
Ruby
mit
225
master
21,168
require 'uri' require 'dry/core/inflector' require 'roxml/definition' require 'roxml/xml' module ROXML # :nodoc: VERSION = File.read(File.expand_path("../../VERSION", __FILE__)) def self.included(base) # :nodoc: base.class_eval do extend ClassMethods::Accessors, ClassMethods::Declaration...
github
Empact/roxml
https://github.com/Empact/roxml
lib/roxml/utils.rb
Ruby
mit
225
master
1,112
require 'concurrent/map' module ROXML module Utils module_function # The following taken from active_support/core_ext/object/blank: BLANK_RE = /\A[[:space:]]*\z/ ENCODED_BLANKS = Concurrent::Map.new do |h, enc| h[enc] = Regexp.new(BLANK_RE.source.encode(enc), BLANK_RE.options | Regexp::FIXEDE...
github
Empact/roxml
https://github.com/Empact/roxml
lib/roxml/definition.rb
Ruby
mit
225
master
6,449
require 'dry/core/inflector' require 'roxml/hash_definition' require 'roxml/utils' require 'time' module ROXML class ContradictoryNamespaces < StandardError end class Definition # :nodoc: attr_reader :name, :sought_type, :wrapper, :blocks, :accessor, :to_xml, :attr_name, :namespace, :inflector [:name_ex...
github
Empact/roxml
https://github.com/Empact/roxml
lib/roxml/xml.rb
Ruby
mit
225
master
936
module ROXML PARSERS = %w[nokogiri libxml].freeze unless const_defined? 'XML_PARSER' parsers = PARSERS.dup begin require parsers.first XML_PARSER = parsers.first # :nodoc: rescue LoadError parsers.shift retry unless parsers.empty? raise "Could not load a parser. Tried #{PAR...
github
Empact/roxml
https://github.com/Empact/roxml
lib/roxml/hash_definition.rb
Ruby
mit
225
master
565
module ROXML class HashDefinition # :nodoc: attr_reader :key, :value attr_accessor :wrapper def initialize(opts) @key = Definition.new(nil, to_definition_options(opts, :key)) @value = Definition.new(nil, to_definition_options(opts, :value)) end private def to_definition_options(opt...
github
Empact/roxml
https://github.com/Empact/roxml
lib/roxml/xml/references.rb
Ruby
mit
225
master
8,027
require "roxml/utils" module ROXML class RequiredElementMissing < ArgumentError # :nodoc: end # # Internal base class that represents an XML - Class binding. # class XMLRef # :nodoc: attr_reader :opts def initialize(opts, instance) @opts = opts @instance = instance end def bl...
github
Empact/roxml
https://github.com/Empact/roxml
lib/roxml/xml/parsers/nokogiri.rb
Ruby
mit
225
master
1,587
require 'nokogiri' module ROXML module XML # :nodoc:all class << self def set_attribute(node, name, value) node[name] = value end def set_content(node, content) node.content = content end def new_node(name) Nokogiri::XML::Node.new(name, Document.new) ...
github
Empact/roxml
https://github.com/Empact/roxml
lib/roxml/xml/parsers/libxml.rb
Ruby
mit
225
master
1,584
require 'libxml' module ROXML module XML # :nodoc:all class << self def set_attribute(node, name, value) node.attributes[name] = value end def set_content(node, content) node.content = content.gsub('&', '&amp;') end def new_node(name) LibXML::XML::Node.new...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
Rakefile
Ruby
mit
225
master
401
begin require 'bundler/setup' rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__) load 'rails/tasks/engine.rake' load 'rails/tasks/statistics.rake' require 'bundler/gem_tasks' require 'rspec/core/rake_t...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
rails_i18n_manager.gemspec
Ruby
mit
225
master
1,722
$:.push File.expand_path("lib", __dir__) # Maintain your gem's version: require "rails_i18n_manager/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |spec| spec.name = "rails_i18n_manager" spec.version = RailsI18nManager::VERSION spec.authors = ["Weston Ganger"...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
Gemfile
Ruby
mit
225
master
828
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } # Declare your gem's dependencies in coders_log.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec # Declare ...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
config/routes.rb
Ruby
mit
225
master
443
RailsI18nManager::Engine.routes.draw do resources :translations, only: [:index, :show, :edit, :update, :destroy] do collection do post :translate_missing get :import post :import delete :delete_inactive_keys end end resources :translation_apps get "/robots", to: "application#...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
lib/rails_i18n_manager.rb
Ruby
mit
225
master
1,331
require "rails_i18n_manager/engine" require "rails_i18n_manager/config" module RailsI18nManager def self.config(&block) c = RailsI18nManager::Config if block_given? block.call(c) else return c end end def self.fetch_flattened_dot_notation_keys(translations_hash) keys = [] ...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
lib/rails_i18n_manager/config.rb
Ruby
mit
225
master
1,105
module RailsI18nManager class Config @@google_translate_api_key = nil mattr_reader :google_translate_api_key def self.google_translate_api_key=(val) @@google_translate_api_key = val end ### List retrieved from Google Translate (2022) @@valid_locales = ["af", "am", "ar", "az", "be", "b...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
lib/rails_i18n_manager/engine.rb
Ruby
mit
225
master
463
require 'slim' require 'active_sort_order' require 'kaminari' require "zip" require "activerecord-import" require "csv" require "easy_translate" module RailsI18nManager class Engine < ::Rails::Engine isolate_namespace RailsI18nManager paths["app/models"] << "app/lib" initializer "rails_i18n_manager.loa...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
db/migrate/20221001001344_add_rails_i18n_manager_tables.rb
Ruby
mit
225
master
798
class AddRailsI18nManagerTables < ActiveRecord::Migration[6.0] def change create_table :rails_i18n_manager_translation_apps do |t| t.string :name t.string :default_locale t.text :additional_locales t.timestamps end create_table :rails_i18n_manager_translation_keys do |t| t....
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
app/models/rails_i18n_manager/translation_key.rb
Ruby
mit
225
master
5,170
module RailsI18nManager class TranslationKey < ApplicationRecord belongs_to :translation_app, class_name: "RailsI18nManager::TranslationApp" has_many :translation_values, class_name: "RailsI18nManager::TranslationValue", dependent: :destroy accepts_nested_attributes_for :translation_values, reject_if: ->...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
app/models/rails_i18n_manager/translation_app.rb
Ruby
mit
225
master
3,239
module RailsI18nManager class TranslationApp < ApplicationRecord NAME = "Translated App".freeze has_many :translation_keys, class_name: "RailsI18nManager::TranslationKey", dependent: :destroy before_validation :clean_additional_locales after_update :handle_removed_locales after_update :handle_ad...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
app/models/rails_i18n_manager/application_record.rb
Ruby
mit
225
master
345
module RailsI18nManager class ApplicationRecord < ActiveRecord::Base self.abstract_class = true include ActiveSortOrder scope :multi_search, ->(full_str){ if full_str.present? rel = self full_str.split(' ').each do |q| rel = rel.search(q) end next rel ...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
app/models/rails_i18n_manager/translation_value.rb
Ruby
mit
225
master
404
module RailsI18nManager class TranslationValue < ApplicationRecord belongs_to :translation_key, class_name: "RailsI18nManager::TranslationKey" validates :translation_key, presence: true validates :locale, presence: true, uniqueness: {scope: :translation_key_id} validates :translation, presence: {if:...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
app/helpers/rails_i18n_manager/application_helper.rb
Ruby
mit
225
master
1,842
module RailsI18nManager module ApplicationHelper def custom_form_for(*args, **options, &block) options[:builder] = CustomFormBuilder if options.has_key?(:defaults) @_custom_form_for_defaults = options.delete(:defaults) end form_for(*args, options, &block) end def custom_f...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
app/lib/rails_i18n_manager/google_translate.rb
Ruby
mit
225
master
1,613
module RailsI18nManager module GoogleTranslate def self.translate(text, from:, to:) api_key = RailsI18nManager.config.google_translate_api_key if !SUPPORTED_LOCALES.include?(to.to_s) || Rails.env.test? || (api_key.blank? && Rails.env.development?) return false end if text.includ...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
app/lib/rails_i18n_manager/custom_form_builder.rb
Ruby
mit
225
master
6,518
module RailsI18nManager class CustomFormBuilder < ActionView::Helpers::FormBuilder ALLOWED_OPTIONS = [ :value, :name, :label, :field_wrapper_html, :label_wrapper_html, :label_html, :input_wrapper_html, :input_html, :required, :required_text, :help...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
app/lib/rails_i18n_manager/translations_importer.rb
Ruby
mit
225
master
2,381
module RailsI18nManager class TranslationsImporter class ImportAbortedError < StandardError; end def self.import(translation_app_id:, parsed_file_contents:, overwrite_existing: false, mark_inactive_translations: false) app_record = TranslationApp.find(translation_app_id) new_locales = parsed_fi...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
app/lib/rails_i18n_manager/forms/base.rb
Ruby
mit
225
master
597
module RailsI18nManager module Forms class Base include ActiveModel::Validations def initialize(attrs={}) attrs ||= {} attrs.each do |k,v| self.send("#{k}=", v) ### Use send so that it checks that attr_accessor has already defined the method so its a valid attribute ...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
app/lib/rails_i18n_manager/forms/translation_file_form.rb
Ruby
mit
225
master
2,059
module RailsI18nManager module Forms class TranslationFileForm < Base attr_accessor :translation_app_id, :file, :overwrite_existing attr_reader :overwrite_existing, :mark_inactive_translations validates :translation_app_id, presence: {message: "Must select an App"} validates :file, prese...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
app/controllers/rails_i18n_manager/translations_controller.rb
Ruby
mit
225
master
8,925
module RailsI18nManager class TranslationsController < ApplicationController before_action :get_translation_key, only: [:show, :edit, :update, :destroy] def index case params[:sort] when "app_name" sort = "#{TranslationApp.table_name}.name" when "updated_at" sort = "#{Transl...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
app/controllers/rails_i18n_manager/translation_apps_controller.rb
Ruby
mit
225
master
1,738
module RailsI18nManager class TranslationAppsController < ApplicationController before_action :set_translation_app, only: [:show, :edit, :update, :destroy] def index @translation_apps = TranslationApp .sort_order(params[:sort], params[:direction], base_sort_order: "#{TranslationApp.table_name}....
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/rails_helper.rb
Ruby
mit
225
master
1,580
require "spec_helper" ENV["RAILS_ENV"] ||= "test" require_relative "dummy/config/environment" abort("The Rails environment is running in production mode!") if Rails.env.production? require "rspec/rails" begin ActiveRecord::Migration.maintain_test_schema! rescue ActiveRecord::PendingMigrationError => e puts e.t...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/spec_helper.rb
Ruby
mit
225
master
1,503
require "rails_helper" require "database_cleaner" require "factory_bot_rails" require "faker" require "minitest_change_assertions" require "rspec-html-matchers" require "active_support/all" RSpec.configure do |config| config.include RSpecHtmlMatchers config.expect_with :rspec do |expectations| expectations.i...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/unit/google_translate_spec.rb
Ruby
mit
225
master
2,423
require 'spec_helper' RSpec.describe RailsI18nManager::GoogleTranslate, type: :model do before do allow(Rails.env).to receive(:test?).and_return(false) allow(RailsI18nManager.config).to receive(:google_translate_api_key).and_return("some-api-key") end context "translate" do it "returns false for un...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/unit/config_spec.rb
Ruby
mit
225
master
530
require 'spec_helper' RSpec.describe RailsI18nManager::Config, type: :model do context "google_translate_api_key" do before do @prev_google_translate_api_key = RailsI18nManager.config.google_translate_api_key end after do RailsI18nManager.config.google_translate_api_key = @prev_google_trans...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/unit/translations_importer_spec.rb
Ruby
mit
225
master
5,775
require "spec_helper" module RailsI18nManager RSpec.describe TranslationsImporter, type: :model do let(:translation_app){ FactoryBot.create(:translation_app, default_locale: :en, additional_locales: [:fr]) } before do @filename = Rails.root.join("tmp/#{SecureRandom.hex(6)}.yml").to_s end aft...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/unit/models/translation_key_spec.rb
Ruby
mit
225
master
5,869
require 'spec_helper' module RailsI18nManager RSpec.describe TranslationKey, type: :model do let!(:translation_app) { FactoryBot.create(:translation_app, default_locale: :en, additional_locales: [:fr]) } let!(:translation_key) { FactoryBot.create(:translation_key) } let!(:default_translation_value) { Fa...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/unit/models/translation_app_spec.rb
Ruby
mit
225
master
2,367
require 'spec_helper' module RailsI18nManager RSpec.describe TranslationApp, type: :model do let(:translation_app) { FactoryBot.create(:translation_app, default_locale: :en, additional_locales: [:fr]) } context "validations" do it "requires a default locale" do translation_app.default_locale ...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/unit/models/translation_value_spec.rb
Ruby
mit
225
master
1,052
require 'spec_helper' module RailsI18nManager RSpec.describe TranslationValue, type: :model do let(:translation_app) { FactoryBot.create(:translation_app, default_locale: :en, additional_locales: [:fr]) } let(:translation_key) { FactoryBot.create(:translation_key) } let(:default_translation_value) { tra...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/request/translations_controller_spec.rb
Ruby
mit
225
master
10,029
require "spec_helper" module RailsI18nManager RSpec.describe "TranslationsController", type: :request do let(:translation_app){ FactoryBot.create(:translation_app, default_locale: :en, additional_locales: [:fr]) } let(:translation_key){ FactoryBot.create(:translation_key, translation_app: translation_app) } ...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/request/translation_apps_controller_spec.rb
Ruby
mit
225
master
2,959
require "spec_helper" module RailsI18nManager RSpec.describe "TranslationAppsController", type: :request do let!(:translation_app){ FactoryBot.create(:translation_app) } let!(:translation_key){ FactoryBot.create(:translation_key, translation_app: translation_app) } context "index" do it "renders"...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/factories/translation_key_factory.rb
Ruby
mit
225
master
758
FactoryBot.define do factory :translation_key, class: RailsI18nManager::TranslationKey do translation_app { FactoryBot.create(:translation_app) } key { [Faker::Verb.base, Faker::Verb.base, Faker::Verb.base][0..(rand(1..2))].join(".").downcase } # after :build do |record| # record.assign_attributes(...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/factories/translation_app_factory.rb
Ruby
mit
225
master
206
FactoryBot.define do factory :translation_app, class: RailsI18nManager::TranslationApp do name { Faker::App.unique.name } default_locale { "en" } additional_locales { ["fr", "es"] } end end
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/factories/translation_value_factory.rb
Ruby
mit
225
master
421
FactoryBot.define do factory :translation_value, class: RailsI18nManager::TranslationValue do translation_key { FactoryBot.create(:translation_key) } locale { translation_key.translation_app.default_locale } translation do if locale == translation_key.translation_app.default_locale translati...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/dummy/db/seeds.rb
Ruby
mit
225
master
402
Dir.glob("#{__dir__}/../../factories/*").each do |x| puts x require_relative(x) end module RailsI18nManager if TranslationKey.first raise "Error already seeded" end puts "Seeding" app = FactoryBot.create(:translation_app, name: "Bluejay") 100.times do FactoryBot.create(:translation_key, :with_...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/dummy/config/application.rb
Ruby
mit
225
master
824
require_relative 'boot' require "logger" # Fix for Rails 7.0 and below, https://github.com/rails/rails/pull/54264 require 'rails/all' Bundler.require(*Rails.groups) require "rails_i18n_manager" module Dummy class Application < Rails::Application # Initialize configuration defaults for originally generated Rai...
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/dummy/config/environments/test.rb
Ruby
mit
225
master
251
Rails.application.configure do config.action_controller.allow_forgery_protection = false if Rails::VERSION::STRING.to_f >= 7.1 config.action_dispatch.show_exceptions = :none else config.action_dispatch.show_exceptions = false end end
github
westonganger/rails_i18n_manager
https://github.com/westonganger/rails_i18n_manager
spec/dummy/config/environments/development.rb
Ruby
mit
225
master
273
Rails.application.configure do config.action_mailer.default_url_options = { host: 'localhost:3000' } config.active_record.migration_error = :page_load config.consider_all_requests_local = true config.eager_load = true ### helps catch more errors in development end
github
phlegx/redmine_gitlab_hook
https://github.com/phlegx/redmine_gitlab_hook
init.rb
Ruby
mit
224
master
581
require 'redmine' Redmine::Plugin.register :redmine_gitlab_hook do name 'Redmine GitLab Hook plugin' author 'Phlegx Systems' description 'This plugin allows your Redmine installation to receive GitLab post-receive notifications' version '4.0.0' url 'https://github.com/phlegx/redmine_gitlab_hook' author_url...
github
phlegx/redmine_gitlab_hook
https://github.com/phlegx/redmine_gitlab_hook
test/functional/gitlab_hook_controller_test.rb
Ruby
mit
224
master
6,311
require File.dirname(__FILE__) + '/../test_helper' require 'test/unit' require 'mocha' class GitlabHookControllerTest < ActionController::TestCase def setup # Sample JSON post from http://github.com/guides/post-receive-hooks @json = '{ "before": "5aef35982fb2d34e9d9d4502f6ede1072793222d", "rep...
github
phlegx/redmine_gitlab_hook
https://github.com/phlegx/redmine_gitlab_hook
app/controllers/gitlab_hook_controller.rb
Ruby
mit
224
master
5,862
require 'json' class GitlabHookController < SysController GIT_BIN = Redmine::Configuration[:scm_git_command] || 'git' def index if request.post? repository = find_repository p repository.inspect git_success = true if repository # Fetch the changes from GitLab if Setti...
github
doorkeeper-gem/doorkeeper-jwt
https://github.com/doorkeeper-gem/doorkeeper-jwt
Gemfile
Ruby
mit
224
master
256
# frozen_string_literal: true source "https://rubygems.org" # Specify your gem's dependencies in doorkeeper-jwt.gemspec gemspec gem "coveralls_reborn", require: false gem "rubocop", "~> 1.8", require: false gem "rubocop-rspec", "~> 3.0", require: false
github
doorkeeper-gem/doorkeeper-jwt
https://github.com/doorkeeper-gem/doorkeeper-jwt
doorkeeper-jwt.gemspec
Ruby
mit
224
master
1,118
# frozen_string_literal: true lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "doorkeeper/jwt/version" Gem::Specification.new do |spec| spec.name = "doorkeeper-jwt" spec.version = Doorkeeper::JWT.gem_version spec.authors = ["Chris Warren", "Nikita Bulai"] ...
github
doorkeeper-gem/doorkeeper-jwt
https://github.com/doorkeeper-gem/doorkeeper-jwt
spec/doorkeeper/jwt_spec.rb
Ruby
mit
224
master
10,069
# frozen_string_literal: true require "spec_helper" describe Doorkeeper::JWT do it "has a version number" do expect(Doorkeeper::JWT::VERSION).not_to be nil end describe ".generate" do it "creates a JWT token" do described_class.configure {} token = described_class.generate({}) decode...
github
doorkeeper-gem/doorkeeper-jwt
https://github.com/doorkeeper-gem/doorkeeper-jwt
spec/doorkeeper/jwt/configuration_spec.rb
Ruby
mit
224
master
2,593
# frozen_string_literal: true require "spec_helper" describe(Doorkeeper::JWT, "#configuration") do subject(:configuration) { described_class.configuration } describe "token_payload" do it "is nil by default" do described_class.configure {} expect(configuration.token_payload).to be_a(Proc) en...
github
doorkeeper-gem/doorkeeper-jwt
https://github.com/doorkeeper-gem/doorkeeper-jwt
lib/doorkeeper/jwt.rb
Ruby
mit
224
master
3,094
# frozen_string_literal: true require "doorkeeper/jwt/version" require "doorkeeper/jwt/config" require "jwt" module Doorkeeper module JWT class << self def generate(opts = {}) ::JWT.encode( token_payload(opts), secret_key(opts), signing_method, token_headers...
github
doorkeeper-gem/doorkeeper-jwt
https://github.com/doorkeeper-gem/doorkeeper-jwt
lib/doorkeeper/jwt/version.rb
Ruby
mit
224
master
351
# frozen_string_literal: true module Doorkeeper module JWT def self.gem_version Gem::Version.new VERSION::STRING end module VERSION # Semantic versioning MAJOR = 0 MINOR = 4 TINY = 2 PRE = nil # Full version number STRING = [MAJOR, MINOR, TINY, PRE].compa...
github
doorkeeper-gem/doorkeeper-jwt
https://github.com/doorkeeper-gem/doorkeeper-jwt
lib/doorkeeper/jwt/config.rb
Ruby
mit
224
master
4,215
# frozen_string_literal: true module Doorkeeper module JWT class MissingConfiguration < StandardError def initialize super("Configuration for doorkeeper-jwt missing.") end end def self.configure(&block) @config = Config::Builder.new(&block).build end def self.configura...
github
davidesantangelo/datoji
https://github.com/davidesantangelo/datoji
Capfile
Ruby
mit
224
master
1,237
# Load DSL and set up stages require 'capistrano/setup' # Include default deployment tasks require 'capistrano/deploy' require 'capistrano/rails' require 'capistrano/passenger' require 'capistrano/rbenv' set :rbenv_type, :user set :rbenv_ruby, '2.7.1' # Load the SCM plugin appropriate to your project: # # require "...
github
davidesantangelo/datoji
https://github.com/davidesantangelo/datoji
Gemfile
Ruby
mit
224
master
2,716
# frozen_string_literal: true source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.7.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 6.0.3', '>= 6.0.3.1' # Use pg as the database for Active Record gem 'pg' # Use Puma as the app serv...
github
davidesantangelo/datoji
https://github.com/davidesantangelo/datoji
app/controllers/tokens_controller.rb
Ruby
mit
224
master
215
class TokensController < BaseController skip_before_action :require_authentication # POST /tokens def create @token = Token.create! json_response_with_serializer(@token, Serializer::TOKEN) end end
github
davidesantangelo/datoji
https://github.com/davidesantangelo/datoji
app/controllers/base_controller.rb
Ruby
mit
224
master
1,648
require 'pagy/extras/headers' require 'pagy/extras/array' class BaseController < ApplicationController include Response include ExceptionHandler include Serializer include Pagy::Backend include ::ActionController::Cookies include ActionController::HttpAuthentication::Token::ControllerMethods Pagy::VARS[...
github
davidesantangelo/datoji
https://github.com/davidesantangelo/datoji
app/controllers/search_controller.rb
Ruby
mit
224
master
685
class SearchController < BaseController # callbacks before_action :check_params before_action :set_pack def index @pagy, @entries = pagy @pack.entries.web_search(data: permitted_params[:q]) json_response_with_serializer(@entries, Serializer::ENTRY) rescue StandardError => e Rails.logger.error(e)...
github
davidesantangelo/datoji
https://github.com/davidesantangelo/datoji
app/controllers/packs_controller.rb
Ruby
mit
224
master
837
class PacksController < BaseController before_action :set_pack, only: %i[show clear destroy] # POST /packs def create @pack = current_packs.create! json_response_with_serializer(@pack, Serializer::PACK) end # POST /packs/:id/clear def clear @pack.entries.delete_all json_response_with_ser...
github
davidesantangelo/datoji
https://github.com/davidesantangelo/datoji
app/controllers/entries_controller.rb
Ruby
mit
224
master
1,623
class EntriesController < BaseController # callbacks before_action :set_pack before_action :set_pack_entry, only: %i[show destroy update] # POST /packs/:id/entries.json def create @entry = @pack.entries.create!(data: entry_params) json_response_with_serializer(@entry, Serializer::ENTRY) end # P...
github
davidesantangelo/datoji
https://github.com/davidesantangelo/datoji
app/models/entry.rb
Ruby
mit
224
master
235
class Entry < ApplicationRecord # scopes default_scope -> { order(created_at: :desc) } # relations belongs_to :pack, counter_cache: true # validations validates :data, presence: true validates :pack, presence: true end
github
davidesantangelo/datoji
https://github.com/davidesantangelo/datoji
app/models/token.rb
Ruby
mit
224
master
768
class Token < ApplicationRecord # relations has_many :packs, dependent: :destroy # callbacks before_create :generate_key # validations validates :key, presence: true, uniqueness: true, allow_blank: true # scopes scope :active, -> { where(active: true).where('expires_at IS NULL OR expires_at >= ?', Ti...
github
davidesantangelo/datoji
https://github.com/davidesantangelo/datoji
app/models/concerns/exception_handler.rb
Ruby
mit
224
master
862
module ExceptionHandler extend ActiveSupport::Concern included do rescue_from ActiveRecord::RecordNotFound do |e| json_error_response('RecordNotFound', e.message, :not_found) end rescue_from ActiveRecord::RecordInvalid do |e| json_error_response('RecordInvalid', e.message, :unprocessable_e...
github
davidesantangelo/datoji
https://github.com/davidesantangelo/datoji
app/models/concerns/response.rb
Ruby
mit
224
master
530
module Response ACCESS_TOKEN_EXCEPTION = 'AccessTokenException'.freeze REQUEST_LIMIT_EXCEPTION = 'RequestLimitException'.freeze def json_success_response(object = {}) render json: object, status: :ok end def json_response_with_serializer(object, serializer, status = :ok) render json: Object.const_ge...
github
davidesantangelo/datoji
https://github.com/davidesantangelo/datoji
db/schema.rb
Ruby
mit
224
master
2,111
# This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # This file is the source Rails uses to define your schema when running `rails #...
github
davidesantangelo/datoji
https://github.com/davidesantangelo/datoji
db/migrate/20200610130328_create_tokens.rb
Ruby
mit
224
master
274
class CreateTokens < ActiveRecord::Migration[6.0] def change create_table :tokens, id: :uuid do |t| t.string :key t.datetime :expires_at t.boolean :active, default: true t.timestamps end add_index :tokens, :key, unique: true end end
github
davidesantangelo/datoji
https://github.com/davidesantangelo/datoji
db/migrate/20200610130448_create_packs.rb
Ruby
mit
224
master
212
class CreatePacks < ActiveRecord::Migration[6.0] def change create_table :packs, id: :uuid do |t| t.references :token, index: true, foreign_key: true, type: :uuid t.timestamps end end end