dev_projects 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/project.rb +10 -2
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9226d313b6618f821088856b6fa4d98899a9a35
4
- data.tar.gz: 344cdba01396f8f8479c94531a22edb7bfad800d
3
+ metadata.gz: 6242bd1484ed36b28381653bb3755878b594a9fd
4
+ data.tar.gz: b28569cab3c00991c5c5f8ceabea5f9614078817
5
5
  SHA512:
6
- metadata.gz: a806cf26fee880086e7a2aa9a1b9668e784c126ad56999133ca459205a1af97e02e21373f1bf67fa61687417d1810260437bb5382398f9d8efd984491f099690
7
- data.tar.gz: 27e3b2c64c13dab0a3c64b62e9b8d449e790a5b022cad02fbc35ba7aa9ed1ce1fd60c57abc5aa662692a4ee7f0e0de326e0d20681e2b2217cc47dc1894261fb9
6
+ metadata.gz: f4f44ed0d090a1441173383c196a1f040ca1ead0e8338a154595162e2d0c6aaba903e6b09aed8514e67339f3be7631634d85ee82cb353d477b3f5480b8bdf9f8
7
+ data.tar.gz: ffeb59f04ea57abe8da568faaecee3ef59acf8576c97db3a9157060c26b733bfee7248f51e2af1fd3816eac190060ee660c8463d776d28b109961c91db988526
data/lib/project.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  class Project < Hash
2
+ attr_accessor :filename
2
3
  def initialize value=''
4
+ @filename=''
3
5
  self[:url]=''
4
6
  self[:url] = value if value.is_a?(String)
5
7
  if(value.is_a?(Hash))
@@ -18,8 +20,14 @@ class Project < Hash
18
20
 
19
21
  def self.load_projects
20
22
  projects=Project.new
21
- h=JSON.parse(IO.read(projects_filename)) if File.exists?(projects_filename)
22
- projects=Project.new(h) if File.exists?(projects_filename)
23
+ if File.exists?(projects_filename)
24
+ projects=Project.new(JSON.parse(IO.read(projects_filename)))
25
+ @filename=projects_filename
26
+ end
23
27
  projects
24
28
  end
29
+
30
+ def save
31
+ File.open(@filename,'w'){|f|f.write(self.to_json)} if @filename.length > 0
32
+ end
25
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dev_projects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lou Parslow