active_model_serializers 0.10.3 → 0.10.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +154 -2
- data/README.md +153 -15
- data/lib/action_controller/serialization.rb +11 -1
- data/lib/active_model/serializable_resource.rb +2 -0
- data/lib/active_model/serializer.rb +275 -81
- data/lib/active_model/serializer/adapter.rb +2 -0
- data/lib/active_model/serializer/adapter/attributes.rb +2 -0
- data/lib/active_model/serializer/adapter/base.rb +2 -0
- data/lib/active_model/serializer/adapter/json.rb +2 -0
- data/lib/active_model/serializer/adapter/json_api.rb +2 -0
- data/lib/active_model/serializer/adapter/null.rb +2 -0
- data/lib/active_model/serializer/array_serializer.rb +2 -0
- data/lib/active_model/serializer/association.rb +53 -14
- data/lib/active_model/serializer/attribute.rb +2 -0
- data/lib/active_model/serializer/belongs_to_reflection.rb +7 -1
- data/lib/active_model/serializer/collection_serializer.rb +8 -5
- data/lib/active_model/serializer/concerns/caching.rb +36 -23
- data/lib/active_model/serializer/error_serializer.rb +2 -0
- data/lib/active_model/serializer/errors_serializer.rb +2 -0
- data/lib/active_model/serializer/field.rb +2 -0
- data/lib/active_model/serializer/fieldset.rb +3 -1
- data/lib/active_model/serializer/has_many_reflection.rb +6 -1
- data/lib/active_model/serializer/has_one_reflection.rb +3 -1
- data/lib/active_model/serializer/lazy_association.rb +99 -0
- data/lib/active_model/serializer/link.rb +23 -0
- data/lib/active_model/serializer/lint.rb +2 -0
- data/lib/active_model/serializer/null.rb +2 -0
- data/lib/active_model/serializer/reflection.rb +122 -73
- data/lib/active_model/serializer/version.rb +3 -1
- data/lib/active_model_serializers.rb +29 -11
- data/lib/active_model_serializers/adapter.rb +3 -1
- data/lib/active_model_serializers/adapter/attributes.rb +23 -0
- data/lib/active_model_serializers/adapter/base.rb +4 -2
- data/lib/active_model_serializers/adapter/json.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api.rb +44 -26
- data/lib/active_model_serializers/adapter/json_api/deserialization.rb +4 -2
- data/lib/active_model_serializers/adapter/json_api/error.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/jsonapi.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/link.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/meta.rb +2 -0
- data/lib/active_model_serializers/adapter/json_api/pagination_links.rb +42 -21
- data/lib/active_model_serializers/adapter/json_api/relationship.rb +52 -9
- data/lib/active_model_serializers/adapter/json_api/resource_identifier.rb +35 -18
- data/lib/active_model_serializers/adapter/null.rb +2 -0
- data/lib/active_model_serializers/callbacks.rb +2 -0
- data/lib/active_model_serializers/deprecate.rb +2 -0
- data/lib/active_model_serializers/deserialization.rb +2 -0
- data/lib/active_model_serializers/json_pointer.rb +2 -0
- data/lib/active_model_serializers/logging.rb +2 -0
- data/lib/active_model_serializers/lookup_chain.rb +2 -0
- data/lib/active_model_serializers/model.rb +111 -30
- data/lib/active_model_serializers/model/caching.rb +25 -0
- data/lib/active_model_serializers/railtie.rb +4 -0
- data/lib/active_model_serializers/register_jsonapi_renderer.rb +2 -0
- data/lib/active_model_serializers/serializable_resource.rb +4 -2
- data/lib/active_model_serializers/serialization_context.rb +2 -0
- data/lib/active_model_serializers/test.rb +2 -0
- data/lib/active_model_serializers/test/schema.rb +4 -2
- data/lib/active_model_serializers/test/serializer.rb +2 -0
- data/lib/generators/rails/resource_override.rb +3 -1
- data/lib/generators/rails/serializer_generator.rb +2 -0
- data/lib/grape/active_model_serializers.rb +2 -0
- data/lib/grape/formatters/active_model_serializers.rb +2 -0
- data/lib/grape/helpers/active_model_serializers.rb +2 -0
- data/lib/tasks/rubocop.rake +55 -0
- metadata +74 -291
- data/.github/ISSUE_TEMPLATE.md +0 -29
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -15
- data/.gitignore +0 -35
- data/.rubocop.yml +0 -102
- data/.simplecov +0 -110
- data/.travis.yml +0 -51
- data/CODE_OF_CONDUCT.md +0 -74
- data/CONTRIBUTING.md +0 -105
- data/Gemfile +0 -56
- data/Rakefile +0 -103
- data/active_model_serializers.gemspec +0 -62
- data/appveyor.yml +0 -24
- data/bin/bench +0 -171
- data/bin/bench_regression +0 -316
- data/bin/serve_benchmark +0 -39
- data/docs/ARCHITECTURE.md +0 -125
- data/docs/README.md +0 -42
- data/docs/STYLE.md +0 -58
- data/docs/general/adapters.md +0 -247
- data/docs/general/caching.md +0 -58
- data/docs/general/configuration_options.md +0 -169
- data/docs/general/deserialization.md +0 -100
- data/docs/general/fields.md +0 -31
- data/docs/general/getting_started.md +0 -133
- data/docs/general/instrumentation.md +0 -40
- data/docs/general/key_transforms.md +0 -40
- data/docs/general/logging.md +0 -14
- data/docs/general/rendering.md +0 -294
- data/docs/general/serializers.md +0 -461
- data/docs/how-open-source-maintained.jpg +0 -0
- data/docs/howto/add_pagination_links.md +0 -138
- data/docs/howto/add_relationship_links.md +0 -137
- data/docs/howto/add_root_key.md +0 -55
- data/docs/howto/grape_integration.md +0 -42
- data/docs/howto/outside_controller_use.md +0 -65
- data/docs/howto/passing_arbitrary_options.md +0 -27
- data/docs/howto/serialize_poro.md +0 -32
- data/docs/howto/test.md +0 -154
- data/docs/howto/upgrade_from_0_8_to_0_10.md +0 -265
- data/docs/integrations/ember-and-json-api.md +0 -144
- data/docs/integrations/grape.md +0 -19
- data/docs/jsonapi/errors.md +0 -56
- data/docs/jsonapi/schema.md +0 -151
- data/docs/jsonapi/schema/schema.json +0 -366
- data/docs/rfcs/0000-namespace.md +0 -106
- data/docs/rfcs/template.md +0 -15
- data/lib/active_model/serializer/collection_reflection.rb +0 -7
- data/lib/active_model/serializer/concerns/associations.rb +0 -102
- data/lib/active_model/serializer/concerns/attributes.rb +0 -82
- data/lib/active_model/serializer/concerns/configuration.rb +0 -59
- data/lib/active_model/serializer/concerns/links.rb +0 -35
- data/lib/active_model/serializer/concerns/meta.rb +0 -29
- data/lib/active_model/serializer/concerns/type.rb +0 -25
- data/lib/active_model/serializer/singular_reflection.rb +0 -7
- data/lib/active_model_serializers/key_transform.rb +0 -74
- data/test/action_controller/adapter_selector_test.rb +0 -53
- data/test/action_controller/explicit_serializer_test.rb +0 -135
- data/test/action_controller/json/include_test.rb +0 -246
- data/test/action_controller/json_api/deserialization_test.rb +0 -112
- data/test/action_controller/json_api/errors_test.rb +0 -40
- data/test/action_controller/json_api/fields_test.rb +0 -57
- data/test/action_controller/json_api/linked_test.rb +0 -202
- data/test/action_controller/json_api/pagination_test.rb +0 -116
- data/test/action_controller/json_api/transform_test.rb +0 -181
- data/test/action_controller/lookup_proc_test.rb +0 -49
- data/test/action_controller/namespace_lookup_test.rb +0 -226
- data/test/action_controller/serialization_scope_name_test.rb +0 -229
- data/test/action_controller/serialization_test.rb +0 -472
- data/test/active_model_serializers/adapter_for_test.rb +0 -208
- data/test/active_model_serializers/json_pointer_test.rb +0 -22
- data/test/active_model_serializers/key_transform_test.rb +0 -297
- data/test/active_model_serializers/logging_test.rb +0 -77
- data/test/active_model_serializers/model_test.rb +0 -22
- data/test/active_model_serializers/railtie_test_isolated.rb +0 -63
- data/test/active_model_serializers/register_jsonapi_renderer_test_isolated.rb +0 -143
- data/test/active_model_serializers/serialization_context_test_isolated.rb +0 -71
- data/test/active_model_serializers/test/schema_test.rb +0 -130
- data/test/active_model_serializers/test/serializer_test.rb +0 -62
- data/test/active_record_test.rb +0 -9
- data/test/adapter/attributes_test.rb +0 -43
- data/test/adapter/deprecation_test.rb +0 -100
- data/test/adapter/json/belongs_to_test.rb +0 -45
- data/test/adapter/json/collection_test.rb +0 -104
- data/test/adapter/json/has_many_test.rb +0 -45
- data/test/adapter/json/transform_test.rb +0 -93
- data/test/adapter/json_api/belongs_to_test.rb +0 -155
- data/test/adapter/json_api/collection_test.rb +0 -96
- data/test/adapter/json_api/errors_test.rb +0 -76
- data/test/adapter/json_api/fields_test.rb +0 -88
- data/test/adapter/json_api/has_many_embed_ids_test.rb +0 -43
- data/test/adapter/json_api/has_many_explicit_serializer_test.rb +0 -96
- data/test/adapter/json_api/has_many_test.rb +0 -165
- data/test/adapter/json_api/has_one_test.rb +0 -80
- data/test/adapter/json_api/include_data_if_sideloaded_test.rb +0 -166
- data/test/adapter/json_api/json_api_test.rb +0 -33
- data/test/adapter/json_api/linked_test.rb +0 -413
- data/test/adapter/json_api/links_test.rb +0 -95
- data/test/adapter/json_api/pagination_links_test.rb +0 -193
- data/test/adapter/json_api/parse_test.rb +0 -137
- data/test/adapter/json_api/relationship_test.rb +0 -397
- data/test/adapter/json_api/resource_identifier_test.rb +0 -110
- data/test/adapter/json_api/resource_meta_test.rb +0 -100
- data/test/adapter/json_api/toplevel_jsonapi_test.rb +0 -82
- data/test/adapter/json_api/transform_test.rb +0 -504
- data/test/adapter/json_api/type_test.rb +0 -61
- data/test/adapter/json_test.rb +0 -46
- data/test/adapter/null_test.rb +0 -22
- data/test/adapter/polymorphic_test.rb +0 -171
- data/test/adapter_test.rb +0 -67
- data/test/array_serializer_test.rb +0 -22
- data/test/benchmark/app.rb +0 -65
- data/test/benchmark/benchmarking_support.rb +0 -67
- data/test/benchmark/bm_active_record.rb +0 -81
- data/test/benchmark/bm_adapter.rb +0 -38
- data/test/benchmark/bm_caching.rb +0 -119
- data/test/benchmark/bm_lookup_chain.rb +0 -83
- data/test/benchmark/bm_transform.rb +0 -45
- data/test/benchmark/config.ru +0 -3
- data/test/benchmark/controllers.rb +0 -83
- data/test/benchmark/fixtures.rb +0 -219
- data/test/cache_test.rb +0 -579
- data/test/collection_serializer_test.rb +0 -110
- data/test/fixtures/active_record.rb +0 -78
- data/test/fixtures/poro.rb +0 -286
- data/test/generators/scaffold_controller_generator_test.rb +0 -24
- data/test/generators/serializer_generator_test.rb +0 -74
- data/test/grape_test.rb +0 -178
- data/test/lint_test.rb +0 -49
- data/test/logger_test.rb +0 -20
- data/test/poro_test.rb +0 -9
- data/test/serializable_resource_test.rb +0 -79
- data/test/serializers/association_macros_test.rb +0 -37
- data/test/serializers/associations_test.rb +0 -370
- data/test/serializers/attribute_test.rb +0 -151
- data/test/serializers/attributes_test.rb +0 -52
- data/test/serializers/caching_configuration_test_isolated.rb +0 -170
- data/test/serializers/configuration_test.rb +0 -32
- data/test/serializers/fieldset_test.rb +0 -14
- data/test/serializers/meta_test.rb +0 -202
- data/test/serializers/options_test.rb +0 -21
- data/test/serializers/read_attribute_for_serialization_test.rb +0 -79
- data/test/serializers/root_test.rb +0 -21
- data/test/serializers/serialization_test.rb +0 -55
- data/test/serializers/serializer_for_test.rb +0 -136
- data/test/serializers/serializer_for_with_namespace_test.rb +0 -87
- data/test/support/custom_schemas/active_model_serializers/test/schema_test/my/index.json +0 -6
- data/test/support/isolated_unit.rb +0 -82
- data/test/support/rails5_shims.rb +0 -53
- data/test/support/rails_app.rb +0 -36
- data/test/support/schemas/active_model_serializers/test/schema_test/my/index.json +0 -6
- data/test/support/schemas/active_model_serializers/test/schema_test/my/show.json +0 -6
- data/test/support/schemas/custom/show.json +0 -7
- data/test/support/schemas/hyper_schema.json +0 -93
- data/test/support/schemas/render_using_json_api.json +0 -43
- data/test/support/schemas/simple_json_pointers.json +0 -10
- data/test/support/serialization_testing.rb +0 -71
- data/test/test_helper.rb +0 -58
data/.github/ISSUE_TEMPLATE.md
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#### Expected behavior vs actual behavior
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
#### Steps to reproduce
|
6
|
-
*(e.g., detailed walkthrough, runnable script, example application)*
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
#### Environment
|
11
|
-
|
12
|
-
ActiveModelSerializers Version *(commit ref if not on tag)*:
|
13
|
-
|
14
|
-
Output of `ruby -e "puts RUBY_DESCRIPTION"`:
|
15
|
-
|
16
|
-
OS Type & Version:
|
17
|
-
|
18
|
-
Integrated application and version *(e.g., Rails, Grape, etc)*:
|
19
|
-
|
20
|
-
|
21
|
-
#### Backtrace
|
22
|
-
*(e.g., provide any applicable backtraces from your application)*
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
#### Additonal helpful information
|
27
|
-
*(e.g., Gemfile.lock, configurations, PR containing a failing test, git bisect results)*
|
28
|
-
|
29
|
-
|
data/.gitignore
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
Gemfile.local
|
8
|
-
InstalledFiles
|
9
|
-
_yardoc
|
10
|
-
coverage
|
11
|
-
doc/
|
12
|
-
lib/bundler/man
|
13
|
-
pkg
|
14
|
-
Vagrantfile
|
15
|
-
.vagrant
|
16
|
-
rdoc
|
17
|
-
spec/reports
|
18
|
-
test/tmp
|
19
|
-
test/version_tmp
|
20
|
-
tmp
|
21
|
-
*.swp
|
22
|
-
.ruby-version
|
23
|
-
.ruby-gemset
|
24
|
-
vendor/bundle
|
25
|
-
tags
|
26
|
-
|
27
|
-
# silly macs
|
28
|
-
.DS_Store
|
29
|
-
.DS_Store?
|
30
|
-
._*
|
31
|
-
.Spotlight-V100
|
32
|
-
.Trashes
|
33
|
-
Icon?
|
34
|
-
ehthumbs.db
|
35
|
-
Thumbs.db
|
data/.rubocop.yml
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.1
|
3
|
-
Exclude:
|
4
|
-
- config/initializers/forbidden_yaml.rb
|
5
|
-
- !ruby/regexp /(vendor|bundle|bin|db|tmp)\/.*/
|
6
|
-
DisplayCopNames: true
|
7
|
-
DisplayStyleGuide: true
|
8
|
-
|
9
|
-
Rails:
|
10
|
-
Enabled: true
|
11
|
-
|
12
|
-
Lint/NestedMethodDefinition:
|
13
|
-
Enabled: false
|
14
|
-
Exclude:
|
15
|
-
- test/action_controller/serialization_test.rb
|
16
|
-
|
17
|
-
Style/Alias:
|
18
|
-
EnforcedStyle: prefer_alias
|
19
|
-
|
20
|
-
Style/StringLiterals:
|
21
|
-
EnforcedStyle: single_quotes
|
22
|
-
|
23
|
-
Metrics/AbcSize:
|
24
|
-
Max: 35 # TODO: Lower to 15
|
25
|
-
|
26
|
-
Metrics/ClassLength:
|
27
|
-
Max: 261 # TODO: Lower to 100
|
28
|
-
Exclude:
|
29
|
-
- test/**/*.rb
|
30
|
-
|
31
|
-
Metrics/CyclomaticComplexity:
|
32
|
-
Max: 7 # TODO: Lower to 6
|
33
|
-
|
34
|
-
Metrics/LineLength:
|
35
|
-
Max: 251 # TODO: Lower to 80
|
36
|
-
|
37
|
-
Metrics/MethodLength:
|
38
|
-
Max: 106 # TODO: Lower to 10
|
39
|
-
|
40
|
-
Metrics/PerceivedComplexity:
|
41
|
-
Max: 9 # TODO: Lower to 7
|
42
|
-
|
43
|
-
Style/AlignParameters:
|
44
|
-
EnforcedStyle: with_fixed_indentation
|
45
|
-
|
46
|
-
Style/ClassAndModuleChildren:
|
47
|
-
EnforcedStyle: nested
|
48
|
-
|
49
|
-
Style/Documentation:
|
50
|
-
Enabled: false
|
51
|
-
|
52
|
-
Style/MissingElse:
|
53
|
-
Enabled: true
|
54
|
-
EnforcedStyle: case
|
55
|
-
|
56
|
-
Style/EmptyElse:
|
57
|
-
EnforcedStyle: empty
|
58
|
-
|
59
|
-
Style/MultilineOperationIndentation:
|
60
|
-
EnforcedStyle: indented
|
61
|
-
|
62
|
-
Style/BlockDelimiters:
|
63
|
-
Enabled: true
|
64
|
-
EnforcedStyle: line_count_based
|
65
|
-
|
66
|
-
Style/SignalException:
|
67
|
-
EnforcedStyle: semantic
|
68
|
-
|
69
|
-
Style/TrailingCommaInLiteral:
|
70
|
-
EnforcedStyleForMultiline: no_comma
|
71
|
-
|
72
|
-
Style/ConditionalAssignment:
|
73
|
-
Enabled: false
|
74
|
-
|
75
|
-
Style/DotPosition:
|
76
|
-
EnforcedStyle: leading
|
77
|
-
|
78
|
-
########## test_helper.rb sanity
|
79
|
-
Style/EndBlock:
|
80
|
-
Exclude:
|
81
|
-
- test/test_helper.rb
|
82
|
-
|
83
|
-
Style/SpecialGlobalVars:
|
84
|
-
Exclude:
|
85
|
-
- test/test_helper.rb
|
86
|
-
|
87
|
-
Style/GlobalVars:
|
88
|
-
Exclude:
|
89
|
-
- test/test_helper.rb
|
90
|
-
|
91
|
-
Style/AndOr:
|
92
|
-
Exclude:
|
93
|
-
- test/test_helper.rb
|
94
|
-
- 'lib/active_model/serializer/lint.rb'
|
95
|
-
|
96
|
-
Style/Not:
|
97
|
-
Exclude:
|
98
|
-
- test/test_helper.rb
|
99
|
-
|
100
|
-
Style/ClassCheck:
|
101
|
-
Exclude:
|
102
|
-
- test/test_helper.rb
|
data/.simplecov
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
# https://github.com/colszowka/simplecov#using-simplecov-for-centralized-config
|
2
|
-
# see https://github.com/colszowka/simplecov/blob/master/lib/simplecov/defaults.rb
|
3
|
-
# vim: set ft=ruby
|
4
|
-
|
5
|
-
## DEFINE VARIABLES
|
6
|
-
@minimum_coverage = ENV.fetch('COVERAGE_MINIMUM') {
|
7
|
-
case (defined?(RUBY_ENGINE) && RUBY_ENGINE) || "ruby"
|
8
|
-
when 'jruby', 'rbx'
|
9
|
-
96.0
|
10
|
-
else
|
11
|
-
98.1
|
12
|
-
end
|
13
|
-
}.to_f.round(2)
|
14
|
-
# rubocop:disable Style/DoubleNegation
|
15
|
-
ENV['FULL_BUILD'] ||= ENV['CI']
|
16
|
-
@running_ci = !!(ENV['FULL_BUILD'] =~ /\Atrue\z/i)
|
17
|
-
@generate_report = @running_ci || !!(ENV['COVERAGE'] =~ /\Atrue\z/i)
|
18
|
-
@output = STDOUT
|
19
|
-
# rubocop:enable Style/DoubleNegation
|
20
|
-
|
21
|
-
## CONFIGURE SIMPLECOV
|
22
|
-
|
23
|
-
SimpleCov.profiles.define 'app' do
|
24
|
-
coverage_dir 'coverage'
|
25
|
-
load_profile 'test_frameworks'
|
26
|
-
|
27
|
-
add_group 'Libraries', 'lib'
|
28
|
-
|
29
|
-
add_group 'Long files' do |src_file|
|
30
|
-
src_file.lines.count > 100
|
31
|
-
end
|
32
|
-
class MaxLinesFilter < SimpleCov::Filter
|
33
|
-
def matches?(source_file)
|
34
|
-
source_file.lines.count < filter_argument
|
35
|
-
end
|
36
|
-
end
|
37
|
-
add_group 'Short files', MaxLinesFilter.new(5)
|
38
|
-
|
39
|
-
# Exclude these paths from analysis
|
40
|
-
add_filter '/config/'
|
41
|
-
add_filter '/db/'
|
42
|
-
add_filter 'tasks'
|
43
|
-
add_filter '/.bundle/'
|
44
|
-
end
|
45
|
-
|
46
|
-
## START TRACKING COVERAGE (before activating SimpleCov)
|
47
|
-
require 'coverage'
|
48
|
-
Coverage.start
|
49
|
-
|
50
|
-
## ADD SOME CUSTOM REPORTING AT EXIT
|
51
|
-
SimpleCov.at_exit do
|
52
|
-
next if $! and not ($!.kind_of? SystemExit and $!.success?)
|
53
|
-
|
54
|
-
header = "#{'*' * 20} SimpleCov Results #{'*' * 20}"
|
55
|
-
results = SimpleCov.result.format!.join("\n")
|
56
|
-
exit_message = <<-EOF
|
57
|
-
|
58
|
-
#{header}
|
59
|
-
{{RESULTS}}
|
60
|
-
{{FAILURE_MESSAGE}}
|
61
|
-
|
62
|
-
#{'*' * header.size}
|
63
|
-
EOF
|
64
|
-
percent = Float(SimpleCov.result.covered_percent)
|
65
|
-
if percent < @minimum_coverage
|
66
|
-
failure_message = <<-EOF
|
67
|
-
Spec coverage was not high enough: #{percent.round(2)}% is < #{@minimum_coverage}%
|
68
|
-
EOF
|
69
|
-
exit_message.sub!('{{RESULTS}}', results).sub!('{{FAILURE_MESSAGE}}', failure_message)
|
70
|
-
@output.puts exit_message
|
71
|
-
abort(failure_message) if @generate_report
|
72
|
-
elsif @running_ci
|
73
|
-
exit_message.sub!('{{RESULTS}}', results).sub!('{{FAILURE_MESSAGE}}', <<-EOF)
|
74
|
-
Nice job! Spec coverage (#{percent.round(2)}%) is still at or above #{@minimum_coverage}%
|
75
|
-
EOF
|
76
|
-
@output.puts exit_message
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
## CAPTURE CONFIG IN CLOSURE 'AppCoverage.start'
|
81
|
-
## to defer running until test/test_helper.rb is loaded.
|
82
|
-
# rubocop:disable Style/MultilineBlockChain
|
83
|
-
AppCoverage = Class.new do
|
84
|
-
def initialize(&block)
|
85
|
-
@block = block
|
86
|
-
end
|
87
|
-
|
88
|
-
def start
|
89
|
-
@block.call
|
90
|
-
end
|
91
|
-
end.new do
|
92
|
-
SimpleCov.start 'app'
|
93
|
-
if @generate_report
|
94
|
-
if @running_ci
|
95
|
-
require 'codeclimate-test-reporter'
|
96
|
-
@output.puts '[COVERAGE] Running with SimpleCov Simple Formatter and CodeClimate Test Reporter'
|
97
|
-
formatters = [
|
98
|
-
SimpleCov::Formatter::SimpleFormatter,
|
99
|
-
CodeClimate::TestReporter::Formatter
|
100
|
-
]
|
101
|
-
else
|
102
|
-
@output.puts '[COVERAGE] Running with SimpleCov HTML Formatter'
|
103
|
-
formatters = [SimpleCov::Formatter::HTMLFormatter]
|
104
|
-
end
|
105
|
-
else
|
106
|
-
formatters = []
|
107
|
-
end
|
108
|
-
SimpleCov.formatters = formatters
|
109
|
-
end
|
110
|
-
# rubocop:enable Style/MultilineBlockChain
|
data/.travis.yml
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
sudo: false
|
4
|
-
|
5
|
-
rvm:
|
6
|
-
- 2.1
|
7
|
-
- 2.2.3
|
8
|
-
- 2.3.0
|
9
|
-
- ruby-head
|
10
|
-
- jruby-9.0.4.0
|
11
|
-
- jruby-head
|
12
|
-
|
13
|
-
jdk:
|
14
|
-
- oraclejdk8
|
15
|
-
|
16
|
-
install: bundle install --path=vendor/bundle --retry=3 --jobs=3
|
17
|
-
cache:
|
18
|
-
directories:
|
19
|
-
- vendor/bundle
|
20
|
-
|
21
|
-
script:
|
22
|
-
- bundle exec rake ci
|
23
|
-
after_success:
|
24
|
-
- codeclimate-test-reporter
|
25
|
-
env:
|
26
|
-
global:
|
27
|
-
- "JRUBY_OPTS='--dev -J-Xmx1024M --debug'"
|
28
|
-
matrix:
|
29
|
-
- "RAILS_VERSION=4.1"
|
30
|
-
- "RAILS_VERSION=4.2"
|
31
|
-
- "RAILS_VERSION=5.0"
|
32
|
-
- "RAILS_VERSION=master"
|
33
|
-
|
34
|
-
matrix:
|
35
|
-
exclude:
|
36
|
-
- rvm: 2.1
|
37
|
-
env: RAILS_VERSION=master
|
38
|
-
- rvm: jruby-9.0.4.0
|
39
|
-
env: RAILS_VERSION=master
|
40
|
-
- rvm: jruby-head
|
41
|
-
env: RAILS_VERSION=master
|
42
|
-
- rvm: 2.1
|
43
|
-
env: RAILS_VERSION=5.0
|
44
|
-
- rvm: jruby-9.0.4.0
|
45
|
-
env: RAILS_VERSION=5.0
|
46
|
-
- rvm: jruby-head
|
47
|
-
env: RAILS_VERSION=5.0
|
48
|
-
allow_failures:
|
49
|
-
- rvm: ruby-head
|
50
|
-
- rvm: jruby-head
|
51
|
-
fast_finish: true
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
-
orientation.
|
11
|
-
|
12
|
-
## Our Standards
|
13
|
-
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
15
|
-
include:
|
16
|
-
|
17
|
-
* Using welcoming and inclusive language
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
* Gracefully accepting constructive criticism
|
20
|
-
* Focusing on what is best for the community
|
21
|
-
* Showing empathy towards other community members
|
22
|
-
|
23
|
-
Examples of unacceptable behavior by participants include:
|
24
|
-
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
-
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
30
|
-
address, without explicit permission
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
professional setting
|
33
|
-
|
34
|
-
## Our Responsibilities
|
35
|
-
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
38
|
-
response to any instances of unacceptable behavior.
|
39
|
-
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
-
threatening, offensive, or harmful.
|
45
|
-
|
46
|
-
## Scope
|
47
|
-
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
-
when an individual is representing the project or its community. Examples of
|
50
|
-
representing a project or community include using an official project e-mail
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
-
|
55
|
-
## Enforcement
|
56
|
-
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting one of the owners listed at https://rubygems.org/gems/active_model_serializers. All
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
63
|
-
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
66
|
-
members of the project's leadership.
|
67
|
-
|
68
|
-
## Attribution
|
69
|
-
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
-
|
73
|
-
[homepage]: http://contributor-covenant.org
|
74
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
data/CONTRIBUTING.md
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
## Have an issue?
|
2
|
-
|
3
|
-
Before opening an issue, try the following:
|
4
|
-
|
5
|
-
##### Consult the documentation
|
6
|
-
|
7
|
-
See if your issue can be resolved by information in the documentation.
|
8
|
-
|
9
|
-
- [0.10 (master) Documentation](https://github.com/rails-api/active_model_serializers/tree/master/docs)
|
10
|
-
- [![API Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/rails-api/active_model_serializers/v0.10.0)
|
11
|
-
- [Guides](docs)
|
12
|
-
- [0.9 (0-9-stable) Documentation](https://github.com/rails-api/active_model_serializers/tree/0-9-stable)
|
13
|
-
- [0.8 (0-8-stable) Documentation](https://github.com/rails-api/active_model_serializers/tree/0-8-stable)
|
14
|
-
|
15
|
-
##### Check for an existing issue
|
16
|
-
|
17
|
-
Take a look at the issues to see if a similar one has already been created. If
|
18
|
-
one exists, please add any additional information that might expedite
|
19
|
-
resolution.
|
20
|
-
|
21
|
-
#### Open an issue
|
22
|
-
|
23
|
-
If the documentation wasn't able to help resolve the issue and no issue already
|
24
|
-
exists, please open a new issue with the following in mind:
|
25
|
-
|
26
|
-
- Please make sure only to include one issue per report. If you encounter
|
27
|
-
multiple, unrelated issues, please report them as such.
|
28
|
-
- Be detailed. Provide backtraces and example code when possible. Provide
|
29
|
-
information about your environment. e.g., Ruby version, rails version, etc.
|
30
|
-
- Own your issue. Actively participate in the discussion and help drive the
|
31
|
-
issue to closure.
|
32
|
-
- If you resolve your own issue, please share the details on the issue and close
|
33
|
-
it out. Others might have the same issue and sharing solutions is helpful.
|
34
|
-
|
35
|
-
## Contributing
|
36
|
-
|
37
|
-
Contributing can be done in many ways and is not exclusive to code. If you have
|
38
|
-
thoughts on a particular issue or feature, we encourage you to open new issues
|
39
|
-
for discussion or add your comments to existing ones.
|
40
|
-
|
41
|
-
#### Pull requests
|
42
|
-
|
43
|
-
We also gladly welcome pull requests. When preparing to work on pull request,
|
44
|
-
please adhere to these standards:
|
45
|
-
|
46
|
-
- Base work on the master branch unless fixing an issue with
|
47
|
-
[0.9-stable](https://github.com/rails-api/active_model_serializers/tree/0-9-stable)
|
48
|
-
or
|
49
|
-
[0.8-stable](https://github.com/rails-api/active_model_serializers/tree/0-8-stable)
|
50
|
-
- Squash your commits and regularly rebase off master.
|
51
|
-
- Provide a description of the changes contained in the pull request.
|
52
|
-
- Note any specific areas that should be reviewed.
|
53
|
-
- Include tests.
|
54
|
-
- The test suite must pass on [supported Ruby versions](.travis.yml)
|
55
|
-
- Include updates to the [documentation](https://github.com/rails-api/active_model_serializers/tree/master/docs)
|
56
|
-
where applicable.
|
57
|
-
- Update the
|
58
|
-
[CHANGELOG](https://github.com/rails-api/active_model_serializers/blob/master/CHANGELOG.md)
|
59
|
-
to the appropriate sections with a brief description of the changes.
|
60
|
-
- Do not change the VERSION file.
|
61
|
-
|
62
|
-
#### Running tests
|
63
|
-
|
64
|
-
Run all tests
|
65
|
-
|
66
|
-
`$ rake test`
|
67
|
-
|
68
|
-
Run a single test suite
|
69
|
-
|
70
|
-
`$ rake test TEST=path/to/test.rb`
|
71
|
-
|
72
|
-
Run a single test
|
73
|
-
|
74
|
-
`$ rake test TEST=path/to/test.rb TESTOPTS="--name=test_something"`
|
75
|
-
|
76
|
-
Run tests against different Rails versions by setting the RAILS_VERSION variable
|
77
|
-
and bundling gems. (save this script somewhere executable and run from top of AMS repository)
|
78
|
-
|
79
|
-
```bash
|
80
|
-
#!/usr/bin/env bash
|
81
|
-
|
82
|
-
rcommand='puts YAML.load_file("./.travis.yml")["env"]["matrix"].join(" ").gsub("RAILS_VERSION=", "")'
|
83
|
-
versions=$(ruby -ryaml -e "$rcommand")
|
84
|
-
|
85
|
-
for version in ${versions[@]}; do
|
86
|
-
export RAILS_VERSION="$version"
|
87
|
-
rm -f Gemfile.lock
|
88
|
-
bundle check || bundle --local || bundle
|
89
|
-
bundle exec rake test
|
90
|
-
if [ "$?" -eq 0 ]; then
|
91
|
-
# green in ANSI
|
92
|
-
echo -e "\033[32m **** Tests passed against Rails ${RAILS_VERSION} **** \033[0m"
|
93
|
-
else
|
94
|
-
# red in ANSI
|
95
|
-
echo -e "\033[31m **** Tests failed against Rails ${RAILS_VERSION} **** \033[0m"
|
96
|
-
read -p '[Enter] any key to continue, [q] to quit...' prompt
|
97
|
-
if [ "$prompt" = 'q' ]; then
|
98
|
-
unset RAILS_VERSION
|
99
|
-
exit 1
|
100
|
-
fi
|
101
|
-
fi
|
102
|
-
unset RAILS_VERSION
|
103
|
-
done
|
104
|
-
```
|
105
|
-
|