roseflow-rails 0.1.0

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: 42cc9df7b6a62729e0e8655230350155b170e7d33ef585a73d255c564f3653ef
4
+ data.tar.gz: 887ac500f437c71ee1f70bbe04a9cd20cd8c12ab7007fda640a1ece3c246dac8
5
+ SHA512:
6
+ metadata.gz: 42378feadfb0506b2d682ccd338b09179297ed9796cce7bc6bc2c472a550057dddfd103df80468a704fa02c980c847a83965a3e25472ebc9e2d074f58f464a79
7
+ data.tar.gz: e370733dd03d875970fe441f21462a1b529dfeec010f9b1d1b065c5b7811b2b96957411136c7106c7e623d084d2f1f8fd6946b56e7027399a1e76c3b6e7c1610
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2023 Lauri Jutila
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Roseflow::Rails
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem "roseflow-rails"
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install roseflow-rails
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/setup"
2
+
3
+ load "rails/tasks/statistics.rake"
4
+
5
+ require "bundler/gem_tasks"
@@ -0,0 +1,6 @@
1
+ module Roseflow
2
+ module Rails
3
+ class ApplicationController < ActionController::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,16 @@
1
+ module Roseflow
2
+ module Rails
3
+ class InteractionController < ApplicationController
4
+ def initialize(interaction)
5
+ super
6
+ @interaction = interaction
7
+ end
8
+
9
+ def call
10
+ context = params[:context] || {}
11
+ result = @interaction.call(context)
12
+ render json: result
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ module Roseflow
2
+ module Rails
3
+ module ApplicationHelper
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ module Roseflow
2
+ module Rails
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ self.abstract_class = true
5
+ end
6
+ end
7
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,35 @@
1
+ Roseflow::Rails::Engine.routes.draw do
2
+ interactions.each do |interaction_name|
3
+ klass = const_get(interaction_name)
4
+
5
+ next unless klass.singleton_class.included_modules.include?(Roseflow::Interaction) &&
6
+ klass.singleton_class.included_modules.include?(Roseflow::Interaction::WithHttpApi)
7
+
8
+ controller_klass = Class.new(InteractionController) do
9
+ def initialize
10
+ super(klass)
11
+ end
12
+ end
13
+
14
+ const_set("#{interaction_name}Controller", controller_klass)
15
+ post "/interactions/#{klass.api_resource_name}", to: "#{interaction_name.underscore}#call"
16
+ end
17
+
18
+ def interaction
19
+ interaction_files.map do |file|
20
+ File.basename(file, ".rb").camelize
21
+ end
22
+ end
23
+
24
+ def interaction_files
25
+ Dir.glob("#{engine_interactions_path}/*.rb") + Dir.glob("#{rails_application_interactions_path}/*.rb")
26
+ end
27
+
28
+ def engine_interactions_path
29
+ File.expand_path("app/interactions", Roseflow::Rails::Engine.root)
30
+ end
31
+
32
+ def rails_application_interactions_path
33
+ File.expand_path("app/interactions", Rails.root)
34
+ end
35
+ end
@@ -0,0 +1,7 @@
1
+ module Roseflow
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace Roseflow::Rails
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Roseflow
2
+ module Rails
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "roseflow/rails/version"
2
+ require "roseflow/rails/engine"
3
+
4
+ module Roseflow
5
+ module Rails
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :roseflow_rails do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: roseflow-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Lauri Jutila
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-05-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 7.0.4.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 7.0.4.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: roseflow
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
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Integrates Roseflow with Ruby on Rails
56
+ email:
57
+ - git@laurijutila.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - MIT-LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - app/controllers/roseflow/rails/application_controller.rb
66
+ - app/controllers/roseflow/rails/interaction_controller.rb
67
+ - app/helpers/roseflow/rails/application_helper.rb
68
+ - app/models/roseflow/rails/application_record.rb
69
+ - config/routes.rb
70
+ - lib/roseflow/rails.rb
71
+ - lib/roseflow/rails/engine.rb
72
+ - lib/roseflow/rails/version.rb
73
+ - lib/tasks/roseflow/rails_tasks.rake
74
+ homepage: https://github.com/roseflow-ai/roseflow-rails
75
+ licenses:
76
+ - MIT
77
+ metadata:
78
+ homepage_uri: https://github.com/roseflow-ai/roseflow-rails
79
+ source_code_uri: https://github.com/roseflow-ai/roseflow-rails.git
80
+ changelog_uri: https://github.com/roseflow-ai/roseflow-rails/blob/main/CHANGELOG.md
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubygems_version: 3.4.1
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Ruby on Rails integration for Roseflow
100
+ test_files: []