golden 0.5.1 → 0.6.2

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
  SHA256:
3
- metadata.gz: cb7d6213bb1ec1308135221959c65ebe9e60d3451867ad900b7b59772ce30108
4
- data.tar.gz: 826478ec45eff91699476be02d45b1319683c227faa60aa39c8a0ca68ecfc1f2
3
+ metadata.gz: 563173c01910c4a67941add131949b606c7691071808a05420fa44eeca9f5b58
4
+ data.tar.gz: 3c2705e9b064a45f4c74bfb21a52a39620908c54b63bae302232ac7e48896b94
5
5
  SHA512:
6
- metadata.gz: b158e3292725f4bd05f8e55691aebff8110966e4b7806954d012caeae8a0366fd5a12c2ea8b9faefbf892c1047e59d5195bee7f41dc244606743976074157153
7
- data.tar.gz: 5568c2e5e7c084e2e996bf3a2c70780fff6e4cd72278174dd5106217f89631f98db185d5a7d55fdf64d50583a444a2b6af32bc3bcf2aa5b540c2312c60fcb0c7
6
+ metadata.gz: 613d514dea41b19b19130f4cf99c6c7fe83f785336db8e5c45dff685a917de4b068d46879ae7835a7d658b4da3d7eead38fa0c24516ce959224b569b24aaf80d
7
+ data.tar.gz: 2613d2a111f93cff7cffad8beb6dafb31e3a5341556b723119924276cb2f223ed27bf85275772aba6e4d4e8fd58384be5d5cef35b9b469dde67d606900b08f6c
data/exe/golden CHANGED
@@ -3,8 +3,20 @@ require "thor"
3
3
  require 'open3'
4
4
  require 'json'
5
5
  require_relative("../lib/crucible.rb")
6
+ require_relative("../lib/golden/logo-banner.rb")
6
7
  module Golden
7
8
  class Cli < Thor
9
+ desc "add [path]", "add library at [path] to the list of known packages"
10
+ method_option :verbose, :aliases => "-v", :desc => "Build with verbose logging"
11
+ def add(path=nil)
12
+ self.load(options)
13
+ if(!path)
14
+ path = Dir.pwd
15
+ end
16
+ @crucible.add(path)
17
+ self.save
18
+ end
19
+
8
20
  desc "build [fileName]", "build library named [fileName]"
9
21
  method_option :verbose, :aliases => "-v", :desc => "Build with verbose logging"
10
22
  def build(fileName)
@@ -37,18 +49,22 @@ module Golden
37
49
  method_option :verbose, :aliases => "-v", :desc => "List with package detail"
38
50
  def list
39
51
  self.load(options)
40
- if(!@crucible.packages || @crucible.packages.keys.length == 0)
52
+ if(!@crucible.packages || @crucible.packages.keys.length <= 1)
41
53
  puts "No libraries have yet been built. Navigate to a go project and build one using 'golden build (LibraryName).'"
42
54
  else
43
55
  puts "Golden has access to the following libraries:"
44
56
  if(@crucible.verbose?)
45
57
  @crucible.packages.each do |name, location|
46
- puts "#{name}\t#{location}"
58
+ if(name != "_config")
59
+ puts "#{name}\t#{location}"
60
+ end
47
61
  end
48
62
  else
49
- puts @crucible.packages.keys
63
+ packages = @crucible.packages.keys.filter{|pkg| pkg != "_config"}
64
+ puts packages
50
65
  end
51
66
  end
67
+ self.save
52
68
  end
53
69
 
54
70
  desc "install [fileName]", "install a library built with golden to the current ruby project"
@@ -61,6 +77,32 @@ module Golden
61
77
  else
62
78
  puts "No libraries named #{packageName} are yet known to golden. You can list all known libraries with 'golden list'"
63
79
  end
80
+ self.save
81
+ end
82
+
83
+ desc "version", "show gem version info"
84
+ def version
85
+ self.load({})
86
+ puts "Golden v#{Golden.gem_version}"
87
+ if(@crucible.get_config("since_last_update_check") != 10 || @crucible.silence_update_notifications?)
88
+ puts Golden::Logo.build
89
+ end
90
+ self.save
91
+ end
92
+
93
+ desc "config", "configure Golden"
94
+ method_option :true, :aliases => "-t", :desc => "set a boolean config option to true"
95
+ method_option :false, :aliases => "-f", :desc => "set a boolean config option to false"
96
+ def config(config_name, value=nil)
97
+ self.load({})
98
+ if(!!options[:true])
99
+ value = true
100
+ elsif(!!options[:false])
101
+ value = false
102
+ end
103
+
104
+ @crucible.config(config_name, value)
105
+ self.save
64
106
  end
65
107
 
66
108
  protected
@@ -68,6 +110,31 @@ module Golden
68
110
  @crucible = Golden::Crucible.new(options)
69
111
  end
70
112
  def save
113
+ count = @crucible.get_config("since_last_update_check")
114
+ if(count >= 10 && !@crucible.silence_update_notifications?)
115
+ if(@crucible.get_config("update_available"))
116
+ update = @crucible.get_config("update_available")
117
+ else
118
+ update = Golden.update_available?
119
+ end
120
+ if(!!update)
121
+ if(!@crucible.get_config("update_available") || @crucible.get_config("update_available").join('.') != update.join("."))
122
+ @crucible.config('update_available', update) # store any discovered update locally to prevent spamming rubygems
123
+ end
124
+ puts "\n"
125
+ puts Golden::Logo.build
126
+ puts "An update is available! You're currently using v#{Golden.gem_version}. "
127
+ puts "To update to v#{update.join(".")} type 'gem update golden'"
128
+ puts "\n"
129
+ puts "Be sure to also update the gemfile or gemspec for any projects that use golden to load libraries."
130
+ puts "To silence these notifications, run 'golden config silence_updates -t'"
131
+ end
132
+ @crucible.config("since_last_update_check", 0)
133
+ else
134
+ if(!@crucible.silence_update_notifications?) #stop incrementing if updates are silenced
135
+ @crucible.config("since_last_update_check", count+1)
136
+ end
137
+ end
71
138
  @crucible.save
72
139
  end
73
140
  end
data/lib/crucible.rb CHANGED
@@ -13,8 +13,20 @@ module Golden
13
13
  else
14
14
  @packages = JSON.parse(File.open(@pkgLogFile).read)
15
15
  end
16
+ set_base_config
17
+ end
18
+ def add(path)
19
+ if(File.directory?(path))
20
+ golden_data = JSON.parse(File.open(File.expand_path(path)+"/golden.json").read)
21
+ elsif(File.basename == "golden" && File.extname(path) == "json")
22
+ golden_data = JSON.parse(File.open(path).read)
23
+ end
24
+ golden_data.keys.each do |libName|
25
+ puts "Adding #{libName}"
26
+ @packages[libName] = File.dirname(path)
27
+ end
28
+ self.save()
16
29
  end
17
-
18
30
  def build(fileName,dir)
19
31
  libName,extension = fileName.split('.')
20
32
  if(!extension)
@@ -67,17 +79,32 @@ module Golden
67
79
  golden_data[libName] = {}
68
80
  exports.each do |e|
69
81
  function_name = e.chomp.lstrip
70
- declaration_regex = Regexp.new("func #{function_name}\s?\((?<args>.*)\) (?<returns>.*) {")
82
+ declaration_regex = Regexp.new('\s*'+"func #{function_name}\s?\((?<args>.*)\) (?<returns>.*) {")
71
83
  export_data = {}
72
84
  export_data[:args] = {}
73
- args = source_code.scan(declaration_regex).flatten[0]
85
+ declaration = source_code.scan(declaration_regex).flatten
86
+ args = declaration[0]
74
87
  args = args[1,args.length-2]
75
88
  args = args.split(',')
76
- args.each do |arg|
89
+
90
+ args.each_with_index do |arg, i|
77
91
  name, type = arg.split(" ")
78
- export_data[:args][name] = type
92
+ if(!!type && type != "")
93
+ export_data[:args][name] = type
94
+ else
95
+ type = nil
96
+ next_args = args.slice(i+1, args.length)
97
+ next_args.each do |next_arg|
98
+ potential_type = next_arg.split(" ")[1]
99
+ if(!!potential_type && !type && potential_type != "")
100
+ type = potential_type
101
+ end
102
+ end
103
+ export_data[:args][name] = type
104
+ end
79
105
  end
80
- export_data[:returns] = source_code.scan(declaration_regex).flatten[1]
106
+
107
+ export_data[:returns] = declaration[1]
81
108
  # require "pry"
82
109
  # binding.pry
83
110
  golden_data[libName][function_name] = export_data
@@ -92,7 +119,15 @@ module Golden
92
119
  end
93
120
  @packages[libName] = dir
94
121
  end
95
-
122
+ def config(config_name, value)
123
+ @packages["_config"][config_name] = value
124
+ end
125
+ def get_config(config_name)
126
+ @packages["_config"][config_name]
127
+ end
128
+ def unset_config(config_name)
129
+ @packages["_config"].delete(config_name)
130
+ end
96
131
  def install(packageName)
97
132
  cwd = Dir.pwd
98
133
  extDestination = File.expand_path(cwd+"/bin")
@@ -118,11 +153,25 @@ module Golden
118
153
  end
119
154
  def clear
120
155
  @packages = {}
156
+ set_base_config
121
157
  save
122
158
  end
159
+ def set_base_config
160
+ if(!@packages["_config"])
161
+ @packages["_config"] = {}
162
+ self.save
163
+ end
164
+ if(!@packages["_config"]["since_last_update_check"])
165
+ @packages["_config"]["since_last_update_check"] = 0
166
+ self.save
167
+ end
168
+ end
123
169
  def verbose?
124
170
  return (!!@options && !!@options[:verbose])
125
171
  end
172
+ def silence_update_notifications?
173
+ return (@packages["_config"]["silence_updates"])
174
+ end
126
175
  def save
127
176
  # @pkgLogFile = File.expand_path(File.dirname(__FILE__)+"/../packages.json") # Installation specific package log
128
177
  File.open(@pkgLogFile,"w") do |f|
data/lib/golden.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'ffi'
2
2
  require 'json'
3
3
  require "crucible"
4
+ require_relative("golden/version")
4
5
  module Golden
5
6
  def self.require(library)
6
7
  golden_data = self.load
@@ -0,0 +1,11 @@
1
+ require 'tty-font'
2
+ module Golden
3
+ module Logo
4
+ def self.build
5
+ require 'pastel'
6
+ pastel = Pastel.new
7
+ font = TTY::Font.new("standard")
8
+ return pastel.yellow(font.write("Golden"))
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ require 'rubygems'
2
+ module Golden
3
+ def self.gem_version
4
+ Gem::Version.new VERSION::STRING
5
+ end
6
+ def self.update_available? # Returns true if update is required
7
+ current = Gem.latest_version_for("golden").segments
8
+ if((VERSION::MAJOR < current[0]) || (VERSION::FEATURE < current[1]) || (VERSION::PATCH < current[2]))
9
+ return current
10
+ end
11
+ end
12
+ module VERSION
13
+ MAJOR = 0
14
+ FEATURE = 6
15
+ PATCH = 2
16
+ PRE = "0"
17
+ if(PRE && PRE != "0")
18
+ STRING = [MAJOR, FEATURE, PATCH, PRE].compact.join(".")
19
+ else
20
+ STRING = [MAJOR, FEATURE, PATCH].compact.join(".")
21
+ end
22
+ end
23
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: golden
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Mikeska
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-23 00:00:00.000000000 Z
11
+ date: 2021-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -24,6 +24,48 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: tty-font
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.5.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.5.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: pastel
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.1'
27
69
  - !ruby/object:Gem::Dependency
28
70
  name: pry
29
71
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +86,14 @@ dependencies:
44
86
  requirements:
45
87
  - - "~>"
46
88
  - !ruby/object:Gem::Version
47
- version: '1.13'
89
+ version: '2'
48
90
  type: :development
49
91
  prerelease: false
50
92
  version_requirements: !ruby/object:Gem::Requirement
51
93
  requirements:
52
94
  - - "~>"
53
95
  - !ruby/object:Gem::Version
54
- version: '1.13'
96
+ version: '2'
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: rake
57
99
  requirement: !ruby/object:Gem::Requirement
@@ -92,6 +134,8 @@ files:
92
134
  - exe/golden
93
135
  - lib/crucible.rb
94
136
  - lib/golden.rb
137
+ - lib/golden/logo-banner.rb
138
+ - lib/golden/version.rb
95
139
  homepage: https://github.com/gmikeska/golden
96
140
  licenses: []
97
141
  metadata: {}
@@ -99,6 +143,7 @@ post_install_message:
99
143
  rdoc_options: []
100
144
  require_paths:
101
145
  - lib
146
+ - lib/golden
102
147
  required_ruby_version: !ruby/object:Gem::Requirement
103
148
  requirements:
104
149
  - - ">="
@@ -110,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
155
  - !ruby/object:Gem::Version
111
156
  version: '0'
112
157
  requirements: []
113
- rubygems_version: 3.0.3
158
+ rubygems_version: 3.1.4
114
159
  signing_key:
115
160
  specification_version: 4
116
161
  summary: Golden is a development tool that makes it easier to wrap Go libraries for