Skip to content

Commit

Permalink
Merge branch 'staging/electro-release'
Browse files Browse the repository at this point in the history
  • Loading branch information
limhoff-r7 committed Jun 18, 2014
2 parents d9b9138 + bf4efe5 commit 26a2618
Show file tree
Hide file tree
Showing 379 changed files with 28,753 additions and 53 deletions.
1 change: 1 addition & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
service_name: travis-ci
38 changes: 23 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
# bundler configuration
.bundle
# Mac OS X folder attributes
.DS_Store
# built gems
*.gem
# Rubymine project configuration
.idea
*.gem
*.rbc
.bundle
.config
# logs
*.log
# Don't check in new rvm version and gemset files
.ruby-gemset
.ruby-version
# Don't check in rvmrc since this is a gem
.rvmrc
# YARD database
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
# coverage report directory for simplecov/Rubymine
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
# generated yardocs
doc
# Installed gem versions. Not stored for the same reasons as .rvmrc
Gemfile.lock
# Packaging directory for builds
pkg/*
# Database configuration (with passwords) for specs
spec/dummy/config/database.yml
4 changes: 4 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--backtrace
--colour
--drb
--format nested
38 changes: 38 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# RM_INFO is set when using Rubymine. In Rubymine, starting SimpleCov is
# controlled by running with coverage, so don't explicitly start coverage (and
# therefore generate a report) when in Rubymine. This _will_ generate a report
# whenever `rake spec` is run.
unless ENV['RM_INFO']
SimpleCov.start
end

SimpleCov.configure do
load_adapter('rails')

# ignore this file
add_filter '.simplecov'

#
# Changed Files in Git Group
# @see http://fredwu.me/post/35625566267/simplecov-test-coverage-for-changed-files-only
#

untracked = `git ls-files --exclude-standard --others`
unstaged = `git diff --name-only`
staged = `git diff --name-only --cached`
all = untracked + unstaged + staged
changed_filenames = all.split("\n")

add_group 'Changed' do |source_file|
changed_filenames.detect { |changed_filename|
source_file.filename.end_with?(changed_filename)
}
end

#
# Specs are reported on to ensure that all examples are being run and all
# lets, befores, afters, etc are being used.
#

add_group 'Specs', 'spec'
end
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: ruby
rvm:
- '1.9.3'
- '2.0'
- '2.1'
- 'jruby-19mode'
5 changes: 5 additions & 0 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--markup markdown
--private
--protected
{app,lib}/**/*.rb
db/migrate/*.rb
39 changes: 39 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,42 @@ source 'https://rubygems.org'

# Specify your gem's dependencies in metasploit-model.gemspec
gemspec

# used by dummy application
group :development, :test do
# supplies factories for producing model instance for specs
# Version 4.1.0 or newer is needed to support generate calls without the 'FactoryGirl.' in factory definitions syntax.
gem 'factory_girl', '>= 4.1.0'
# auto-load factories from spec/factories
gem 'factory_girl_rails'
end

group :test do
# rails is not used because activerecord should not be included, but rails would normally coordinate the versions
# between its dependencies, which is now handled by this constraint.
rails_version_constraint = [
'>= 3.2.0',
'< 4.0.0'
]

# Dummy app uses actionpack for ActionController, but not rails since it doesn't use activerecord.
gem 'actionpack', *rails_version_constraint
# Uploads simplecov reports to coveralls.io
gem 'coveralls', require: false
# Engine tasks are loaded using railtie
gem 'railties', *rails_version_constraint
gem 'rspec'
# need rspec-core >= 2.14.0 because 2.14.0 introduced RSpec::Core::SharedExampleGroup::TopLevel
gem 'rspec-core', '>= 2.14.0', '< 3.0.0'
# need rspec-rails >= 2.12.0 as 2.12.0 adds support for redefining named subject in nested context that uses the
# named subject from the outer context without causing a stack overflow.
gem 'rspec-rails', '>= 2.12.0'
# In a full rails project, factory_girl_rails would be in both the :development, and :test group, but since we only
# want rails in :test, factory_girl_rails must also only be in :test.
# add matchers from shoulda, such as validates_presence_of, which are useful for testing validations
gem 'shoulda-matchers'
# code coverage of tests
gem 'simplecov', :require => false
# defines time zones for activesupport. Must be explicit since it is normally implicit with activerecord
gem 'tzinfo'
end
27 changes: 27 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (C) 2012-2013, Rapid7, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of Rapid7 LLC nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 changes: 0 additions & 22 deletions LICENSE.txt

This file was deleted.

8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Metasploit::Model
# Metasploit::Model [![Build Status](https://travis-ci.org/rapid7/metasploit-model.png?branch=feature/exploit)](https://travis-ci.org/rapid7/metasploit-model)[![Coverage Status](https://coveralls.io/repos/rapid7/metasploit-model/badge.png?branch=feature%2Fexploit)](https://coveralls.io/r/rapid7/metasploit-model?branch=feature%2Fexploit)

TODO: Write a gem description
## Versioning

`Metasploit::Model` is versioned using [semantic versioning 2.0](http://semver.org/spec/v2.0.0.html). Each branch
should set `Metasploit::Model::Version::PRERELEASE` to the branch name, while master should have no `PRERELEASE`
and the `PRERELEASE` section of `Metasploit::Model::VERSION` does not exist.

## Installation

Expand Down
53 changes: 52 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1 +1,52 @@
require "bundler/gem_tasks"
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end

print_without = false
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)

begin
load 'rails/tasks/engine.rake'
rescue LoadError
puts "railties not in bundle, so can't load engine tasks."
print_without = true
end

Bundler::GemHelper.install_tasks

#
# load rake files like a normal rails app
# @see http://viget.com/extend/rails-engine-testing-with-rspec-capybara-and-factorygirl
#

pathname = Pathname.new(__FILE__)
root = pathname.parent
rakefile_glob = root.join('lib', 'tasks', '**', '*.rake').to_path

Dir.glob(rakefile_glob) do |rakefile|
load rakefile
end

begin
require 'rspec/core'
rescue LoadError
puts "rspec not in bundle, so can't set up spec tasks. " \
"To run specs ensure to install the development and test groups."
print_without = true
else
require 'rspec/core/rake_task'

# @see http://viget.com/extend/rails-engine-testing-with-rspec-capybara-and-factorygirl
RSpec::Core::RakeTask.new(:spec)

task :default => :spec
end

if print_without
puts "Bundle currently installed '--without #{Bundler.settings.without.join(' ')}'."
puts "To clear the without option do `bundle install --without ''` (the --without flag with an empty string) or " \
"`rm -rf .bundle` to remove the .bundle/config manually and then `bundle install`"
end
46 changes: 46 additions & 0 deletions app/models/metasploit/model/association/reflection.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Reflection of the call to {Metasploit::Model::Association::ClassMethods#association}.
class Metasploit::Model::Association::Reflection < Metasploit::Model::Base
#
# Attributes
#

# @!attribute [rw] class_name
# The name {#klass}. The name of {#klass} is given instead of {#klass} directly when initializing this
# reflection to prevent circular references with autoloading or ActiveSupport::Dependencies loading.
#
# @return [String] Fully-qualified name of class in this association
attr_accessor :class_name

# @!attribute [rw] model
# The model on which this association was declared. The equivalent for ActiveRecord association reflections
# would be #active_record.
#
# @return [Class]
attr_accessor :model

# @!attribute [rw] name
# The name of this association.
#
# @return [String]
attr_accessor :name

#
# Validations
#

validates :model, :presence => true
validates :name, :presence => true
validates :class_name, :presence => true

#
# Methods
#

# Class with name {#class_name}.
#
# @return []
# @raise [NameError] if {#class_name} cannot be constantized
def klass
class_name.constantize
end
end
Loading

0 comments on commit 26a2618

Please sign in to comment.