hsql 0.3.2 → 0.3.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62f4bf6d7898b093c37c45d8ba77bbc0e118cd56
4
- data.tar.gz: b2a275351fecde1842b35385e4845ff2a849cabf
3
+ metadata.gz: d0b1d10006e41de74e480422871f77ce7770c985
4
+ data.tar.gz: adf5420beded1734f2d4e33c82d90d673a7fe320
5
5
  SHA512:
6
- metadata.gz: ff13992845af044851e1f408ea434909e8b7cabb684a731e58535e33376870708b40edab68372f0d829ad3481614582cb3a3d477a0a347d8eedf036ab7d71dd7
7
- data.tar.gz: 432d09d96805356507658107826a6bea4c6f61504c42c0341ebf539065507997ad2b4c003786826fbcf7418a36b06613352e9ce4a6d53780d7e222bcb78b8d20
6
+ metadata.gz: 518e45b1f4e3a5841e55e54126169f0a38bac3230fad17b485c348ab3efd1e0c4debc1790ef2a00c8393bc993c3e62474e5ae8f087e73b55fd7e44fa38de0129
7
+ data.tar.gz: 326cd1909458d927e713ff26a6651fb4288f9e8bf17296d9026e0fd40388f3476ea5e9ed90cb51403ec67f7a801a6045fd54cdd4c1a51e8e16339e0412a64418
data/Rakefile CHANGED
@@ -2,9 +2,18 @@ require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
3
  require 'rubocop/rake_task'
4
4
 
5
- RSpec::Core::RakeTask.new
5
+ ROOT = File.expand_path('../', __FILE__)
6
+
6
7
  RuboCop::RakeTask.new
7
8
 
9
+ # Avoiding RSpec::Core::RakeTask.new
10
+ # because we want to run each spec individually. Slower startup time but it
11
+ # allows us to ensure there are no missing dependencies.
12
+ task :spec do
13
+ Dir["#{ROOT}/spec/**/*_spec.rb"].each do |spec|
14
+ exit 1 unless system("bundle exec rspec -f d -bc #{spec}")
15
+ end
16
+ end
8
17
  task default: [:lint, :spec]
9
18
  task test: :spec
10
19
  task lint: :rubocop
data/bin/hsql CHANGED
@@ -83,9 +83,9 @@ require_relative '../lib/hsql'
83
83
 
84
84
  file = HSQL::File.parse_file(file, options)
85
85
  if 'yaml' == options[:meta_only]
86
- puts file.metadata.to_yaml
86
+ puts file.to_yaml
87
87
  elsif 'json' == options[:meta_only]
88
- puts file.metadata.to_json
88
+ puts file.to_json
89
89
  else
90
90
  file.queries.each do |query|
91
91
  # Runs the query through the parser and then deparses it
data/lib/hsql/file.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'yaml'
2
2
  require_relative 'query'
3
3
  require_relative 'data'
4
+ require_relative 'template'
4
5
  module HSQL
5
6
  # HSQL::File parses the input file and provides reader methods to the hash of
6
7
  # YAML data from the front matter section and a list of the queries in the SQL
@@ -29,6 +30,14 @@ module HSQL
29
30
  parse(file.read, options)
30
31
  end
31
32
 
33
+ def to_yaml
34
+ metadata.to_yaml
35
+ end
36
+
37
+ def to_json
38
+ metadata.to_json
39
+ end
40
+
32
41
  def metadata
33
42
  @metadata ||= @front_matter ? ::YAML.load(@front_matter) : {}
34
43
  end
@@ -60,20 +69,12 @@ module HSQL
60
69
 
61
70
  def data
62
71
  @data ||= begin
63
- validate_environment_exists!
64
-
65
72
  hash = metadata['data'] || {}
66
- hash = hash[environment] || {} if environment
73
+ hash = hash.merge(hash[environment] || {})
67
74
  hash.merge(Data.for_machines(timestamp))
68
75
  end
69
76
  end
70
77
 
71
- def validate_environment_exists!
72
- return unless environment
73
- return if metadata['data'].blank? || metadata['data'].key?(environment)
74
- fail ArgumentError, "The environment #{environment.inspect} is not specified"
75
- end
76
-
77
78
  def interpolate_data!
78
79
  template = Template.new(@sql)
79
80
  template.variable_names.each do |name|
data/lib/hsql/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # http://semver.org/
2
2
  module HSQL
3
- VERSION = '0.3.2'
3
+ VERSION = '0.3.3'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hsql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Danger Canty