ar2gostruct 0.1.0 → 0.1.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: 3861f4676a60c926267fc2a6e8ae604b92122f17
4
- data.tar.gz: af54f1c63cfac46899a8a48403d7abfb66d4b74f
3
+ metadata.gz: 0d72454f20c5ac352cc5614c1aeb15239683333e
4
+ data.tar.gz: 326cf39650b897f66cd677b746b8eaaa17f54c43
5
5
  SHA512:
6
- metadata.gz: 1a70b09199ff41a98f49d52e0897346955791fb3d6c2e0a1248023afa8001d824bcc34010871687636fd7f8e017a6cbc865d415bfc6966d47137c381610abfd4
7
- data.tar.gz: 40a12625a3613330e8dec3a855b831ddafa397ecad0cb60415f6ab520f21b1669420d37eabffb62a35967370c937ddc67eb12f6285ae7360290915ba026cdb6f
6
+ metadata.gz: c644d1df25f285e4495aa73572721375cd1b20b253df53ee06533b5a31821e5e523c1c45e0dc2d4e06053ae8a8363c9471697cb6fe1ced7f70573de8587fbb53
7
+ data.tar.gz: abdfc344a2397d7b3b12145bb81b1cdb3421ffca61dc61f7ce293c030b800fae9627fe2f17b56c99f4b3b5a63567a5e2d4abbf84658c17e03405df066b38028a
data/bin/ar2gostruct CHANGED
@@ -1,28 +1,32 @@
1
1
  #!/usr/bin/env ruby
2
- require 'rubygems'
2
+ require "rubygems"
3
3
 
4
- require 'optparse'
5
- require 'ar2gostruct'
4
+ require "optparse"
5
+ require "ar2gostruct"
6
6
 
7
7
  OptionParser.new do |opt|
8
8
  opt.banner = "Usage: ar2gostruct [options]"
9
9
 
10
- opt.on('-v', '--version',
10
+ opt.on("-v", "--version",
11
11
  "Show the current version of this gem") do
12
12
  puts "ar2gostruct v#{Ar2gostruct.version}"; exit
13
13
  end
14
14
 
15
- opt.on('--orm orm', "Specify ORM. Currently supports only qbs") do |orm|
16
- ENV['orm'] = orm.to_s
15
+ opt.on("--orm orm", "Specify ORM. Currently supports only qbs") do |orm|
16
+ ENV["orm"] = orm.to_s
17
17
  end
18
18
 
19
- opt.on('--plural', "Pluralize struct name") do
20
- ENV['plural'] = "true"
19
+ opt.on("--plural", "Pluralize struct name") do
20
+ ENV["plural"] = "true"
21
21
  end
22
22
 
23
- opt.on('--model-dir dir',
23
+ opt.on("--model-dir dir",
24
24
  "Model files stored in dir rather than app/models") do |dir|
25
- ENV['model_dir'] = dir.to_s
25
+ ENV["model_dir"] = dir.to_s
26
+ end
27
+
28
+ opt.on("--require r", "require path") do |r|
29
+ ENV["require_path"] = r.to_s
26
30
  end
27
31
  opt.parse!(ARGV)
28
32
  end
@@ -1,3 +1,3 @@
1
1
  module Ar2gostruct
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/ar2gostruct.rb CHANGED
@@ -1,3 +1,14 @@
1
+ unless File.exists?("./Rakefile") || File.exists?("./Gemfile")
2
+ abort "Please run ar2gostruct from the root of the project."
3
+ end
4
+
5
+ require "rubygems"
6
+ begin
7
+ require "rubygems"
8
+ require "bundler/setup"
9
+ rescue Exception => e
10
+ end
11
+
1
12
  require "ar2gostruct/version"
2
13
 
3
14
  require "active_support/inflector"
@@ -23,16 +34,18 @@ module Ar2gostruct
23
34
  }
24
35
 
25
36
  def self.load
26
- begin
27
- require "#{Dir.pwd}/config/environment"
28
- rescue
37
+ path = ENV["require_path"] || "#{Dir.pwd}/config/environment"
38
+ if File.exists?(path) || File.exists?("#{path}.rb")
39
+ require path
40
+ Rails.application.eager_load! if defined?(Rails)
41
+ else
42
+ raise "failed to load app"
29
43
  end
30
- Rails.application.eager_load!
31
44
  end
32
45
 
33
46
  def self.get_schema_info(klass)
34
47
  info = "// Table name: #{klass.table_name}\n"
35
- if ENV['plural']
48
+ if ENV["plural"]
36
49
  struct_name = klass.table_name.camelize
37
50
  else
38
51
  struct_name = klass.to_s.tr_s('::', '')
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar2gostruct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tatsuo Kaniwa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-24 00:00:00.000000000 Z
11
+ date: 2014-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.8.7
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.8.7
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.3.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.3.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.3.0
55
55
  description: Generate Go Struct from activerecord models
@@ -61,9 +61,9 @@ extensions: []
61
61
  extra_rdoc_files:
62
62
  - README.md
63
63
  files:
64
- - .gitignore
65
- - .rspec
66
- - .travis.yml
64
+ - ".gitignore"
65
+ - ".rspec"
66
+ - ".travis.yml"
67
67
  - Gemfile
68
68
  - LICENSE.txt
69
69
  - README.md
@@ -80,25 +80,25 @@ licenses:
80
80
  metadata: {}
81
81
  post_install_message:
82
82
  rdoc_options:
83
- - --line-numbers
84
- - --inline-source
85
- - --title
83
+ - "--line-numbers"
84
+ - "--inline-source"
85
+ - "--title"
86
86
  - ar2gostruct
87
87
  require_paths:
88
88
  - lib
89
89
  required_ruby_version: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - '>='
91
+ - - ">="
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - '>='
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.0.3
101
+ rubygems_version: 2.2.2
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: Generate Go Struct from activerecord models