Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dd0549b

Browse files
committedMar 19, 2020
feat: Add models
1 parent e97b03a commit dd0549b

27 files changed

+260
-69
lines changed
 

‎.rubocop.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
AllCops:
2+
TargetRubyVersion: 2.6
3+
EnabledByDefault: true
4+
5+
Style:
6+
Enabled: false
7+
8+
Layout:
9+
Enabled: false

‎CODE_OF_CONDUCT.md

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at waghanza@gmail.com. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at [https://contributor-covenant.org/version/1/4][version]
72+
73+
[homepage]: https://contributor-covenant.org
74+
[version]: https://contributor-covenant.org/version/1/4/

‎Gemfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
source("https://rubygems.org")
4+
5+
gemspec
6+
7+
group :development, :test do
8+
# Keep code consistency
9+
gem "rubocop"
10+
end

‎LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2020 Marwan Rabbâa
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

‎Rakefile

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# frozen_string_literal: true
2+
3+
require('bundler/gem_tasks')
4+
task(default: :spec)
5+
6+
require('active_record')
7+
require('active_record/database_configurations/database_config')
8+
require('active_record/database_configurations/url_config')
9+
10+
database_url = ENV.fetch('DATABASE_URL')
11+
12+
namespace :db do
13+
task :create do
14+
database = ActiveRecord::DatabaseConfigurations::UrlConfig.new(nil, nil, database_url)
15+
16+
ActiveRecord::Tasks::DatabaseTasks.create(database.config)
17+
end
18+
19+
task :migrate do
20+
base_path = Gem.loaded_specs['benchmarker-data'].full_gem_path
21+
full_path = File.join(base_path, 'db', 'migrations')
22+
ActiveRecord::MigrationContext.new(full_path, ActiveRecord::SchemaMigration).migrate
23+
end
24+
25+
task :drop do
26+
database = ActiveRecord::DatabaseConfigurations::UrlConfig.new(nil, nil, database_url)
27+
28+
ActiveRecord::Tasks::DatabaseTasks.drop(database.config)
29+
end
30+
end

‎benchmarker-data.gemspec

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# frozen_string_literal: true
2+
3+
require_relative("lib/benchmarker/data/version")
4+
5+
Gem::Specification.new do |spec|
6+
spec.name = "benchmarker-data"
7+
spec.version = Benchmarker::Data::VERSION
8+
spec.authors = ["Marwan Rabbâa"]
9+
spec.email = ["waghanza@gmail.com"]
10+
11+
spec.summary = "Shared data for the benchmarker tools"
12+
spec.homepage = "https://github.com/the-benchmarker/benchmarker-data"
13+
spec.license = "MIT"
14+
spec.required_ruby_version = "~> 2.6"
15+
16+
spec.metadata["allowed_push_host"] = "https://rubygems.pkg.github.com"
17+
18+
spec.metadata["homepage_uri"] = spec.homepage
19+
spec.metadata["source_code_uri"] = spec.homepage
20+
spec.metadata["changelog_uri"] = "https://github.com/the-benchmarker/benchmarker-data/releases"
21+
22+
spec.add_runtime_dependency("activerecord", "~> 6.0")
23+
spec.add_runtime_dependency("pg", "~> 1.2")
24+
spec.add_runtime_dependency("rake", "~> 13.0")
25+
26+
spec.add_development_dependency("bundler", "~> 2.0")
27+
28+
spec.files = Dir.glob("lib/**/*.rb")
29+
spec.files << "LICENSE.txt"
30+
spec.files << "Rakefile"
31+
spec.require_paths = ["lib", "db/migrations"]
32+
end

‎benchmarker_data.gemspec

-29
This file was deleted.

‎bin/console

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require('bundler/setup')
5+
require('benchmarker/data')
6+
7+
require('irb')
8+
IRB.start(__FILE__)

‎bin/setup

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
IFS=$'\n\t'
4+
set -vx
5+
6+
bundle install
7+
8+
# Do any other automated setup that you need to do here

‎lib/benchmarker/data/migrations/0001_languages.rb ‎db/migrations/0001_languages.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class Languages < ActiveRecord::Migration[6.0]
44
def change
55
create_table :languages do |t|
6-
t.string :label, index: { unique: true }
6+
t.string(:label, index: { unique: true })
77
end
88
end
99
end

‎lib/benchmarker/data/migrations/0002_frameworks.rb ‎db/migrations/0002_frameworks.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
class Frameworks < ActiveRecord::Migration[6.0]
44
def change
55
create_table :frameworks do |t|
6-
t.string :label
7-
t.references :language
6+
t.string(:label)
7+
t.references(:language)
88
end
99

10-
add_index :frameworks, [:label, :language_id], unique: true
10+
add_index(:frameworks, %i[label language_id], unique: true)
1111
end
1212
end

‎lib/benchmarker/data/migrations/0003_concurrencies.rb ‎db/migrations/0003_concurrencies.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class Concurrencies < ActiveRecord::Migration[6.0]
44
def change
55
create_table :concurrencies do |t|
6-
t.numeric :level, index: { unique: true }
6+
t.numeric(:level, index: { unique: true })
77
end
88
end
99
end

‎lib/benchmarker/data/migrations/0004_keys.rb ‎db/migrations/0004_keys.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class Keys < ActiveRecord::Migration[6.0]
44
def change
55
create_table :keys do |t|
6-
t.string :label, index: { unique: true }
6+
t.string(:label, index: { unique: true })
77
end
88
end
99
end

‎lib/benchmarker/data/migrations/0005_values.rb ‎db/migrations/0005_values.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
class Values < ActiveRecord::Migration[6.0]
44
def change
55
create_table :values do |t|
6-
t.float :value
7-
t.references :key
6+
t.float(:value)
7+
t.references(:key)
88
end
99
end
1010
end

‎db/migrations/0006_metrics.rb

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
class Metrics < ActiveRecord::Migration[6.0]
4+
def change
5+
create_table :metrics do |t|
6+
t.references(:framework)
7+
t.references(:value)
8+
t.references(:concurrency)
9+
end
10+
11+
add_index(:metrics, %i[framework_id value_id concurrency_id])
12+
end
13+
end

‎lib/benchmarker/data/migrations/0007_writable.rb ‎db/migrations/0007_writable.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
class Writable < ActiveRecord::Migration[6.0]
44
def change
55
create_table :writable, id: false do |t|
6-
t.references :language
7-
t.references :framework
6+
t.references(:language)
7+
t.references(:framework)
88
end
99
end
1010
end

‎lib/benchmarker/data.rb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
require("active_record")
4+
5+
require("benchmarker/data/base")
6+
require("benchmarker/data/language")
7+
require("benchmarker/data/framework")
8+
require("benchmarker/data/key")
9+
require("benchmarker/data/metric")
10+
require("benchmarker/data/concurrency")
11+
require("benchmarker/data/value")

‎lib/benchmarker/data/models/model.rb ‎lib/benchmarker/data/base.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
module Benchmarker
44
module Data
5-
class Model < ::ActiveRecord::Base
5+
class Base < ::ActiveRecord::Base
66
self.abstract_class = true
7+
establish_connection
78
end
89
end
910
end
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# frozen_string_literal: true
2+
23
module Benchmarker
34
module Data
4-
class Concurrency < Model
5+
class Concurrency < Base
56
end
67
end
78
end

‎lib/benchmarker/data/framework.rb

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
module Benchmarker
4+
module Data
5+
class Framework < Base
6+
belongs_to :language
7+
end
8+
end
9+
end
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# frozen_string_literal: true
2+
23
module Benchmarker
34
module Data
4-
class Framework < Model
5-
has_one :language
5+
class Key < Base
6+
belongs_to :metric
67
end
78
end
89
end
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# frozen_string_literal: true
2+
23
module Benchmarker
34
module Data
4-
class Key < Model
5+
class Language < Base
56
end
67
end
78
end

‎lib/benchmarker/data/metric.rb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
module Benchmarker
4+
module Data
5+
class Metric < Base
6+
belongs_to :framework
7+
belongs_to :value
8+
belongs_to :concurrency
9+
end
10+
end
11+
end

‎lib/benchmarker/data/migrations/0006_metrics.rb

-13
This file was deleted.
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Please sign in to comment.