penelope-core 0.0.1-java

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0bfde6e68ace01a567d038a780ec1634b9de1312
4
+ data.tar.gz: 7ca13d3aebffa77538ef7916c0461b46bc40b0ab
5
+ SHA512:
6
+ metadata.gz: 7346c0eb212c7c8c837bdeb316e196ee9d298647f5575a96e06ac6a92ef7a0ad91bb348b8335d09225ed43c205d1928d2aecfaafe5a5a7791d8659d8af2a927f
7
+ data.tar.gz: 8c10d71a80489de4aa36c328334e13e1cb26cd7be8c96eb998da9e0c0678f56fed00ff7b410e406952b35a2d31e38d7157928625673dcb310ce35fca52c9a0da
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /*.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,13 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
6
+ deploy:
7
+ provider: rubygems
8
+ api_key:
9
+ secure: j/UUXdlVT0yyn9RholJgifLWjyA8LmXSSViHTc4/vmbaOZMkY0z/V062Hy0PWgfdg1pCnx45cemgnIVu9amJ6ZKT8lXQrxcoqAQDubC66k/QB/ac8e272K2zGu8Ly9O9smnTKMcESkujOOmVuWTEzT6c/NUgv5hJlwHqYl/gTftrqbaytBiZ5QmTVZCDAsgw8OyVYdKC+BJl4BI2xbhCDtVl3SSfs5wyvJmGQrB3mWsX8bnxzL2FLeSykwUSoWTZYTrca1aR6ilyvD7nTMGh5msnD+anxWOtYYQoDxeML9kpBosFnP3LwuTQF3tjwnvPgdeeNCyj9RkvB40FHd6twAz7jw0JAYvZCZ0p301o1X4c4F/sl/yaKJOU6BuOaVT+jSwGU7iRKfIOWFTSKGe0kBGKWEFjDHK+xYWLSgSzOXcgon1yPnFx/amELg9LmS7P+l9MyP2Fe9lUm+9Pdq7T4Nyj9AsR1h5R/725oBWHqaHHAWGmnm0PgZom3zutGM4pFEqmszqwmul2xZOJ1FFq8UiRUVXGVaph+6IolLcAMxe90q3MDwski2CJj/Y21WEtknANkMgmJNPRUN3Uab+S3iIj2yQZzjEpmjyyGk86HRl8DUq4hquRukaUA1+g5Q/giAJcljuUXUrrcmgvSa7aUzgz7kJYtO1c6zJuIxZsYD0=
10
+ gem: penelope-core
11
+ on:
12
+ tags: true
13
+ repo: jgnagy/penelope-core
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in penelope-core.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Jonathan Gnagy
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.
@@ -0,0 +1,41 @@
1
+ # Penelope::Core
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/penelope/core`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'penelope-core'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install penelope-core
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/penelope-core.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+ require 'yard'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ RuboCop::RakeTask.new(:rubocop)
8
+ YARD::Rake::YardocTask.new
9
+
10
+ task default: [:spec, :rubocop, :yard]
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "penelope/core"
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
@@ -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
@@ -0,0 +1,57 @@
1
+ # Standard Library Requirements
2
+ require 'fileutils'
3
+
4
+ # External Requirements
5
+ require 'dm-core'
6
+ require 'dm-validations'
7
+ require 'dm-timestamps'
8
+ require 'dm-migrations'
9
+ require 'dm-serializer'
10
+ require 'dm-types'
11
+ require 'dm-transactions'
12
+ require 'rjgit'
13
+ require 'resque'
14
+
15
+ require 'jdbc/mysql'
16
+ Jdbc::MySQL.load_driver
17
+
18
+ module Penelope
19
+ # The core Penelope queued job module
20
+ module Core
21
+ CONFIG = {
22
+ data: {
23
+ directory: File.expand_path(
24
+ ENV['PENELOPE_DATA_DIR'] ? ENV['PENELOPE_DATA_DIR'] : File.join('~', '.penelope', 'data')
25
+ )
26
+ },
27
+ debug: false,
28
+ db: {
29
+ adapter: 'mysql',
30
+ pool: ENV['PENELOPE_DB_POOL_SIZE'] ? ENV['PENELOPE_DB_POOL_SIZE'] : 5,
31
+ host: ENV['PENELOPE_DB_HOST'] ? ENV['PENELOPE_DB_HOST'] : 'localhost',
32
+ database: ENV['PENELOPE_DB_NAME'] ? ENV['PENELOPE_DB_NAME'] : 'penelopedb'
33
+ }
34
+ }
35
+ CONFIG[:db][:username] = ENV['PENELOPE_DB_USER'] if ENV['PENELOPE_DB_USER']
36
+ CONFIG[:db][:password] = ENV['PENELOPE_DB_PASSWORD'] if ENV['PENELOPE_DB_PASSWORD']
37
+ CONFIG[:debug] = true if ENV['PENELOPE_DEBUG'] == 'true'
38
+ end
39
+ end
40
+
41
+ # Internal Requirements
42
+ require "penelope/core/version"
43
+ require 'penelope/core/job_report'
44
+ require "penelope/core/job"
45
+ require "penelope/core/git_job"
46
+ require "penelope/core/run"
47
+
48
+ # Setup the data store
49
+ puts '>> Connecting to DB'
50
+ DataMapper::Logger.new(STDOUT, :debug) if Penelope::Core::CONFIG[:debug]
51
+ adapter = DataMapper.setup(:default, Penelope::Core::CONFIG[:db])
52
+ adapter.resource_naming_convention =
53
+ DataMapper::NamingConventions::Resource::UnderscoredAndPluralizedWithoutModule
54
+
55
+ # Finish the data store setup
56
+ DataMapper.finalize
57
+ DataMapper.auto_upgrade!
@@ -0,0 +1,9 @@
1
+ module Penelope
2
+ module Core
3
+ class GitJob < Job
4
+ def retrieve
5
+ RJGit::RubyGit.clone uri, working_directory
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,80 @@
1
+ module Penelope
2
+ module Core
3
+ class Job
4
+ include DataMapper::Resource
5
+
6
+ property :id, Serial
7
+ property :type, Discriminator, required: true, index: true
8
+ property :uri, String, required: true
9
+ property :entry_point, String, required: true
10
+ property :submitted_by, String, required: true, index: true
11
+
12
+ property :created_at, DateTime, index: true
13
+
14
+ has 1, :job_report
15
+
16
+ def cleanup
17
+ # TODO archive working directory
18
+ FileUtils.rm_rf working_directory
19
+ end
20
+
21
+ def perform
22
+ @start_time = Time.now
23
+ begin
24
+ prepare
25
+ retrieve
26
+ run
27
+ rescue Exception => e
28
+ @exceptions ||= []
29
+ @exceptions << e.message
30
+ end
31
+ @end_time = Time.now
32
+ report
33
+ cleanup
34
+ end
35
+
36
+ def prepare
37
+ FileUtils.mkdir_p working_directory
38
+ end
39
+
40
+ def retrieve
41
+ raise 'Not Implemented'
42
+ end
43
+
44
+ def run
45
+ @exceptions = nil
46
+ # TODO wrap in Docker container
47
+ begin
48
+ FileUtils.cd(working_directory) do
49
+ @result = IO.popen(entry_point).read
50
+ end
51
+ @exit_status = $?.exitstatus
52
+ @pid = $?.pid
53
+ rescue Exception => e
54
+ @exit_status ||= -1
55
+ @pid ||= -1
56
+ @exceptions ||= []
57
+ @exceptions << e.message
58
+ end
59
+ @ran = true
60
+ end
61
+
62
+ def report
63
+ jr = JobReport.new(
64
+ pid: @pid,
65
+ exit_status: @exit_status,
66
+ start_time: @start_time,
67
+ end_time: @end_time,
68
+ result: @result,
69
+ job_id: id
70
+ )
71
+ jr.exceptions = @exceptions.to_yaml if @exceptions
72
+ jr.save
73
+ end
74
+
75
+ def working_directory
76
+ File.join(CONFIG[:data][:directory], self.class.name, id.to_s)
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,18 @@
1
+ module Penelope
2
+ module Core
3
+ class JobReport
4
+ include DataMapper::Resource
5
+
6
+ property :id, Serial
7
+
8
+ belongs_to :job
9
+
10
+ property :exit_status, Integer, index: true
11
+ property :pid, Integer
12
+ property :start_time, DateTime, index: true
13
+ property :end_time, DateTime, index: true
14
+ property :result, Text, required: true
15
+ property :exceptions, Text
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ module Penelope
2
+ module Core
3
+ module Run
4
+ @queue = :job_run
5
+
6
+ def self.perform(id)
7
+ job = Core::Job.get(id)
8
+ job.perform
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ module Penelope
2
+ module Core
3
+ VERSION = [
4
+ 0, # Major
5
+ 0, # Minor
6
+ 1 # Patch
7
+ ].join('.')
8
+ end
9
+ end
@@ -0,0 +1,41 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'penelope/core/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "penelope-core"
8
+ spec.version = Penelope::Core::VERSION
9
+ spec.authors = ["Jonathan Gnagy"]
10
+ spec.email = ["jonathan.gnagy@gmail.com"]
11
+
12
+ spec.summary = %q{Penelope Core library}
13
+ spec.homepage = 'https://github.com/jgnagy/penelope-core'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.metadata['yard.run'] = 'yri'
24
+ spec.platform = %q{java}
25
+ spec.required_ruby_version = '~> 2.0'
26
+
27
+ spec.add_runtime_dependency 'data_mapper', '~> 1.2'
28
+ spec.add_runtime_dependency "dm-mysql-adapter", '~> 1.2'
29
+ spec.add_runtime_dependency 'do_jdbc', '~> 0.10'
30
+ spec.add_runtime_dependency 'jdbc-mysql', '~> 5.1'
31
+ spec.add_runtime_dependency 'rjgit', '~> 4.2'
32
+ spec.add_runtime_dependency 'resque', '~> 1.26'
33
+
34
+ spec.add_development_dependency "bundler", "~> 1.12"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "rspec", "~> 3.1"
37
+ spec.add_development_dependency 'rubocop', '~> 0.35'
38
+ spec.add_development_dependency 'yard', '~> 0.8'
39
+ spec.add_development_dependency 'travis', '~> 1.8'
40
+ spec.add_development_dependency 'simplecov'
41
+ end
metadata ADDED
@@ -0,0 +1,243 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: penelope-core
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: java
6
+ authors:
7
+ - Jonathan Gnagy
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-01-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: data_mapper
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dm-mysql-adapter
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: do_jdbc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.10'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jdbc-mysql
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rjgit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.2'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: resque
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.26'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.26'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.12'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.12'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '10.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '10.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.1'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.1'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.35'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.35'
153
+ - !ruby/object:Gem::Dependency
154
+ name: yard
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.8'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.8'
167
+ - !ruby/object:Gem::Dependency
168
+ name: travis
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '1.8'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '1.8'
181
+ - !ruby/object:Gem::Dependency
182
+ name: simplecov
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ description:
196
+ email:
197
+ - jonathan.gnagy@gmail.com
198
+ executables: []
199
+ extensions: []
200
+ extra_rdoc_files: []
201
+ files:
202
+ - ".gitignore"
203
+ - ".rspec"
204
+ - ".travis.yml"
205
+ - Gemfile
206
+ - LICENSE
207
+ - README.md
208
+ - Rakefile
209
+ - bin/console
210
+ - bin/setup
211
+ - lib/penelope/core.rb
212
+ - lib/penelope/core/git_job.rb
213
+ - lib/penelope/core/job.rb
214
+ - lib/penelope/core/job_report.rb
215
+ - lib/penelope/core/run.rb
216
+ - lib/penelope/core/version.rb
217
+ - penelope-core.gemspec
218
+ homepage: https://github.com/jgnagy/penelope-core
219
+ licenses:
220
+ - MIT
221
+ metadata:
222
+ yard.run: yri
223
+ post_install_message:
224
+ rdoc_options: []
225
+ require_paths:
226
+ - lib
227
+ required_ruby_version: !ruby/object:Gem::Requirement
228
+ requirements:
229
+ - - "~>"
230
+ - !ruby/object:Gem::Version
231
+ version: '2.0'
232
+ required_rubygems_version: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ requirements: []
238
+ rubyforge_project:
239
+ rubygems_version: 2.5.1
240
+ signing_key:
241
+ specification_version: 4
242
+ summary: Penelope Core library
243
+ test_files: []