2017-05-19 10 views
0

firebase의 새로 오픈 소스 인 java firebase-admin sdk을 jruby와 함께 사용하려고합니다. 중포 기지 문서는 자바 초기화를위한 다음과 같은 지침이 있습니다jruby의 Firebase java 패키지

FileInputStream serviceAccount = new FileInputStream("path/to/serviceAccountKey.json"); 

FirebaseOptions options = new FirebaseOptions.Builder() 
    .setCredential(FirebaseCredentials.fromCertificate(serviceAccount)) 
    .setDatabaseUrl("https://<DATABASE_NAME>.firebaseio.com/") 
    .build(); 

FirebaseApp.initializeApp(options); 

처음 JRuby를 사용하려고. jbuilder를 사용하여 firebase 패키지를로드했습니다. 이러한 초기화 방법에 액세스하는 데 약간의 문제가 있습니다. 이것을 java에서 jruby로 번역 할 때 필요한 지침이 필요합니다.

답변

0

class FirebaseInstance 
    attr_accessor :options, :app 
    include_package 'com.google.firebase' 
    include_package 'com.google.firebase.auth' 

    def initialize 
    @options = set_options 
    @app = FirebaseApp.initializeApp(@options) 
    end 

    def set_options 
    builder = FirebaseOptions::Builder.new 
    builder.setDatabaseUrl(<URL>) 
    builder.setCredential(credentials) 
    builder.build 
    end 

    def credentials 
    service_account = Java.JavaIo.FileInputStream.new(<FILE LOCATION>) 
    credentials = FirebaseCredentials.fromCertificate(service_account) 
    end 
end 

을이 알아 냈어