learn-open 1.2.0 → 1.2.1

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: 7330aa259179cd5f2c28ba41d279ac632266ba03
4
- data.tar.gz: a70cf18a1f3791570d59a3185de77a2f9b572501
3
+ metadata.gz: 754f2bb0465443b07c6813b89bf718c97e01efbe
4
+ data.tar.gz: 846b8500f598af688e6162d078bbb64594024dd7
5
5
  SHA512:
6
- metadata.gz: e3cdc0b4da3b50bb866ac3257b5ac8f6b723276eeaa1fa998342af876d9cf4bc866cfd5745a004b3f870285e7523f1c3d5af0a7cd250ebc3e9b4b9eb9c03fc8f
7
- data.tar.gz: f6e7f8a06fa9feb544a8682defa64d5b139ed20d93a33c7559f87ff60ad3c171986f921b5fba666f82968f50d41281da8a533ecfac7a65eda5c82aceb4e7912e
6
+ metadata.gz: 7da69af22e33989482ee69b598f0fb91232f692aedb914d56d00591e50ae67612f3b42773e5752c470704142a1422ab83f278e9e2b773434d84b90f1020a3046
7
+ data.tar.gz: f4dbe515cc2b81abcaa9496d7f4f1674f177371dd359448dfafbe10a89d1e381d0b4193a28dcddf8f3d3bcb48fa265cee8cf13ce69bd57d8e4ee2af547bb3c96
@@ -1,5 +1,6 @@
1
1
  module LearnOpen
2
2
  class Opener
3
+ HOME_DIR = File.expand_path("~")
3
4
  attr_reader :editor, :client, :lessons_dir, :file_path, :get_next_lesson, :token
4
5
  attr_accessor :lesson, :repo_dir, :lesson_is_lab, :lesson_id, :later_lesson, :dot_learn
5
6
 
@@ -14,8 +15,8 @@ module LearnOpen
14
15
  @lesson = lesson
15
16
  @editor = editor
16
17
  @get_next_lesson = get_next_lesson
17
- @lessons_dir = YAML.load(File.read(File.expand_path('~/.learn-config')))[:learn_directory]
18
- @file_path = File.expand_path('~/.learn-open-tmp')
18
+ @lessons_dir = YAML.load(File.read("#{HOME_DIR}/.learn-config"))[:learn_directory]
19
+ @file_path = "#{HOME_DIR}/.learn-open-tmp"
19
20
  end
20
21
 
21
22
  def run
@@ -37,6 +38,18 @@ module LearnOpen
37
38
  end
38
39
  end
39
40
 
41
+ def repo_exists?
42
+ done_labs = "#{HOME_DIR}/.done_labs"
43
+ if File.exists?(done_labs)
44
+ File.
45
+ readlines(done_labs).
46
+ grep(/#{repo_dir}/).
47
+ any?
48
+ else
49
+ File.exists?("#{lessons_dir}/#{repo_dir}")
50
+ end
51
+ end
52
+
40
53
  private
41
54
 
42
55
  def ping_fork_completion(retries=3)
@@ -248,10 +261,6 @@ module LearnOpen
248
261
  end
249
262
  end
250
263
 
251
- def repo_exists?
252
- File.exists?("#{lessons_dir}/#{repo_dir}")
253
- end
254
-
255
264
  def open_with_editor
256
265
  if ios_lesson?
257
266
  open_ios_lesson
@@ -1,3 +1,3 @@
1
1
  module LearnOpen
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
@@ -0,0 +1,3 @@
1
+ ---
2
+ :learn_directory: 'spec/home_dir/code/labs'
3
+ :editor: 'atom'
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe LearnOpen::Opener do
4
+ LearnOpen::Opener::HOME_DIR = File.join(__dir__, "..", "home_dir")
5
+
6
+ context "Verifying repo existance" do
7
+ let(:opener) { LearnOpen::Opener.new("","","") }
8
+ context "with .done_labs file" do
9
+ before do
10
+ done_labs = "#{LearnOpen::Opener::HOME_DIR}/.done_labs"
11
+ FileUtils.rm(done_labs) if File.exists?(done_labs)
12
+ end
13
+ it "returns true if lab is in the .done_labs file" do
14
+ expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling")
15
+
16
+ File.open("#{LearnOpen::Opener::HOME_DIR}/.done_labs", "w+") do |f|
17
+ f.puts("js-rubber-duck-wrangling")
18
+ end
19
+
20
+ expect(opener.repo_exists?).to be_truthy
21
+ end
22
+ it "returns false if lab is not in the .done_labs file" do
23
+ expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling")
24
+ expect(opener.repo_exists?).to be_falsy
25
+ end
26
+ end
27
+
28
+ context "without .done_labs file" do
29
+ before do
30
+ path = File.join(__dir__, "..", "home_dir", "code")
31
+ FileUtils.rm_rf(path)
32
+ end
33
+
34
+ it "returns true if directory for lab exists" do
35
+ expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling")
36
+ FileUtils.mkdir_p("#{opener.lessons_dir}/js-rubber-duck-wrangling")
37
+
38
+ expect(opener.repo_exists?).to be_truthy
39
+ end
40
+
41
+ it "returns false if directory for lab doesn't exists" do
42
+ expect(opener).to receive(:repo_dir).and_return("js-rubber-duck-wrangling")
43
+ expect(opener.repo_exists?).to be_falsy
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1 @@
1
+ require_relative '../lib/learn_open'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: learn-open
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flatiron School
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-14 00:00:00.000000000 Z
11
+ date: 2016-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,6 +99,9 @@ files:
99
99
  - lib/learn_open/argument_parser.rb
100
100
  - lib/learn_open/opener.rb
101
101
  - lib/learn_open/version.rb
102
+ - spec/home_dir/.learn-config
103
+ - spec/learn_open/opener_spec.rb
104
+ - spec/spec_helper.rb
102
105
  homepage: https://github.com/learn-co/learn-open
103
106
  licenses:
104
107
  - MIT
@@ -120,8 +123,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
123
  version: '0'
121
124
  requirements: []
122
125
  rubyforge_project:
123
- rubygems_version: 2.4.8
126
+ rubygems_version: 2.5.1
124
127
  signing_key:
125
128
  specification_version: 4
126
129
  summary: Open Learn lessons locally
127
- test_files: []
130
+ test_files:
131
+ - spec/home_dir/.learn-config
132
+ - spec/learn_open/opener_spec.rb
133
+ - spec/spec_helper.rb