orb_def 0.0.1

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.
Files changed (113) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +79 -0
  3. data/.gitignore +14 -0
  4. data/.rakeTasks +7 -0
  5. data/.rspec +1 -0
  6. data/Gemfile +15 -0
  7. data/Gemfile.lock +207 -0
  8. data/MIT-LICENSE +20 -0
  9. data/README.md +30 -0
  10. data/Rakefile +23 -0
  11. data/app/assets/config/orb_def_manifest.js +2 -0
  12. data/app/assets/javascripts/orb_def/application.js +15 -0
  13. data/app/assets/stylesheets/orb_def/application.css +15 -0
  14. data/app/controllers/orb_def/api/v1/fires_controller.rb +64 -0
  15. data/app/controllers/orb_def/api/v1/weather_readings_controller.rb +16 -0
  16. data/app/controllers/orb_def/application_controller.rb +5 -0
  17. data/app/helpers/orb_def/application_helper.rb +4 -0
  18. data/app/jobs/orb_def/application_job.rb +4 -0
  19. data/app/mailers/orb_def/application_mailer.rb +6 -0
  20. data/app/models/orb_def/application_record.rb +5 -0
  21. data/app/models/orb_def/detection_type.rb +7 -0
  22. data/app/models/orb_def/fire.rb +60 -0
  23. data/app/models/orb_def/weather_reading.rb +41 -0
  24. data/app/models/orb_def/weather_station.rb +33 -0
  25. data/app/serializers/orb_def/api/v1/fire_serializer.rb +17 -0
  26. data/app/services/orb_def/fire_weather_data.rb +36 -0
  27. data/app/services/orb_def/nasa/firms_client.rb +38 -0
  28. data/app/services/orb_def/nasa/firms_import.rb +44 -0
  29. data/app/services/orb_def/open_weather_api/weather_by_coordinates.rb +31 -0
  30. data/app/views/layouts/orb_def/application.html.erb +16 -0
  31. data/bin/rails +25 -0
  32. data/config/routes.rb +13 -0
  33. data/db/migrate/20200422073925_create_orb_def_weather_stations.rb +12 -0
  34. data/db/migrate/20200422073938_create_orb_def_weather_readings.rb +20 -0
  35. data/db/migrate/20200423064313_create_orb_def_detection_types.rb +9 -0
  36. data/db/migrate/20200428063630_create_orb_def_fires.rb +28 -0
  37. data/db/seeds.rb +8 -0
  38. data/lib/orb_def/engine.rb +16 -0
  39. data/lib/orb_def/version.rb +3 -0
  40. data/lib/orb_def.rb +16 -0
  41. data/lib/tasks/orb_def_tasks.rake +4 -0
  42. data/orb_def.gemspec +38 -0
  43. data/spec/controllers/orb_def/api/v1/fires_controller_spec.rb +16 -0
  44. data/spec/dummy/Rakefile +6 -0
  45. data/spec/dummy/app/assets/config/manifest.js +4 -0
  46. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  47. data/spec/dummy/app/assets/javascripts/cable.js +13 -0
  48. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  49. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  50. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  51. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  52. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  53. data/spec/dummy/app/jobs/application_job.rb +2 -0
  54. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  55. data/spec/dummy/app/models/application_record.rb +3 -0
  56. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  57. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  58. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  59. data/spec/dummy/bin/bundle +3 -0
  60. data/spec/dummy/bin/rails +4 -0
  61. data/spec/dummy/bin/rake +4 -0
  62. data/spec/dummy/bin/setup +36 -0
  63. data/spec/dummy/bin/update +31 -0
  64. data/spec/dummy/bin/yarn +11 -0
  65. data/spec/dummy/config/application.rb +30 -0
  66. data/spec/dummy/config/boot.rb +5 -0
  67. data/spec/dummy/config/cable.yml +10 -0
  68. data/spec/dummy/config/database.yml +21 -0
  69. data/spec/dummy/config/environment.rb +5 -0
  70. data/spec/dummy/config/environments/development.rb +61 -0
  71. data/spec/dummy/config/environments/production.rb +94 -0
  72. data/spec/dummy/config/environments/test.rb +46 -0
  73. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  74. data/spec/dummy/config/initializers/assets.rb +14 -0
  75. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  76. data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
  77. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  78. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  79. data/spec/dummy/config/initializers/inflections.rb +16 -0
  80. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  81. data/spec/dummy/config/initializers/orb_def.rb +4 -0
  82. data/spec/dummy/config/initializers/pagy.rb +170 -0
  83. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  84. data/spec/dummy/config/locales/en.yml +33 -0
  85. data/spec/dummy/config/orb_def/spring.rb +1 -0
  86. data/spec/dummy/config/puma.rb +37 -0
  87. data/spec/dummy/config/routes.rb +3 -0
  88. data/spec/dummy/config/spring.rb +6 -0
  89. data/spec/dummy/config/storage.yml +34 -0
  90. data/spec/dummy/config.ru +5 -0
  91. data/spec/dummy/db/schema.rb +87 -0
  92. data/spec/dummy/package.json +5 -0
  93. data/spec/dummy/public/404.html +67 -0
  94. data/spec/dummy/public/422.html +67 -0
  95. data/spec/dummy/public/500.html +66 -0
  96. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  97. data/spec/dummy/public/apple-touch-icon.png +0 -0
  98. data/spec/dummy/public/favicon.ico +0 -0
  99. data/spec/factories/detection_type.rb +5 -0
  100. data/spec/fixtures/files/modis_c6.txt +3 -0
  101. data/spec/fixtures/nasa/firms/viirs.txt +3 -0
  102. data/spec/rails_helper.rb +72 -0
  103. data/spec/services/orbital_defence_engine/nasa/firms_import_spec.rb +27 -0
  104. data/spec/services/orbital_defence_engine/open_weather_api/weather_by_coordinates_spec.rb +16 -0
  105. data/spec/spec/vcr/cassettes/OrbitalDefenceEngine_Nasa_FirmsImport/_all/when_request_successful/creates_fires.yml +77 -0
  106. data/spec/spec/vcr/cassettes/OrbitalDefenceEngine_OpenWeatherApi_WeatherByCoordinates/_fetch_weather_by_coordinates/returns_json_data_as_a_hash.yml +41 -0
  107. data/spec/spec_helper.rb +96 -0
  108. data/spec/support/factory_bot.rb +3 -0
  109. data/spec/support/vcr.rb +9 -0
  110. data/spec/vcr/cassettes/OpenWeatherApi_WeatherByCoordinates/_fetch_weather_by_coordinates/returns_json_data_as_a_hash.yml +41 -0
  111. data/spec/vcr/cassettes/OrbDef_Nasa_FirmsImport/_all/when_request_successful/creates_fires.yml +4766 -0
  112. data/spec/vcr/cassettes/OrbDef_OpenWeatherApi_WeatherByCoordinates/_fetch_weather_by_coordinates/returns_json_data_as_a_hash.yml +41 -0
  113. metadata +438 -0
@@ -0,0 +1,37 @@
1
+ # Puma can serve each request in a thread from an internal thread pool.
2
+ # The `threads` method setting takes two numbers: a minimum and maximum.
3
+ # Any libraries that use thread pools should be configured to match
4
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
+ # and maximum; this matches the default thread size of Active Record.
6
+ #
7
+ threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8
+ threads threads_count, threads_count
9
+
10
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
11
+ #
12
+ port ENV.fetch("PORT") { 3000 }
13
+
14
+ # Specifies the `environment` that Puma will run in.
15
+ #
16
+ environment ENV.fetch("RAILS_ENV") { "development" }
17
+
18
+ # Specifies the `pidfile` that Puma will use.
19
+ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
20
+
21
+ # Specifies the number of `workers` to boot in clustered mode.
22
+ # Workers are forked webserver processes. If using threads and workers together
23
+ # the concurrency of the application would be max `threads` * `workers`.
24
+ # Workers do not work on JRuby or Windows (both of which do not support
25
+ # processes).
26
+ #
27
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
28
+
29
+ # Use the `preload_app!` method when specifying a `workers` number.
30
+ # This directive tells Puma to first boot the application and load code
31
+ # before forking the application. This takes advantage of Copy On Write
32
+ # process behavior so workers use less memory.
33
+ #
34
+ # preload_app!
35
+
36
+ # Allow puma to be restarted by `rails restart` command.
37
+ plugin :tmp_restart
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ mount OrbDef::Engine => "/orb_def"
3
+ end
@@ -0,0 +1,6 @@
1
+ %w[
2
+ .ruby-version
3
+ .rbenv-vars
4
+ tmp/restart.txt
5
+ tmp/caching-dev.txt
6
+ ].each { |path| Spring.watch(path) }
@@ -0,0 +1,34 @@
1
+ test:
2
+ service: Disk
3
+ root: <%= Rails.root.join("tmp/storage") %>
4
+
5
+ local:
6
+ service: Disk
7
+ root: <%= Rails.root.join("storage") %>
8
+
9
+ # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10
+ # amazon:
11
+ # service: S3
12
+ # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13
+ # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14
+ # region: us-east-1
15
+ # bucket: your_own_bucket
16
+
17
+ # Remember not to checkin your GCS keyfile to a repository
18
+ # google:
19
+ # service: GCS
20
+ # project: your_project
21
+ # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
22
+ # bucket: your_own_bucket
23
+
24
+ # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25
+ # microsoft:
26
+ # service: AzureStorage
27
+ # storage_account_name: your_account_name
28
+ # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29
+ # container: your_container_name
30
+
31
+ # mirror:
32
+ # service: Mirror
33
+ # primary: local
34
+ # mirrors: [ amazon, google, microsoft ]
@@ -0,0 +1,5 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require_relative 'config/environment'
4
+
5
+ run Rails.application
@@ -0,0 +1,87 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(version: 2020_04_28_063630) do
14
+
15
+ # These are extensions that must be enabled in order to support this database
16
+ enable_extension "plpgsql"
17
+
18
+ create_table "orb_def_detection_types", force: :cascade do |t|
19
+ t.string "name"
20
+ t.datetime "created_at", null: false
21
+ t.datetime "updated_at", null: false
22
+ end
23
+
24
+ create_table "orb_def_fires", force: :cascade do |t|
25
+ t.bigint "weather_station_id"
26
+ t.bigint "detected_at_weather_reading_id"
27
+ t.bigint "detection_type_id"
28
+ t.float "latitude"
29
+ t.float "longitude"
30
+ t.float "brightness"
31
+ t.float "bright_t31"
32
+ t.float "bright_ti5"
33
+ t.float "bright_ti4"
34
+ t.float "scan"
35
+ t.float "track"
36
+ t.float "frp"
37
+ t.integer "distance"
38
+ t.string "scan_type"
39
+ t.string "identifier"
40
+ t.string "lat_long"
41
+ t.string "satellite"
42
+ t.string "confidence"
43
+ t.string "version"
44
+ t.string "day_night"
45
+ t.datetime "detected_at"
46
+ t.datetime "created_at", null: false
47
+ t.datetime "updated_at", null: false
48
+ t.index ["detected_at"], name: "index_orb_def_fires_on_detected_at"
49
+ t.index ["detected_at_weather_reading_id"], name: "index_orb_def_fires_on_detected_at_weather_reading_id"
50
+ t.index ["detection_type_id"], name: "index_orb_def_fires_on_detection_type_id"
51
+ t.index ["identifier"], name: "index_orb_def_fires_on_identifier"
52
+ t.index ["lat_long"], name: "index_orb_def_fires_on_lat_long"
53
+ t.index ["latitude"], name: "index_orb_def_fires_on_latitude"
54
+ t.index ["longitude"], name: "index_orb_def_fires_on_longitude"
55
+ t.index ["weather_station_id"], name: "index_orb_def_fires_on_weather_station_id"
56
+ end
57
+
58
+ create_table "orb_def_weather_readings", force: :cascade do |t|
59
+ t.bigint "weather_station_id"
60
+ t.string "identifier"
61
+ t.float "temperature"
62
+ t.float "pressure"
63
+ t.float "ground_level"
64
+ t.integer "humidity"
65
+ t.float "wind_speed"
66
+ t.float "wind_direction"
67
+ t.float "rain"
68
+ t.integer "cloud"
69
+ t.string "description"
70
+ t.datetime "reading_at"
71
+ t.datetime "created_at", null: false
72
+ t.datetime "updated_at", null: false
73
+ t.index ["identifier"], name: "index_orb_def_weather_readings_on_identifier"
74
+ t.index ["weather_station_id"], name: "index_orb_def_weather_readings_on_weather_station_id"
75
+ end
76
+
77
+ create_table "orb_def_weather_stations", force: :cascade do |t|
78
+ t.string "name"
79
+ t.float "latitude"
80
+ t.float "longitude"
81
+ t.string "identifier"
82
+ t.datetime "created_at", null: false
83
+ t.datetime "updated_at", null: false
84
+ t.index ["identifier"], name: "index_orb_def_weather_stations_on_identifier"
85
+ end
86
+
87
+ end
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "dummy",
3
+ "private": true,
4
+ "dependencies": {}
5
+ }
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ FactoryBot.define do
2
+ factory :detection_type, class: OrbDef::DetectionType do
3
+ name { "Satellite" }
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ latitude,longitude,brightness,scan,track,acq_date,acq_time,satellite,confidence,version,bright_t31,frp,daynight
2
+ -12.875,142.334,309.8,1.5,1.2,2020-01-22,01:05,T,17,6.0NRT,284.4,9.2,D
3
+ -12.878,142.327,310.4,1.5,1.2,2020-01-22,01:05,T,44,6.0NRT,283.9,11.4,D
@@ -0,0 +1,3 @@
1
+ latitude,longitude,bright_ti4,scan,track,acq_date,acq_time,satellite,confidence,version,bright_ti5,frp,daynight
2
+ -39.78852,175.59128,347,0.43,0.38,2020-01-21,01:54,N,nominal,1.0NRT,307.4,6.1,D
3
+ -39.78751,175.59363,367,0.43,0.38,2020-01-21,01:54,N,high,1.0NRT,308.6,10,D
@@ -0,0 +1,72 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ require 'spec_helper'
3
+ ENV['RAILS_ENV'] ||= 'test'
4
+
5
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
6
+
7
+ # Prevent database truncation if the environment is production
8
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
9
+ ENGINE_ROOT = File.join(File.dirname(__FILE__), '../')
10
+
11
+ require 'rspec/rails'
12
+ require 'factory_bot_rails'
13
+ require 'support/factory_bot'
14
+ require 'timecop'
15
+ require 'vcr'
16
+ require 'support/vcr'
17
+
18
+ FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
19
+ # FactoryBot.find_definitions
20
+ # Add additional requires below this line. Rails is not loaded until this point!
21
+ # Requires supporting ruby files with custom matchers and macros, etc, in
22
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
23
+ # run as spec files by default. This means that files in spec/support that end
24
+ # in _spec.rb will both be required and run as specs, causing the specs to be
25
+ # run twice. It is recommended that you do not name files matching this glob to
26
+ # end with _spec.rb. You can configure this pattern with the --pattern
27
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
28
+ #
29
+ # The following line is provided for convenience purposes. It has the downside
30
+ # of increasing the boot-up time by auto-requiring all files in the support
31
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
32
+ # require only the support files necessary.
33
+ #
34
+ # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
35
+
36
+ # Checks for pending migrations and applies them before tests are run.
37
+ # If you are not using ActiveRecord, you can remove these lines.
38
+ begin
39
+ ActiveRecord::Migration.maintain_test_schema!
40
+ rescue ActiveRecord::PendingMigrationError => e
41
+ puts e.to_s.strip
42
+ exit 1
43
+ end
44
+ RSpec.configure do |config|
45
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
46
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
47
+
48
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
49
+ # examples within a transaction, remove the following line or assign false
50
+ # instead of true.
51
+ config.use_transactional_fixtures = true
52
+
53
+ # RSpec Rails can automatically mix in different behaviours to your tests
54
+ # based on their file location, for example enabling you to call `get` and
55
+ # `post` in specs under `spec/controllers`.
56
+ #
57
+ # You can disable this behaviour by removing the line below, and instead
58
+ # explicitly tag your specs with their type, e.g.:
59
+ #
60
+ # RSpec.describe UsersController, :type => :controller do
61
+ # # ...
62
+ # end
63
+ #
64
+ # The different available types are documented in the features, such as in
65
+ # https://relishapp.com/rspec/rspec-rails/docs
66
+ config.infer_spec_type_from_file_location!
67
+
68
+ # Filter lines from Rails gems in backtraces.
69
+ config.filter_rails_from_backtrace!
70
+ # arbitrary gems may also be filtered via:
71
+ # config.filter_gems_from_backtrace("gem name")
72
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_helper'
4
+
5
+ RSpec.describe OrbDef::Nasa::FirmsImport, type: :service do
6
+
7
+ describe ".all" do
8
+ context 'when request successful' do
9
+ let(:vcr_time) { "2020-01-22 07:56:44 +0000".to_time }
10
+
11
+ it 'creates fires', :vcr do
12
+ create(:detection_type)
13
+ Timecop.freeze(vcr_time) do
14
+ expect{ OrbDef::Nasa::FirmsImport.all }.to change{ OrbDef::Fire.count }.by(3)
15
+ end
16
+ end
17
+ end
18
+
19
+ #context 'when request fails', :vcr do
20
+ # it 'logs an error' do
21
+ # expect(Rails.logger).to receive(:info).with('Nasa::FirmsImport#all - Failed to fetch')
22
+ #
23
+ # Nasa::FirmsImport.all
24
+ # end
25
+ #end
26
+ end
27
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_helper'
4
+
5
+ RSpec.describe OrbDef::OpenWeatherApi::WeatherByCoordinates, type: :service do
6
+
7
+ context '#fetch_weather_by_coordinates', :vcr do
8
+ let(:latitude) { '1' }
9
+ let(:longitude) { '1' }
10
+ let(:station_data) { OrbDef::OpenWeatherApi::WeatherByCoordinates.fetch(latitude: latitude, longitude: longitude) }
11
+
12
+ it 'returns json data as a hash' do
13
+ expect(station_data).to be_a(Hash)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,77 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://nrt4.modaps.eosdis.nasa.gov/api/v2/content/archives/FIRMS/c6/Global/MODIS_C6_Global_MCD14DL_NRT_2020022.txt
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.4
12
+ Authorization:
13
+ - Bearer <NASA_API_KEY>
14
+ response:
15
+ status:
16
+ code: 404
17
+ message: Not Found
18
+ headers:
19
+ server:
20
+ - openresty
21
+ date:
22
+ - Tue, 28 Apr 2020 07:07:59 GMT
23
+ content-type:
24
+ - text/html;charset=UTF-8
25
+ content-length:
26
+ - '9'
27
+ connection:
28
+ - close
29
+ x-frame-options:
30
+ - SAMEORIGIN
31
+ access-control-allow-credentials:
32
+ - 'true'
33
+ strict-transport-security:
34
+ - max-age=31536000; includeSubDomains
35
+ body:
36
+ encoding: UTF-8
37
+ string: Not Found
38
+ http_version: null
39
+ recorded_at: Wed, 22 Jan 2020 07:56:44 GMT
40
+ - request:
41
+ method: get
42
+ uri: https://nrt4.modaps.eosdis.nasa.gov/api/v2/content/archives/FIRMS/viirs/Global/VIIRS_I_Global_VNP14IMGTDL_NRT_2020022.txt
43
+ body:
44
+ encoding: US-ASCII
45
+ string: ''
46
+ headers:
47
+ User-Agent:
48
+ - Faraday v0.15.4
49
+ Authorization:
50
+ - Bearer <NASA_API_KEY>
51
+ response:
52
+ status:
53
+ code: 404
54
+ message: Not Found
55
+ headers:
56
+ server:
57
+ - openresty
58
+ date:
59
+ - Tue, 28 Apr 2020 07:08:00 GMT
60
+ content-type:
61
+ - text/html;charset=UTF-8
62
+ content-length:
63
+ - '9'
64
+ connection:
65
+ - close
66
+ access-control-allow-credentials:
67
+ - 'true'
68
+ x-frame-options:
69
+ - SAMEORIGIN
70
+ strict-transport-security:
71
+ - max-age=31536000; includeSubDomains
72
+ body:
73
+ encoding: UTF-8
74
+ string: Not Found
75
+ http_version: null
76
+ recorded_at: Wed, 22 Jan 2020 07:56:44 GMT
77
+ recorded_with: VCR 5.1.0
@@ -0,0 +1,41 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.openweathermap.org/data/2.5/weather?appid=<OPEN_WEATHER_API_KEY>&lat=1&lon=1
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.4
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ server:
18
+ - openresty
19
+ date:
20
+ - Tue, 28 Apr 2020 07:08:00 GMT
21
+ content-type:
22
+ - application/json; charset=utf-8
23
+ content-length:
24
+ - '440'
25
+ connection:
26
+ - close
27
+ x-cache-key:
28
+ - "/data/2.5/weather?lat=1&lon=1"
29
+ access-control-allow-origin:
30
+ - "*"
31
+ access-control-allow-credentials:
32
+ - 'true'
33
+ access-control-allow-methods:
34
+ - GET, POST
35
+ body:
36
+ encoding: UTF-8
37
+ string: '{"coord":{"lon":1,"lat":1},"weather":[{"id":500,"main":"Rain","description":"light
38
+ rain","icon":"10d"}],"base":"stations","main":{"temp":301.6,"feels_like":305.52,"temp_min":301.6,"temp_max":301.6,"pressure":1013,"humidity":71,"sea_level":1013,"grnd_level":1013},"wind":{"speed":1.63,"deg":254},"rain":{"1h":0.81},"clouds":{"all":100},"dt":1588057680,"sys":{"sunrise":1588052932,"sunset":1588096666},"timezone":0,"id":0,"name":"","cod":200}'
39
+ http_version: null
40
+ recorded_at: Tue, 28 Apr 2020 07:08:00 GMT
41
+ recorded_with: VCR 5.1.0