aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorXinhui2017-08-25 17:13:24 +0200
committerXinhui2017-08-25 17:13:24 +0200
commit0777d35ff4460cf07c34e69ee7c10c0270a446bf (patch)
treeb2d850bbce3c8669ee6c636fa93e91c5a6a662bc /lib
parent5dda0f5286043823acab68a73d84437a3cbd803f (diff)
parent1d7db2b6c254ac55105c08ee177580036b0377f3 (diff)
downloadchouette-core-0777d35ff4460cf07c34e69ee7c10c0270a446bf.tar.bz2
Merge branch 'master' into staging
Diffstat (limited to 'lib')
-rw-r--r--lib/result.rb37
-rw-r--r--lib/tasks/ci.rake9
-rw-r--r--lib/tasks/generate.rake9
-rw-r--r--lib/tasks/imports.rake6
4 files changed, 57 insertions, 4 deletions
diff --git a/lib/result.rb b/lib/result.rb
new file mode 100644
index 000000000..96e03d323
--- /dev/null
+++ b/lib/result.rb
@@ -0,0 +1,37 @@
+# A value wrapper adding status information to any value
+# Status can be :ok or :error, we are thusly implementing
+# what is expressed in Elixir/Erlang as result tuples and
+# in Haskell as `Data.Either`
+class Result
+
+ attr_reader :status, :value
+
+ class << self
+ def ok value
+ make :ok, value
+ end
+ def error value
+ make :error, value
+ end
+
+ def new *args
+ raise NoMethodError, "No default constructor for #{self}"
+ end
+
+ private
+ def make status, value
+ allocate.tap do | o |
+ o.instance_exec do
+ @status = status
+ @value = value
+ end
+ end
+ end
+ end
+
+ def ok?; status == :ok end
+
+ def == other
+ other.kind_of?(self.class) && other.status == status && other.value == value
+ end
+end
diff --git a/lib/tasks/ci.rake b/lib/tasks/ci.rake
index 658e4e04e..90e47560e 100644
--- a/lib/tasks/ci.rake
+++ b/lib/tasks/ci.rake
@@ -3,7 +3,7 @@ namespace :ci do
task :setup do
cp "config/database/jenkins.yml", "config/database.yml"
sh "RAILS_ENV=test rake db:migrate"
- sh "npm install"
+ sh "npm --production --no-progress install"
end
def git_branch
@@ -27,11 +27,14 @@ namespace :ci do
sh "bundle exec bundle-audit check --update"
end
+ task :spec do
+ sh "bundle exec rspec --profile"
+ end
+
task :teaspoon do
sh "RAILS_ENV=test bundle exec rake teaspoon"
end
-
desc "Deploy after CI"
task :deploy do
sh "cap #{deploy_env} deploy:migrations"
@@ -44,4 +47,4 @@ namespace :ci do
end
desc "Run continuous integration tasks (spec, ...)"
-task :ci => ["ci:setup", "spec", "ci:teaspoon", "cucumber", "ci:check_security", "ci:deploy", "ci:clean"]
+task :ci => ["ci:setup", "ci:spec", "ci:teaspoon", "cucumber", "ci:check_security", "ci:deploy", "ci:clean"]
diff --git a/lib/tasks/generate.rake b/lib/tasks/generate.rake
index f02a75cc2..a9b1a3454 100644
--- a/lib/tasks/generate.rake
+++ b/lib/tasks/generate.rake
@@ -2,8 +2,15 @@ namespace :generate do
desc "Create model diagrams for Chouette"
task :model_diagram => :environment do
- sh "bundle exec rake erd only='Calendar,Referential,Chouette::Line,Chouette::Route,Chouette::JourneyPattern,Chouette::VehicleJourney,Chouette::VehicleJourneyAtStop,Chouette::TimeTable,Chouette::TimeTableDate,Chouette::TimeTablePeriod,Chouette::Footnote,Chouette::Network,Chouette::Company,Chouette::StopPoint,Chouette::StopArea' filename='offer_datas' title='Offer Datas'"
sh "bundle exec rake erd only='Organisation,Referential,User,Workbench' filename='organisation' title='Organisation'"
+ sh "bundle exec rake erd only='Calendar,Referential,Chouette::Line,Chouette::Route,Chouette::JourneyPattern,Chouette::VehicleJourney,Chouette::VehicleJourneyAtStop,Chouette::TimeTable,Chouette::TimeTableDate,Chouette::TimeTablePeriod,Chouette::Footnote,Chouette::Network,Chouette::Company,Chouette::StopPoint,Chouette::StopArea' filename='offer_datas' title='Offer Datas'"
+ sh "bundle exec rake erd only='Organisation,StopAreaReferential,StopAreaReferentialSync,StopAreaReferentialSyncMessage,StopAreaReferentialMembership,LineReferential,LineReferentialSync,LineReferentialSyncMessage,LineReferentialMembership' filename='referentiels_externes' title='Référentiels externes'"
+ sh "bundle exec rake erd only='NetexImport,Import,WorkbenchImport,ImportResource,ImportMessage' filename='import' title='Import'"
+ #sh "bundle exec rake erd only='' filename='validation' title='Validation'"
+ #sh "bundle exec rake erd only='VehicleJourney,VehicleJourneyExport' filename='export' title='Export'"
+ #sh "bundle exec rake erd only='' filename='intégration' title='Integration'"
+ #sh "bundle exec rake erd only='' filename='fusion' title='Fusion'"
+ #sh "bundle exec rake erd only='' filename='publication' title='Publication'"
end
end
diff --git a/lib/tasks/imports.rake b/lib/tasks/imports.rake
new file mode 100644
index 000000000..6bc84acc8
--- /dev/null
+++ b/lib/tasks/imports.rake
@@ -0,0 +1,6 @@
+namespace :import do
+ desc "Notify parent imports when children finish"
+ task notify_parent: :environment do
+ ParentImportNotifier.notify_when_finished
+ end
+end