mogura 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f6bc5aa33e336d1e5be7f39cdad45b4bce529b57318c2f54e86b11c3b6860c41
4
+ data.tar.gz: 52a22d938b4a4a15b8a3f87d991a504ae4c0bc977f6ced0760934a42faf951b3
5
+ SHA512:
6
+ metadata.gz: 36ebc243e929de22263e22274ddef440502fedc3dd6916741d4da5ad0b38108ffaa418d44cb79cf6f2e4ce1976d1850059c2f209160862ed14e432240da8d4a3
7
+ data.tar.gz: 5682cd2395b0fb2a8f392f70c7f706ccd2cc7bb292277ea86917f8a9c9a61464f75d6da5521350aab9f96858f2f0b58d0d8f7dba1cd78369b8244f1929dcfcee
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.volumes/
2
+ /.bundle/
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -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 kent.where.the.light.is@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/
data/Dockerfile ADDED
@@ -0,0 +1,44 @@
1
+ FROM ruby:3.0.3-slim AS ruby
2
+
3
+ RUN gem update bundler
4
+
5
+ FROM openjdk:11-jre-slim
6
+
7
+ COPY --from=ruby /usr/local/bin/ /usr/local/bin/
8
+ COPY --from=ruby /usr/local/lib/ /usr/local/lib/
9
+ COPY --from=ruby /usr/local/etc/ /usr/local/etc/
10
+ COPY --from=ruby /usr/local/include/ /usr/local/include/
11
+ COPY --from=ruby /usr/local/bundle /usr/local/bundle
12
+
13
+ # init
14
+ ENV LANG="C.UTF-8" \
15
+ TZ="Asia/Tokyo" \
16
+ GEM_HOME="/usr/local/bundle" \
17
+ BUNDLE_APP_CONFIG="/usr/local/bundle" \
18
+ BUNDLE_SILENCE_ROOT_WARNING="1" \
19
+ BUNDLE_GEMFILE="/usr/src/mogura/Gemfile" \
20
+ RUBYLIB="/usr/src/mogura" \
21
+ DIGDAG_VERSION="0.10.4"
22
+
23
+ ## dependencies
24
+ RUN apt-get update && apt-get install -y \
25
+ curl \
26
+ build-essential \
27
+ git \
28
+ libyaml-dev \
29
+ libssl-dev \
30
+ libreadline-dev \
31
+ default-libmysqlclient-dev \
32
+ zlib1g-dev \
33
+ jlha-utils \
34
+ && apt-get clean
35
+
36
+ # digdag
37
+ RUN curl -o /usr/local/bin/digdag --create-dirs -fL "https://dl.digdag.io/digdag-${DIGDAG_VERSION}" \
38
+ && chmod +x /usr/local/bin/digdag
39
+
40
+ WORKDIR /usr/src/mogura
41
+
42
+ ADD . .
43
+
44
+ RUN bin/setup
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in mogura.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
8
+ gem 'pry'
data/Gemfile.lock ADDED
@@ -0,0 +1,183 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mogura (0.1.0)
5
+ rails
6
+ thor
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actioncable (7.0.2.4)
12
+ actionpack (= 7.0.2.4)
13
+ activesupport (= 7.0.2.4)
14
+ nio4r (~> 2.0)
15
+ websocket-driver (>= 0.6.1)
16
+ actionmailbox (7.0.2.4)
17
+ actionpack (= 7.0.2.4)
18
+ activejob (= 7.0.2.4)
19
+ activerecord (= 7.0.2.4)
20
+ activestorage (= 7.0.2.4)
21
+ activesupport (= 7.0.2.4)
22
+ mail (>= 2.7.1)
23
+ net-imap
24
+ net-pop
25
+ net-smtp
26
+ actionmailer (7.0.2.4)
27
+ actionpack (= 7.0.2.4)
28
+ actionview (= 7.0.2.4)
29
+ activejob (= 7.0.2.4)
30
+ activesupport (= 7.0.2.4)
31
+ mail (~> 2.5, >= 2.5.4)
32
+ net-imap
33
+ net-pop
34
+ net-smtp
35
+ rails-dom-testing (~> 2.0)
36
+ actionpack (7.0.2.4)
37
+ actionview (= 7.0.2.4)
38
+ activesupport (= 7.0.2.4)
39
+ rack (~> 2.0, >= 2.2.0)
40
+ rack-test (>= 0.6.3)
41
+ rails-dom-testing (~> 2.0)
42
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
43
+ actiontext (7.0.2.4)
44
+ actionpack (= 7.0.2.4)
45
+ activerecord (= 7.0.2.4)
46
+ activestorage (= 7.0.2.4)
47
+ activesupport (= 7.0.2.4)
48
+ globalid (>= 0.6.0)
49
+ nokogiri (>= 1.8.5)
50
+ actionview (7.0.2.4)
51
+ activesupport (= 7.0.2.4)
52
+ builder (~> 3.1)
53
+ erubi (~> 1.4)
54
+ rails-dom-testing (~> 2.0)
55
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
56
+ activejob (7.0.2.4)
57
+ activesupport (= 7.0.2.4)
58
+ globalid (>= 0.3.6)
59
+ activemodel (7.0.2.4)
60
+ activesupport (= 7.0.2.4)
61
+ activerecord (7.0.2.4)
62
+ activemodel (= 7.0.2.4)
63
+ activesupport (= 7.0.2.4)
64
+ activestorage (7.0.2.4)
65
+ actionpack (= 7.0.2.4)
66
+ activejob (= 7.0.2.4)
67
+ activerecord (= 7.0.2.4)
68
+ activesupport (= 7.0.2.4)
69
+ marcel (~> 1.0)
70
+ mini_mime (>= 1.1.0)
71
+ activesupport (7.0.2.4)
72
+ concurrent-ruby (~> 1.0, >= 1.0.2)
73
+ i18n (>= 1.6, < 2)
74
+ minitest (>= 5.1)
75
+ tzinfo (~> 2.0)
76
+ builder (3.2.4)
77
+ coderay (1.1.3)
78
+ concurrent-ruby (1.1.10)
79
+ crass (1.0.6)
80
+ diff-lcs (1.5.0)
81
+ digest (3.1.0)
82
+ erubi (1.10.0)
83
+ globalid (1.0.0)
84
+ activesupport (>= 5.0)
85
+ i18n (1.10.0)
86
+ concurrent-ruby (~> 1.0)
87
+ loofah (2.17.0)
88
+ crass (~> 1.0.2)
89
+ nokogiri (>= 1.5.9)
90
+ mail (2.7.1)
91
+ mini_mime (>= 0.1.1)
92
+ marcel (1.0.2)
93
+ method_source (1.0.0)
94
+ mini_mime (1.1.2)
95
+ minitest (5.15.0)
96
+ net-imap (0.2.3)
97
+ digest
98
+ net-protocol
99
+ strscan
100
+ net-pop (0.1.1)
101
+ digest
102
+ net-protocol
103
+ timeout
104
+ net-protocol (0.1.3)
105
+ timeout
106
+ net-smtp (0.3.1)
107
+ digest
108
+ net-protocol
109
+ timeout
110
+ nio4r (2.5.8)
111
+ nokogiri (1.13.4-x86_64-darwin)
112
+ racc (~> 1.4)
113
+ nokogiri (1.13.4-x86_64-linux)
114
+ racc (~> 1.4)
115
+ pry (0.14.1)
116
+ coderay (~> 1.1)
117
+ method_source (~> 1.0)
118
+ racc (1.6.0)
119
+ rack (2.2.3)
120
+ rack-test (1.1.0)
121
+ rack (>= 1.0, < 3)
122
+ rails (7.0.2.4)
123
+ actioncable (= 7.0.2.4)
124
+ actionmailbox (= 7.0.2.4)
125
+ actionmailer (= 7.0.2.4)
126
+ actionpack (= 7.0.2.4)
127
+ actiontext (= 7.0.2.4)
128
+ actionview (= 7.0.2.4)
129
+ activejob (= 7.0.2.4)
130
+ activemodel (= 7.0.2.4)
131
+ activerecord (= 7.0.2.4)
132
+ activestorage (= 7.0.2.4)
133
+ activesupport (= 7.0.2.4)
134
+ bundler (>= 1.15.0)
135
+ railties (= 7.0.2.4)
136
+ rails-dom-testing (2.0.3)
137
+ activesupport (>= 4.2.0)
138
+ nokogiri (>= 1.6)
139
+ rails-html-sanitizer (1.4.2)
140
+ loofah (~> 2.3)
141
+ railties (7.0.2.4)
142
+ actionpack (= 7.0.2.4)
143
+ activesupport (= 7.0.2.4)
144
+ method_source
145
+ rake (>= 12.2)
146
+ thor (~> 1.0)
147
+ zeitwerk (~> 2.5)
148
+ rake (12.3.3)
149
+ rspec (3.11.0)
150
+ rspec-core (~> 3.11.0)
151
+ rspec-expectations (~> 3.11.0)
152
+ rspec-mocks (~> 3.11.0)
153
+ rspec-core (3.11.0)
154
+ rspec-support (~> 3.11.0)
155
+ rspec-expectations (3.11.0)
156
+ diff-lcs (>= 1.2.0, < 2.0)
157
+ rspec-support (~> 3.11.0)
158
+ rspec-mocks (3.11.1)
159
+ diff-lcs (>= 1.2.0, < 2.0)
160
+ rspec-support (~> 3.11.0)
161
+ rspec-support (3.11.0)
162
+ strscan (3.0.1)
163
+ thor (1.2.1)
164
+ timeout (0.2.0)
165
+ tzinfo (2.0.4)
166
+ concurrent-ruby (~> 1.0)
167
+ websocket-driver (0.7.5)
168
+ websocket-extensions (>= 0.1.0)
169
+ websocket-extensions (0.1.5)
170
+ zeitwerk (2.5.4)
171
+
172
+ PLATFORMS
173
+ x86_64-darwin-19
174
+ x86_64-linux
175
+
176
+ DEPENDENCIES
177
+ mogura!
178
+ pry
179
+ rake (~> 12.0)
180
+ rspec (~> 3.0)
181
+
182
+ BUNDLED WITH
183
+ 2.3.12
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 KentFujii
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.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # Mogura
2
+
3
+ Digdag REST API and Ruby language API bridge for Rails.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your Rails application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'mogura'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```
16
+ $ bundle install
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```
22
+ $ bundle exec mogura help
23
+ Commands:
24
+ mogura help [COMMAND] # Describe available commands or one specific command
25
+ mogura init # Initialize Digdag files
26
+ mogura push # Push Digdag workflows
27
+ mogura version # Prints version
28
+ ```
29
+
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mogura. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/mogura/blob/master/CODE_OF_CONDUCT.md).
40
+
41
+
42
+ ## License
43
+
44
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
45
+
46
+ ## Code of Conduct
47
+
48
+ Everyone interacting in the Mogura project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/mogura/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mogura"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/mogura ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require 'mogura'
5
+ require 'thor'
6
+ module Mogura
7
+ module CLI
8
+ class Runner < Thor
9
+ desc 'version', 'Prints version'
10
+ def version
11
+ say "Mogura #{Mogura::VERSION}"
12
+ end
13
+
14
+ desc 'init', 'Initialize Digdag files'
15
+ def init
16
+ Mogura::Init.init
17
+ end
18
+
19
+ desc 'push', 'Push Digdag workflows'
20
+ method_option :endpoint, aliases: '-e', type: :string, desc: 'Endpoint of Digdag'
21
+ def push
22
+ opts = options.to_h.symbolize_keys
23
+ Mogura::Push.push(**opts.freeze)
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ Mogura::CLI::Runner.start
data/bin/setup ADDED
@@ -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
data/digdag.properties ADDED
@@ -0,0 +1,23 @@
1
+ agent.max-task-threads = 5
2
+
3
+ server.bind = 0.0.0.0
4
+ server.port = 65432
5
+
6
+ database.type = postgresql
7
+ database.host = db
8
+ database.port = 5432
9
+ database.user = mogura
10
+ database.password = password
11
+ database.database = mogura
12
+ database.maximumPoolSize = 16
13
+
14
+ param_server.type = postgresql
15
+ param_server.host = db
16
+ param_server.port = 5432
17
+ param_server.user = mogura
18
+ param_server.password = password
19
+ param_server.database = mogura
20
+ param_server.maximumPoolSize = 16
21
+
22
+ log-server.type = local
23
+ log-server.local.path = /var/log/digdag
@@ -0,0 +1,23 @@
1
+ version: "3"
2
+ networks:
3
+ default:
4
+ external: true
5
+ name: katana
6
+ services:
7
+ mogura:
8
+ build:
9
+ context: .
10
+ volumes:
11
+ - .:/usr/src/mogura
12
+ command: bash -c "digdag server -c digdag.properties"
13
+ ports:
14
+ - "65432:65432"
15
+ db:
16
+ image: postgres:11.1
17
+ container_name: db
18
+ ports:
19
+ - "5432:5432"
20
+ environment:
21
+ POSTGRES_USER: mogura
22
+ POSTGRES_PASSWORD: password
23
+ POSTGRES_DB: mogura
@@ -0,0 +1,52 @@
1
+ require 'rails'
2
+
3
+ module Mogura
4
+ class Init
5
+ CONFIG_PATH = 'config/digdag'.freeze
6
+ APP_PATH = 'app/dags'.freeze
7
+
8
+ class << self
9
+ def init
10
+ require File.expand_path('config/environment') unless ENV['environment'] == 'test'
11
+ init_dig
12
+ init_dag
13
+ end
14
+
15
+ private
16
+
17
+ def init_dig
18
+ Dir.mkdir(Rails.root.join('config/digdag').to_s)
19
+ out_file = File.new(Rails.root.join("#{CONFIG_PATH}/sample.dig").to_s, "w")
20
+ out_file.puts(dig_sample_content)
21
+ out_file.close
22
+ end
23
+
24
+ def init_dag
25
+ Dir.mkdir(Rails.root.join('app/dags').to_s)
26
+ out_sample_file = File.new(Rails.root.join("#{APP_PATH}/sample_dag.rb").to_s, "w")
27
+ out_sample_file.puts(dag_sample_content)
28
+ out_sample_file.close
29
+ end
30
+
31
+ def dig_sample_content
32
+ <<~TEXT
33
+ _export:
34
+ rb:
35
+ require: #{Rails.root.join('config/environment').to_s}
36
+ +run:
37
+ rb>: SampleDag.run
38
+ TEXT
39
+ end
40
+
41
+ def dag_sample_content
42
+ <<~TEXT
43
+ class SampleDag
44
+ def run
45
+ puts "Hello Rails \#{Rails.env}"
46
+ end
47
+ end
48
+ TEXT
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,74 @@
1
+ require 'rails'
2
+ require 'rubygems'
3
+ require 'rubygems/package'
4
+ require 'zlib'
5
+ require 'fileutils'
6
+ require 'net/http'
7
+ require 'uri'
8
+
9
+ module Mogura
10
+ class Push
11
+ DEFAULT_ENDPOINT = 'http://localhost:65432'.freeze
12
+
13
+ class << self
14
+ def push(endpoint: DEFAULT_ENDPOINT)
15
+ require File.expand_path('config/environment') unless ENV['environment'] == 'test'
16
+ upload(gzip(tar(path)), endpoint, project, revision)
17
+ end
18
+
19
+ private
20
+
21
+ def path
22
+ Rails.root.join('config/digdag').to_s
23
+ end
24
+
25
+ def tar(path)
26
+ tarfile = StringIO.new("")
27
+ Gem::Package::TarWriter.new(tarfile) do |tar|
28
+ Dir[File.join(path, "**/*")].each do |file|
29
+ mode = File.stat(file).mode
30
+ relative_file = file.sub /^#{Regexp::escape path}\/?/, ''
31
+
32
+ if File.directory?(file)
33
+ tar.mkdir relative_file, mode
34
+ else
35
+ tar.add_file relative_file, mode do |tf|
36
+ File.open(file, "rb") { |f| tf.write f.read }
37
+ end
38
+ end
39
+ end
40
+ end
41
+ tarfile
42
+ end
43
+
44
+ def gzip(tarfile)
45
+ gz = StringIO.new("")
46
+ z = Zlib::GzipWriter.new(gz)
47
+ z.write tarfile.string
48
+ z.close
49
+ StringIO.new(gz.string, binmode: true)
50
+ end
51
+
52
+ def project
53
+ Rails.application.class.module_parent_name
54
+ end
55
+
56
+ def revision
57
+ SecureRandom.hex(10)
58
+ end
59
+
60
+ def upload(gzip, endpoint, project, revision)
61
+ uri = URI.parse("#{endpoint}/api/projects?project=#{project}&revision=#{revision}")
62
+ request = Net::HTTP::Put.new(uri)
63
+ request.content_type = "application/gzip"
64
+ request.body = gzip.read
65
+ req_options = {
66
+ use_ssl: uri.scheme == "https",
67
+ }
68
+ Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
69
+ http.request(request)
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,3 @@
1
+ module Mogura
2
+ VERSION = "0.1.0"
3
+ end
data/lib/mogura.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "mogura/init"
2
+ require "mogura/push"
3
+ require "mogura/version"
4
+
data/mogura.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ require_relative 'lib/mogura/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "mogura"
5
+ spec.version = Mogura::VERSION
6
+ spec.authors = ["KentFujii"]
7
+ spec.email = ["kent.where.the.light.is@gmail.com"]
8
+
9
+ spec.summary = %q{Digdag bridge for Rails}
10
+ spec.description = %q{Digdag REST API and Ruby language API bridge for Rails}
11
+ spec.homepage = "https://github.com/KentFujii/mogura"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = spec.homepage
17
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/v#{spec.version}/CHANGELOG.md"
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "bin"
25
+ spec.executables = ["mogura"]
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_dependency "rails"
29
+ spec.add_dependency 'thor'
30
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mogura
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - KentFujii
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-05-02 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
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: Digdag REST API and Ruby language API bridge for Rails
42
+ email:
43
+ - kent.where.the.light.is@gmail.com
44
+ executables:
45
+ - mogura
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - ".rspec"
51
+ - CODE_OF_CONDUCT.md
52
+ - Dockerfile
53
+ - Gemfile
54
+ - Gemfile.lock
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - bin/console
59
+ - bin/mogura
60
+ - bin/setup
61
+ - digdag.properties
62
+ - docker-compose.yml
63
+ - lib/mogura.rb
64
+ - lib/mogura/init.rb
65
+ - lib/mogura/push.rb
66
+ - lib/mogura/version.rb
67
+ - mogura.gemspec
68
+ homepage: https://github.com/KentFujii/mogura
69
+ licenses:
70
+ - MIT
71
+ metadata:
72
+ homepage_uri: https://github.com/KentFujii/mogura
73
+ source_code_uri: https://github.com/KentFujii/mogura
74
+ changelog_uri: https://github.com/KentFujii/mogura/blob/v0.1.0/CHANGELOG.md
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 2.3.0
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubygems_version: 3.2.33
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Digdag bridge for Rails
94
+ test_files: []