fuzion 0.0.1pre → 0.0.2pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/fuzion.rb +31 -25
- data/lib/fuzion/fileparser.rb +27 -4
- data/lib/fuzion/firebasesender.rb +2 -2
- data/lib/fuzion/listener.rb +18 -11
- data/lib/fuzion/version.rb +1 -1
- metadata +1 -2
- data/f.rb +0 -22
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjIyZjdmOGYxOGRjMjY4YzRjNzY3NjJiZDk0MDFjMDY1YjA0NGQ2ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWEzYmVjZGFhM2QzYmUzYTJiNDE5ZGYyNjU5MDhhMmJmOTQwYzRhNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTk4MTZlNDJkODJiZjBjYTc1NDRkMWMwY2MzZTcxNWRjMjkxZTZlNTM3ZThk
|
10
|
+
ZjhjZjE5MDJmZTU1Njc4ZTU4ZGMyOGUyZTAxZDhkNDAwOGJhYmJhN2YzNDI2
|
11
|
+
ZWIyNDdmMmVlMzg1ZmQ0ODQ0NjhjMjhiNGYzYTM2ZDI0OGM4ZGI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
39
|
-
|
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
|
data/lib/fuzion/fileparser.rb
CHANGED
@@ -5,13 +5,36 @@ class FileParser
|
|
5
5
|
@path=path
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
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(
|
13
|
-
|
14
|
-
|
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 "
|
13
|
-
|
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
|
data/lib/fuzion/listener.rb
CHANGED
@@ -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
|
-
|
9
|
-
|
6
|
+
@firebase_uuid = ''
|
10
7
|
|
11
|
-
|
12
|
-
|
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(
|
15
|
-
|
16
|
-
|
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"}})
|
data/lib/fuzion/version.rb
CHANGED
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.
|
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
|
-
|