From d87de1f3637296be189774c4837f9f2d1ace2e54 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Wed, 10 Jun 2015 03:05:07 +0200 Subject: [PATCH] initial commit --- .gitignore | 3 + .rubocop.yml | 137 ++++++++++++++++++ .ruby-gemset | 1 + .ruby-version | 1 + Gemfile | 15 ++ Gemfile.lock | 107 ++++++++++++++ LICENSE | 15 ++ README.rdoc | 3 + Rakefile | 37 +++++ .../application_controller.rb | 4 + .../diaspora_federation/application_helper.rb | 4 + bin/rails | 12 ++ config/routes.rb | 2 + diaspora_federation.gemspec | 21 +++ lib/diaspora_federation.rb | 4 + lib/diaspora_federation/engine.rb | 5 + lib/diaspora_federation/version.rb | 3 + lib/tasks/diaspora_federation_tasks.rake | 4 + test/diaspora_federation_test.rb | 7 + test/test_helper.rb | 11 ++ 20 files changed, 396 insertions(+) create mode 100644 .gitignore create mode 100644 .rubocop.yml create mode 100644 .ruby-gemset create mode 100644 .ruby-version create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 LICENSE create mode 100644 README.rdoc create mode 100644 Rakefile create mode 100644 app/controllers/diaspora_federation/application_controller.rb create mode 100644 app/helpers/diaspora_federation/application_helper.rb create mode 100755 bin/rails create mode 100644 config/routes.rb create mode 100644 diaspora_federation.gemspec create mode 100644 lib/diaspora_federation.rb create mode 100644 lib/diaspora_federation/engine.rb create mode 100644 lib/diaspora_federation/version.rb create mode 100644 lib/tasks/diaspora_federation_tasks.rake create mode 100644 test/diaspora_federation_test.rb create mode 100644 test/test_helper.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8619e09 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.bundle/ +log/*.log +pkg/ diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..7cbf4af --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,137 @@ +AllCops: + RunRailsCops: true + +# Commonly used screens these days easily fit more than 80 characters. +Metrics/LineLength: + Max: 120 + +# Too short methods lead to extraction of single-use methods, which can make +# the code easier to read (by naming things), but can also clutter the class +Metrics/MethodLength: + Max: 20 + +# The guiding principle of classes is SRP, SRP can't be accurately measured by LoC +Metrics/ClassLength: + Max: 1500 + +# No space makes the method definition shorter and differentiates +# from a regular assignment. +Style/SpaceAroundEqualsInParameterDefault: + EnforcedStyle: no_space + +# Single quotes being faster is hardly measurable and only affects parse time. +# Enforcing double quotes reduces the times where you need to change them +# when introducing an interpolation. Use single quotes only if their semantics +# are needed. +Style/StringLiterals: + EnforcedStyle: double_quotes + +# We do not need to support Ruby 1.9, so this is good to use. +Style/SymbolArray: + Enabled: true + +# Most readable form. +Style/AlignHash: + EnforcedHashRocketStyle: table + EnforcedColonStyle: table + +# Mixing the styles looks just silly. +Style/HashSyntax: + EnforcedStyle: ruby19_no_mixed_keys + +# has_key? and has_value? are far more readable than key? and value? +Style/DeprecatedHashMethods: + Enabled: false + +# String#% is by far the least verbose and only object oriented variant. +Style/FormatString: + EnforcedStyle: percent + +Style/CollectionMethods: + Enabled: true + PreferredMethods: + # inject seems more common in the community. + reduce: "inject" + + +# Either allow this style or don't. Marking it as safe with parenthesis +# is silly. Let's try to live without them for now. +Style/ParenthesesAroundCondition: + AllowSafeAssignment: false +Lint/AssignmentInCondition: + AllowSafeAssignment: false + +# A specialized exception class will take one or more arguments and construct the message from it. +# So both variants make sense. +Style/RaiseArgs: + Enabled: false + +# Indenting the chained dots beneath each other is not supported by this cop, +# see https://github.com/bbatsov/rubocop/issues/1633 +Style/MultilineOperationIndentation: + Enabled: false + +# Fail is an alias of raise. Avoid aliases, it's more cognitive load for no gain. +# The argument that fail should be used to abort the program is wrong too, +# there's Kernel#abort for that. +Style/SignalException: + EnforcedStyle: only_raise + +# Suppressing exceptions can be perfectly fine, and be it to avoid to +# explicitly type nil into the rescue since that's what you want to return, +# or suppressing LoadError for optional dependencies +Lint/HandleExceptions: + Enabled: false + +Style/SpaceInsideBlockBraces: + # The space here provides no real gain in readability while consuming + # horizontal space that could be used for a better parameter name. + # Also {| differentiates better from a hash than { | does. + SpaceBeforeBlockParameters: false + +# No trailing space differentiates better from the block: +# foo} means hash, foo } means block. +Style/SpaceInsideHashLiteralBraces: + EnforcedStyle: no_space + +# { ... } for multi-line blocks is okay, follow Weirichs rule instead: +# https://web.archive.org/web/20140221124509/http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc +Style/BlockDelimiters: + Enabled: false + +# do / end blocks should be used for side effects, +# methods that run a block for side effects and have +# a useful return value are rare, assign the return +# value to a local variable for those cases. +Style/MethodCalledOnDoEndBlock: + Enabled: true + +# Enforcing the names of variables? To single letter ones? Just no. +Style/SingleLineBlockParams: + Enabled: false + +# Shadowing outer local variables with block parameters is often useful +# to not reinvent a new name for the same thing, it highlights the relation +# between the outer variable and the parameter. The cases where it's actually +# confusing are rare, and usually bad for other reasons already, for example +# because the method is too long. +Lint/ShadowingOuterLocalVariable: + Enabled: false + +# Check with yard instead. +Style/Documentation: + Enabled: false + +# This is just silly. Calling the argument `other` in all cases makes no sense. +Style/OpMethod: + Enabled: false + +# There are valid cases, for example debugging Cucumber steps, +# also they'll fail CI anyway +Lint/Debugger: + Enabled: false + + +# Reset some HoundCI changes back to Rubocop defaults +Style/DotPosition: + EnforcedStyle: leading diff --git a/.ruby-gemset b/.ruby-gemset new file mode 100644 index 0000000..6891ee9 --- /dev/null +++ b/.ruby-gemset @@ -0,0 +1 @@ +diaspora-federation diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..8bbe6cf --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.2 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..83f03c8 --- /dev/null +++ b/Gemfile @@ -0,0 +1,15 @@ +source 'https://rubygems.org' + +# Declare your gem's dependencies in diaspora_federation.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +# Declare any dependencies that are still in development here instead of in +# your gemspec. These might include edge Rails or gems from your path or +# Git. Remember to move these dependencies to your gemspec before releasing +# your gem to rubygems.org. + +# To use a debugger +# gem 'byebug', group: [:development, :test] + diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..72725eb --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,107 @@ +PATH + remote: . + specs: + diaspora_federation (0.0.1) + rails (~> 4.2.1) + +GEM + remote: https://rubygems.org/ + specs: + actionmailer (4.2.1) + actionpack (= 4.2.1) + actionview (= 4.2.1) + activejob (= 4.2.1) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.1) + actionview (= 4.2.1) + activesupport (= 4.2.1) + rack (~> 1.6) + rack-test (~> 0.6.2) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.1) + actionview (4.2.1) + activesupport (= 4.2.1) + builder (~> 3.1) + erubis (~> 2.7.0) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.1) + activejob (4.2.1) + activesupport (= 4.2.1) + globalid (>= 0.3.0) + activemodel (4.2.1) + activesupport (= 4.2.1) + builder (~> 3.1) + activerecord (4.2.1) + activemodel (= 4.2.1) + activesupport (= 4.2.1) + arel (~> 6.0) + activesupport (4.2.1) + i18n (~> 0.7) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + arel (6.0.0) + builder (3.2.2) + erubis (2.7.0) + globalid (0.3.5) + activesupport (>= 4.1.0) + i18n (0.7.0) + json (1.8.3) + loofah (2.0.2) + nokogiri (>= 1.5.9) + mail (2.6.3) + mime-types (>= 1.16, < 3) + mime-types (2.6.1) + mini_portile (0.6.2) + minitest (5.7.0) + nokogiri (1.6.6.2) + mini_portile (~> 0.6.0) + rack (1.6.1) + rack-test (0.6.3) + rack (>= 1.0) + rails (4.2.1) + actionmailer (= 4.2.1) + actionpack (= 4.2.1) + actionview (= 4.2.1) + activejob (= 4.2.1) + activemodel (= 4.2.1) + activerecord (= 4.2.1) + activesupport (= 4.2.1) + bundler (>= 1.3.0, < 2.0) + railties (= 4.2.1) + sprockets-rails + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.6) + activesupport (>= 4.2.0.beta, < 5.0) + nokogiri (~> 1.6.0) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.0.2) + loofah (~> 2.0) + railties (4.2.1) + actionpack (= 4.2.1) + activesupport (= 4.2.1) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (10.4.2) + sprockets (3.2.0) + rack (~> 1.0) + sprockets-rails (2.3.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (>= 2.8, < 4.0) + thor (0.19.1) + thread_safe (0.3.5) + tzinfo (1.2.2) + thread_safe (~> 0.1) + +PLATFORMS + ruby + +DEPENDENCIES + diaspora_federation! + +BUNDLED WITH + 1.10.3 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f097ca6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,15 @@ +Diaspora Federation Rails Engine +Copyright (C) 2015 Benjamin Neff + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..2b6ff3f --- /dev/null +++ b/README.rdoc @@ -0,0 +1,3 @@ += DiasporaFederation + +This project rocks and uses LICENSE. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..de49882 --- /dev/null +++ b/Rakefile @@ -0,0 +1,37 @@ +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end + +require 'rdoc/task' + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'DiasporaFederation' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') +end + +APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) +load 'rails/tasks/engine.rake' + + +load 'rails/tasks/statistics.rake' + + + +Bundler::GemHelper.install_tasks + +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + + +task default: :test diff --git a/app/controllers/diaspora_federation/application_controller.rb b/app/controllers/diaspora_federation/application_controller.rb new file mode 100644 index 0000000..4db5f90 --- /dev/null +++ b/app/controllers/diaspora_federation/application_controller.rb @@ -0,0 +1,4 @@ +module DiasporaFederation + class ApplicationController < ActionController::Base + end +end diff --git a/app/helpers/diaspora_federation/application_helper.rb b/app/helpers/diaspora_federation/application_helper.rb new file mode 100644 index 0000000..4011241 --- /dev/null +++ b/app/helpers/diaspora_federation/application_helper.rb @@ -0,0 +1,4 @@ +module DiasporaFederation + module ApplicationHelper + end +end diff --git a/bin/rails b/bin/rails new file mode 100755 index 0000000..4595731 --- /dev/null +++ b/bin/rails @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. + +ENGINE_ROOT = File.expand_path('../..', __FILE__) +ENGINE_PATH = File.expand_path('../../lib/diaspora_federation/engine', __FILE__) + +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) + +require 'rails/all' +require 'rails/engine/commands' diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..0453f2c --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,2 @@ +DiasporaFederation::Engine.routes.draw do +end diff --git a/diaspora_federation.gemspec b/diaspora_federation.gemspec new file mode 100644 index 0000000..ffe6ea8 --- /dev/null +++ b/diaspora_federation.gemspec @@ -0,0 +1,21 @@ +$:.push File.expand_path("../lib", __FILE__) + +# Maintain your gem's version: +require "diaspora_federation/version" + +# Describe your gem and declare its dependencies: +Gem::Specification.new do |s| + s.name = "diaspora_federation" + s.version = DiasporaFederation::VERSION + s.authors = ["Benjamin Neff"] + s.email = ["benjamin@coding4.coffee"] + s.homepage = "https://github.com/SuperTux88/diaspora_federation" + s.summary = "Diaspora Federation Rails Engine" + s.description = "A rails engine that adds the diaspora federation protocol to a rails app" + s.license = "AGPL 3.0 - http://www.gnu.org/licenses/agpl-3.0.html" + + s.files = Dir["{app,config,db,lib}/**/*", "LICENSE", "Rakefile", "README.rdoc"] + s.test_files = Dir["test/**/*"] + + s.add_dependency "rails", "~> 4.2.1" +end diff --git a/lib/diaspora_federation.rb b/lib/diaspora_federation.rb new file mode 100644 index 0000000..c5faea4 --- /dev/null +++ b/lib/diaspora_federation.rb @@ -0,0 +1,4 @@ +require "diaspora_federation/engine" + +module DiasporaFederation +end diff --git a/lib/diaspora_federation/engine.rb b/lib/diaspora_federation/engine.rb new file mode 100644 index 0000000..6c5a42c --- /dev/null +++ b/lib/diaspora_federation/engine.rb @@ -0,0 +1,5 @@ +module DiasporaFederation + class Engine < ::Rails::Engine + isolate_namespace DiasporaFederation + end +end diff --git a/lib/diaspora_federation/version.rb b/lib/diaspora_federation/version.rb new file mode 100644 index 0000000..6120d2a --- /dev/null +++ b/lib/diaspora_federation/version.rb @@ -0,0 +1,3 @@ +module DiasporaFederation + VERSION = "0.0.1" +end diff --git a/lib/tasks/diaspora_federation_tasks.rake b/lib/tasks/diaspora_federation_tasks.rake new file mode 100644 index 0000000..26df6e9 --- /dev/null +++ b/lib/tasks/diaspora_federation_tasks.rake @@ -0,0 +1,4 @@ +# desc "Explaining what the task does" +# task :diaspora_federation do +# # Task goes here +# end diff --git a/test/diaspora_federation_test.rb b/test/diaspora_federation_test.rb new file mode 100644 index 0000000..7c02a5b --- /dev/null +++ b/test/diaspora_federation_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class DiasporaFederationTest < ActiveSupport::TestCase + test "truth" do + assert_kind_of Module, DiasporaFederation + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..122bd97 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,11 @@ +# Configure Rails Environment +ENV["RAILS_ENV"] = "test" + +require "rails/test_help" + +# Filter out Minitest backtrace while allowing backtrace from other libraries +# to be shown. +Minitest.backtrace_filter = Minitest::BacktraceFilter.new + +# Load support files +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }