harpiya_extension 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 79ba0177324a0aa08a83290988e33143beca88b85d6578b8ab9446683e7e3871
4
+ data.tar.gz: eb310a9f86615ac1e8af1d2ba8899d33abb071d24f3fc399ff15a3c62b325d1e
5
+ SHA512:
6
+ metadata.gz: ef483ed10df85be01932702a1875b04a0d685c48971bc0884be04d045182636e02501dac23a8daecf8dad0eab2e8e38c9dd2a0ff6cae3169911f1690eab7b064
7
+ data.tar.gz: ed8986c63d99cb27fb492e879d34b5333ab1b4dcad5964cf523bc8bb9980501e12d8ecb24237612286dd0cbf28ed1bb523a49d344acf38bafd48183f854ce00d
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ Gemfile.lock
46
+ .ruby-version
47
+ .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Datasource local storage ignored files
5
+ /dataSources/
6
+ /dataSources.local.xml
7
+ # Editor-based HTTP Client requests
8
+ /httpRequests/
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$">
8
+ <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
+ </content>
12
+ <orderEntry type="inheritedJdk" />
13
+ <orderEntry type="sourceFolder" forTests="false" />
14
+ <orderEntry type="library" scope="PROVIDED" name="activemodel (v6.1.4, ruby-2.6.3-p62) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="activerecord (v6.1.4, ruby-2.6.3-p62) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="activesupport (v6.1.4, ruby-2.6.3-p62) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.3, ruby-2.6.3-p62) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.9, ruby-2.6.3-p62) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="i18n (v1.8.10, ruby-2.6.3-p62) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.14.4, ruby-2.6.3-p62) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.4, ruby-2.6.3-p62) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.4.2, ruby-2.6.3-p62) [gem]" level="application" />
23
+ </component>
24
+ </module>
data/.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="ruby-2.6.3-p62" project-jdk-type="RUBY_SDK" />
4
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/harpiya_extension.iml" filepath="$PROJECT_DIR$/.idea/harpiya_extension.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
data/Gemfile ADDED
@@ -0,0 +1 @@
1
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2017-2019 Spark Solutions Sp. z o.o.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Harpiya nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,18 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'harpiya_extension'
3
+ s.version = '0.0.9'
4
+ s.summary = 'Common tools and helpers for Harpiya Extensions developers'
5
+ s.description = 'Common tools and helpers for Harpiya Extensions developers'
6
+ s.authors = ['Harpiya Software Technologies']
7
+ s.email = 'info@harpiya.com'
8
+ s.homepage = 'https://harpiya.com'
9
+ s.license = 'BSD-3'
10
+
11
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
12
+ f.match(%r{^(test|spec|features)/})
13
+ end
14
+ s.require_paths = ['lib']
15
+
16
+ s.add_dependency 'activerecord', '>= 4.2'
17
+ s.add_dependency 'harpiya_core'
18
+ end
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,3 @@
1
+ require 'harpiya_extension/migration'
2
+ require 'harpiya_extension/service_module'
3
+ require 'harpiya_extension/components_checker'
@@ -0,0 +1,25 @@
1
+ module HarpiyaExtension
2
+ module ComponentsChecker
3
+ def self.included(base)
4
+ base.extend(ClassMethods)
5
+ end
6
+
7
+ module ClassMethods
8
+ def api_available?
9
+ @@api_available ||= engines_classes.include?('Harpiya::Api::Engine')
10
+ end
11
+
12
+ def backend_available?
13
+ @@backend_available ||= engines_classes.include?('Harpiya::Backend::Engine')
14
+ end
15
+
16
+ def frontend_available?
17
+ @@frontend_available ||= engines_classes.include?('Harpiya::Frontend::Engine')
18
+ end
19
+
20
+ def engines_classes
21
+ ::Rails::Engine.subclasses.map(&:instance).map { |e| e.class.to_s }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,13 @@
1
+ module HarpiyaExtension
2
+ module Migration
3
+ def self.[](version)
4
+ # Rails 5.1 requires to use versioned migrations
5
+ # but < 5.0 doesn't support them
6
+ if Rails.gem_version >= Gem::Version.new('5.x')
7
+ ActiveRecord::Migration[version]
8
+ else
9
+ ActiveRecord::Migration
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,103 @@
1
+ # This is a backported ServiceModule introduced in Harpiya 3.7
2
+ # Older versions of Harpiya don't have this feature
3
+ # see: https://github.com/harpiya/harpiya/blob/master/core/lib/harpiya/service_module.rb
4
+ unless defined?(Harpiya::ServiceModule)
5
+ module Harpiya
6
+ module ServiceModule
7
+ module Callable
8
+ def call(*args)
9
+ new.call(*args).tap do |result|
10
+ return yield(result) if block_given?
11
+ end
12
+ end
13
+ end
14
+
15
+ class MethodNotImplemented < StandardError; end
16
+ class WrongDataPassed < StandardError; end
17
+ class NonCallablePassedToRun < StandardError; end
18
+ class IncompatibleParamsPassed < StandardError; end
19
+
20
+ Result = Struct.new(:success, :value, :error) do
21
+ def success?
22
+ success
23
+ end
24
+
25
+ def failure?
26
+ !success
27
+ end
28
+ end
29
+
30
+ ResultError = Struct.new(:value) do
31
+ def to_s
32
+ return value.full_messages.join(', ') if value && value.respond_to?(:full_messages)
33
+
34
+ value.to_s
35
+ end
36
+
37
+ def to_h
38
+ return value.messages if value && value.respond_to?(:messages)
39
+
40
+ {}
41
+ end
42
+ end
43
+
44
+ module Base
45
+ def self.prepended(base)
46
+ class << base
47
+ prepend Callable
48
+ end
49
+ end
50
+
51
+ def call(input = nil)
52
+ input ||= {}
53
+ @_passed_input = Result.new(true, input)
54
+ result = super
55
+ @_passed_input = result if result.is_a? Result
56
+ enforce_data_format
57
+ @_passed_input
58
+ end
59
+
60
+ private
61
+
62
+ def run(callable)
63
+ return unless @_passed_input.success?
64
+
65
+ if callable.instance_of? Symbol
66
+ unless respond_to?(callable, true)
67
+ raise MethodNotImplemented, "You didn't implement #{callable} method. Implement it before calling this class"
68
+ end
69
+
70
+ callable = method(callable)
71
+ end
72
+
73
+ unless callable.respond_to?(:call)
74
+ raise NonCallablePassedToRun, 'You can pass only symbol with method name or instance of callable class to run method'
75
+ end
76
+
77
+ begin
78
+ @_passed_input = callable.call(@_passed_input.value)
79
+ rescue ArgumentError => e
80
+ if e.message.include? 'missing'
81
+ raise IncompatibleParamsPassed, "You didn't pass #{e.message} to callable '#{callable.name}'"
82
+ else
83
+ raise IncompatibleParamsPassed, "You passed #{e.message} to callable '#{callable.name}'"
84
+ end
85
+ end
86
+ end
87
+
88
+ def success(value)
89
+ Result.new(true, value, nil)
90
+ end
91
+
92
+ def failure(value, error = nil)
93
+ error = value.errors if error.nil? && value.respond_to?(:errors)
94
+ Result.new(false, value, ResultError.new(error))
95
+ end
96
+
97
+ def enforce_data_format
98
+ raise WrongDataPassed, "You didn't use `success` or `failure` method to return value from method." unless @_passed_input.instance_of? Result
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: harpiya_extension
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.9
5
+ platform: ruby
6
+ authors:
7
+ - Harpiya Software Technologies
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-07-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: harpiya_core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Common tools and helpers for Harpiya Extensions developers
42
+ email: info@harpiya.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - ".DS_Store"
48
+ - ".gitignore"
49
+ - ".idea/.gitignore"
50
+ - ".idea/harpiya_extension.iml"
51
+ - ".idea/misc.xml"
52
+ - ".idea/modules.xml"
53
+ - ".idea/vcs.xml"
54
+ - Gemfile
55
+ - LICENSE.md
56
+ - harpiya_extension.gemspec
57
+ - lib/.DS_Store
58
+ - lib/harpiya_extension.rb
59
+ - lib/harpiya_extension/components_checker.rb
60
+ - lib/harpiya_extension/migration.rb
61
+ - lib/harpiya_extension/service_module.rb
62
+ homepage: https://harpiya.com
63
+ licenses:
64
+ - BSD-3
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubygems_version: 3.2.3
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Common tools and helpers for Harpiya Extensions developers
85
+ test_files: []