built_in_data 1.1.4 → 1.2.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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +58 -0
  4. data/Rakefile +3 -8
  5. data/lib/built_in_data/version.rb +3 -1
  6. data/lib/built_in_data.rb +24 -20
  7. metadata +11 -100
  8. data/README.rdoc +0 -53
  9. data/test/built_in_data_test.rb +0 -104
  10. data/test/dummy/README.rdoc +0 -28
  11. data/test/dummy/Rakefile +0 -6
  12. data/test/dummy/app/assets/config/manifest.js +0 -4
  13. data/test/dummy/app/assets/javascripts/application.js +0 -13
  14. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  15. data/test/dummy/app/controllers/application_controller.rb +0 -5
  16. data/test/dummy/app/helpers/application_helper.rb +0 -2
  17. data/test/dummy/app/models/national_park.rb +0 -3
  18. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  19. data/test/dummy/bin/bundle +0 -3
  20. data/test/dummy/bin/rails +0 -4
  21. data/test/dummy/bin/rake +0 -4
  22. data/test/dummy/config/application.rb +0 -22
  23. data/test/dummy/config/boot.rb +0 -5
  24. data/test/dummy/config/database.yml +0 -25
  25. data/test/dummy/config/environment.rb +0 -5
  26. data/test/dummy/config/environments/development.rb +0 -37
  27. data/test/dummy/config/environments/production.rb +0 -78
  28. data/test/dummy/config/environments/test.rb +0 -42
  29. data/test/dummy/config/initializers/assets.rb +0 -8
  30. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  31. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  32. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  33. data/test/dummy/config/initializers/inflections.rb +0 -16
  34. data/test/dummy/config/initializers/mime_types.rb +0 -4
  35. data/test/dummy/config/initializers/session_store.rb +0 -3
  36. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  37. data/test/dummy/config/locales/en.yml +0 -23
  38. data/test/dummy/config/routes.rb +0 -56
  39. data/test/dummy/config/secrets.yml +0 -22
  40. data/test/dummy/config.ru +0 -4
  41. data/test/dummy/db/built_in_data/national_parks.yml +0 -13
  42. data/test/dummy/db/migrate/20121024195810_create_national_parks.rb +0 -11
  43. data/test/dummy/db/migrate/20121024201818_add_built_in_key_to_national_parks.rb +0 -5
  44. data/test/dummy/db/migrate/20121101224000_add_protected_attribute_column_to_national_parks.rb +0 -5
  45. data/test/dummy/db/migrate/20141111224715_remove_protected_attribute_column_from_national_parks.rb +0 -5
  46. data/test/dummy/db/migrate/20141113214328_add_active_to_national_parks.rb +0 -5
  47. data/test/dummy/db/schema.rb +0 -26
  48. data/test/dummy/db/test.sqlite3 +0 -0
  49. data/test/dummy/log/test.log +0 -3533
  50. data/test/dummy/public/404.html +0 -67
  51. data/test/dummy/public/422.html +0 -67
  52. data/test/dummy/public/500.html +0 -66
  53. data/test/dummy/public/favicon.ico +0 -0
  54. data/test/test_helper.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9394bd2479dccf207f906c6ca48653287a621c5d6522306b770e556fce552d56
4
- data.tar.gz: 9e1d7d9e4ef5706036452492f31bdd1061b79d8fc048c8cd891a1c68bb9f1793
3
+ metadata.gz: 1dcb3fbcceaeff5cb4d43a1bc0c08edb3b375324ad4797c1ffcf24923913f0cd
4
+ data.tar.gz: 2b2195a4b426b877bb80cfb36c51e4244e05540ed71e8cb853c9eb0175373cde
5
5
  SHA512:
6
- metadata.gz: 638ce6c855a13e1254ff71a0e3fe5888d7c4c8996d70277e58ea2636f470dabde48922bca6aa60c6459487d0604329a4f8d9d49c266732c2dcd192281f49e874
7
- data.tar.gz: 6d737a730d0b4a63b7393babcb4de49fdff07e0b1a556bd07d436769c97d3d8c6bf05ee9befea440798a580ad19a2f291f32f9c05529cae747b6e65ed972006a
6
+ metadata.gz: 8252552d62e0f142c16f51465205ff986e11f5f30d23c4af1db7d45359e36b90a32814d66d277fdb29cb982fadaee65e6a2419352a97c19c3c5b1efde5a59e8c
7
+ data.tar.gz: 973e5ec125c4e846c63ec464de0e3a3824491f5704d478d2dedab136ba269a4b8e0a0e00d387ceaf548c812fb75dacc631e239f44d2e431a0163e7c4db0d6638
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2012-2013 WorldWide IDEA, Inc http://www.wwidea.org
1
+ Copyright 2012-2023 Brightways Learning https://www.brightwayslearning.org
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # BuiltInData
2
+
3
+ [![Maintainability](https://api.codeclimate.com/v1/badges/02eb42a4a53414adae01/maintainability)](https://codeclimate.com/github/wwidea/built_in_data/maintainability)
4
+
5
+ BuiltInData is a simple tool for loading and updating data in a Rails application.
6
+
7
+ Objects are stored in the database with a **built_in_key** that is used on subsequent loads to update or remove the object. Items in the table without a **built_in_key** will not be modified or removed.
8
+
9
+ BuiltInData is designed to address the data gray area between customer data and constants. It allows developers to deliver, update, and destroy data that is stored in the database.
10
+
11
+ ## Setup
12
+ Add **built_in_key** to your model:
13
+ ```bash
14
+ ruby script/rails generate migration AddBuiltInKeyToYourModel built_in_key:string:index
15
+ rake db:migrate
16
+ ```
17
+
18
+ Include **BuiltInData** in your model:
19
+ ```ruby
20
+ class YourModel < ActiveRecord::Base
21
+ include BuiltInData
22
+ end
23
+ ```
24
+
25
+ ## Loading Data
26
+ There are two methods to load data
27
+
28
+ - Pass as a hash to load_built_in_data!
29
+ ```ruby
30
+ YourModel.load_built_in_data!({
31
+ glacier: {
32
+ name: 'Glacier National Park'
33
+ },
34
+ yellowstone: {
35
+ name: 'Yellowstone National Park'
36
+ }
37
+ })
38
+ ```
39
+
40
+ - Create a yaml load file in **db/built_in_data** with the name of the model (ie. national_parks.yml), and load the data with `YourModel.load_built_in_data!` without any arguments. The yaml file can contain erb.
41
+ ```yaml
42
+ glacier:
43
+ name: Glacier National Park
44
+ established: <%= Date.parse('1910-05-11') %>
45
+
46
+ yellowstone:
47
+ name: Yellowstone National Park
48
+ established: 1872-03-01
49
+ ```
50
+
51
+ ## Other
52
+ Use **built_in?** to check if an object was loaded by BuiltInData:
53
+ ```ruby
54
+ object.built_in?
55
+ ```
56
+
57
+ ## License
58
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,10 +1,5 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
1
+ # frozen_string_literal: true
3
2
 
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
8
- end
3
+ require "bundler/setup"
9
4
 
10
- task default: :test
5
+ require "bundler/gem_tasks"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BuiltInData
2
- VERSION = "1.1.4"
4
+ VERSION = "1.2.1"
3
5
  end
data/lib/built_in_data.rb CHANGED
@@ -1,30 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "built_in_data/version"
4
+
1
5
  module BuiltInData
2
6
  extend ActiveSupport::Concern
3
7
 
4
8
  included do
5
- # all built in data objects should have a built_in_key, model objects without a key will not be modified or removed
9
+ # All built in data objects should have a built_in_key, model objects without a key will not be modified or removed
6
10
  validates_uniqueness_of :built_in_key, allow_nil: true, case_sensitive: false
7
11
 
8
- scope :built_in, -> { where "#{table_name}.built_in_key IS NOT NULL" }
12
+ scope :built_in, -> { where.not(built_in_key: nil) }
9
13
  end
10
14
 
11
15
  module ClassMethods
16
+ # Inserts new, updates existing, and destorys removed built_in objects
12
17
  def load_built_in_data!(hash = nil)
13
18
  objects_hash = prepare_objects_hash(hash)
14
- Array.new.tap do |updated_objects|
15
-
16
- objects_hash.each do |key, attributes|
17
- updated_objects << create_or_update!(key, attributes)
18
- end
19
+ destroy_removed_built_in_objects!(objects_hash.keys)
19
20
 
20
- # destroy any built_in objects that have been removed from built_in_data_attributes
21
- self.built_in.each do |object|
22
- object.destroy unless objects_hash.has_key?(object.built_in_key)
23
- end
21
+ objects_hash.map do |key, attributes|
22
+ create_or_update!(key, attributes)
24
23
  end
25
24
  end
26
25
 
27
- # cached database id for fixture files
26
+ # Cached database id for fixture files
28
27
  def built_in_object_id(key)
29
28
  built_in_object_ids[key]
30
29
  end
@@ -37,20 +36,25 @@ module BuiltInData
37
36
  private
38
37
 
39
38
  def prepare_objects_hash(hash)
40
- return hash.nil? ? load_yaml_data : hash.with_indifferent_access
39
+ hash.nil? ? load_yaml_data : hash.with_indifferent_access
41
40
  end
42
41
 
43
42
  def load_yaml_data
44
43
  # allow a standard key to be used for defaults in YAML files
45
44
  YAML.safe_load(
46
45
  read_and_erb_process_yaml_file,
47
- permitted_classes: [Date],
48
- aliases: true
49
- ).except('DEFAULTS')
46
+ permitted_classes: [Date],
47
+ aliases: true
48
+ ).except("DEFAULTS")
50
49
  end
51
50
 
52
51
  def read_and_erb_process_yaml_file
53
- ERB.new(File.read(Rails.root.join('db', 'built_in_data', "#{table_name}.yml"))).result
52
+ ERB.new(Rails.root.join("db", "built_in_data", "#{table_name}.yml").read).result
53
+ end
54
+
55
+ # Destroys built_in objects with a built_in_key not present in built_in_keys array
56
+ def destroy_removed_built_in_objects!(built_in_keys)
57
+ built_in.where.not(built_in_key: built_in_keys).destroy_all
54
58
  end
55
59
 
56
60
  def create_or_update!(key, attributes)
@@ -60,15 +64,15 @@ module BuiltInData
60
64
  end
61
65
  end
62
66
 
63
- # memoized hash of built in object ids
67
+ # Memoized hash of built in object ids
64
68
  def built_in_object_ids
65
69
  @built_in_object_ids ||= Hash.new do |hash, key|
66
- hash[key] = where(built_in_key: key).pluck(:id).first
70
+ hash[key] = where(built_in_key: key).pick(:id)
67
71
  end
68
72
  end
69
73
  end
70
74
 
71
75
  def built_in?
72
- !built_in_key.blank?
76
+ built_in_key.present?
73
77
  end
74
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: built_in_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Baldwin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-02-07 00:00:00.000000000 Z
12
+ date: 2023-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -28,66 +28,23 @@ dependencies:
28
28
  description: BuiltInData is a simple tool for loading and updating data in a Rails
29
29
  application.
30
30
  email:
31
- - developers@brightwayslearning.org
31
+ - baldwina@brightwayslearning.org
32
32
  executables: []
33
33
  extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
36
  - MIT-LICENSE
37
- - README.rdoc
37
+ - README.md
38
38
  - Rakefile
39
39
  - lib/built_in_data.rb
40
40
  - lib/built_in_data/version.rb
41
- - test/built_in_data_test.rb
42
- - test/dummy/README.rdoc
43
- - test/dummy/Rakefile
44
- - test/dummy/app/assets/config/manifest.js
45
- - test/dummy/app/assets/javascripts/application.js
46
- - test/dummy/app/assets/stylesheets/application.css
47
- - test/dummy/app/controllers/application_controller.rb
48
- - test/dummy/app/helpers/application_helper.rb
49
- - test/dummy/app/models/national_park.rb
50
- - test/dummy/app/views/layouts/application.html.erb
51
- - test/dummy/bin/bundle
52
- - test/dummy/bin/rails
53
- - test/dummy/bin/rake
54
- - test/dummy/config.ru
55
- - test/dummy/config/application.rb
56
- - test/dummy/config/boot.rb
57
- - test/dummy/config/database.yml
58
- - test/dummy/config/environment.rb
59
- - test/dummy/config/environments/development.rb
60
- - test/dummy/config/environments/production.rb
61
- - test/dummy/config/environments/test.rb
62
- - test/dummy/config/initializers/assets.rb
63
- - test/dummy/config/initializers/backtrace_silencers.rb
64
- - test/dummy/config/initializers/cookies_serializer.rb
65
- - test/dummy/config/initializers/filter_parameter_logging.rb
66
- - test/dummy/config/initializers/inflections.rb
67
- - test/dummy/config/initializers/mime_types.rb
68
- - test/dummy/config/initializers/session_store.rb
69
- - test/dummy/config/initializers/wrap_parameters.rb
70
- - test/dummy/config/locales/en.yml
71
- - test/dummy/config/routes.rb
72
- - test/dummy/config/secrets.yml
73
- - test/dummy/db/built_in_data/national_parks.yml
74
- - test/dummy/db/migrate/20121024195810_create_national_parks.rb
75
- - test/dummy/db/migrate/20121024201818_add_built_in_key_to_national_parks.rb
76
- - test/dummy/db/migrate/20121101224000_add_protected_attribute_column_to_national_parks.rb
77
- - test/dummy/db/migrate/20141111224715_remove_protected_attribute_column_from_national_parks.rb
78
- - test/dummy/db/migrate/20141113214328_add_active_to_national_parks.rb
79
- - test/dummy/db/schema.rb
80
- - test/dummy/db/test.sqlite3
81
- - test/dummy/log/test.log
82
- - test/dummy/public/404.html
83
- - test/dummy/public/422.html
84
- - test/dummy/public/500.html
85
- - test/dummy/public/favicon.ico
86
- - test/test_helper.rb
87
41
  homepage: https://github.com/wwidea/built_in_data
88
42
  licenses:
89
43
  - MIT
90
- metadata: {}
44
+ metadata:
45
+ homepage_uri: https://github.com/wwidea/built_in_data
46
+ source_code_uri: https://github.com/wwidea/built_in_data
47
+ rubygems_mfa_required: 'true'
91
48
  post_install_message:
92
49
  rdoc_options: []
93
50
  require_paths:
@@ -96,61 +53,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
53
  requirements:
97
54
  - - ">="
98
55
  - !ruby/object:Gem::Version
99
- version: '0'
56
+ version: 2.7.0
100
57
  required_rubygems_version: !ruby/object:Gem::Requirement
101
58
  requirements:
102
59
  - - ">="
103
60
  - !ruby/object:Gem::Version
104
61
  version: '0'
105
62
  requirements: []
106
- rubygems_version: 3.3.6
63
+ rubygems_version: 3.4.5
107
64
  signing_key:
108
65
  specification_version: 4
109
66
  summary: Data management for Rails models.
110
- test_files:
111
- - test/dummy/app/models/national_park.rb
112
- - test/dummy/app/controllers/application_controller.rb
113
- - test/dummy/app/views/layouts/application.html.erb
114
- - test/dummy/app/assets/config/manifest.js
115
- - test/dummy/app/assets/javascripts/application.js
116
- - test/dummy/app/assets/stylesheets/application.css
117
- - test/dummy/app/helpers/application_helper.rb
118
- - test/dummy/bin/rake
119
- - test/dummy/bin/bundle
120
- - test/dummy/bin/rails
121
- - test/dummy/config/secrets.yml
122
- - test/dummy/config/routes.rb
123
- - test/dummy/config/locales/en.yml
124
- - test/dummy/config/environments/production.rb
125
- - test/dummy/config/environments/development.rb
126
- - test/dummy/config/environments/test.rb
127
- - test/dummy/config/environment.rb
128
- - test/dummy/config/application.rb
129
- - test/dummy/config/database.yml
130
- - test/dummy/config/boot.rb
131
- - test/dummy/config/initializers/backtrace_silencers.rb
132
- - test/dummy/config/initializers/mime_types.rb
133
- - test/dummy/config/initializers/filter_parameter_logging.rb
134
- - test/dummy/config/initializers/session_store.rb
135
- - test/dummy/config/initializers/wrap_parameters.rb
136
- - test/dummy/config/initializers/assets.rb
137
- - test/dummy/config/initializers/cookies_serializer.rb
138
- - test/dummy/config/initializers/inflections.rb
139
- - test/dummy/config.ru
140
- - test/dummy/Rakefile
141
- - test/dummy/public/favicon.ico
142
- - test/dummy/public/422.html
143
- - test/dummy/public/500.html
144
- - test/dummy/public/404.html
145
- - test/dummy/db/schema.rb
146
- - test/dummy/db/test.sqlite3
147
- - test/dummy/db/built_in_data/national_parks.yml
148
- - test/dummy/db/migrate/20121101224000_add_protected_attribute_column_to_national_parks.rb
149
- - test/dummy/db/migrate/20121024195810_create_national_parks.rb
150
- - test/dummy/db/migrate/20121024201818_add_built_in_key_to_national_parks.rb
151
- - test/dummy/db/migrate/20141111224715_remove_protected_attribute_column_from_national_parks.rb
152
- - test/dummy/db/migrate/20141113214328_add_active_to_national_parks.rb
153
- - test/dummy/log/test.log
154
- - test/dummy/README.rdoc
155
- - test/built_in_data_test.rb
156
- - test/test_helper.rb
67
+ test_files: []
data/README.rdoc DELETED
@@ -1,53 +0,0 @@
1
- =BuiltInData
2
-
3
- {<img src="https://codeclimate.com/github/wwidea/built_in_data/badges/gpa.svg" />}[https://codeclimate.com/github/wwidea/built_in_data]
4
-
5
- BuiltInData is a simple tool for loading and updating data in a Rails application.
6
-
7
- Objects are stored in the database with a *built_in_key* that is used on subsequent loads to update or remove the object.
8
- Items in the table without a *built_in_key* will not be modified or removed.
9
-
10
- BuiltInData is designed to address the data gray area between customer data and constants.
11
- It allows developers to deliver, update, and destroy data that is stored in the database.
12
-
13
- == Setup
14
- Add *built_in_key* to your model:
15
-
16
- ruby script/rails generate migration AddBuiltInKeyToYourModel built_in_key:string:index
17
- rake db:migrate
18
-
19
- Include *BuiltInData* in your model:
20
-
21
- class YourModel < ActiveRecord::Base
22
- include BuiltInData
23
- end
24
-
25
- == Loading Data
26
- There are two methods to load data
27
-
28
- * Pass as a hash to load_built_in_data!
29
- YourModel.load_built_in_data!({
30
- :glacier => {
31
- :name => 'Glacier National Park',
32
- },
33
-
34
- :yellowstone => {
35
- :name => 'Yellowstone National Park',
36
- }
37
- })
38
-
39
-
40
- * Create a yaml load file in *db/built_in_data* with the name of the model (ie. national_parks.yml), and load the data with <tt>YourModel.load_built_in_data!</tt> without any arguments. The yaml file can contain erb.
41
-
42
- glacier:
43
- name: Glacier National Park
44
- established: <%= Date.parse('1910-05-11') %>
45
-
46
- yellowstone:
47
- name: Yellowstone National Park
48
- established: 1872-03-01
49
-
50
- == Other
51
- Use *built_in?* to check if an object was loaded by BuiltInData:
52
-
53
- object.built_in?
@@ -1,104 +0,0 @@
1
- require 'test_helper'
2
-
3
- class BuiltInDataTest < ActiveSupport::TestCase
4
- HASH_DATA = {
5
- test: {
6
- name: 'Yellowstone National Park',
7
- established: '1872-03-01',
8
- url: 'http://www.nps.gov/yell/index.htm',
9
- }
10
- }
11
-
12
- test 'should return true for built_in?' do
13
- assert_equal true, NationalPark.new(built_in_key: 'test').built_in?
14
- end
15
-
16
- test 'should return false for built_in?' do
17
- assert_equal false, NationalPark.new(built_in_key: '').built_in?
18
- end
19
-
20
- test "should load built in data" do
21
- assert_difference 'NationalPark.count' do
22
- load_hash_data
23
- end
24
-
25
- assert_equal 'Yellowstone National Park', NationalPark.find_by_built_in_key('test').name
26
- end
27
-
28
- test "should remove built in data" do
29
- load_hash_data
30
-
31
- assert_difference 'NationalPark.count', -1 do
32
- NationalPark.load_built_in_data!({})
33
- end
34
-
35
- assert_nil NationalPark.find_by_built_in_key('test')
36
- end
37
-
38
- test "should not remove a record without a built_in_key" do
39
- park = NationalPark.create(:name => 'Testing')
40
-
41
- assert_difference 'NationalPark.count', 1 do
42
- load_hash_data
43
- end
44
- assert_equal 'Testing', park.reload.name
45
- end
46
-
47
- test "should update existing built in data" do
48
- load_hash_data
49
- assert_not_equal 'http://en.wikipedia.org/wiki/Yellowstone_National_Park', NationalPark.find_by_built_in_key('test').url
50
- modified_hash = HASH_DATA.dup
51
- modified_hash[:test][:url] = 'http://en.wikipedia.org/wiki/Yellowstone_National_Park'
52
- NationalPark.load_built_in_data!(modified_hash)
53
- assert_equal 'http://en.wikipedia.org/wiki/Yellowstone_National_Park', NationalPark.find_by_built_in_key('test').url
54
- end
55
-
56
- test "should load built in data from yaml file" do
57
- assert_difference 'NationalPark.count', 2 do
58
- NationalPark.load_built_in_data!
59
- end
60
- end
61
-
62
- test "should load elements from file only once" do
63
- NationalPark.load_built_in_data!
64
-
65
- assert_no_difference 'NationalPark.count' do
66
- NationalPark.load_built_in_data!
67
- end
68
- end
69
-
70
- test "should process erb in yaml file" do
71
- assert_equal '1910-05-11', NationalPark.send(:load_yaml_data)['glacier']['established'].to_s(:db)
72
- end
73
-
74
- test 'should return active record objects from load' do
75
- parks = NationalPark.load_built_in_data!
76
- assert_equal(2,parks.size)
77
- assert_equal(NationalPark,parks.first.class)
78
- assert_equal(false,parks.first.new_record?)
79
- end
80
-
81
- test 'should load yaml defaults' do
82
- NationalPark.load_built_in_data!
83
- assert_equal true, NationalPark.find_by(name: 'Yellowstone National Park').active
84
- end
85
-
86
- test 'should return built_in_data object database id' do
87
- load_hash_data
88
- assert_equal NationalPark.where(name: 'Yellowstone National Park').first.id, NationalPark.built_in_object_id(:test)
89
- end
90
-
91
- test 'should clear built_in_object_ids cache when delete_all is called' do
92
- NationalPark.instance_variable_set('@built_in_object_ids', 'testing')
93
-
94
- NationalPark.delete_all
95
- assert_nil NationalPark.instance_variable_get('@built_in_object_ids')
96
- end
97
-
98
- private
99
-
100
- def load_hash_data
101
- NationalPark.load_built_in_data!(HASH_DATA)
102
- end
103
-
104
- end
@@ -1,28 +0,0 @@
1
- == README
2
-
3
- This README would normally document whatever steps are necessary to get the
4
- application up and running.
5
-
6
- Things you may want to cover:
7
-
8
- * Ruby version
9
-
10
- * System dependencies
11
-
12
- * Configuration
13
-
14
- * Database creation
15
-
16
- * Database initialization
17
-
18
- * How to run the test suite
19
-
20
- * Services (job queues, cache servers, search engines, etc.)
21
-
22
- * Deployment instructions
23
-
24
- * ...
25
-
26
-
27
- Please feel free to use a different markup language if you do not plan to run
28
- <tt>rake doc:app</tt>.
data/test/dummy/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require File.expand_path('../config/application', __FILE__)
5
-
6
- Rails.application.load_tasks
@@ -1,4 +0,0 @@
1
-
2
- //= link_tree ../images
3
- //= link_directory ../javascripts .js
4
- //= link_directory ../stylesheets .css
@@ -1,13 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
9
- //
10
- // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require_tree .
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
- * file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
@@ -1,5 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- # Prevent CSRF attacks by raising an exception.
3
- # For APIs, you may want to use :null_session instead.
4
- protect_from_forgery with: :exception
5
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,3 +0,0 @@
1
- class NationalPark < ActiveRecord::Base
2
- include BuiltInData
3
- end
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
- <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
- load Gem.bin_path('bundler', 'bundle')
data/test/dummy/bin/rails DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
3
- require_relative '../config/boot'
4
- require 'rails/commands'
data/test/dummy/bin/rake DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require_relative '../config/boot'
3
- require 'rake'
4
- Rake.application.run
@@ -1,22 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'rails/all'
4
-
5
- Bundler.require(*Rails.groups)
6
- require "built_in_data"
7
-
8
- module Dummy
9
- class Application < Rails::Application
10
- # Settings in config/environments/* take precedence over those specified here.
11
- # Application configuration should go into files in config/initializers
12
- # -- all .rb files in that directory are automatically loaded.
13
-
14
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
- # config.time_zone = 'Central Time (US & Canada)'
17
-
18
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
- # config.i18n.default_locale = :de
21
- end
22
- end
@@ -1,5 +0,0 @@
1
- # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
-
4
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)