golden 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/exe/golden +57 -10
  3. data/lib/crucible.rb +24 -1
  4. metadata +29 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21334769c3c957e390f4232d2a1c66ac4f217d7606d35ca852b377194c30438e
4
- data.tar.gz: e3589f5034926223a9c43db49ef57e160c92f55703e2a8b5aeace610b49e876f
3
+ metadata.gz: dff8a0319b31fd1883d8556debd42aba58fc4c24dbaf1bbd7832519d9fb73617
4
+ data.tar.gz: 314840d1301029ec6b316750abfc6db4ff78db980d5b96f46e3f957ff5bc88f9
5
5
  SHA512:
6
- metadata.gz: 7e25720a29021f9c67d70cfb6528f7324d7b332890c764112b4df5547e4f99a8e12335f5e1279375cca4a655bbb57241416cc19c31fff6772c6e1d0ee04fc1b0
7
- data.tar.gz: e672cdea504ba63749bc2b8dae8945507b3e39ee90859e554cd316fb39c1d346ebc1461bc59fdedb7a9c4347e84a59afc00079a24cecd5fb7efe5de465dfab66
6
+ metadata.gz: 23a6be1147a3c138a8c928f8819606384116680d6d98d334a43581630935306883ab755f1fb544d16ed85810e436ec81264bb40be3a566eea77bb92b7a22d3ba
7
+ data.tar.gz: c2218a23d781f3c4b97f0b4cbc84f083838ffda187c913ae068ce78480a6b51373995f71945f28bdd2113d6a6b9b383785b5414587908ae5af86136a15d01656
data/exe/golden CHANGED
@@ -3,6 +3,7 @@ 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
8
9
  desc "add [path]", "add library at [path] to the list of known packages"
@@ -20,6 +21,8 @@ module Golden
20
21
  method_option :verbose, :aliases => "-v", :desc => "Build with verbose logging"
21
22
  def build(fileName)
22
23
  self.load(options)
24
+ require "pry"
25
+ binding.pry
23
26
  @crucible.build(fileName,Dir.pwd)
24
27
  self.save
25
28
  end
@@ -48,18 +51,22 @@ module Golden
48
51
  method_option :verbose, :aliases => "-v", :desc => "List with package detail"
49
52
  def list
50
53
  self.load(options)
51
- if(!@crucible.packages || @crucible.packages.keys.length == 0)
54
+ if(!@crucible.packages || @crucible.packages.keys.length <= 1)
52
55
  puts "No libraries have yet been built. Navigate to a go project and build one using 'golden build (LibraryName).'"
53
56
  else
54
57
  puts "Golden has access to the following libraries:"
55
58
  if(@crucible.verbose?)
56
59
  @crucible.packages.each do |name, location|
57
- puts "#{name}\t#{location}"
60
+ if(name != "_config")
61
+ puts "#{name}\t#{location}"
62
+ end
58
63
  end
59
64
  else
60
- puts @crucible.packages.keys
65
+ packages = @crucible.packages.keys.filter{|pkg| pkg != "_config"}
66
+ puts packages
61
67
  end
62
68
  end
69
+ self.save
63
70
  end
64
71
 
65
72
  desc "install [fileName]", "install a library built with golden to the current ruby project"
@@ -72,17 +79,32 @@ module Golden
72
79
  else
73
80
  puts "No libraries named #{packageName} are yet known to golden. You can list all known libraries with 'golden list'"
74
81
  end
82
+ self.save
75
83
  end
76
84
 
77
85
  desc "version", "show gem version info"
78
- def version(packageName)
79
- self.load(options)
80
- if(!!@crucible.packages[packageName])
81
- puts "installing #{packageName}."
82
- @crucible.install(packageName)
83
- else
84
- puts "No libraries named #{packageName} are yet known to golden. You can list all known libraries with 'golden list'"
86
+ def version
87
+ self.load({})
88
+ puts "Golden v#{Golden.gem_version}"
89
+ if(@crucible.get_config("since_last_update_check") != 10 || @crucible.silence_update_notifications?)
90
+ puts Golden::Logo.build
85
91
  end
92
+ self.save
93
+ end
94
+
95
+ desc "config", "configure Golden"
96
+ method_option :true, :aliases => "-t", :desc => "set a boolean config option to true"
97
+ method_option :false, :aliases => "-f", :desc => "set a boolean config option to false"
98
+ def config(config_name, value=nil)
99
+ self.load({})
100
+ if(!!options[:true])
101
+ value = true
102
+ elsif(!!options[:false])
103
+ value = false
104
+ end
105
+
106
+ @crucible.config(config_name, value)
107
+ self.save
86
108
  end
87
109
 
88
110
  protected
@@ -90,6 +112,31 @@ module Golden
90
112
  @crucible = Golden::Crucible.new(options)
91
113
  end
92
114
  def save
115
+ count = @crucible.get_config("since_last_update_check")
116
+ if(count >= 10 && !@crucible.silence_update_notifications?)
117
+ if(@crucible.get_config("update_available"))
118
+ update = @crucible.get_config("update_available")
119
+ else
120
+ update = Golden.update_available?
121
+ end
122
+ if(!!update)
123
+ if(!@crucible.get_config("update_available") || @crucible.get_config("update_available").join('.') != update.join("."))
124
+ @crucible.config('update_available', update) # store any discovered update locally to prevent spamming rubygems
125
+ end
126
+ puts "\n"
127
+ puts Golden::Logo.build
128
+ puts "An update is available! You're currently using v#{Golden.gem_version}. "
129
+ puts "To update to v#{update.join(".")} type 'gem update golden'"
130
+ puts "\n"
131
+ puts "Be sure to also update the gemfile or gemspec for any projects that use golden to load libraries."
132
+ puts "To silence these notifications, run 'golden config silence_updates -t'"
133
+ end
134
+ @crucible.config("since_last_update_check", 0)
135
+ else
136
+ if(!@crucible.silence_update_notifications?) #stop incrementing if updates are silenced
137
+ @crucible.config("since_last_update_check", count+1)
138
+ end
139
+ end
93
140
  @crucible.save
94
141
  end
95
142
  end
data/lib/crucible.rb CHANGED
@@ -13,6 +13,7 @@ module Golden
13
13
  else
14
14
  @packages = JSON.parse(File.open(@pkgLogFile).read)
15
15
  end
16
+ set_base_config
16
17
  end
17
18
  def add(path)
18
19
  if(File.directory?(path))
@@ -118,7 +119,15 @@ module Golden
118
119
  end
119
120
  @packages[libName] = dir
120
121
  end
121
-
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
122
131
  def install(packageName)
123
132
  cwd = Dir.pwd
124
133
  extDestination = File.expand_path(cwd+"/bin")
@@ -144,11 +153,25 @@ module Golden
144
153
  end
145
154
  def clear
146
155
  @packages = {}
156
+ set_base_config
147
157
  save
148
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
149
169
  def verbose?
150
170
  return (!!@options && !!@options[:verbose])
151
171
  end
172
+ def silence_update_notifications?
173
+ return (@packages["_config"]["silence_updates"])
174
+ end
152
175
  def save
153
176
  # @pkgLogFile = File.expand_path(File.dirname(__FILE__)+"/../packages.json") # Installation specific package log
154
177
  File.open(@pkgLogFile,"w") do |f|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: golden
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Mikeska
@@ -24,6 +24,34 @@ 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
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: thor
29
57
  requirement: !ruby/object:Gem::Requirement