hyper-d3 1.0.0.lap23

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 (204) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +313 -0
  5. data/README.md +118 -0
  6. data/Rakefile +31 -0
  7. data/hyper-d3.gemspec +27 -0
  8. data/lib/d3.rb +68 -0
  9. data/lib/d3/arc.rb +29 -0
  10. data/lib/d3/area.rb +53 -0
  11. data/lib/d3/axis.rb +79 -0
  12. data/lib/d3/band_scale.rb +30 -0
  13. data/lib/d3/collections.rb +9 -0
  14. data/lib/d3/color.rb +76 -0
  15. data/lib/d3/color_schemes.rb +34 -0
  16. data/lib/d3/continuous_scale.rb +60 -0
  17. data/lib/d3/creator.rb +11 -0
  18. data/lib/d3/curve.rb +74 -0
  19. data/lib/d3/dsv.rb +103 -0
  20. data/lib/d3/ease.rb +319 -0
  21. data/lib/d3/format.rb +95 -0
  22. data/lib/d3/histograms.rb +46 -0
  23. data/lib/d3/interpolate.rb +125 -0
  24. data/lib/d3/line.rb +27 -0
  25. data/lib/d3/map.rb +48 -0
  26. data/lib/d3/misc.rb +15 -0
  27. data/lib/d3/native.rb +112 -0
  28. data/lib/d3/nest.rb +100 -0
  29. data/lib/d3/ordinal_scale.rb +39 -0
  30. data/lib/d3/path.rb +24 -0
  31. data/lib/d3/pie.rb +25 -0
  32. data/lib/d3/point_scale.rb +27 -0
  33. data/lib/d3/polygon.rb +18 -0
  34. data/lib/d3/quadtree.rb +89 -0
  35. data/lib/d3/quantile_scale.rb +19 -0
  36. data/lib/d3/quantize_scale.rb +20 -0
  37. data/lib/d3/radial_area.rb +55 -0
  38. data/lib/d3/radial_line.rb +27 -0
  39. data/lib/d3/random.rb +14 -0
  40. data/lib/d3/search.rb +30 -0
  41. data/lib/d3/selection.rb +151 -0
  42. data/lib/d3/sequential_scale.rb +31 -0
  43. data/lib/d3/set.rb +30 -0
  44. data/lib/d3/source/d3-drag.js +234 -0
  45. data/lib/d3/source/d3-scale-chromatic.js +484 -0
  46. data/lib/d3/source/d3.js +17178 -0
  47. data/lib/d3/stack.rb +13 -0
  48. data/lib/d3/statistics.rb +81 -0
  49. data/lib/d3/symbol.rb +70 -0
  50. data/lib/d3/threshold_scale.rb +22 -0
  51. data/lib/d3/time_format.rb +47 -0
  52. data/lib/d3/time_interval.rb +85 -0
  53. data/lib/d3/transformations.rb +16 -0
  54. data/lib/hyper-d3.rb +17 -0
  55. data/lib/hyperloop/d3/component.rb +12 -0
  56. data/lib/hyperloop/d3/mixin.rb +59 -0
  57. data/lib/hyperloop/d3/version.rb +5 -0
  58. data/spec/arc_spec.rb +80 -0
  59. data/spec/area_spec.rb +98 -0
  60. data/spec/axis_spec.rb +174 -0
  61. data/spec/band_scale_spec.rb +73 -0
  62. data/spec/color_spec.rb +74 -0
  63. data/spec/continuous_scale_spec.rb +217 -0
  64. data/spec/coverage_spec.rb +16 -0
  65. data/spec/creator_spec.rb +15 -0
  66. data/spec/curve_spec.rb +206 -0
  67. data/spec/dsv_spec.rb +194 -0
  68. data/spec/ease_spec.rb +370 -0
  69. data/spec/format_spec.rb +87 -0
  70. data/spec/histograms_spec.rb +61 -0
  71. data/spec/html/index.html.erb +11 -0
  72. data/spec/interpolate_spec.rb +152 -0
  73. data/spec/line_spec.rb +54 -0
  74. data/spec/map_spec.rb +80 -0
  75. data/spec/misc_spec.rb +21 -0
  76. data/spec/nest_spec.rb +89 -0
  77. data/spec/objects_spec.rb +22 -0
  78. data/spec/ordinal_scale_spec.rb +59 -0
  79. data/spec/path_spec.rb +65 -0
  80. data/spec/pie_spec.rb +114 -0
  81. data/spec/point_scale_spec.rb +58 -0
  82. data/spec/polygon_spec.rb +51 -0
  83. data/spec/quadtree_spec.rb +128 -0
  84. data/spec/quantile_scale_spec.rb +24 -0
  85. data/spec/quantize_scale_spec.rb +40 -0
  86. data/spec/radial_area_spec.rb +123 -0
  87. data/spec/radial_line_spec.rb +50 -0
  88. data/spec/random_spec.rb +34 -0
  89. data/spec/search_spec.rb +69 -0
  90. data/spec/selection_data_spec.rb +64 -0
  91. data/spec/selection_manipulation_spec.rb +166 -0
  92. data/spec/selection_spec.rb +187 -0
  93. data/spec/sequential_scale_spec.rb +90 -0
  94. data/spec/set_spec.rb +57 -0
  95. data/spec/spec_helper.rb +1 -0
  96. data/spec/stack_spec.rb +5 -0
  97. data/spec/statistics_spec.rb +65 -0
  98. data/spec/symbol_spec.rb +116 -0
  99. data/spec/test_app/.gitignore +23 -0
  100. data/spec/test_app/Gemfile +7 -0
  101. data/spec/test_app/Gemfile.lock +206 -0
  102. data/spec/test_app/README.md +9 -0
  103. data/spec/test_app/Rakefile +6 -0
  104. data/spec/test_app/app/assets/config/manifest.js +3 -0
  105. data/spec/test_app/app/assets/images/.keep +0 -0
  106. data/spec/test_app/app/assets/javascripts/application.js +13 -0
  107. data/spec/test_app/app/assets/javascripts/cable.js +13 -0
  108. data/spec/test_app/app/assets/javascripts/channels/.keep +0 -0
  109. data/spec/test_app/app/assets/javascripts/data/elections_2016.rb +10 -0
  110. data/spec/test_app/app/assets/javascripts/data/harry_potter.rb +19 -0
  111. data/spec/test_app/app/assets/javascripts/data/iphones.rb +29 -0
  112. data/spec/test_app/app/assets/javascripts/data/london_population.rb +26 -0
  113. data/spec/test_app/app/assets/javascripts/data/man_vs_horse.rb +55 -0
  114. data/spec/test_app/app/assets/javascripts/data/mtg_modern_colors.rb +96 -0
  115. data/spec/test_app/app/assets/javascripts/data/mtg_modern_creatures.rb +116 -0
  116. data/spec/test_app/app/assets/javascripts/data/olympics_2016_medals.rb +100 -0
  117. data/spec/test_app/app/assets/javascripts/data/paradox.rb +60 -0
  118. data/spec/test_app/app/assets/javascripts/data/polish_pms.rb +28 -0
  119. data/spec/test_app/app/assets/javascripts/data/star_trek_voyager.rb +183 -0
  120. data/spec/test_app/app/assets/javascripts/data/weather_in_london.rb +381 -0
  121. data/spec/test_app/app/assets/javascripts/elections_2016.rb +27 -0
  122. data/spec/test_app/app/assets/javascripts/harry_potter.rb +42 -0
  123. data/spec/test_app/app/assets/javascripts/iphones.rb +54 -0
  124. data/spec/test_app/app/assets/javascripts/london_population.rb +53 -0
  125. data/spec/test_app/app/assets/javascripts/london_population_area.rb +49 -0
  126. data/spec/test_app/app/assets/javascripts/man_vs_horse.rb +60 -0
  127. data/spec/test_app/app/assets/javascripts/mtg_modern_colors.rb +56 -0
  128. data/spec/test_app/app/assets/javascripts/mtg_modern_creatures.rb +70 -0
  129. data/spec/test_app/app/assets/javascripts/olympics_2016_medals.rb +62 -0
  130. data/spec/test_app/app/assets/javascripts/paradox.rb +64 -0
  131. data/spec/test_app/app/assets/javascripts/polish_pms.rb +60 -0
  132. data/spec/test_app/app/assets/javascripts/star_trek_voyager.rb +44 -0
  133. data/spec/test_app/app/assets/javascripts/weather_in_london.rb +69 -0
  134. data/spec/test_app/app/assets/stylesheets/application.css +15 -0
  135. data/spec/test_app/app/channels/application_cable/channel.rb +4 -0
  136. data/spec/test_app/app/channels/application_cable/connection.rb +4 -0
  137. data/spec/test_app/app/controllers/application_controller.rb +27 -0
  138. data/spec/test_app/app/controllers/concerns/.keep +0 -0
  139. data/spec/test_app/app/helpers/application_helper.rb +2 -0
  140. data/spec/test_app/app/jobs/application_job.rb +2 -0
  141. data/spec/test_app/app/mailers/application_mailer.rb +4 -0
  142. data/spec/test_app/app/models/application_record.rb +3 -0
  143. data/spec/test_app/app/models/concerns/.keep +0 -0
  144. data/spec/test_app/app/views/application/index.erb +18 -0
  145. data/spec/test_app/app/views/application/visualization.erb +28 -0
  146. data/spec/test_app/app/views/layouts/application.html.erb +13 -0
  147. data/spec/test_app/bin/bundle +3 -0
  148. data/spec/test_app/bin/rails +4 -0
  149. data/spec/test_app/bin/rake +4 -0
  150. data/spec/test_app/bin/setup +38 -0
  151. data/spec/test_app/bin/update +29 -0
  152. data/spec/test_app/bin/yarn +11 -0
  153. data/spec/test_app/config.ru +5 -0
  154. data/spec/test_app/config/application.rb +18 -0
  155. data/spec/test_app/config/boot.rb +3 -0
  156. data/spec/test_app/config/cable.yml +10 -0
  157. data/spec/test_app/config/database.yml +25 -0
  158. data/spec/test_app/config/environment.rb +5 -0
  159. data/spec/test_app/config/environments/development.rb +54 -0
  160. data/spec/test_app/config/environments/production.rb +91 -0
  161. data/spec/test_app/config/environments/test.rb +42 -0
  162. data/spec/test_app/config/initializers/application_controller_renderer.rb +8 -0
  163. data/spec/test_app/config/initializers/assets.rb +14 -0
  164. data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
  165. data/spec/test_app/config/initializers/cookies_serializer.rb +5 -0
  166. data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
  167. data/spec/test_app/config/initializers/inflections.rb +16 -0
  168. data/spec/test_app/config/initializers/mime_types.rb +4 -0
  169. data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
  170. data/spec/test_app/config/locales/en.yml +33 -0
  171. data/spec/test_app/config/puma.rb +56 -0
  172. data/spec/test_app/config/routes.rb +5 -0
  173. data/spec/test_app/config/secrets.yml +32 -0
  174. data/spec/test_app/config/spring.rb +6 -0
  175. data/spec/test_app/db/seeds.rb +7 -0
  176. data/spec/test_app/lib/assets/.keep +0 -0
  177. data/spec/test_app/lib/tasks/.keep +0 -0
  178. data/spec/test_app/log/.keep +0 -0
  179. data/spec/test_app/package.json +5 -0
  180. data/spec/test_app/public/404.html +67 -0
  181. data/spec/test_app/public/422.html +67 -0
  182. data/spec/test_app/public/500.html +66 -0
  183. data/spec/test_app/public/apple-touch-icon-precomposed.png +0 -0
  184. data/spec/test_app/public/apple-touch-icon.png +0 -0
  185. data/spec/test_app/public/favicon.ico +0 -0
  186. data/spec/test_app/public/robots.txt +1 -0
  187. data/spec/test_app/test/application_system_test_case.rb +5 -0
  188. data/spec/test_app/test/controllers/.keep +0 -0
  189. data/spec/test_app/test/fixtures/.keep +0 -0
  190. data/spec/test_app/test/fixtures/files/.keep +0 -0
  191. data/spec/test_app/test/helpers/.keep +0 -0
  192. data/spec/test_app/test/integration/.keep +0 -0
  193. data/spec/test_app/test/mailers/.keep +0 -0
  194. data/spec/test_app/test/models/.keep +0 -0
  195. data/spec/test_app/test/system/.keep +0 -0
  196. data/spec/test_app/test/test_helper.rb +10 -0
  197. data/spec/test_app/tmp/.keep +0 -0
  198. data/spec/test_app/vendor/.keep +0 -0
  199. data/spec/threshold_scale_spec.rb +28 -0
  200. data/spec/time_format_spec.rb +100 -0
  201. data/spec/time_interval_spec.rb +314 -0
  202. data/spec/transformations_spec.rb +51 -0
  203. data/startrekvoyager.png +0 -0
  204. metadata +529 -0
@@ -0,0 +1,5 @@
1
+ Rails.application.routes.draw do
2
+ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
3
+ get "visualizations/:id", to: "application#visualization"
4
+ root "application#index"
5
+ end
@@ -0,0 +1,32 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rails secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ # Shared secrets are available across all environments.
14
+
15
+ # shared:
16
+ # api_key: a1B2c3D4e5F6
17
+
18
+ # Environmental secrets are only available for that specific environment.
19
+
20
+ development:
21
+ secret_key_base: 08da4ca30e4a39f3ad21203e10a313a52dcccec9dbd03d0f5f9eebbae561e4cc4e69af0e4806a29b71138da076b2ef913238573e419e58a03ca3610b44b1fcb0
22
+
23
+ test:
24
+ secret_key_base: 58ad4c6f15ed67e5b0662f06e91a0cc00b2e814553f7eeb3342c2e9c4f63428ee9af643838c0ca683170115a93ee571bacee7c731dfc820e0806d11537e6267c
25
+
26
+ # Do not keep production secrets in the unencrypted secrets file.
27
+ # Instead, either read values from the environment.
28
+ # Or, use `bin/rails secrets:setup` to configure encrypted secrets
29
+ # and move the `production:` environment over there.
30
+
31
+ production:
32
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -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,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
7
+ # Character.create(name: 'Luke', movie: movies.first)
File without changes
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "test_app",
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 @@
1
+ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
@@ -0,0 +1,5 @@
1
+ require "test_helper"
2
+
3
+ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
4
+ driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
5
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,10 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
7
+ fixtures :all
8
+
9
+ # Add more helper methods to be used by all tests here...
10
+ end
File without changes
File without changes
@@ -0,0 +1,28 @@
1
+ describe "d3 - threshold scale" do
2
+ let(:color) { D3.scale_threshold.domain([0, 1]).range(["red", "white", "green"]) }
3
+ it "d3.scale_threshold" do
4
+ expect(D3.scale_threshold).to be_instance_of(D3::ThresholdScale)
5
+ end
6
+
7
+ it "basics" do
8
+ expect(color.(-1)).to eq("red")
9
+ expect(color.(0)).to eq("white")
10
+ expect(color.(0.5)).to eq("white")
11
+ expect(color.(1)).to eq("green")
12
+ expect(color.(1000)).to eq("green")
13
+ end
14
+
15
+ it "invert_extent" do
16
+ expect(color.invert_extent("red")).to eq([nil, 0])
17
+ expect(color.invert_extent("white")).to eq([0, 1])
18
+ expect(color.invert_extent("green")).to eq([1, nil])
19
+ end
20
+
21
+ it "copy" do
22
+ cc = color.copy.domain([0,10])
23
+ expect(cc.domain).to eq([0,10])
24
+ expect(cc.range).to eq(["red", "white", "green"])
25
+ expect(color.domain).to eq([0,1])
26
+ expect(color.range).to eq(["red", "white", "green"])
27
+ end
28
+ end
@@ -0,0 +1,100 @@
1
+ # This test will fail in any non-UTC timezone
2
+ require "time"
3
+
4
+ # Running these specs in weird timezone will fail because javascript timezones are pile of fail
5
+ describe "d3 - time format" do
6
+ let(:us) {{
7
+ date_time: "%x, %X",
8
+ date: "%-m/%-d/%Y",
9
+ time: "%-I:%M:%S %p",
10
+ periods: ["AM", "PM"],
11
+ days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
12
+ short_days: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
13
+ months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
14
+ short_months: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
15
+ }}
16
+ let(:pl) {{
17
+ date_time: "%A, %e %B %Y, %X",
18
+ date: "%d/%m/%Y",
19
+ time: "%H:%M:%S",
20
+ periods: ["AM", "PM"],
21
+ days: ["Niedziela", "Poniedziałek", "Wtorek", "Środa", "Czwartek", "Piątek", "Sobota"],
22
+ short_days: ["Niedz.", "Pon.", "Wt.", "Śr.", "Czw.", "Pt.", "Sob."],
23
+ months: ["Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień"],
24
+ short_months: ["Stycz.", "Luty", "Marz.", "Kwie.", "Maj", "Czerw.", "Lipc.", "Sierp.", "Wrz.", "Paźdz.", "Listop.", "Grudz."],
25
+ }}
26
+
27
+ it "d3.time_format" do
28
+ f = D3.time_format("%B %d, %Y")
29
+ expect(f).to be_instance_of(Proc)
30
+ expect(f.(Time.parse("June 30, 2015"))).to eq("June 30, 2015")
31
+ end
32
+
33
+ it "d3.time_parse" do
34
+ f = D3.time_parse("%B %d, %Y")
35
+ expect(f).to be_instance_of(Proc)
36
+ expect(f.("June 30, 2015")).to eq(Time.parse("June 30, 2015 00:00:00"))
37
+ end
38
+
39
+ it "d3.utc_format" do
40
+ f = D3.utc_format("%B %d, %Y")
41
+ expect(f).to be_instance_of(Proc)
42
+ expect(f.(Time.parse("June 30, 2015 12:00:00"))).to eq("June 30, 2015")
43
+ end
44
+
45
+ it "d3.utc_parse" do
46
+ f = D3.utc_parse("%B %d, %Y")
47
+ expect(f).to be_instance_of(Proc)
48
+ expect(f.("June 30, 2015")).to eq(Time.parse("June 30, 2015 00:00:00 UTC"))
49
+ end
50
+
51
+ it "d3.iso_format / d3.iso_parse" do
52
+ t = Time.parse("June 30, 2015 12:30:45 UTC")
53
+ s = "2015-06-30T12:30:45.000Z"
54
+ expect(D3.iso_format(t)).to eq(s)
55
+ expect(D3.iso_parse(s)).to eq(t)
56
+ end
57
+
58
+ describe "locale" do
59
+ let(:locale) { D3.time_format_locale(pl) }
60
+
61
+ it "d3.format" do
62
+ f = locale.format("%B %d, %Y")
63
+ expect(f).to be_instance_of(Proc)
64
+ expect(f.(Time.parse("June 30, 2015"))).to eq("Czerwiec 30, 2015")
65
+ end
66
+
67
+ it "d3.parse" do
68
+ f = locale.parse("%B %d, %Y")
69
+ expect(f).to be_instance_of(Proc)
70
+ expect(f.("Czerwiec 30, 2015")).to eq(Time.parse("June 30, 2015 00:00:00"))
71
+ end
72
+
73
+ it "d3.utc_format" do
74
+ f = locale.utc_format("%B %d, %Y")
75
+ expect(f).to be_instance_of(Proc)
76
+ expect(f.(Time.parse("June 30, 2015 12:00:00"))).to eq("Czerwiec 30, 2015")
77
+ end
78
+
79
+ it "d3.utc_parse" do
80
+ f = locale.utc_parse("%B %d, %Y")
81
+ expect(f).to be_instance_of(Proc)
82
+ expect(f.("Czerwiec 30, 2015")).to eq(Time.parse("June 30, 2015 00:00:00 UTC"))
83
+ end
84
+ end
85
+
86
+ # This test affects global state, so we must be sure to restore it
87
+ it "d3.time_format_default_locale" do
88
+ t = Time.parse("June 30, 2015 12:30:00")
89
+ expect(D3.time_format("%c").(t)).to eq("6/30/2015, 12:30:00 PM")
90
+
91
+ locale_pl = D3.time_format_default_locale(pl)
92
+ expect(D3.time_format("%c").(t)).to eq("Wtorek, 30 Czerwiec 2015, 12:30:00")
93
+
94
+ locale_us = D3.time_format_default_locale(us)
95
+ expect(D3.time_format("%c").(t)).to eq("6/30/2015, 12:30:00 PM")
96
+
97
+ expect(locale_pl.format("%c").(t)).to eq("Wtorek, 30 Czerwiec 2015, 12:30:00")
98
+ expect(locale_us.format("%c").(t)).to eq("6/30/2015, 12:30:00 PM")
99
+ end
100
+ end