fuzion 0.0.1pre → 0.0.2pre

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTZhOTIxNjExNzRmNjQzNGE1YTJmNGEzMDBiMzRlM2UxY2I1MGNiZQ==
4
+ MjIyZjdmOGYxOGRjMjY4YzRjNzY3NjJiZDk0MDFjMDY1YjA0NGQ2ZA==
5
5
  data.tar.gz: !binary |-
6
- OGU1ODU5MThlZGQzMzMyYjljZTI1ODViZGZmYmJhZTRiMGEzNGFiZg==
6
+ YWEzYmVjZGFhM2QzYmUzYTJiNDE5ZGYyNjU5MDhhMmJmOTQwYzRhNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDJhMDk2MDY3MmQ0MjQ4OTUzZTQ0NGIyMGMyZGVmYzUxYjJhOGRiYzFmOGY3
10
- ZWEyMzNjODllNDQ4ZmRhMzc3NjdjYWFjZTVkZGYzZWYzOTY4NzY4YzQ2MGIz
11
- MTVkYzc3NWU0N2NjNTk4N2JkMTZjNjAxZWUwMmVmNWYxMDI3YTA=
9
+ YTk4MTZlNDJkODJiZjBjYTc1NDRkMWMwY2MzZTcxNWRjMjkxZTZlNTM3ZThk
10
+ ZjhjZjE5MDJmZTU1Njc4ZTU4ZGMyOGUyZTAxZDhkNDAwOGJhYmJhN2YzNDI2
11
+ ZWIyNDdmMmVlMzg1ZmQ0ODQ0NjhjMjhiNGYzYTM2ZDI0OGM4ZGI=
12
12
  data.tar.gz: !binary |-
13
- NTk1MTE2ZDc4YTQ3ODAyNmQ3MTdlNDYyYzMyNGRjYWFmYWRiMmZmN2Q3YTUx
14
- NjNhNTY3OWRiMzM3NjE1ZGM0OGM1NjA3OTE4ZjAwYzMzYzI2OTc0ZGJkZjlh
15
- MzAxZmExMTVkMmM5Mjc2ZTJjYTE0MGVmYTM4NTNmOTRmY2NiZTU=
13
+ N2U3ZDFhMWI1NTBiMjAzYWI0NWZlYzNhOTkxYzlmNmU0NWU1ZGUwNDJjMzBk
14
+ MmU1OTM3YTczMjNkNDJmNGI0MDI4OWM1MzZhYTE3ZDVkZjA0MTAyOTg2N2E1
15
+ MjY4NzcxODIxZDJlMTgzNDY2NWQwNDM0M2VmYzRkMjkwYjU5Nzk=
data/lib/fuzion.rb CHANGED
@@ -7,37 +7,43 @@ require 'fuzion/firebasesender'
7
7
  class KickOff
8
8
  attr_accessor :fb_session
9
9
 
10
- def initialize()
11
- file_name_to_watch = get_file_name
12
- dir_to_watch = Dir.pwd
13
- session_url_key = generate_classroom_code
14
- print_teacher_message(file_name_to_watch, dir_to_watch, session_url_key)
15
- # @fb_session=FBSender.new(session_url_key)
16
- file = FileParser.new("#{dir_to_watch}/#{file_name_to_watch}")
17
- # gobbledy_gook = fb_session.post(file_name_to_watch, file )
18
- Listener.start(dir_to_watch, file_name_to_watch, session_url_key, file)
10
+ def initialize
11
+ target_file = get_file_name
12
+ target_dir = Dir.pwd
13
+ classroom_code = generate_classroom_code
14
+
15
+ Listener.start(target_dir, target_file, classroom_code)
16
+ # fb_session = FBSender.new(classroom_code)
17
+ # fb_session.post(target_file, file)
18
+
19
+ # fileParser = FileParser.new("#{target_dir}/#{target_file}")
20
+ # file = fileParser.make_JSON(file_text, target_file, session_url="")
21
+ # FileParser.to_JSON("#{target_dir}/#{target_file}")
22
+
23
+ # print_classroom_url (target_file, target_dir, classroom_code)
24
+
25
+
19
26
  end
20
27
 
21
28
  private
22
29
 
23
30
  def get_file_name
24
- if ARGV[0][0] == '/'
25
- return ARGV[0][1..-1]
26
- elsif ARGV !=nil
27
- return ARGV[0]
28
- else
29
- puts "please enter a file name"
30
- exit
31
- end
32
- e nd
33
-
34
- def generate_classroom_code
35
- SecureRandom::urlsafe_base64(1)
31
+ if ARGV[0][0] == '/'
32
+ return ARGV[0][1..-1]
33
+ elsif ARGV != nil
34
+ return ARGV[0]
35
+ else
36
+ puts "please enter a file name"
37
+ exit
38
+ end
36
39
  end
37
40
 
38
- def print_teacher_message(file_name_to_watch, dir_to_watch, session_url_key)
39
- puts 'http://fuzion-app.herokuapp.com/classrooms/' + session_url_key
40
- puts "WATCHING " + dir_to_watch + "/" + file_name_to_watch
41
+ def generate_classroom_code
42
+ SecureRandom::urlsafe_base64(1)
41
43
  end
42
- end
43
44
 
45
+ def print_classroom_url (target_file, target_dir, classroom_code)
46
+ puts 'http://fuzion-app.herokuapp.com/classrooms/' + classroom_code
47
+ puts "WATCHING " + target_dir + "/" + target_file
48
+ end
49
+ end
@@ -5,13 +5,36 @@ class FileParser
5
5
  @path=path
6
6
  end
7
7
 
8
- def read_file()
8
+ # def get_file_as_JSON
9
+ # read_file
10
+ # make_JSON()
11
+ # end
12
+
13
+ def read_file
9
14
  return File.read("#{@path}")
10
15
  end
11
16
 
12
- def make_JSON(file_text, file_to_watch, session_url="")
13
- j_hash={"classroom_code"=> session_url, "file_name"=> file_to_watch, "file_content"=> file_text}
14
- return j_hash.to_json
17
+ def make_JSON(target_file, session_url="")
18
+ file_text = read_file
19
+ hash = {"classroom_code"=> session_url, "file_name"=> target_file, "file_content"=> file_text}
20
+ return hash.to_json
15
21
  end
16
22
 
17
23
  end
24
+
25
+ # class FileParser
26
+ # def initialize(path)
27
+ # @path=path
28
+ # end
29
+
30
+ # def read_file
31
+ # return File.read("#{@path}")
32
+ # end
33
+
34
+ # def self.to_JSON(classroom_code="", target_file, file_content)
35
+ # read_file
36
+ # hash = {"classroom_code"=> classroom_code, "file_name"=> target_file, "file_content"=> file_content}
37
+ # return hash.to_json
38
+ # end
39
+
40
+ # end
@@ -9,8 +9,8 @@ class FBSender
9
9
  end
10
10
 
11
11
  def self.send_post(file_name, file_content)
12
- post "whadddup?"
13
- HTTParty.post("https://radiant-fire-3325.firebaseio.com/classrooms.json", :body => {"classroom_id" => "akt", "content" => "def method test ruby gem"}.to_json, :options => { :headers => { "Content-Type" => "application/json"}})
12
+ response = HTTParty.post("https://radiant-fire-3325.firebaseio.com/classrooms.json", :body => {"classroom_code" => @classroom_code, "file_name" => file_name, "file_content" => file_content}.to_json, :options => { :headers => { "Content-Type" => "application/json"}})
13
+ puts response
14
14
  end
15
15
 
16
16
  end
@@ -1,19 +1,27 @@
1
1
  require_relative 'fileparser.rb'
2
2
  require_relative 'firebasesender'
3
3
 
4
-
5
-
6
4
  class Listener
7
5
 
8
- def self.start(dir_to_watch, file_to_watch, session_url_key, file)
9
-
6
+ @firebase_uuid = ''
10
7
 
11
- listener = Listen.to(dir_to_watch, only: /#{file_to_watch}/) do |modified, added, removed|
12
- file = FileParser.new("#{dir_to_watch}/#{file_to_watch}")
8
+ def self.start(target_dir, target_file, classroom_code)
9
+ listener = Listen.to(target_dir, only: /#{target_file}/) do |modified, added, removed|
10
+ # puts "firebase UUID before request: #{@firebase_uuid}"
11
+ file = FileParser.new("#{target_dir}/#{target_file}")
13
12
  file_contents = file.read_file
14
- completed_json = file.make_JSON(file_contents,file_to_watch, session_url_key)
15
- p "updating"
16
- HTTParty.post("https://radiant-fire-3325.firebaseio.com/classrooms.json", :body => completed_json, :options => { :headers => { "Content-Type" => "application/json"}})
13
+ completed_json = file.make_JSON(target_file, classroom_code)
14
+
15
+ if @firebase_uuid == ''
16
+ response = HTTParty.post("https://radiant-fire-3325.firebaseio.com/classrooms#{@firebase_uuid}.json", :body => completed_json, :options => { :headers => { "Content-Type" => "application/json"}})
17
+ @firebase_uuid = response["name"].prepend("/")
18
+ else
19
+ response = HTTParty.put("https://radiant-fire-3325.firebaseio.com/classrooms#{@firebase_uuid}.json", :body => completed_json, :options => { :headers => { "Content-Type" => "application/json"}})
20
+ end
21
+
22
+ # puts "response: #{response['name']}"
23
+ # @firebase_uuid = response["name"].prepend("/")
24
+ # puts "firebase UUID after request: #{@firebase_uuid}"
17
25
  end
18
26
 
19
27
  puts "Listening for file changes."
@@ -25,5 +33,4 @@ class Listener
25
33
  end
26
34
 
27
35
 
28
-
29
-
36
+ # HTTParty.put("https://radiant-fire-3325.firebaseio.com/classrooms/-JNh5278LYVpeSXfD_vz.json", :body => {"classroom_code"=> "_A", "file_name"=> "hey.txt", "file_content"=> "Hi Aaron"}.to_json, :options => { :headers => { "Content-Type" => "application/json"}})
@@ -1,3 +1,3 @@
1
1
  module Fuzion
2
- VERSION = "0.0.1pre"
2
+ VERSION = "0.0.2pre"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuzion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1pre
4
+ version: 0.0.2pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Stavis, Ben Myhre, Drew West, Aaron Wertman, James Hulley
@@ -109,7 +109,6 @@ files:
109
109
  - README.md
110
110
  - Rakefile
111
111
  - bin/fuzion
112
- - f.rb
113
112
  - fuzion.gemspec
114
113
  - lib/fuzion.rb
115
114
  - lib/fuzion/fileparser.rb
data/f.rb DELETED
@@ -1,22 +0,0 @@
1
- #keep in order to allow for getting around annoying ass gem update things
2
-
3
- # require 'SecureRandom'
4
-
5
- # require_relative '../lib/fuzion.rb'
6
-
7
- # unless ARGV.empty?
8
- # if ARGV[0][0] == '/'
9
- # file_name_to_watch = ARGV[0][1..-1]
10
- # else
11
- # file_name_to_watch = ARGV[0] #comeback to this
12
- # end
13
- # session_url_key = SecureRandom::urlsafe_base64(1)
14
- # puts 'http://fuzion-app.herokuapp.com/classrooms/' + session_url_key
15
- # dir_to_watch=Dir.pwd
16
- # file_to_watch=file_name_to_watch
17
- # puts "WATCHING " + dir_to_watch + file_to_watch
18
- # Fuzion.thing(dir_to_watch, file_to_watch, session_url_key)
19
- # else
20
- # print "Please pass a filename."
21
- # end
22
-