github-ds 0.2.0 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a1aaf710b392b3606a470e855ffc6df96bb8d02d
4
- data.tar.gz: a0ccd759cda221b0749c2868e3b55f03aa800589
3
+ metadata.gz: e3dda4d4ed9f093a4e3d098f5701f804bde5fc55
4
+ data.tar.gz: ee1f88f94fcd6986913b9c4ee1dc85269b8bb108
5
5
  SHA512:
6
- metadata.gz: 6b557340535961e3e89fe98a4f5cb84cad5b66d44accff0bec41398677d6d0f9e40df761da62360aae7083ce4a4df4c31be38750767d404eeb6f208b25af5312
7
- data.tar.gz: 0fa602a4a8de432e7db165aacef4207e81daa4e03c8c0907aa7a48278f0aa5ae03ebc0dbf9949008bd62dc512151285e8a96bce293571bad4b0184fddfa7ba3b
6
+ metadata.gz: dcff9123a791a1ca4e81f2db9faef112331712070cf5920465c4bcd46c42eabc36b48626f80eeff886dd8791e98e0d6611be9b94b7f20ff179b17fe585ee2f9d
7
+ data.tar.gz: a30eed58460e4f4e9430f12fe41f6ab1537eb1f3b07a33d990606cb62b8e19dedd079ac210da68105ff8f30dec56b91e2f5ebd9213606882dcf6b32e31067014
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  /test/tmp/
11
+ /db/
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.1
4
+
5
+ Additions
6
+
7
+ * `Result.new` without block returns `true` for `ok?` https://github.com/github/github-ds/pull/19
8
+
3
9
  ## 0.2.0
4
10
 
5
11
  Fixes
@@ -10,16 +10,29 @@ attempts = 0
10
10
  begin
11
11
  ActiveRecord::Base.establish_connection({
12
12
  adapter: "mysql2",
13
+ username: "root",
13
14
  database: "github_ds_test",
14
15
  })
15
16
  ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS `key_values`")
16
- require "generators/github/ds/templates/migration"
17
+
18
+ # remove db tree if present so we can start fresh
19
+ db_path = root_path.join("db")
20
+ db_path.rmtree if db_path.exist?
21
+
22
+ # use generator to create the migration
23
+ require "rails/generators"
24
+ require "generators/github/ds/active_record_generator"
25
+ Rails::Generators.invoke "github:ds:active_record"
26
+
27
+ # require migration and run it so we have the key values table
28
+ require db_path.join("migrate").children.first.to_s
17
29
  ActiveRecord::Migration.verbose = false
18
30
  CreateKeyValuesTable.up
19
31
  rescue
20
32
  raise if attempts >= 1
21
33
  ActiveRecord::Base.establish_connection({
22
34
  adapter: "mysql2",
35
+ username: "root",
23
36
  })
24
37
  ActiveRecord::Base.connection.execute("CREATE DATABASE `github_ds_test`")
25
38
  attempts += 1
@@ -7,6 +7,7 @@ class SomeModel < ActiveRecord::Base
7
7
  establish_connection({
8
8
  adapter: "mysql2",
9
9
  database: "github_ds_test",
10
+ username: "root",
10
11
  })
11
12
  end
12
13
 
@@ -1,5 +1,5 @@
1
1
  require "rails/generators/active_record"
2
-
2
+ require "rails/version"
3
3
  module Github
4
4
  module Ds
5
5
  module Generators
@@ -10,12 +10,22 @@ module Github
10
10
  source_paths << File.join(File.dirname(__FILE__), "templates")
11
11
 
12
12
  def create_migration_file
13
- migration_template "migration.rb", "db/migrate/create_key_values_table.rb"
13
+ migration_template "migration.rb", "db/migrate/create_key_values_table.rb", migration_version: migration_version
14
14
  end
15
15
 
16
16
  def self.next_migration_number(dirname)
17
17
  ::ActiveRecord::Generators::Base.next_migration_number(dirname)
18
18
  end
19
+
20
+ def self.migration_version
21
+ if Rails.version.start_with?('5')
22
+ "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
23
+ end
24
+ end
25
+
26
+ def migration_version
27
+ self.class.migration_version
28
+ end
19
29
  end
20
30
  end
21
31
  end
@@ -1,4 +1,4 @@
1
- class CreateKeyValuesTable < ActiveRecord::Migration
1
+ class CreateKeyValuesTable < ActiveRecord::Migration<%= migration_version %>
2
2
  def self.up
3
3
  create_table :key_values do |t|
4
4
  t.string :key, :null => false
@@ -1,5 +1,5 @@
1
1
  module GitHub
2
2
  module DS
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -15,7 +15,7 @@ module GitHub
15
15
  #
16
16
  def initialize
17
17
  begin
18
- @value = yield
18
+ @value = yield if block_given?
19
19
  @error = nil
20
20
  rescue => e
21
21
  @error = e
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-ds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-05-22 00:00:00.000000000 Z
12
+ date: 2017-07-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord