repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/data/tree/traversal.rb
lib/i18n/tasks/data/tree/traversal.rb
# frozen_string_literal: true require "set" module I18n::Tasks module Data::Tree # Any Enumerable that yields nodes can mix in this module module Traversal # rubocop:disable Metrics/ModuleLength def nodes(&) depth_first(&) end def leaves(&visitor) return to_enum(:leaves) u...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/pattern_mapper.rb
lib/i18n/tasks/scanners/pattern_mapper.rb
# frozen_string_literal: true require "i18n/tasks/scanners/file_scanner" require "i18n/tasks/scanners/relative_keys" require "i18n/tasks/scanners/occurrence_from_position" require "i18n/tasks/scanners/ruby_key_literals" module I18n::Tasks::Scanners # Maps the provided patterns to keys. class PatternMapper < FileS...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/ruby_ast_call_finder.rb
lib/i18n/tasks/scanners/ruby_ast_call_finder.rb
# frozen_string_literal: true require "ast" module I18n::Tasks::Scanners class RubyAstCallFinder include AST::Processor::Mixin # @param root_node [Parser::AST:Node] # @return [Pair<Parser::AST::Node, method_name as string>] for all nodes with :send type def collect_calls(root_node) @results =...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/ruby_parser_factory.rb
lib/i18n/tasks/scanners/ruby_parser_factory.rb
# frozen_string_literal: true # This module provides a factory class for creating a Ruby parser instance. # It temporarily disables verbose mode to suppress compatibility warnings # when loading the "parser/current" library. # # Example warning for the release of Ruby 3.4.1: # warning: parser/current is loading pars...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/occurrence_from_position.rb
lib/i18n/tasks/scanners/occurrence_from_position.rb
# frozen_string_literal: true module I18n module Tasks module Scanners module OccurrenceFromPosition # Given a path to a file, its contents and a position in the file, # return a {Results::Occurrence} at the position until the end of the line. # # @param path [String] ...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/pattern_scanner.rb
lib/i18n/tasks/scanners/pattern_scanner.rb
# frozen_string_literal: true require "i18n/tasks/scanners/file_scanner" require "i18n/tasks/scanners/relative_keys" require "i18n/tasks/scanners/occurrence_from_position" require "i18n/tasks/scanners/ruby_key_literals" module I18n::Tasks::Scanners # Scan for I18n.t usages using a simple regular expression. class...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/erb_ast_scanner.rb
lib/i18n/tasks/scanners/erb_ast_scanner.rb
# frozen_string_literal: true require "i18n/tasks/scanners/ruby_scanner" require "i18n/tasks/scanners/local_ruby_parser" require "i18n/tasks/scanners/occurrence_from_position" require "prism" module I18n::Tasks::Scanners # Scan for I18n.translate calls in ERB-file using regexp and Parser/Prism class ErbAstScanner...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/scanner.rb
lib/i18n/tasks/scanners/scanner.rb
# frozen_string_literal: true require "i18n/tasks/scanners/results/key_occurrences" module I18n::Tasks::Scanners # Describes the API of a scanner. # # @abstract # @since 0.9.0 class Scanner # @abstract # @return [Array<Results::KeyOccurrences>] the keys found by this scanner and their occurrences. ...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/file_scanner.rb
lib/i18n/tasks/scanners/file_scanner.rb
# frozen_string_literal: true require "i18n/tasks/scanners/scanner" module I18n::Tasks::Scanners # A base class for a scanner that analyses files. # # @abstract The child must implement {#scan_file}. # @since 0.9.0 class FileScanner < Scanner attr_reader :config def initialize( config: {}, ...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/scanner_multiplexer.rb
lib/i18n/tasks/scanners/scanner_multiplexer.rb
# frozen_string_literal: true require "i18n/tasks/scanners/scanner" module I18n::Tasks::Scanners # Run multiple {Scanner Scanners} and merge their results. class ScannerMultiplexer < Scanner # @param scanners [Array<Scanner>] def initialize(scanners:) super() @scanners = scanners end ...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/pattern_with_scope_scanner.rb
lib/i18n/tasks/scanners/pattern_with_scope_scanner.rb
# frozen_string_literal: true require "i18n/tasks/scanners/pattern_scanner" module I18n::Tasks::Scanners # Scans for I18n.t(key, scope: ...) usages # both scope: "literal", and scope: [:array, :of, 'literals'] forms are supported # Caveat: scope is only detected when it is the first argument class PatternWith...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/relative_keys.rb
lib/i18n/tasks/scanners/relative_keys.rb
# frozen_string_literal: true module I18n module Tasks module Scanners module RelativeKeys # @param key [String] relative i18n key (starts with a .) # @param path [String] path to the file containing the key # @param roots [Array<String>] paths to relative roots # @param cal...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/ruby_key_literals.rb
lib/i18n/tasks/scanners/ruby_key_literals.rb
# frozen_string_literal: true module I18n::Tasks::Scanners module RubyKeyLiterals LITERAL_RE = /:?".+?"|:?'.+?'|:\w+/ # Match literals: # * String: '', "#{}" # * Symbol: :sym, :'', :"#{}" def literal_re LITERAL_RE end # remove the leading colon and unwrap quotes from the key match...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/ruby_scanner.rb
lib/i18n/tasks/scanners/ruby_scanner.rb
# frozen_string_literal: true require "i18n/tasks/logging" require "i18n/tasks/scanners/file_scanner" require "i18n/tasks/scanners/relative_keys" require "i18n/tasks/scanners/ruby_ast_call_finder" require "i18n/tasks/scanners/ruby_parser_factory" require "i18n/tasks/scanners/ast_matchers/default_i18n_subject_matcher" ...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/local_ruby_parser.rb
lib/i18n/tasks/scanners/local_ruby_parser.rb
# frozen_string_literal: true require "i18n/tasks/scanners/ruby_parser_factory" module I18n::Tasks::Scanners class LocalRubyParser # ignore_blocks feature inspired by shopify/better-html # https://github.com/Shopify/better-html/blob/087943ffd2a5877fa977d71532010b0c91239519/lib/better_html/test_helper/ruby_n...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/results/key_occurrences.rb
lib/i18n/tasks/scanners/results/key_occurrences.rb
# frozen_string_literal: true require "i18n/tasks/scanners/results/occurrence" module I18n::Tasks::Scanners::Results # A scanned key and all its occurrences. # # @note This is a value type. Equality and hash code are determined from the attributes. class KeyOccurrences # @return [String] the key. attr...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/results/occurrence.rb
lib/i18n/tasks/scanners/results/occurrence.rb
# frozen_string_literal: true module I18n::Tasks module Scanners module Results # The occurrence of some key in a file. # # @note This is a value type. Equality and hash code are determined from the attributes. class Occurrence # @return [String] source path relative to the curren...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/files/caching_file_finder.rb
lib/i18n/tasks/scanners/files/caching_file_finder.rb
# frozen_string_literal: true require "i18n/tasks/concurrent/cached_value" require "i18n/tasks/scanners/files/file_finder" module I18n::Tasks::Scanners::Files # Finds the files in the specified search paths with support for exclusion / inclusion patterns. # Wraps a {FileFinder} and caches the results. # # @no...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
# frozen_string_literal: true require "i18n/tasks/concurrent/cache" require "i18n/tasks/scanners/files/caching_file_finder" module I18n::Tasks::Scanners::Files # Finds the files and provides their contents. # # @note This class is thread-safe. All methods are cached. # @since 0.9.0 class CachingFileFinderPr...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/files/file_finder.rb
lib/i18n/tasks/scanners/files/file_finder.rb
# frozen_string_literal: true module I18n::Tasks::Scanners::Files # Finds the files in the specified search paths with support for exclusion / inclusion patterns. # # @since 0.9.0 class FileFinder include I18n::Tasks::Logging # @param paths [Array<String>] {Find.find}-compatible paths to traverse, ...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/files/caching_file_reader.rb
lib/i18n/tasks/scanners/files/caching_file_reader.rb
# frozen_string_literal: true require "i18n/tasks/concurrent/cache" require "i18n/tasks/scanners/files/file_reader" module I18n::Tasks::Scanners::Files # Reads the files in 'rb' mode and UTF-8 encoding. # Wraps a {FileReader} and caches the results. # # @note This class is thread-safe. All methods are cached....
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/files/file_reader.rb
lib/i18n/tasks/scanners/files/file_reader.rb
# frozen_string_literal: true module I18n::Tasks::Scanners::Files # Reads the files in 'rb' mode and UTF-8 encoding. # # @since 0.9.0 class FileReader # Return the contents of the file at the given path. # The file is read in the 'rb' mode and UTF-8 encoding. # # @param path [String] Path to th...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/prism_scanners/nodes.rb
lib/i18n/tasks/scanners/prism_scanners/nodes.rb
# frozen_string_literal: true # These classes are used in the PrismScanners::Visitor class to store the translations found in the parsed code # Used in the PrismScanners::Visitor class. module I18n::Tasks::Scanners::PrismScanners class Root attr_reader(:calls, :translation_calls, :children, :node, :parent, :rail...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/prism_scanners/visitor.rb
lib/i18n/tasks/scanners/prism_scanners/visitor.rb
# frozen_string_literal: true require "prism/visitor" require_relative "nodes" require_relative "arguments_visitor" # Implementation of Prism::Visitor (https://ruby.github.io/prism/rb/Prism/Visitor.html) # It processes the parsed AST from Prism and creates a new AST with the nodes defined in prism_scanners/nodes.rb #...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/prism_scanners/arguments_visitor.rb
lib/i18n/tasks/scanners/prism_scanners/arguments_visitor.rb
# frozen_string_literal: true require "prism/visitor" # This class is used to parse the arguments to e.g. a Prism::CallNode and return the values we need # for turning them into translations and occurrences. # Used in the PrismScanners::Visitor class. module I18n::Tasks::Scanners::PrismScanners class ArgumentsVisit...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/ast_matchers/base_matcher.rb
lib/i18n/tasks/scanners/ast_matchers/base_matcher.rb
# frozen_string_literal: true module I18n::Tasks::Scanners::AstMatchers class BaseMatcher def initialize(scanner:) @scanner = scanner end def convert_to_key_occurrences(send_node, _method_name, location: send_node.loc) fail("Not implemented") end protected # If the node type is...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/ast_matchers/default_i18n_subject_matcher.rb
lib/i18n/tasks/scanners/ast_matchers/default_i18n_subject_matcher.rb
# frozen_string_literal: true require "i18n/tasks/scanners/ast_matchers/base_matcher" require "i18n/tasks/scanners/results/occurrence" module I18n::Tasks::Scanners::AstMatchers class DefaultI18nSubjectMatcher < BaseMatcher def convert_to_key_occurrences(send_node, method_name, location: send_node.loc) chi...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/ast_matchers/rails_model_matcher.rb
lib/i18n/tasks/scanners/ast_matchers/rails_model_matcher.rb
# frozen_string_literal: true require "i18n/tasks/scanners/results/occurrence" module I18n::Tasks::Scanners::AstMatchers class RailsModelMatcher < BaseMatcher def convert_to_key_occurrences(send_node, _method_name, location: send_node.loc) human_attribute_name_to_key_occurences(send_node: send_node, locat...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
glebm/i18n-tasks
https://github.com/glebm/i18n-tasks/blob/b7db1cb2fe1484d93ee1cf14b5100c321d16392a/lib/i18n/tasks/scanners/ast_matchers/message_receivers_matcher.rb
lib/i18n/tasks/scanners/ast_matchers/message_receivers_matcher.rb
# frozen_string_literal: true require "i18n/tasks/scanners/ast_matchers/base_matcher" require "i18n/tasks/scanners/results/occurrence" module I18n::Tasks::Scanners::AstMatchers class MessageReceiversMatcher < BaseMatcher def initialize(scanner:, receivers:, message:) super(scanner: scanner) @receive...
ruby
MIT
b7db1cb2fe1484d93ee1cf14b5100c321d16392a
2026-01-04T15:57:47.349094Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/api_spec.rb
spec/api_spec.rb
# encoding: utf-8 require File.join(File.dirname(__FILE__), "spec_helper.rb") describe Her::API do subject { Her::API.new } context "initialization" do describe "#setup" do context "when setting custom middleware" do before do class Foo; end class Bar; end subject...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/model_spec.rb
spec/model_spec.rb
# encoding: utf-8 require "spec_helper" describe Her::Model do before do Her::API.setup url: "https://api.example.com" do |connection| connection.use Her::Middleware::FirstLevelParseJSON connection.adapter :test do |stub| stub.get("/users/1") { [200, {}, { id: 1, name: "Tobias Fünke" }.to_js...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/collection_spec.rb
spec/collection_spec.rb
require "spec_helper" describe Her::Collection do let(:items) { [1, 2, 3, 4] } let(:metadata) { { name: "Testname" } } let(:errors) { { name: ["not_present"] } } describe "#new" do context "without parameters" do subject { Her::Collection.new } it { is_expected.to eq([]) } describe "#m...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/spec_helper.rb
spec/spec_helper.rb
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "lib") require "rspec" require "her" # Require everything in `spec/support` Dir[File.expand_path("../../spec/support/**/*.rb", __FILE__)].map(&method(:require)) # Remove ActiveModel deprecation message I18n.enforce_available_locales = false RSpec.configure ...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/support/macros/her_macros.rb
spec/support/macros/her_macros.rb
module Her module Testing module Macros def ok!(body) [200, {}, body.to_json] end def error!(body) [400, {}, body.to_json] end def params(env) Faraday::Utils.parse_query(env[:body]) end end end end
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/support/macros/request_macros.rb
spec/support/macros/request_macros.rb
module Her module Testing module Macros module RequestMacros def ok!(body) [200, {}, body.to_json] end def error!(body) [400, {}, body.to_json] end def params(env) @params ||= begin parsed_query = Faraday::Utils.parse_nested...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/support/macros/model_macros.rb
spec/support/macros/model_macros.rb
module Her module Testing module Macros module ModelMacros # Create a class and automatically inject Her::Model into it def spawn_model(klass, options = {}, &block) super_class = options[:super_class] model_type = options[:type] || Her::Model new_class = if supe...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/support/extensions/array.rb
spec/support/extensions/array.rb
class Array def to_json MultiJson.dump(self) end end
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/support/extensions/hash.rb
spec/support/extensions/hash.rb
class Hash def to_json MultiJson.dump(self) end end
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/model/parse_spec.rb
spec/model/parse_spec.rb
# encoding: utf-8 require File.join(File.dirname(__FILE__), "../spec_helper.rb") describe Her::Model::Parse do context "when include_root_in_json is set" do before do Her::API.setup url: "https://api.example.com" do |builder| builder.use Her::Middleware::FirstLevelParseJSON builder.use Far...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/model/callbacks_spec.rb
spec/model/callbacks_spec.rb
# encoding: utf-8 require File.join(File.dirname(__FILE__), "../spec_helper.rb") describe "Her::Model and ActiveModel::Callbacks" do before do Her::API.setup url: "https://api.example.com" do |builder| builder.use Her::Middleware::FirstLevelParseJSON end end context :before_save do subject { ...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/model/nested_attributes_spec.rb
spec/model/nested_attributes_spec.rb
# encoding: utf-8 require File.join(File.dirname(__FILE__), "../spec_helper.rb") describe Her::Model::NestedAttributes do context "with a belongs_to association" do before do Her::API.setup url: "https://api.example.com" do |builder| builder.use Her::Middleware::FirstLevelParseJSON builder...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/model/paths_spec.rb
spec/model/paths_spec.rb
# encoding: utf-8 require File.join(File.dirname(__FILE__), "../spec_helper.rb") describe Her::Model::Paths do context "building request paths" do context "simple model" do before do spawn_model "Foo::User" end describe "#request_path" do it "builds paths with defaults" do ...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/model/validations_spec.rb
spec/model/validations_spec.rb
# encoding: utf-8 require File.join(File.dirname(__FILE__), "../spec_helper.rb") describe "Her::Model and ActiveModel::Validations" do context "validating attributes" do before do spawn_model "Foo::User" do attributes :fullname, :email validates_presence_of :fullname validates_pres...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/model/orm_spec.rb
spec/model/orm_spec.rb
# encoding: utf-8 require File.join(File.dirname(__FILE__), "../spec_helper.rb") describe Her::Model::ORM do context "mapping data to Ruby objects" do before do api = Her::API.new api.setup url: "https://api.example.com" do |builder| builder.use Her::Middleware::FirstLevelParseJSON b...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/model/http_spec.rb
spec/model/http_spec.rb
# encoding: utf-8 require File.join(File.dirname(__FILE__), "../spec_helper.rb") describe Her::Model::HTTP do context "binding a model with an API" do let(:api1) { Her::API.new url: "https://api1.example.com" } let(:api2) { Her::API.new url: "https://api2.example.com" } before do spawn_model("Foo...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/model/associations_spec.rb
spec/model/associations_spec.rb
# encoding: utf-8 require File.join(File.dirname(__FILE__), "../spec_helper.rb") describe Her::Model::Associations do context "setting associations without details" do before { spawn_model "Foo::User" } subject(:associations) { Foo::User.associations } describe "has_many associations" do subject ...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/model/relation_spec.rb
spec/model/relation_spec.rb
# encoding: utf-8 require File.join(File.dirname(__FILE__), "../spec_helper.rb") describe Her::Model::Relation do describe :where do context "for base classes" do before do Her::API.setup url: "https://api.example.com" do |builder| builder.use Her::Middleware::FirstLevelParseJSON ...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/model/dirty_spec.rb
spec/model/dirty_spec.rb
# encoding: utf-8 require File.join(File.dirname(__FILE__), "../spec_helper.rb") describe "Her::Model and ActiveModel::Dirty" do context "checking dirty attributes" do before do Her::API.setup url: "https://api.example.com" do |builder| builder.use Her::Middleware::FirstLevelParseJSON buil...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/model/introspection_spec.rb
spec/model/introspection_spec.rb
# encoding: utf-8 require File.join(File.dirname(__FILE__), "../spec_helper.rb") describe Her::Model::Introspection do context "introspecting a resource" do before do Her::API.setup url: "https://api.example.com" do |builder| builder.use Her::Middleware::FirstLevelParseJSON builder.use Far...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/model/attributes_spec.rb
spec/model/attributes_spec.rb
# encoding: utf-8 require File.join(File.dirname(__FILE__), "../spec_helper.rb") describe Her::Model::Attributes do context "mapping data to Ruby objects" do before { spawn_model "Foo::User" } it "handles new resource" do @new_user = Foo::User.new(fullname: "Tobias Fünke") expect(@new_user.new?...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/model/associations/association_proxy_spec.rb
spec/model/associations/association_proxy_spec.rb
# encoding: utf-8 require "spec_helper" describe Her::Model::Associations::AssociationProxy do describe "proxy assignment methods" do before do Her::API.setup url: "https://api.example.com" do |builder| builder.use Her::Middleware::FirstLevelParseJSON builder.use Faraday::Request::UrlEncod...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/middleware/first_level_parse_json_spec.rb
spec/middleware/first_level_parse_json_spec.rb
# encoding: utf-8 require "spec_helper" describe Her::Middleware::FirstLevelParseJSON do subject { described_class.new } let(:body_without_errors) { "{\"id\": 1, \"name\": \"Tobias Fünke\", \"metadata\": 3}" } let(:body_with_errors) { "{\"id\": 1, \"name\": \"Tobias Fünke\", \"errors\": { \"name\": [ \"not_vali...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/middleware/json_api_parser_spec.rb
spec/middleware/json_api_parser_spec.rb
# encoding: utf-8 require "spec_helper" describe Her::Middleware::JsonApiParser do subject { described_class.new } context "with valid JSON body" do let(:body) { '{"data": {"type": "foo", "id": "bar", "attributes": {"baz": "qux"} }, "meta": {"api": "json api"} }' } let(:env) { { body: body } } it "p...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/middleware/second_level_parse_json_spec.rb
spec/middleware/second_level_parse_json_spec.rb
# encoding: utf-8 require "spec_helper" describe Her::Middleware::SecondLevelParseJSON do subject { described_class.new } context "with valid JSON body" do let(:body) { "{\"data\": 1, \"errors\": 2, \"metadata\": 3}" } it "parses body as json" do subject.parse(body).tap do |json| expect(jso...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/middleware/accept_json_spec.rb
spec/middleware/accept_json_spec.rb
# encoding: utf-8 require "spec_helper" describe Her::Middleware::AcceptJSON do it "adds an Accept header" do described_class.new.add_header({}).tap do |headers| expect(headers["Accept"]).to eq("application/json") end end end
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/spec/json_api/model_spec.rb
spec/json_api/model_spec.rb
require "spec_helper" describe Her::JsonApi::Model do before do Her::API.setup url: "https://api.example.com" do |connection| connection.use Her::Middleware::JsonApiParser connection.adapter :test do |stub| stub.get("/users/1") do [ 200, {}, { ...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her.rb
lib/her.rb
require "her/version" require "multi_json" require "faraday" require "active_support" require "active_support/inflector" require "active_support/core_ext/hash" require "her/model" require "her/api" require "her/middleware" require "her/errors" require "her/collection" module Her module JsonApi autoload :Model,...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/collection.rb
lib/her/collection.rb
module Her class Collection < ::Array attr_reader :metadata, :errors # @private def initialize(items = [], metadata = {}, errors = {}) super(items) @metadata = metadata @errors = errors end end end
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/version.rb
lib/her/version.rb
module Her VERSION = "1.1.1" end
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/errors.rb
lib/her/errors.rb
module Her module Errors class PathError < StandardError attr_reader :missing_parameter def initialize(message, missing_parameter = nil) super(message) @missing_parameter = missing_parameter end end class AssociationUnknownError < StandardError end class Parse...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/middleware.rb
lib/her/middleware.rb
require "her/middleware/parse_json" require "her/middleware/first_level_parse_json" require "her/middleware/second_level_parse_json" require "her/middleware/accept_json" module Her module Middleware DefaultParseJSON = FirstLevelParseJSON autoload :JsonApiParser, 'her/middleware/json_api_parser' end end
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/api.rb
lib/her/api.rb
module Her # This class is where all HTTP requests are made. Before using Her, you must configure it # so it knows where to make those requests. In Rails, this is usually done in `config/initializers/her.rb`: class API # @private attr_reader :connection, :options # Constants FARADAY_OPTIONS = [:...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model.rb
lib/her/model.rb
require "her/model/base" require "her/model/deprecated_methods" require "her/model/http" require "her/model/attributes" require "her/model/relation" require "her/model/orm" require "her/model/parse" require "her/model/associations" require "her/model/introspection" require "her/model/paths" require "her/model/nested_at...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model/attributes.rb
lib/her/model/attributes.rb
module Her module Model # This module handles all methods related to model attributes module Attributes extend ActiveSupport::Concern # Initialize a new object with data # # @param [Hash] attributes The attributes to initialize the object with # @option attributes [Hash,Array] :...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model/deprecated_methods.rb
lib/her/model/deprecated_methods.rb
module Her module Model # @private module DeprecatedMethods extend ActiveSupport::Concern def self.deprecate!(old, new, object, *args) line = begin raise StandardError rescue StandardError => e e.backtrace[2] end warn "#{line} - The `#{old}` me...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model/orm.rb
lib/her/model/orm.rb
# coding: utf-8 module Her module Model # This module adds ORM-like capabilities to the model module ORM extend ActiveSupport::Concern # Return `true` if a resource was not saved yet def new? id.nil? end alias new_record? new? # Return `true` if a resource is not...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model/nested_attributes.rb
lib/her/model/nested_attributes.rb
module Her module Model module NestedAttributes extend ActiveSupport::Concern module ClassMethods # Allow nested attributes for an association # # @example # class User # include Her::Model # # has_one :role # accepts_neste...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model/relation.rb
lib/her/model/relation.rb
module Her module Model class Relation # @private attr_accessor :params attr_writer :parent # @private def initialize(parent) @parent = parent @params = {} end # @private def apply_to(attributes) @params.merge(attributes) end ...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model/paths.rb
lib/her/model/paths.rb
module Her module Model module Paths extend ActiveSupport::Concern # Return a path based on the collection path and a resource data # # @example # class User # include Her::Model # collection_path "/utilisateurs" # end # # User.find(1) # Fe...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model/http.rb
lib/her/model/http.rb
module Her module Model # This module interacts with Her::API to fetch HTTP data module HTTP extend ActiveSupport::Concern METHODS = [:get, :post, :put, :patch, :delete, :options] # For each HTTP method, define these class methods: # # - <method>(path, params) # - <method>...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model/base.rb
lib/her/model/base.rb
module Her module Model # This module includes basic functionnality to Her::Model module Base extend ActiveSupport::Concern # Returns true if attribute_name is # * in resource attributes # * an association # # @private def has_key?(attribute_name) has_attribu...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model/introspection.rb
lib/her/model/introspection.rb
module Her module Model module Introspection extend ActiveSupport::Concern # Inspect an element, returns it for introspection. # # @example # class User # include Her::Model # end # # @user = User.find(1) # p @user # => #<User(/users/1) id=1 ...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model/parse.rb
lib/her/model/parse.rb
module Her module Model # This module handles resource data parsing at the model level (after the parsing middleware) module Parse extend ActiveSupport::Concern # Convert into a hash of request parameters, based on `include_root_in_json`. # # @example # @user.to_params #...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model/associations.rb
lib/her/model/associations.rb
require "her/model/associations/association" require "her/model/associations/association_proxy" require "her/model/associations/belongs_to_association" require "her/model/associations/has_many_association" require "her/model/associations/has_one_association" module Her module Model # This module adds association...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model/associations/has_one_association.rb
lib/her/model/associations/has_one_association.rb
module Her module Model module Associations class HasOneAssociation < Association # @private def self.attach(klass, name, opts) opts = { :class_name => name.to_s.classify, :name => name, :data_key => name, :default => nil, ...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model/associations/has_many_association.rb
lib/her/model/associations/has_many_association.rb
module Her module Model module Associations class HasManyAssociation < Association # @private def self.attach(klass, name, opts) opts = { :class_name => name.to_s.classify, :name => name, :data_key => name, :defau...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model/associations/belongs_to_association.rb
lib/her/model/associations/belongs_to_association.rb
module Her module Model module Associations class BelongsToAssociation < Association # @private def self.attach(klass, name, opts) opts = { :class_name => name.to_s.classify, :name => name, :data_key => name, :default => nil, ...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model/associations/association_proxy.rb
lib/her/model/associations/association_proxy.rb
module Her module Model module Associations class AssociationProxy < (ActiveSupport.const_defined?('ProxyObject') ? ActiveSupport::ProxyObject : ActiveSupport::BasicObject) # @private def self.install_proxy_methods(target_name, *names) names.each do |name| module_eval ...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/model/associations/association.rb
lib/her/model/associations/association.rb
module Her module Model module Associations class Association # @private attr_accessor :params # @private def initialize(parent, opts = {}) @parent = parent @opts = opts @params = {} @klass = @parent.class.her_nearby_class(@opts[:cla...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/middleware/second_level_parse_json.rb
lib/her/middleware/second_level_parse_json.rb
module Her module Middleware # This middleware expects the resource/collection data to be contained in the `data` # key of the JSON object class SecondLevelParseJSON < ParseJSON # Parse the response body # # @param [String] body The response body # @return [Mixed] the parsed respo...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/middleware/json_api_parser.rb
lib/her/middleware/json_api_parser.rb
module Her module Middleware # This middleware expects the resource/collection data to be contained in the `data` # key of the JSON object class JsonApiParser < ParseJSON # Parse the response body # # @param [String] body The response body # @return [Mixed] the parsed response ...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/middleware/parse_json.rb
lib/her/middleware/parse_json.rb
module Her module Middleware class ParseJSON < Faraday::Response::Middleware # @private def parse_json(body = nil) body = '{}' if body.blank? message = "Response from the API must behave like a Hash or an Array (last JSON response was #{body.inspect})" json = begin ...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/middleware/first_level_parse_json.rb
lib/her/middleware/first_level_parse_json.rb
module Her module Middleware # This middleware treat the received first-level JSON structure as the resource data. class FirstLevelParseJSON < ParseJSON # Parse the response body # # @param [String] body The response body # @return [Mixed] the parsed response # @private de...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/middleware/accept_json.rb
lib/her/middleware/accept_json.rb
module Her module Middleware # This middleware adds a "Accept: application/json" HTTP header class AcceptJSON < Faraday::Middleware # @private def add_header(headers) headers.merge! "Accept" => "application/json" end # @private def call(env) add_header(env[:requ...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
remi/her
https://github.com/remi/her/blob/b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a/lib/her/json_api/model.rb
lib/her/json_api/model.rb
module Her module JsonApi module Model def self.included(klass) klass.class_eval do include Her::Model [:parse_root_in_json, :include_root_in_json, :root_element, :primary_key].each do |method| define_method method do |*_| raise NoMethodError, "Her::Jso...
ruby
MIT
b59a05aa12ac9da44d4d51dcfbbfb7c67a4a156a
2026-01-04T15:57:51.915871Z
false
markevans/dragonfly
https://github.com/markevans/dragonfly/blob/ddede200b093ebe09467128bff071b40ad85e382/dev/irbrc.rb
dev/irbrc.rb
require "rubygems" require "bundler/setup" $:.unshift(File.expand_path('../../lib', __FILE__)) require 'dragonfly' require 'pry' APP = Dragonfly.app.configure do plugin :imagemagick datastore :memory end class Model extend Dragonfly::Model attr_accessor :image_uid, :image_name, :image_width, :small_image_uid ...
ruby
MIT
ddede200b093ebe09467128bff071b40ad85e382
2026-01-04T15:58:00.805242Z
false
markevans/dragonfly
https://github.com/markevans/dragonfly/blob/ddede200b093ebe09467128bff071b40ad85e382/dev/rails_template.rb
dev/rails_template.rb
after_bundle do gem 'dragonfly', :path => File.expand_path('../..', __FILE__) generate "dragonfly" generate "scaffold", "photo image_uid:string image_name:string" rake "db:migrate" route %( get "text/:text" => Dragonfly.app.endpoint { |params, app| app.generate(:text, params[:text]) } ) rout...
ruby
MIT
ddede200b093ebe09467128bff071b40ad85e382
2026-01-04T15:58:00.805242Z
false
markevans/dragonfly
https://github.com/markevans/dragonfly/blob/ddede200b093ebe09467128bff071b40ad85e382/spec/dragonfly_spec.rb
spec/dragonfly_spec.rb
require 'spec_helper' require 'logger' require 'stringio' describe Dragonfly do it "returns a default app" do Dragonfly.app.should == Dragonfly::App.instance end it "returns a named app" do Dragonfly.app(:mine).should == Dragonfly::App.instance(:mine) end describe "logging" do context "logger e...
ruby
MIT
ddede200b093ebe09467128bff071b40ad85e382
2026-01-04T15:58:00.805242Z
false
markevans/dragonfly
https://github.com/markevans/dragonfly/blob/ddede200b093ebe09467128bff071b40ad85e382/spec/spec_helper.rb
spec/spec_helper.rb
require "rubygems" require "bundler" Bundler.setup(:default, :test) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib")) $LOAD_PATH.unshift(File.dirname(__FILE__)) require "rspec" require "dragonfly" require "fileutils" require "tempfile" require "webmock/rspec" require "pry" # Requires supporting files...
ruby
MIT
ddede200b093ebe09467128bff071b40ad85e382
2026-01-04T15:58:00.805242Z
false
markevans/dragonfly
https://github.com/markevans/dragonfly/blob/ddede200b093ebe09467128bff071b40ad85e382/spec/support/model_helpers.rb
spec/support/model_helpers.rb
require 'active_model' require 'dragonfly/model/validations' # Generic activemodel model class MyModel extend Dragonfly::Model # Callbacks extend ActiveModel::Callbacks define_model_callbacks :save, :destroy include ActiveModel::Dirty class << self attr_writer :attribute_names def attribute_nam...
ruby
MIT
ddede200b093ebe09467128bff071b40ad85e382
2026-01-04T15:58:00.805242Z
false
markevans/dragonfly
https://github.com/markevans/dragonfly/blob/ddede200b093ebe09467128bff071b40ad85e382/spec/support/simple_matchers.rb
spec/support/simple_matchers.rb
RSpec::Matchers.define :match_url do |url| match do |given| given_path, given_query_string = given.split('?') path, query_string = url.split('?') path == given_path && given_query_string.split('&').sort == query_string.split('&').sort end end RSpec::Matchers.define :be_an_empty_directory do match do...
ruby
MIT
ddede200b093ebe09467128bff071b40ad85e382
2026-01-04T15:58:00.805242Z
false
markevans/dragonfly
https://github.com/markevans/dragonfly/blob/ddede200b093ebe09467128bff071b40ad85e382/spec/support/image_matchers.rb
spec/support/image_matchers.rb
def image_properties(image) details = `identify #{image.path}` raise "couldn't identify #{image.path} in image_properties" if details.empty? # example of details string: # myimage.png PNG 200x100 200x100+0+0 8-bit DirectClass 31.2kb filename, format, geometry, geometry_2, depth, image_class, size = details.sp...
ruby
MIT
ddede200b093ebe09467128bff071b40ad85e382
2026-01-04T15:58:00.805242Z
false
markevans/dragonfly
https://github.com/markevans/dragonfly/blob/ddede200b093ebe09467128bff071b40ad85e382/spec/support/argument_matchers.rb
spec/support/argument_matchers.rb
def string_matching(regexp) Spec::Mocks::ArgumentMatchers::RegexpMatcher.new(regexp) end class ContentArgumentMatcher def initialize(data) @data = data end def ==(actual) actual.is_a?(Dragonfly::Content) && actual.data == @data end end def content_with_data(data) ContentArgumentMatcher.new(d...
ruby
MIT
ddede200b093ebe09467128bff071b40ad85e382
2026-01-04T15:58:00.805242Z
false
markevans/dragonfly
https://github.com/markevans/dragonfly/blob/ddede200b093ebe09467128bff071b40ad85e382/spec/support/rack_helpers.rb
spec/support/rack_helpers.rb
module RackHelpers def request(app, path) Rack::MockRequest.new(app).get(path) end end
ruby
MIT
ddede200b093ebe09467128bff071b40ad85e382
2026-01-04T15:58:00.805242Z
false
markevans/dragonfly
https://github.com/markevans/dragonfly/blob/ddede200b093ebe09467128bff071b40ad85e382/spec/dragonfly/temp_object_spec.rb
spec/dragonfly/temp_object_spec.rb
require 'spec_helper' describe Dragonfly::TempObject do ####### Helper Methods ####### def sample_path(filename) SAMPLES_DIR.join(filename) end def new_tempfile(data='HELLO') tempfile = Tempfile.new('test') tempfile.write(data) tempfile.rewind tempfile end def new_file(data='HELLO',...
ruby
MIT
ddede200b093ebe09467128bff071b40ad85e382
2026-01-04T15:58:00.805242Z
false
markevans/dragonfly
https://github.com/markevans/dragonfly/blob/ddede200b093ebe09467128bff071b40ad85e382/spec/dragonfly/url_mapper_spec.rb
spec/dragonfly/url_mapper_spec.rb
# encoding: utf-8 require 'spec_helper' describe Dragonfly::UrlMapper do describe "validating the url format" do it "should be ok with a valid one" do Dragonfly::UrlMapper.new('/media/:job/:name') end it "should throw an error if params aren't separated" do lambda{ Dragonfly::UrlMapp...
ruby
MIT
ddede200b093ebe09467128bff071b40ad85e382
2026-01-04T15:58:00.805242Z
false
markevans/dragonfly
https://github.com/markevans/dragonfly/blob/ddede200b093ebe09467128bff071b40ad85e382/spec/dragonfly/file_data_store_spec.rb
spec/dragonfly/file_data_store_spec.rb
require 'spec_helper' require 'dragonfly/spec/data_store_examples' describe Dragonfly::FileDataStore do def touch_file(filename) FileUtils.mkdir_p(File.dirname(filename)) FileUtils.touch(filename) end def assert_exists(path) File.exist?(path).should be_truthy end def assert_does_not_exist(path...
ruby
MIT
ddede200b093ebe09467128bff071b40ad85e382
2026-01-04T15:58:00.805242Z
false
markevans/dragonfly
https://github.com/markevans/dragonfly/blob/ddede200b093ebe09467128bff071b40ad85e382/spec/dragonfly/middleware_spec.rb
spec/dragonfly/middleware_spec.rb
require 'spec_helper' require 'rack' def dummy_rack_app lambda{|env| [200, {"content-type" => "text/html"}, ["dummy_rack_app body"]] } end describe Dragonfly::Middleware do def make_request(app, url) Rack::MockRequest.new(app).get(url) end describe "using the default app" do before(:each) do @...
ruby
MIT
ddede200b093ebe09467128bff071b40ad85e382
2026-01-04T15:58:00.805242Z
false
markevans/dragonfly
https://github.com/markevans/dragonfly/blob/ddede200b093ebe09467128bff071b40ad85e382/spec/dragonfly/url_attributes_spec.rb
spec/dragonfly/url_attributes_spec.rb
require 'spec_helper' describe Dragonfly::UrlAttributes do let(:url_attributes) { Dragonfly::UrlAttributes.new } describe "empty" do it "returns true when empty" do url_attributes.empty?.should be_truthy end it "returns false when not empty" do url_attributes.some = 'thing' url_att...
ruby
MIT
ddede200b093ebe09467128bff071b40ad85e382
2026-01-04T15:58:00.805242Z
false
markevans/dragonfly
https://github.com/markevans/dragonfly/blob/ddede200b093ebe09467128bff071b40ad85e382/spec/dragonfly/whitelist_spec.rb
spec/dragonfly/whitelist_spec.rb
require 'spec_helper' describe Dragonfly::Whitelist do it "matches regexps" do whitelist = Dragonfly::Whitelist.new([/platipus/]) whitelist.include?("platipus").should be_truthy whitelist.include?("small platipus in the bath").should be_truthy whitelist.include?("baloney").should be_falsey end i...
ruby
MIT
ddede200b093ebe09467128bff071b40ad85e382
2026-01-04T15:58:00.805242Z
false