fedux_org-stdlib 0.0.4 → 0.0.5
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.
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'active_support/core_ext/string/inflections'
|
2
|
+
require 'active_support/core_ext/object/blank'
|
2
3
|
require 'fedux_org/stdlib/models/filesystem_based_model'
|
3
4
|
|
4
5
|
module FeduxOrg
|
@@ -44,6 +45,8 @@ module FeduxOrg
|
|
44
45
|
def load_from_filesystem
|
45
46
|
files = Dir.glob( path_to_instances )
|
46
47
|
|
48
|
+
raise FeduxOrg::Stdlib::Models::Exceptions::NoImplementationsForModelFound, "You might need to store files at \"#{File.dirname(path_to_instances)}\" to make the library work." if files.blank?
|
49
|
+
|
47
50
|
files.each do |f|
|
48
51
|
instance_name = name( f )
|
49
52
|
|
@@ -23,6 +23,9 @@ module FeduxOrg
|
|
23
23
|
#raised if one tries to use an unimplemented exception
|
24
24
|
class ExceptionNeedsToBeImplemented < InternalError; end
|
25
25
|
|
26
|
+
#raised if one forgot to store files at `path_to_instances`
|
27
|
+
class NoImplementationsForModelFound < InternalError; end
|
28
|
+
|
26
29
|
#raised if an file system error occured
|
27
30
|
class FilesystemError < Exception ; end
|
28
31
|
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
unless ENV['TRAVIS_CI'] == 'true'
|
4
|
+
namespace :gem do
|
5
|
+
require 'bundler/gem_tasks'
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'yard'
|
9
|
+
require 'rubygems/package_task'
|
10
|
+
require 'active_support/core_ext/string/strip'
|
11
|
+
require 'erubis'
|
12
|
+
end
|
13
|
+
|
14
|
+
YARD::Rake::YardocTask.new() do |y|
|
15
|
+
# y.options << '--verbose'
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
desc 'start tmux'
|
20
|
+
task :terminal do
|
21
|
+
sh "script/terminal"
|
22
|
+
end
|
23
|
+
|
24
|
+
task :term => :terminal
|
25
|
+
task :t => :terminal
|
26
|
+
|
27
|
+
namespace :version do
|
28
|
+
version_file = Dir.glob('lib/**/version.rb').first
|
29
|
+
|
30
|
+
desc 'bump version of library to new version'
|
31
|
+
task :bump do
|
32
|
+
|
33
|
+
new_version = ENV['VERSION'] || ENV['version']
|
34
|
+
|
35
|
+
raw_module_names = File.open(version_file, "r").readlines.grep(/module/)
|
36
|
+
module_names = raw_module_names.collect { |n| n.chomp.match(/module\s+(\S+)/) {$1} }
|
37
|
+
|
38
|
+
template = <<-EOF
|
39
|
+
#main <%= @modules.first %>
|
40
|
+
<% @modules.each do |m| %>
|
41
|
+
module <%= m %>
|
42
|
+
<% end %>
|
43
|
+
VERSION = '<%= @version %>'
|
44
|
+
<% @modules.size.times do |m| %>
|
45
|
+
end
|
46
|
+
<% end %>
|
47
|
+
EOF
|
48
|
+
|
49
|
+
version_string = Erubis::Eruby.new(template).evaluate(modules: module_names, version: new_version)
|
50
|
+
|
51
|
+
File.open(version_file, "w") do |f|
|
52
|
+
f.write version_string.strip_heredoc
|
53
|
+
end
|
54
|
+
|
55
|
+
sh "git add #{version_file}"
|
56
|
+
sh "git commit -m 'version bump to #{new_version}'"
|
57
|
+
#project = 'the_array_comparator'
|
58
|
+
#sh "git tag #{project}-v#{new_version}"
|
59
|
+
end
|
60
|
+
|
61
|
+
desc 'show version of library'
|
62
|
+
task :show do
|
63
|
+
raw_version = File.open(version_file, "r").readlines.grep(/VERSION/).first
|
64
|
+
|
65
|
+
if raw_version
|
66
|
+
version = raw_version.chomp.match(/VERSION\s+=\s+["']([^'"]+)["']/) { $1 }
|
67
|
+
puts version
|
68
|
+
else
|
69
|
+
warn "Could not parse version file \"#{version_file}\""
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
desc 'Restore version file from git repository'
|
75
|
+
task :restore do
|
76
|
+
sh "git checkout #{version_file}"
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
namespace :travis do
|
82
|
+
desc 'Runs travis-lint to check .travis.yml'
|
83
|
+
task :check do
|
84
|
+
sh 'travis-lint'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
namespace :test do
|
89
|
+
desc 'Run specs'
|
90
|
+
task :specs do
|
91
|
+
sh 'bundle exec rspec spec'
|
92
|
+
end
|
93
|
+
|
94
|
+
desc 'Run tests in "travis mode"'
|
95
|
+
task :travis_specs do
|
96
|
+
ENV['TRAVIS_CI'] = 'true'
|
97
|
+
sh 'rspec spec'
|
98
|
+
sh 'cucumber -p all'
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
task :console do
|
103
|
+
sh 'script/console'
|
104
|
+
end
|
@@ -240,4 +240,26 @@ describe Models::ClassBasedModel do
|
|
240
240
|
}.to raise_error FeduxOrg::Stdlib::Models::Exceptions::UnauthorizedUseOfKeyword
|
241
241
|
end
|
242
242
|
|
243
|
+
it "raises an exception if no valid algorithms could be found for model" do
|
244
|
+
klass = Class.new(FeduxOrg::Stdlib::Models::BaseModel) do
|
245
|
+
include FeduxOrg::Stdlib::Models::FilesystemBasedModel
|
246
|
+
include FeduxOrg::Stdlib::Models::ClassBasedModel
|
247
|
+
|
248
|
+
def self.module_name
|
249
|
+
'ProjectXY'
|
250
|
+
end
|
251
|
+
|
252
|
+
def self.model_name
|
253
|
+
'Internal'
|
254
|
+
end
|
255
|
+
|
256
|
+
def self.path
|
257
|
+
'asdfasf'
|
258
|
+
end
|
259
|
+
end
|
260
|
+
expect {
|
261
|
+
klass.send(:load_from_filesystem)
|
262
|
+
}.to raise_error FeduxOrg::Stdlib::Models::Exceptions::NoImplementationsForModelFound
|
263
|
+
end
|
264
|
+
|
243
265
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fedux_org-stdlib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/fedux_org/stdlib/models/class_based_model.rb
|
90
90
|
- lib/fedux_org/stdlib/models/exceptions.rb
|
91
91
|
- lib/fedux_org/stdlib/models/filesystem_based_model.rb
|
92
|
+
- lib/fedux_org/stdlib/rake/library.rake
|
92
93
|
- lib/fedux_org/stdlib/version.rb
|
93
94
|
- script/console
|
94
95
|
- script/terminal
|