array_in_file 0.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fd6745540aa042eb67611024973d9786d64fef02
4
+ data.tar.gz: 391d49dd68f0e9451fc127b9d421117a7d7151fc
5
+ SHA512:
6
+ metadata.gz: af9075655e2ac85060a88e6f96ac921f1a963fde5557c2c69179cb0de95fa9c0c9eeab2c6c4aa168316861ba832748d8eb39f8d4678b9761d76ebf7732b4beb3
7
+ data.tar.gz: aadb75a9870eb60ad9de8b8317b36fd58872d2f8a5374d7ad9267356f0a987da3ab350262e60b829497e78ea56583ad08714505721bd09227790fa9c1ec9678c
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ spec/lib/file_to_write.txt
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in array_in_file.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # ArrayInFile
2
+
3
+ This gem allows you to store an array of strings in a file. It's the ultimate global variable.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'array_in_file'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install array_in_file
18
+
19
+ ## Usage
20
+
21
+ ### Store the strings "Doppler Value Investing" and "Bargain Stock Funds" at /home/wbuffett/test.txt:
22
+ array1 = ["Doppler Value Investing", "Bargain Stock Funds"]
23
+ ArrayInFile.write(array1, "/home/wbuffett/test.txt")
24
+
25
+ ### Read the string stored at /home/wbuffett/test.txt:
26
+ ArrayInFile.read("/home/wbuffett/test.txt")
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "array_in_file/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "array_in_file"
7
+ spec.version = ArrayInFile::VERSION
8
+ spec.authors = ["Jason Hsu"]
9
+ spec.email = ["rubyist@jasonhsu.com"]
10
+ spec.summary = %q{Stores string arrays in files}
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files`.split($/)
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_development_dependency "bundler", "~> 1.3"
19
+ spec.add_development_dependency "rake"
20
+ spec.add_development_dependency 'rspec'
21
+ end
@@ -0,0 +1,3 @@
1
+ module ArrayInFile
2
+ VERSION = "0.0.0"
3
+ end
@@ -0,0 +1,23 @@
1
+ require "array_in_file/version"
2
+
3
+ module ArrayInFile
4
+
5
+ # Reads contents of file into a string
6
+ # Newlines denote the break between array elements
7
+ def self.read (path)
8
+ array1 = File.open(path, "r").read.split("\n")
9
+ array1.delete ''
10
+ return array1
11
+ end
12
+
13
+ # Writes an array into a file
14
+ # Newlines denote the break between array elements
15
+ def self.write (array_to_write, path)
16
+ f = File.open(path, 'w')
17
+ array_to_write.each do |element|
18
+ f.puts (element.to_s)
19
+ end
20
+ f.close
21
+ end
22
+
23
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe ArrayInFile do
4
+
5
+ it "should return the array contents of a file" do
6
+ file_to_read = File.expand_path("../file_to_read.txt", __FILE__)
7
+ array_to_read = ArrayInFile.read(file_to_read)
8
+ array_to_read.should == ["Doppler Value Investing", "Bargain Stock Funds"]
9
+ end
10
+
11
+ it "should write the array contents to a file" do
12
+ file_to_write = File.expand_path("../file_to_write.txt", __FILE__)
13
+ array_to_write = ["Warren Buffett", "Charlie Munger"]
14
+ ArrayInFile.write(array_to_write, file_to_write)
15
+ array_to_read = ArrayInFile.read(file_to_write)
16
+ array_to_read.should == array_to_write
17
+ end
18
+
19
+ end
@@ -0,0 +1,2 @@
1
+ Doppler Value Investing
2
+ Bargain Stock Funds
@@ -0,0 +1 @@
1
+ require 'array_in_file'
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: array_in_file
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jason Hsu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - rubyist@jasonhsu.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - array_in_file.gemspec
68
+ - lib/array_in_file.rb
69
+ - lib/array_in_file/version.rb
70
+ - spec/lib/array_in_file_spec.rb
71
+ - spec/lib/file_to_read.txt
72
+ - spec/spec_helper.rb
73
+ homepage:
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.0.3
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Stores string arrays in files
97
+ test_files:
98
+ - spec/lib/array_in_file_spec.rb
99
+ - spec/lib/file_to_read.txt
100
+ - spec/spec_helper.rb
101
+ has_rdoc: