golf_handicap 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6330b3b1924977562fa31d6732856110126b32cd
4
- data.tar.gz: 7c8ed59edab10c19e2066c625215f077e548e20d
3
+ metadata.gz: 23ddfc069fe08429f6a83e1d3157f2fc1dc94eb4
4
+ data.tar.gz: df17e1668629da3ba46c4facc21c9cc535d7b887
5
5
  SHA512:
6
- metadata.gz: 3d83e70f7ce4e8976c32477bab04ffb7da32fe8ea60466f5882d3839d35de83c2faff7490247d8a8e3e0af28dccdf005188f756ae00e45d0721b89f5c35e8e62
7
- data.tar.gz: f2590ca8791cb5bca884fdf5c48fc710855d085ff27fc1560a7469fd62e50c4ae128a6db7c8303674e96a87426554b1c707123365371ac214bb93e81a0509a47
6
+ metadata.gz: e2ada036b3c35e0d78f67ad0f93414ec8868eeb2fcacc0d156ec5d8e19c83a28707fe02aafc79b1204d122146543a8a9745062c0ceabc374da3c0441a66f8c8e
7
+ data.tar.gz: f25ec4dc71fc76e0b06d3d435cb51c4ad46e4cff3aa7e17c6be2eb7f98c2ab9eb0f0a6843297d027cb3caa777d75c2f4a84ee735061136ac18615dca14eb1405
@@ -5,33 +5,14 @@ require "vrlib"
5
5
  # from require_all gem:
6
6
  require_rel 'src/'
7
7
 
8
+ last_file = Dir.glob(File.expand_path("~/visualruby/golf_handicap/*.yaml")).max_by {|f| File.mtime(f)}
8
9
 
9
- files = []
10
- names = []
11
- Dir[File.expand_path('~/visualruby/golf_handicap/**/*.yaml')].each do |file_name|
12
- files << file_name
13
- names << File.basename(file_name, ".*")
14
- end
15
-
16
- answer = files.empty? ? false : alert("Choose Golfer:", choices: names, button_no: "New Golfer")
17
-
18
- if answer.is_a?(String)
19
- load_file = files[names.index(answer)]
20
- elsif answer == false
21
- golfer_name = alert("Enter Name of Golfer to Create a new Handicap File:",
22
- input_text: "",
23
- button_yes: "Add Golfer"
24
- )
25
- exit unless golfer_name.is_a?(String)
26
- exit unless golfer_name.length > 2
27
- load_file = golfer_name.downcase.tr("^a-z\s", '').gsub(" ", "_") + ".yaml"
10
+ if File.exist?(last_file)
11
+ VR::load_yaml(Handicap, last_file).show_glade
28
12
  else
29
- exit
13
+ load_new_golfer
30
14
  end
31
15
 
32
- $MAIN = VR::load_yaml(Handicap, load_file)
33
-
34
- $MAIN.show_glade()
35
16
 
36
17
 
37
18
 
@@ -13,9 +13,13 @@ class Handicap
13
13
  @view.col_xalign(diff: 1, hcp: 1, score: 1)
14
14
  @view.col_sortable(date: true, course: true)
15
15
  @view.show
16
- golfer = File.basename(@vr_yaml_file, ".*")
17
- golfer = golfer.split("_").map(&:capitalize).join(' ')
16
+ golfer_file = File.basename(@vr_yaml_file, ".*")
17
+ golfer = golfer_file.split("_").map(&:capitalize).join(' ')
18
18
  @builder[:name].label = "<big><big><big><big><big>#{golfer}</big></big></big></big></big>"
19
+ if File.exists?(golfer_file + ".jpg")
20
+ @builder[:image].file = golfer_file + ".jpg"
21
+ @builder[:image].visible = true
22
+ end
19
23
  refresh()
20
24
  end
21
25
 
@@ -72,6 +76,13 @@ class Handicap
72
76
  score_array[0].handicap = count > 0 ? x[0..x.index(".")+1] : "n/a" if score_array[0]
73
77
  end
74
78
 
79
+ def buttonChangeGolfer__clicked(*a)
80
+ @view = nil # so it doesn't save contents
81
+ VR::save_yaml(self)
82
+ @builder[:window1].destroy
83
+ load_new_golfer
84
+ end
85
+
75
86
 
76
87
  def window1__delete_event(*)
77
88
  @view = nil
@@ -0,0 +1,27 @@
1
+ def load_new_golfer
2
+ files = []
3
+ names = []
4
+ Dir[File.expand_path('~/visualruby/golf_handicap/**/*.yaml')].each do |file_name|
5
+ files << file_name
6
+ names << File.basename(file_name, ".*")
7
+ end
8
+
9
+ answer = files.empty? ? false : alert("Choose Golfer:", choices: names, button_no: "New Golfer")
10
+
11
+ if answer.is_a?(String)
12
+ load_file = files[names.index(answer)]
13
+ elsif answer == false
14
+ golfer_name = alert("Enter Name of Golfer to Create a new Handicap File:",
15
+ input_text: "",
16
+ button_yes: "Add Golfer"
17
+ )
18
+ exit unless golfer_name.is_a?(String)
19
+ exit unless golfer_name.length > 2
20
+ load_file = golfer_name.downcase.tr("^a-z\s", '').gsub(" ", "_") + ".yaml"
21
+ else
22
+ exit
23
+ end
24
+
25
+ VR::load_yaml(Handicap, load_file).show_glade
26
+
27
+ end
@@ -24,6 +24,16 @@
24
24
  <property name="visible">True</property>
25
25
  <property name="can_focus">False</property>
26
26
  <property name="spacing">20</property>
27
+ <child>
28
+ <object class="GtkImage" id="image">
29
+ <property name="can_focus">False</property>
30
+ </object>
31
+ <packing>
32
+ <property name="expand">False</property>
33
+ <property name="fill">True</property>
34
+ <property name="position">0</property>
35
+ </packing>
36
+ </child>
27
37
  <child>
28
38
  <object class="GtkLabel" id="name">
29
39
  <property name="visible">True</property>
@@ -34,7 +44,7 @@
34
44
  <packing>
35
45
  <property name="expand">True</property>
36
46
  <property name="fill">True</property>
37
- <property name="position">0</property>
47
+ <property name="position">1</property>
38
48
  </packing>
39
49
  </child>
40
50
  <child>
@@ -70,7 +80,7 @@
70
80
  <packing>
71
81
  <property name="expand">False</property>
72
82
  <property name="fill">True</property>
73
- <property name="position">1</property>
83
+ <property name="position">2</property>
74
84
  </packing>
75
85
  </child>
76
86
  </object>
@@ -103,6 +113,19 @@
103
113
  <property name="can_focus">False</property>
104
114
  <property name="spacing">5</property>
105
115
  <property name="layout_style">end</property>
116
+ <child>
117
+ <object class="GtkButton" id="buttonChangeGolfer">
118
+ <property name="label" translatable="yes">Change Golfer</property>
119
+ <property name="visible">True</property>
120
+ <property name="can_focus">True</property>
121
+ <property name="receives_default">True</property>
122
+ </object>
123
+ <packing>
124
+ <property name="expand">False</property>
125
+ <property name="fill">True</property>
126
+ <property name="position">0</property>
127
+ </packing>
128
+ </child>
106
129
  <child>
107
130
  <object class="GtkButton" id="buttonAdd">
108
131
  <property name="label" translatable="yes">Add Score</property>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: golf_handicap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Cunningham
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir:
10
10
  - "."
11
11
  cert_chain: []
12
- date: 2018-05-01 00:00:00.000000000 Z
12
+ date: 2018-05-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: visualruby
@@ -17,28 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 3.1.11
20
+ version: 3.2.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 3.1.11
28
- - !ruby/object:Gem::Dependency
29
- name: require_all
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 1.2.0
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: 1.2.0
27
+ version: 3.2.0
42
28
  description: Calculates your USGA handicap. Just enter your scores, and this calculator
43
29
  will calculate your golf handicap index using the exact formula that the USGA uses.
44
30
  email: you@yoursite.com
@@ -49,6 +35,7 @@ extra_rdoc_files: []
49
35
  files:
50
36
  - "./golf_handicap"
51
37
  - src/Handicap.rb
38
+ - src/LoadGolfer.rb
52
39
  - src/Score.rb
53
40
  - src/glade/Handicap.glade
54
41
  - src/glade/Score.glade