en14960 0.1.0 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e392aeaeca04d9c6c7648b5517675cecdd55470c983aa834e7f09cd083cedc6c
4
- data.tar.gz: 0a60d6ac76ca2bee3463215f0ec2e94c9947b1d881be4d2abdc83f70d07a1784
3
+ metadata.gz: c67498bb729209fdbcc4ef698e79f5c188a315d012a27f0daf7031c5b28ff670
4
+ data.tar.gz: f66236adac1a34aca5acd16ca8224d53d54d7395c733a959ba2331244b7aa1d0
5
5
  SHA512:
6
- metadata.gz: '0953db3f8d5c86091ff07ac92f9597299cef1ef4482d67fb877b1d3dfc08bd60e92c4fc7396827ad0946f7e4c4bcee4a28bb663d669f403af1b917c1e01b5725'
7
- data.tar.gz: 023212ec36c17575cc234413fb42812d041dc1df8a393b0e747570e0a890d352876f178a12a6b48b7e7676222eb9b0d382748605c451d3f54fe30eef6d0c24b9
6
+ metadata.gz: ab09615f5545d20fabc178f2da0699a9feea2f0631ceef4d257568415524940ecdee9fb18b83dc716daa39147fe8dfa43db2161c98893e87c39c2d21669b00a1
7
+ data.tar.gz: c55328b4ff2250ab7d330ac3672c501417e3c05444bc0a93d2262113cef3b7b5a0e598b9cf1e4667f7af5e85a550e3cc4c5a4d5d0014b074ae8d85df79d44971
data/.envrc ADDED
@@ -0,0 +1 @@
1
+ use flake
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  A Ruby gem providing calculators and validators for BS EN 14960:2019 - the British/European safety standard for inflatable play equipment.
4
4
 
5
+ - [gem install en14960](https://rubygems.org/gems/en14960)
6
+
5
7
  ## Features
6
8
 
7
9
  - **Anchor Calculations**: Calculate required ground anchors based on dimensions and wind loads
@@ -188,8 +190,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/chobbl
188
190
  ## License
189
191
 
190
192
  The gem is available as open source under the terms of the [GNU Affero General Public License v3.0](https://www.gnu.org/licenses/agpl-3.0.html).
191
-
192
- ## References
193
-
194
- - BS EN 14960:2019 - Inflatable play equipment - Safety requirements and test methods
195
- - EN 71-3 - Safety of toys - Migration of certain elements
data/flake.lock ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "nodes": {
3
+ "flake-utils": {
4
+ "inputs": {
5
+ "systems": "systems"
6
+ },
7
+ "locked": {
8
+ "lastModified": 1731533236,
9
+ "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
10
+ "owner": "numtide",
11
+ "repo": "flake-utils",
12
+ "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
13
+ "type": "github"
14
+ },
15
+ "original": {
16
+ "owner": "numtide",
17
+ "repo": "flake-utils",
18
+ "type": "github"
19
+ }
20
+ },
21
+ "nixpkgs": {
22
+ "locked": {
23
+ "lastModified": 1745526057,
24
+ "narHash": "sha256-ITSpPDwvLBZBnPRS2bUcHY3gZSwis/uTe255QgMtTLA=",
25
+ "owner": "NixOS",
26
+ "repo": "nixpkgs",
27
+ "rev": "f771eb401a46846c1aebd20552521b233dd7e18b",
28
+ "type": "github"
29
+ },
30
+ "original": {
31
+ "owner": "NixOS",
32
+ "ref": "nixos-unstable",
33
+ "repo": "nixpkgs",
34
+ "type": "github"
35
+ }
36
+ },
37
+ "root": {
38
+ "inputs": {
39
+ "flake-utils": "flake-utils",
40
+ "nixpkgs": "nixpkgs"
41
+ }
42
+ },
43
+ "systems": {
44
+ "locked": {
45
+ "lastModified": 1681028828,
46
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
47
+ "owner": "nix-systems",
48
+ "repo": "default",
49
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
50
+ "type": "github"
51
+ },
52
+ "original": {
53
+ "owner": "nix-systems",
54
+ "repo": "default",
55
+ "type": "github"
56
+ }
57
+ }
58
+ },
59
+ "root": "root",
60
+ "version": 7
61
+ }
data/flake.nix ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ description = "EN14960 gem development environment";
3
+
4
+ inputs = {
5
+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6
+ flake-utils.url = "github:numtide/flake-utils";
7
+ };
8
+
9
+ outputs =
10
+ {
11
+ self,
12
+ nixpkgs,
13
+ flake-utils,
14
+ }:
15
+ flake-utils.lib.eachDefaultSystem (
16
+ system:
17
+ let
18
+ pkgs = nixpkgs.legacyPackages.${system};
19
+ in
20
+ {
21
+ devShells.default = pkgs.mkShell {
22
+ buildInputs = with pkgs; [
23
+ ruby_3_4
24
+ ];
25
+
26
+ shellHook = ''
27
+ export GEM_HOME=$PWD/.gems
28
+ export PATH=$GEM_HOME/bin:$PATH
29
+ export PATH=$PWD/bin:$PATH
30
+
31
+ if [ ! -d ".gems" ]; then
32
+ echo "Installing gems..."
33
+ bundle install
34
+ fi
35
+
36
+ echo "Ruby $(ruby --version)"
37
+ '';
38
+ };
39
+ }
40
+ );
41
+ }
@@ -3,7 +3,7 @@
3
3
  module EN14960
4
4
  # Data class for calculator responses
5
5
  # Provides a consistent structure for all calculator results
6
- class CalculatorResponse < Struct.new(:value, :value_suffix, :breakdown, keyword_init: true)
6
+ CalculatorResponse = Data.define(:value, :value_suffix, :breakdown) do
7
7
  def initialize(value:, value_suffix: "", breakdown: [])
8
8
  super
9
9
  end
@@ -0,0 +1,129 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EN14960
4
+ module SourceCode
5
+ def self.get_method_source(method_name, module_name, additional_methods = [])
6
+ method_obj = module_name.method(method_name)
7
+ source_location = method_obj.source_location
8
+
9
+ return "Source code not available" unless source_location
10
+
11
+ file_path, line_number = source_location
12
+ return "Source file not found" unless File.exist?(file_path)
13
+
14
+ lines = File.readlines(file_path)
15
+
16
+ constants_code = ""
17
+ module_constants = get_module_constants(module_name, method_name)
18
+
19
+ if module_constants.any?
20
+ module_constants.each do |constant_name|
21
+ constant_def = extract_constant_definition(lines, constant_name)
22
+ constants_code += strip_consistent_indentation(constant_def) + "\n"
23
+ end
24
+ end
25
+
26
+ methods_code = ""
27
+
28
+ additional_methods.each do |additional_method|
29
+ if module_name.respond_to?(additional_method)
30
+ additional_obj = module_name.method(additional_method)
31
+ additional_location = additional_obj.source_location
32
+ if additional_location && additional_location[0] == file_path
33
+ additional_lines = extract_method_lines(lines, additional_location[1] - 1, additional_method)
34
+ methods_code += strip_consistent_indentation(additional_lines.join("")) + "\n\n"
35
+ end
36
+ end
37
+ end
38
+
39
+ method_lines = extract_method_lines(lines, line_number - 1, method_name)
40
+ methods_code += strip_consistent_indentation(method_lines.join(""))
41
+
42
+ output = ""
43
+ if constants_code.strip.length > 0
44
+ output += "# Related Constants:\n"
45
+ output += constants_code
46
+ output += "\n# Method Implementation:\n"
47
+ end
48
+ output += methods_code
49
+
50
+ output
51
+ end
52
+
53
+ private_class_method def self.get_module_constants(module_name, method_name)
54
+ module_name.constants.select do |const_name|
55
+ module_name.const_get(const_name).is_a?(Hash)
56
+ end
57
+ end
58
+
59
+ private_class_method def self.extract_constant_definition(lines, constant_name)
60
+ constant_lines = []
61
+ in_constant = false
62
+ brace_count = 0
63
+
64
+ lines.each_with_index do |line, index|
65
+ if line.strip.start_with?("#{constant_name} =")
66
+ in_constant = true
67
+ constant_lines << line
68
+ brace_count += line.count("{") - line.count("}")
69
+ next
70
+ end
71
+
72
+ if in_constant
73
+ constant_lines << line
74
+ brace_count += line.count("{") - line.count("}")
75
+
76
+ if brace_count <= 0 && (line.strip.end_with?(".freeze") || line.strip == "}")
77
+ break
78
+ end
79
+ end
80
+ end
81
+
82
+ constant_lines.join("")
83
+ end
84
+
85
+ private_class_method def self.extract_method_lines(lines, start_line, method_name)
86
+ method_lines = []
87
+ current_line = start_line
88
+ indent_level = nil
89
+
90
+ while current_line < lines.length
91
+ line = lines[current_line]
92
+ if line.strip.start_with?("def #{method_name}")
93
+ indent_level = line.index("def")
94
+ method_lines << line
95
+ current_line += 1
96
+ break
97
+ end
98
+ current_line += 1
99
+ end
100
+
101
+ return ["Method definition not found"] if indent_level.nil?
102
+
103
+ while current_line < lines.length
104
+ line = lines[current_line]
105
+ method_lines << line
106
+
107
+ if line.strip == "end" && (line.index(/\S/) || 0) <= indent_level
108
+ break
109
+ end
110
+
111
+ current_line += 1
112
+ end
113
+
114
+ method_lines
115
+ end
116
+
117
+ private_class_method def self.strip_consistent_indentation(source_code)
118
+ lines = source_code.split("\n")
119
+
120
+ min_indent = lines.reject(&:empty?).map { |line| line.match(/^(\s*)/)[1].length }.min || 0
121
+
122
+ lines.map { |line|
123
+ line.empty? ?
124
+ line :
125
+ line[min_indent..] || ""
126
+ }.join("\n")
127
+ end
128
+ end
129
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EN14960
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.6"
5
5
  end
data/lib/en14960.rb CHANGED
@@ -7,6 +7,7 @@ require_relative "en14960/calculators/anchor_calculator"
7
7
  require_relative "en14960/calculators/slide_calculator"
8
8
  require_relative "en14960/calculators/user_capacity_calculator"
9
9
  require_relative "en14960/validators/material_validator"
10
+ require_relative "en14960/source_code"
10
11
 
11
12
  # EN14960 provides calculators and validators for BS EN 14960:2019
12
13
  # the safety standard for inflatable play equipment
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: en14960
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chobble.com
@@ -89,20 +89,22 @@ executables: []
89
89
  extensions: []
90
90
  extra_rdoc_files: []
91
91
  files:
92
+ - ".envrc"
92
93
  - ".rspec"
93
- - ".rspec_status"
94
94
  - CHANGELOG.md
95
95
  - LICENSE
96
96
  - LICENSE.txt
97
97
  - README.md
98
98
  - Rakefile
99
- - en14960.gemspec
99
+ - flake.lock
100
+ - flake.nix
100
101
  - lib/en14960.rb
101
102
  - lib/en14960/calculators/anchor_calculator.rb
102
103
  - lib/en14960/calculators/slide_calculator.rb
103
104
  - lib/en14960/calculators/user_capacity_calculator.rb
104
105
  - lib/en14960/constants.rb
105
106
  - lib/en14960/models/calculator_response.rb
107
+ - lib/en14960/source_code.rb
106
108
  - lib/en14960/validators/material_validator.rb
107
109
  - lib/en14960/version.rb
108
110
  homepage: https://github.com/chobbledotcom/en14960
@@ -121,14 +123,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
123
  requirements:
122
124
  - - ">="
123
125
  - !ruby/object:Gem::Version
124
- version: 3.0.0
126
+ version: 3.2.0
125
127
  required_rubygems_version: !ruby/object:Gem::Requirement
126
128
  requirements:
127
129
  - - ">="
128
130
  - !ruby/object:Gem::Version
129
131
  version: '0'
130
132
  requirements: []
131
- rubygems_version: 3.4.19
133
+ rubygems_version: 3.5.22
132
134
  signing_key:
133
135
  specification_version: 4
134
136
  summary: BS EN 14960:2019 safety standard calculators for inflatable play equipment
data/.rspec_status DELETED
@@ -1,31 +0,0 @@
1
- example_id | status | run_time |
2
- ----------------------------------------------------- | ------ | --------------- |
3
- ./spec/calculators/anchor_calculator_spec.rb[1:1:1:1] | passed | 0.00004 seconds |
4
- ./spec/calculators/anchor_calculator_spec.rb[1:1:1:2] | passed | 0.00006 seconds |
5
- ./spec/calculators/anchor_calculator_spec.rb[1:1:1:3] | passed | 0.00005 seconds |
6
- ./spec/calculators/anchor_calculator_spec.rb[1:1:2:1] | passed | 0.00005 seconds |
7
- ./spec/calculators/anchor_calculator_spec.rb[1:1:2:2] | passed | 0.00004 seconds |
8
- ./spec/calculators/anchor_calculator_spec.rb[1:1:3:1] | passed | 0.001 seconds |
9
- ./spec/calculators/anchor_calculator_spec.rb[1:1:3:2] | passed | 0.00043 seconds |
10
- ./spec/calculators/anchor_calculator_spec.rb[1:1:4:1] | passed | 0.00028 seconds |
11
- ./spec/calculators/anchor_calculator_spec.rb[1:1:4:2] | passed | 0.00003 seconds |
12
- ./spec/calculators/anchor_calculator_spec.rb[1:1:4:3] | passed | 0.00002 seconds |
13
- ./spec/calculators/anchor_calculator_spec.rb[1:1:5:1] | passed | 0.00005 seconds |
14
- ./spec/calculators/anchor_calculator_spec.rb[1:1:5:2] | passed | 0.00007 seconds |
15
- ./spec/calculators/anchor_calculator_spec.rb[1:2:1:1] | passed | 0.00002 seconds |
16
- ./spec/calculators/anchor_calculator_spec.rb[1:2:1:2] | passed | 0.00003 seconds |
17
- ./spec/calculators/anchor_calculator_spec.rb[1:2:1:3] | passed | 0.00003 seconds |
18
- ./spec/calculators/anchor_calculator_spec.rb[1:2:1:4] | passed | 0.00003 seconds |
19
- ./spec/calculators/anchor_calculator_spec.rb[1:2:1:5] | passed | 0.00005 seconds |
20
- ./spec/calculators/anchor_calculator_spec.rb[1:3:1] | passed | 0.00003 seconds |
21
- ./spec/calculators/anchor_calculator_spec.rb[1:4:1] | passed | 0.00044 seconds |
22
- ./spec/en14960_spec.rb[1:1] | passed | 0.00027 seconds |
23
- ./spec/en14960_spec.rb[1:2:1:1] | passed | 0.00004 seconds |
24
- ./spec/en14960_spec.rb[1:2:2:1] | passed | 0.00022 seconds |
25
- ./spec/en14960_spec.rb[1:2:2:2] | passed | 0.00004 seconds |
26
- ./spec/en14960_spec.rb[1:2:3:1] | passed | 0.00006 seconds |
27
- ./spec/en14960_spec.rb[1:2:4:1] | passed | 0.00008 seconds |
28
- ./spec/en14960_spec.rb[1:2:4:2] | passed | 0.00005 seconds |
29
- ./spec/en14960_spec.rb[1:2:5:1] | passed | 0.00005 seconds |
30
- ./spec/en14960_spec.rb[1:2:6:1] | passed | 0.00004 seconds |
31
- ./spec/en14960_spec.rb[1:2:7:1] | passed | 0.00003 seconds |
data/en14960.gemspec DELETED
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/en14960/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "en14960"
7
- spec.version = EN14960::VERSION
8
- spec.authors = ["Chobble.com"]
9
- spec.email = ["hello@chobble.com"]
10
-
11
- spec.summary = "BS EN 14960:2019 safety standard calculators for inflatable play equipment"
12
- spec.description = "A Ruby gem providing calculators and validators for BS EN 14960:2019 - the safety standard for inflatable play equipment. Includes calculations for anchoring requirements, slide safety, user capacity, and material specifications."
13
- spec.homepage = "https://github.com/chobbledotcom/en14960"
14
- spec.license = "AGPL-3.0-or-later"
15
- spec.required_ruby_version = ">= 3.0.0"
16
-
17
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
-
19
- spec.metadata["homepage_uri"] = spec.homepage
20
- spec.metadata["source_code_uri"] = spec.homepage
21
- spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
22
-
23
- # Specify which files should be added to the gem when it is released.
24
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
- spec.files = Dir.chdir(__dir__) do
26
- `git ls-files -z`.split("\x0").reject do |f|
27
- (File.expand_path(f) == __FILE__) ||
28
- f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile]) ||
29
- f.end_with?(".gem")
30
- end
31
- end
32
- spec.bindir = "exe"
33
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
- spec.require_paths = ["lib"]
35
-
36
- # No runtime dependencies - this gem is standalone
37
-
38
- # Development dependencies
39
- spec.add_development_dependency "bundler", "~> 2.0"
40
- spec.add_development_dependency "rake", "~> 13.0"
41
- spec.add_development_dependency "rspec", "~> 3.0"
42
- spec.add_development_dependency "standard", "~> 1.0"
43
- spec.add_development_dependency "simplecov", "~> 0.21"
44
-
45
- # For more information and examples about making a new gem, check out our
46
- # guide at: https://bundler.io/guides/creating_gem.html
47
- end