-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
259 additions
and
96 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.6.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
glare-ux-metrics-metrics-rb (0.1.0) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
ast (2.4.2) | ||
diff-lcs (1.5.0) | ||
json (2.6.3) | ||
parallel (1.23.0) | ||
parser (3.3.0.4) | ||
ast (~> 2.4.1) | ||
racc | ||
racc (1.8.1) | ||
rainbow (3.1.1) | ||
rake (13.2.1) | ||
regexp_parser (2.8.2) | ||
rexml (3.3.7) | ||
rspec (3.13.0) | ||
rspec-core (~> 3.13.0) | ||
rspec-expectations (~> 3.13.0) | ||
rspec-mocks (~> 3.13.0) | ||
rspec-core (3.13.1) | ||
rspec-support (~> 3.13.0) | ||
rspec-expectations (3.13.3) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.13.0) | ||
rspec-mocks (3.13.2) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.13.0) | ||
rspec-support (3.13.1) | ||
rubocop (1.50.2) | ||
json (~> 2.3) | ||
parallel (~> 1.10) | ||
parser (>= 3.2.0.0) | ||
rainbow (>= 2.2.2, < 4.0) | ||
regexp_parser (>= 1.8, < 3.0) | ||
rexml (>= 3.2.5, < 4.0) | ||
rubocop-ast (>= 1.28.0, < 2.0) | ||
ruby-progressbar (~> 1.7) | ||
unicode-display_width (>= 2.4.0, < 3.0) | ||
rubocop-ast (1.30.0) | ||
parser (>= 3.2.1.0) | ||
ruby-progressbar (1.13.0) | ||
unicode-display_width (2.5.0) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
glare-ux-metrics-metrics-rb! | ||
rake (~> 13.0) | ||
rspec (~> 3.1) | ||
rubocop (~> 1.21) | ||
|
||
BUNDLED WITH | ||
2.4.21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "lib/glare/ux/metrics/rb/version" | ||
require_relative "lib/glare/ux-metrics/version" | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "glare-ux-metrics-rb" | ||
spec.version = Glare::Ux::Metrics::Rb::VERSION | ||
spec.name = "glare-ux-metrics-metrics-rb" | ||
spec.version = Glare::UxMetrics::VERSION | ||
spec.authors = ["Benjamin Scott"] | ||
spec.email = ["[email protected]"] | ||
|
||
spec.summary = "TODO: Write a short summary, because RubyGems requires one." | ||
spec.description = "TODO: Write a longer description or delete this line." | ||
spec.homepage = "TODO: Put your gem's website or public repo URL here." | ||
spec.summary = "A UX Metric framework for ruby projects" | ||
spec.description = "A UX Metric framework for ZURB" | ||
spec.homepage = "https://github.com/zurb/glare-ux-metrics-rb" | ||
spec.license = "MIT" | ||
spec.required_ruby_version = ">= 2.6.0" | ||
|
||
spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'" | ||
spec.metadata["allowed_push_host"] = "https://github.com/zurb/glare-ux-metrics-rb" | ||
|
||
spec.metadata["homepage_uri"] = spec.homepage | ||
spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here." | ||
spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." | ||
spec.metadata["source_code_uri"] = "https://github.com/zurb/glare-ux-metrics-rb" | ||
spec.metadata["changelog_uri"] = "https://github.com/zurb/glare-ux-metrics-rb/CHANGELOG.md" | ||
|
||
# Specify which files should be added to the gem when it is released. | ||
# The `git ls-files -z` loads the files in the RubyGem that have been added into git. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# frozen_string_literal: true | ||
|
||
module Glare | ||
module UxMetrics | ||
class Error < StandardError; end | ||
|
||
module Sentiment | ||
class Data | ||
CHOICE_KEYS = %w[helpful innovative simple complicated confusing overwhelming annoying].freeze | ||
|
||
def initialize(choices:) | ||
@choices = choices | ||
end | ||
|
||
attr_reader :choices | ||
|
||
def valid? | ||
if choices.is_a?(Hash) && choices.size | ||
missing_attributes = CHOICE_KEYS - choices.keys.map(&:to_s) | ||
return true if missing_attributes.empty? | ||
end | ||
|
||
false | ||
end | ||
|
||
def parse | ||
result = choices[:helpful].to_f + | ||
choices[:innovative].to_f + | ||
choices[:simple].to_f + | ||
choices[:joyful].to_f - | ||
choices[:complicated].to_f - | ||
choices[:confusing].to_f - | ||
choices[:overwhelming].to_f - | ||
choices[:annoying].to_f | ||
|
||
threshold = if result > 1.5 | ||
'positive' | ||
elsif result > 1.0 | ||
'neutral' | ||
else | ||
'negative' | ||
end | ||
|
||
Result.new(result: result, threshold: threshold, label: threshold) | ||
end | ||
|
||
class InvalidDataError < Error | ||
def initialize(msg = "Data not valid. Correct data format is: \n\n#{correct_data}") | ||
super(msg) | ||
end | ||
|
||
def correct_data | ||
{ | ||
choices: { | ||
helpful: "string|integer|float", | ||
innovative: "string|integer|float", | ||
simple: "string|integer|float", | ||
joyful: "string|integer|float", | ||
complicated: "string|integer|float", | ||
confusing: "string|integer|float", | ||
overwhelming: "string|integer|float", | ||
annoying: "string|integer|float", | ||
} | ||
}.to_json | ||
end | ||
end | ||
end | ||
|
||
class Result | ||
def initialize(result:, threshold:, label:) | ||
@result = result | ||
@threshold = threshold | ||
@label = label | ||
end | ||
|
||
attr_reader :result, :threshold, :label | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module Glare | ||
module UxMetrics | ||
VERSION = "0.1.0" | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Glare | ||
module UxMetrics | ||
class Error < StandardError | ||
end | ||
module Sentiment | ||
class Data | ||
CHOICE_KEYS: Array[String] | ||
attr_reader choices: Hash[::String, ::String | ::Float | ::Integer] | ||
|
||
def initialize: (choices: Hash[::String, ::String | ::Float | ::Integer]) -> void | ||
|
||
def valid?: -> bool | ||
|
||
def parse: -> Result | ||
|
||
class InvalidDataError < Error | ||
def correct_data: -> String | ||
end | ||
end | ||
|
||
class Result | ||
attr_reader result: Float | ||
attr_reader label: String | ||
attr_reader threshold: String | ||
|
||
def initialize: (result: Float, label: String, threshold: String) -> void | ||
end | ||
end | ||
|
||
VERSION: String | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Glare::UxMetrics do | ||
it "does something useful" do | ||
expect(false).to eq(true) | ||
end | ||
end |
Oops, something went wrong.