abid 0.2.8 → 0.3.0.pre.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 423898158e4ca8b8c73ad5c4058c44e93943c096
4
- data.tar.gz: bd9e7a3e20e83bf28cb94f783fef3ee9dbeb7cc7
3
+ metadata.gz: 84be77dd59b4a3d27716db8501118f9df14df077
4
+ data.tar.gz: 9cfae6fa33ba3b746eeb215592fe36c824eacaec
5
5
  SHA512:
6
- metadata.gz: 62f05370ee659a08357f7a85c714f46bf61225022b46037772c4983534858107e02acf6031ddf12649b31a039dfe2b23c28c4149b5fd524512f7df8419f1ec54
7
- data.tar.gz: 9c1592632ca93929f7a2118fec95872d73259bf0d947ee3e40efd7466012b1db14d2dfdae4eace47111cdef07773854a30b17a729bc0d615bf1c25dc3ce74fbe
6
+ metadata.gz: efc5b93b010454faa05029162fb5848ec60609a95283e1120e12699dea36d0ef6ec621784cfe25fc9ec7cbdd6b559f8eb070cbca396c05c38ba32c2f2d80e084
7
+ data.tar.gz: f89f4eacf5bb56985af9ca165a41235ccbe692f0c2415b8578ccec6380acbfa8523bf4fa4ea179c502ebe0a6522f687aa7c108662df77fca71b322fc3ea9630c
data/.gitignore CHANGED
@@ -9,3 +9,7 @@
9
9
  /tmp/
10
10
  *.db
11
11
  /sample/out/
12
+
13
+ /vendor/bundle
14
+ .ruby-version
15
+ .DS_Store
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ -m markdown
data/abid.gemspec CHANGED
@@ -4,29 +4,30 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'abid/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "abid"
7
+ spec.name = 'abid'
8
8
  spec.version = Abid::VERSION
9
- spec.authors = ["Hikaru Ojima"]
10
- spec.email = ["amijo4rihaku@gmail.com"]
9
+ spec.authors = ['Hikaru Ojima']
10
+ spec.email = ['amijo4rihaku@gmail.com']
11
11
 
12
- spec.summary = "Abid is a simple Workflow Engine based on Rake."
13
- spec.description = "Abid is a simple Workflow Engine based on Rake."
14
- spec.homepage = "https://github.com/ojima-h/abid"
15
- spec.license = "MIT"
12
+ spec.summary = 'Abid is a simple Workflow Engine based on Rake.'
13
+ spec.description = 'Abid is a simple Workflow Engine based on Rake.'
14
+ spec.homepage = 'https://github.com/ojima-h/abid'
15
+ spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|sample)/}) }
18
- spec.bindir = "exe"
18
+ spec.bindir = 'exe'
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
20
+ spec.require_paths = ['lib']
21
21
 
22
- spec.add_development_dependency "bundler", "~> 1.10"
23
- spec.add_development_dependency "minitest"
24
- spec.add_development_dependency "pry-byebug"
22
+ spec.add_development_dependency 'bundler', '~> 1.10'
23
+ spec.add_development_dependency 'minitest'
24
+ spec.add_development_dependency 'pry-byebug'
25
+ spec.add_development_dependency 'yard'
25
26
 
26
- spec.add_dependency "rake", "~> 10.0"
27
- spec.add_dependency "concurrent-ruby-ext"
28
- spec.add_dependency "inifile"
29
- spec.add_dependency "sequel"
30
- spec.add_dependency "sqlite3"
31
- spec.add_dependency "rbtree"
27
+ spec.add_dependency 'rake', '~> 10.0'
28
+ spec.add_dependency 'concurrent-ruby-ext'
29
+ spec.add_dependency 'inifile'
30
+ spec.add_dependency 'sequel'
31
+ spec.add_dependency 'sqlite3'
32
+ spec.add_dependency 'rbtree'
32
33
  end
data/lib/abid.rb CHANGED
@@ -12,6 +12,8 @@ require 'rbtree'
12
12
  require 'sqlite3'
13
13
  require 'sequel'
14
14
 
15
+ require 'abid/config'
16
+ require 'abid/error'
15
17
  require 'abid/rake_extensions'
16
18
  require 'abid/version'
17
19
  require 'abid/abid_module'
@@ -11,5 +11,9 @@ module Abid
11
11
  @application = app
12
12
  Rake.application = app
13
13
  end
14
+
15
+ def config
16
+ @config ||= Config.new
17
+ end
14
18
  end
15
19
  end
@@ -3,15 +3,13 @@ module Abid
3
3
  include Abid::TaskManager
4
4
 
5
5
  attr_reader :worker
6
- attr_reader :config
7
6
 
8
7
  def initialize
9
8
  super
10
9
  @rakefiles = %w(abidfile Abidfile abidfile.rb Abidfile.rb) << abidfile
11
10
  @worker = Worker.new(self)
12
11
 
13
- @config = IniFile.new(content: default_config)
14
- @config.merge!(IniFile.load('config/abid.conf'))
12
+ Abid.config.load
15
13
  end
16
14
 
17
15
  def run
@@ -48,18 +46,6 @@ module Abid
48
46
  self[name].async_invoke(*args).wait!
49
47
  end
50
48
 
51
- def default_config
52
- {}
53
- end
54
-
55
- def default_database_config
56
- {
57
- adapter: 'sqlite',
58
- database: File.join(Dir.pwd, 'abid.db'),
59
- max_connections: 1
60
- }
61
- end
62
-
63
49
  def standard_rake_options
64
50
  super.each do |opt|
65
51
  case opt.first
@@ -78,10 +64,6 @@ module Abid
78
64
  def abid_options # :nodoc:
79
65
  sort_options(
80
66
  [
81
- ['--retry-failed-job',
82
- 'Retry failed job.',
83
- proc { options.retry_failed_job = true }
84
- ],
85
67
  ['--repair',
86
68
  'Run the task in repair mode.',
87
69
  proc { options.repair = true }
@@ -132,12 +114,12 @@ module Abid
132
114
 
133
115
  def database
134
116
  return @database if @database
135
- if config.sections.include?('abid database')
136
- cfg = config['abid database'].map { |k, v| [k.to_sym, v] }.to_h
137
- else
138
- cfg = default_database_config
139
- end
140
- @database = Sequel.connect(**cfg)
117
+
118
+ # symbolize keys
119
+ params = {}
120
+ Abid.config.database.each { |k, v| params[k.to_sym] = v }
121
+
122
+ @database = Sequel.connect(**params)
141
123
  end
142
124
  end
143
125
  end
@@ -0,0 +1,67 @@
1
+ module Abid
2
+ class Config < Hash
3
+ DEFAULT_DATABASE_CONFIG = {
4
+ 'adapter' => 'sqlite',
5
+ 'database' => './abid.db',
6
+ 'max_connections' => 1
7
+ }.freeze
8
+
9
+ # Config#load searches config file in `search_path` list.
10
+ #
11
+ # You can append an additinal config file path:
12
+ #
13
+ # Config.search_path.unshift('your_config_file')
14
+ #
15
+ # @return [Array<String>] search path
16
+ def self.search_path
17
+ @search_path ||= [
18
+ './config/abid.yml'
19
+ ]
20
+ end
21
+
22
+ # @return [Hash] database configuration
23
+ attr_reader :database
24
+
25
+ def initialize
26
+ super
27
+ @database = {}
28
+ end
29
+
30
+ # Load config file.
31
+ #
32
+ # If `config_file` is specified and does not exist, it raises an error.
33
+ #
34
+ # If `config_file` is not specified, it searches config file in
35
+ # Config.earch_path.
36
+ #
37
+ # When #load is called again, original cofnigurations is cleared.
38
+ #
39
+ # @param config_file [String] config file
40
+ # @return [Config] self
41
+ def load(config_file = nil)
42
+ replace(load_config_file(config_file))
43
+ @database = load_database_config
44
+ self
45
+ end
46
+
47
+ private
48
+
49
+ def load_config_file(file_path)
50
+ return YAML.load_file(file_path) if file_path
51
+
52
+ load_default_config_file
53
+ rescue => e
54
+ raise Error, 'failed to load config file: ' + e.message
55
+ end
56
+
57
+ def load_default_config_file
58
+ file_path = self.class.search_path.find { |path| File.exist?(path) }
59
+ return {} unless file_path
60
+ YAML.load_file(file_path)
61
+ end
62
+
63
+ def load_database_config
64
+ fetch('database') { DEFAULT_DATABASE_CONFIG.dup }
65
+ end
66
+ end
67
+ end
data/lib/abid/error.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Abid
2
+ class Error < StandardError; end
3
+ end
data/lib/abid/task.rb CHANGED
@@ -107,7 +107,7 @@ module Abid
107
107
  def concerned?
108
108
  state.reload
109
109
 
110
- if !application.options.retry_failed_job && !application.options.repair && state.failed? && !top_level?
110
+ if !application.options.repair && state.failed? && !top_level?
111
111
  fail "#{name} -- task has been failed"
112
112
  end
113
113
 
data/lib/abid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Abid
2
- VERSION = "0.2.8"
2
+ VERSION = '0.3.0-alpha.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.3.0.pre.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hikaru Ojima
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-12 00:00:00.000000000 Z
11
+ date: 2016-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -146,6 +160,7 @@ extra_rdoc_files: []
146
160
  files:
147
161
  - ".gitignore"
148
162
  - ".travis.yml"
163
+ - ".yardopts"
149
164
  - CODE_OF_CONDUCT.md
150
165
  - Gemfile
151
166
  - LICENSE.txt
@@ -159,7 +174,9 @@ files:
159
174
  - lib/abid.rb
160
175
  - lib/abid/abid_module.rb
161
176
  - lib/abid/application.rb
177
+ - lib/abid/config.rb
162
178
  - lib/abid/dsl_definition.rb
179
+ - lib/abid/error.rb
163
180
  - lib/abid/mixin_task.rb
164
181
  - lib/abid/params_parser.rb
165
182
  - lib/abid/play.rb
@@ -190,9 +207,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
190
207
  version: '0'
191
208
  required_rubygems_version: !ruby/object:Gem::Requirement
192
209
  requirements:
193
- - - ">="
210
+ - - ">"
194
211
  - !ruby/object:Gem::Version
195
- version: '0'
212
+ version: 1.3.1
196
213
  requirements: []
197
214
  rubyforge_project:
198
215
  rubygems_version: 2.4.5.1