social_snippet 0.0.8 → 0.0.9

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
- ZGQwZjI1YTVhNDJiZjY2MDdkYjdiYTU5NDU0NjU1OGFiYmE5OGVlMw==
4
+ ZjJjNzJiN2EzNjk0Yzk3MjA0ODU3YWRiODIxYzE0NDYyNjZmODg3Nw==
5
5
  data.tar.gz: !binary |-
6
- ZmU2MjBkOGYwNTUzNTdjYjIzOGI1ZWI1ODkwY2EwOWM3YTBiMzllMw==
6
+ NjA2MGEwNzEzZjk3NjZkMGEzMTE4ZGU5MzM1OWIxMmJjNjY4MzU5Yg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjkwMGFiNmExZDM1NGIzN2Y2ZmY5YmEyZGQ2YjUzNTdhZWY0MTBhOTFjNzRl
10
- NTg3YjAyMGUxMjNmOWQwMjBkZTk3YjVkMzg0YzYwMDhiMTI4ZDBjZmY0MWYw
11
- NTE3YzIwYzNlNmE4OWNmZGFlM2M4NzdmYmMxYTlhZDRiZjFkNmU=
9
+ YzVlYzRiZmQwM2MyZGM3ZWY5YjkxMjU4OGRlMmIzYjQyMmI0YmY1NzM3YTBl
10
+ OTBkYjBhMDliYTJjMzkyMjg2YWM0MjI3MDkzODA1MmY5M2Q1ZmRlNWZjYTdk
11
+ MTBjZTA1NDE4ZjljNGQ0ZTBkMDAwMWIxZjY3YjEwN2UzMDMyZmE=
12
12
  data.tar.gz: !binary |-
13
- YTBkNzc5OTQ1NmU0YmE3NzlmNGVjNGEyMTkxOTc4NTdhMmY3NTk2YzY2NDQy
14
- ZDViZDEzNzUxYzg3OTY1ZjI4ZjNkM2QzYWYwODZhNTFiYzY3MzFjYzRkNmE3
15
- NTJlMmZhNmUzNDUwNWRmOGNiODMzNzM4MDQzM2ZiNzU1YTJhNGY=
13
+ MDQxZWI2MDMyOTA0ODhkNTBiN2FmMjUxZDBhNjdiYjI1NzJjMjcwYzE0YmMy
14
+ NWIzMTgwZDkzZjA5YTllZWNkZmMzY2Q4YzFmNDZhZTU0NWJhM2ViYjBkNDYw
15
+ NWUyZjRhYmUxZTg4OWQzZThhNWY4ZDk4N2VhNzI5Zjg4YTZlODU=
@@ -15,6 +15,13 @@ script:
15
15
  - bundle exec rake spec_without_fakefs
16
16
  - bundle exec rake test_without_fakefs
17
17
 
18
+ # shell access test
19
+ - bundle exec rake build
20
+ - gem install pkg/social_snippet-*.gem
21
+ - sspm install example-repo
22
+ - sspm update
23
+ - echo "// @snip <example-repo:func.cpp>" | ssnip
24
+
18
25
  deploy:
19
26
  provider: rubygems
20
27
  api_key:
data/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  [![Code Climate](https://img.shields.io/codeclimate/github/social-snippet/social-snippet.svg?style=flat)](https://codeclimate.com/github/social-snippet/social-snippet)
6
6
  [![Test Coverage](https://img.shields.io/codeclimate/coverage/github/social-snippet/social-snippet.svg?style=flat)](https://codeclimate.com/github/social-snippet/social-snippet)
7
7
  [![API Doc](http://img.shields.io/badge/RubyDocs-API-green.svg?style=flat)](http://www.rubydoc.info/github/social-snippet/social-snippet)
8
+ [![Dependencies Status](https://img.shields.io/gemnasium/social-snippet/social-snippet.svg)](https://gemnasium.com/social-snippet/social-snippet)
8
9
 
9
10
  TODO: Write a gem description
10
11
 
@@ -1,5 +1,17 @@
1
- module SocialSnippet; end
1
+ require "tsort"
2
+ require "logger"
3
+ require "highline"
4
+ require "pathname"
5
+ require "json"
6
+ require "yaml"
7
+ require "version_sorter"
8
+ require "rest_client"
9
+ require "optparse"
10
+ require "uri"
11
+ require "rugged"
12
+ require "wisper"
2
13
 
14
+ module SocialSnippet; end
3
15
  require_relative "social_snippet/core"
4
16
  require_relative "social_snippet/version"
5
17
  require_relative "social_snippet/tag"
@@ -12,6 +12,8 @@ require_relative "api/registry_api"
12
12
 
13
13
  class SocialSnippet::Api
14
14
 
15
+ include ::Wisper::Publisher
16
+
15
17
  attr_reader :core
16
18
 
17
19
  # Constructor
@@ -36,7 +38,7 @@ class SocialSnippet::Api
36
38
  private
37
39
 
38
40
  def output(message)
39
- core.logger.say message
41
+ broadcast :message, message
40
42
  end
41
43
 
42
44
  end
@@ -1,12 +1,8 @@
1
1
  module SocialSnippet::Api::CompletionApi
2
2
 
3
3
  def complete_snippet_path(keyword)
4
- core.repo_manager.complete(keyword)
5
- end
6
-
7
- def cli_complete_snippet_path(keyword)
8
- complete_snippet_path(keyword).each do |cand_repo|
9
- output cand_repo
4
+ core.repo_manager.complete(keyword).each do |snippet_path|
5
+ output snippet_path
10
6
  end
11
7
  end
12
8
 
@@ -8,7 +8,7 @@ module SocialSnippet::Api::ConfigApi
8
8
  # $ sspm config key
9
9
  def config_get(key)
10
10
  value = core.config.get(key)
11
- core.logger.say "#{key}=#{value}"
11
+ output "#{key}=#{value}"
12
12
  end
13
13
 
14
14
  end
@@ -1,7 +1,5 @@
1
1
  module SocialSnippet::Api::ManifestApi
2
2
 
3
- require "json"
4
-
5
3
  # Initialize the snippet.json interactively.
6
4
  # $ sspm init
7
5
  def init_manifest(options = {})
@@ -16,9 +14,9 @@ module SocialSnippet::Api::ManifestApi
16
14
  def loop_manifest_questions(answer)
17
15
  loop do
18
16
  answer = ask_manifest_questions(manifest_questions(answer), answer)
19
- core.logger.say ""
20
- core.logger.say ::JSON.pretty_generate(answer)
21
- core.logger.say ""
17
+ output ""
18
+ output ::JSON.pretty_generate(answer)
19
+ output ""
22
20
  break if ask_confirm("Is this okay? [Y/N]: ")
23
21
  end
24
22
  answer
@@ -1,10 +1,9 @@
1
1
  module SocialSnippet::Api::ShowApi
2
2
 
3
- require "json"
4
-
5
3
  def show_info(repo_name)
6
4
  repo_info = core.registry_client.repositories.find(repo_name)
7
5
  output ::JSON.pretty_generate(repo_info)
8
6
  end
9
7
 
10
8
  end
9
+
@@ -8,8 +8,6 @@
8
8
  #
9
9
  class SocialSnippet::CommandLine::Command
10
10
 
11
- require "optparse"
12
-
13
11
  attr_reader :args
14
12
  attr_reader :tokens
15
13
  attr_reader :options
@@ -65,6 +63,9 @@ class SocialSnippet::CommandLine::Command
65
63
  define_options
66
64
  parse_line_options
67
65
  @tokens = args
66
+ core.api.on :message do |message|
67
+ core.logger.say message
68
+ end
68
69
  end
69
70
 
70
71
  def run
@@ -17,7 +17,7 @@ EOF
17
17
 
18
18
  def run
19
19
  if has_next_token?
20
- core.api.cli_complete_snippet_path next_token
20
+ core.api.complete_snippet_path next_token
21
21
  else
22
22
  help
23
23
  end
@@ -1,9 +1,5 @@
1
1
  module SocialSnippet::CommandLine
2
2
 
3
- require "uri"
4
- require "pathname"
5
- require "json"
6
-
7
3
  class SSpm::SubCommands::InstallCommand < Command
8
4
 
9
5
  def usage
@@ -1,7 +1,5 @@
1
1
  class SocialSnippet::Config
2
2
 
3
- require "json"
4
-
5
3
  attr_reader :core
6
4
  attr_reader :home
7
5
  attr_reader :fields
@@ -1,7 +1,5 @@
1
1
  class SocialSnippet::Context
2
2
 
3
- require "pathname"
4
-
5
3
  attr_reader :flag_absolute
6
4
  attr_reader :path
7
5
  attr_reader :pathname
@@ -1,5 +1,3 @@
1
- require "highline"
2
-
3
1
  class SocialSnippet::Core
4
2
 
5
3
  attr_reader :input_stream
@@ -31,3 +29,4 @@ class SocialSnippet::Core
31
29
  end
32
30
 
33
31
  end # SocialSnippet
32
+
@@ -1,5 +1,3 @@
1
- require "logger"
2
-
3
1
  class SocialSnippet::Logger < ::Logger
4
2
 
5
3
  def say(s)
@@ -7,3 +5,4 @@ class SocialSnippet::Logger < ::Logger
7
5
  end
8
6
 
9
7
  end
8
+
@@ -1,8 +1,5 @@
1
1
  module SocialSnippet::Registry::RegistryResources
2
2
 
3
- require "rest_client"
4
- require "json"
5
-
6
3
  class Base
7
4
 
8
5
  attr_reader :core
@@ -1,8 +1,5 @@
1
1
  module SocialSnippet::Repository::Drivers
2
2
 
3
- require "version_sorter"
4
- require "json"
5
-
6
3
  # Repository base class
7
4
  # usage: class GitRepository < BaseRepository
8
5
  class BaseRepository
@@ -1,7 +1,5 @@
1
1
  module SocialSnippet::Repository::Drivers
2
2
 
3
- require "rugged"
4
-
5
3
  class GitRepository < BaseRepository
6
4
 
7
5
  attr_reader :rugged_repo
@@ -1,7 +1,5 @@
1
1
  module SocialSnippet::Repository
2
2
 
3
- require "yaml"
4
-
5
3
  class RepositoryInstaller
6
4
 
7
5
  attr_reader :core
@@ -84,3 +82,4 @@ module SocialSnippet::Repository
84
82
  end # RepositoryInstaller
85
83
 
86
84
  end # SocialSnippet
85
+
@@ -13,7 +13,11 @@ module SocialSnippet
13
13
  end
14
14
 
15
15
  def read_file
16
- @code = ::File.read(filepath).split($/)
16
+ begin
17
+ @code = ::File.read(filepath).split($/)
18
+ rescue ::Errno::ENOENT => e
19
+ @code = ["ERROR: #{e.to_s}"]
20
+ end
17
21
  end
18
22
 
19
23
  def read_text(s)
@@ -1,7 +1,5 @@
1
1
  class SocialSnippet::Tag
2
2
 
3
- require "pathname"
4
-
5
3
  attr_reader :path
6
4
  attr_reader :repo
7
5
  attr_reader :ref
@@ -1,7 +1,5 @@
1
1
  module SocialSnippet
2
2
 
3
- require "tsort"
4
-
5
3
  class TSortableHash < ::Hash
6
4
 
7
5
  include ::TSort
@@ -1,6 +1,6 @@
1
1
  module SocialSnippet
2
2
 
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
4
4
 
5
5
  module Version
6
6
 
@@ -19,10 +19,11 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.required_ruby_version = ">= 1.9.3"
21
21
 
22
- spec.add_runtime_dependency "version_sorter", "~> 1.1.0"
22
+ spec.add_runtime_dependency "version_sorter", "~> 2.0.0"
23
23
  spec.add_runtime_dependency "rugged", ["~> 0.21.4", ">= 0.21.4"]
24
24
  spec.add_runtime_dependency "rest-client", "~> 1.7.0"
25
- spec.add_runtime_dependency "highline", "~> 1.6.0"
25
+ spec.add_runtime_dependency "highline", "~> 1.7.0"
26
+ spec.add_runtime_dependency "wisper", "~> 1.6.0"
26
27
 
27
28
  spec.add_development_dependency "bundler"
28
29
  spec.add_development_dependency "rake"
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  module SocialSnippet
4
4
 
5
- describe Api do
5
+ describe Api::InsertSnippetApi do
6
6
 
7
7
  describe "#insert_snippet()", :without_fakefs => true do
8
8
 
@@ -54,7 +54,7 @@ module SocialSnippet
54
54
  # tests from here
55
55
  #
56
56
 
57
- context "$ ssnip / without snip" do
57
+ context "insert a plain text" do
58
58
 
59
59
  let(:input) do
60
60
  [
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe SocialSnippet::Core do
3
+ describe SocialSnippet::Api::InsertSnippetApi do
4
4
 
5
5
  before do
6
6
  allow_any_instance_of(::SocialSnippet::CommandLine::Command).to receive(:social_snippet).and_return fake_core
@@ -2791,13 +2791,54 @@ describe SocialSnippet::Core do
2791
2791
  subject { fake_core.api.insert_snippet input }
2792
2792
  it { should eq output }
2793
2793
 
2794
- end
2794
+ end # snip proxy
2795
2795
 
2796
- end # add module
2796
+ end # add nested module
2797
2797
 
2798
2798
  end # for ruby module
2799
2799
 
2800
- end
2800
+ end # @no_tag
2801
+
2802
+ describe "not found case" do
2803
+
2804
+ context "create project on current directory" do
2805
+
2806
+ before do
2807
+ ::FileUtils.touch "snippet.c"
2808
+ ::FileUtils.mkdir_p "path/to"
2809
+ ::FileUtils.touch "path/to/found.c"
2810
+
2811
+ ::File.write "snippet.c", [
2812
+ "/* @snip <path/to/found.c> */",
2813
+ "/* @snip <path/to/not_found.c> */",
2814
+ ].join($/)
2815
+ end
2816
+
2817
+ context "snip snippet.c" do
2818
+
2819
+ let(:input) do
2820
+ [
2821
+ "/* @snip<snippet.c> */",
2822
+ ].join($/)
2823
+ end
2824
+
2825
+ let(:output) do
2826
+ [
2827
+ "/* @snippet<path/to/found.c> */",
2828
+ "/* @snippet<path/to/not_found.c> */",
2829
+ "ERROR: No such file or directory - ./path/to/not_found.c",
2830
+ "/* @snippet<snippet.c> */",
2831
+ ].join($/)
2832
+ end
2833
+
2834
+ subject { fake_core.api.insert_snippet input }
2835
+ it { should eq output }
2836
+
2837
+ end # snip snippet.c
2838
+
2839
+ end # create project on current directory
2840
+
2841
+ end # not found case
2801
2842
 
2802
2843
  end # insert_snippet
2803
2844
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_snippet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroyuki Sano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-16 00:00:00.000000000 Z
11
+ date: 2015-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: version_sorter
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.0
19
+ version: 2.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 1.1.0
26
+ version: 2.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rugged
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -60,6 +60,20 @@ dependencies:
60
60
  version: 1.7.0
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: highline
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 1.7.0
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ version: 1.7.0
75
+ - !ruby/object:Gem::Dependency
76
+ name: wisper
63
77
  requirement: !ruby/object:Gem::Requirement
64
78
  requirements:
65
79
  - - ~>
@@ -274,7 +288,7 @@ files:
274
288
  - spec/helpers/codeclimate_helper.rb
275
289
  - spec/helpers/fakefs_helper.rb
276
290
  - spec/helpers/webmock_helper.rb
277
- - spec/lib/api_spec.rb
291
+ - spec/lib/api/insert_snippet_spec.rb
278
292
  - spec/lib/command_line/sspm_config_spec.rb
279
293
  - spec/lib/command_line/sspm_init_spec.rb
280
294
  - spec/lib/command_line/sspm_install_spec.rb
@@ -298,8 +312,8 @@ files:
298
312
  - test/command_test.rb
299
313
  - test/config_test.rb
300
314
  - test/context_test.rb
301
- - test/core_test.rb
302
315
  - test/git_repository_test.rb
316
+ - test/insert_snippet_test.rb
303
317
  - test/install_command_test.rb
304
318
  - test/repository_manager_test.rb
305
319
  - test/snippet_test.rb
@@ -335,7 +349,7 @@ test_files:
335
349
  - spec/helpers/codeclimate_helper.rb
336
350
  - spec/helpers/fakefs_helper.rb
337
351
  - spec/helpers/webmock_helper.rb
338
- - spec/lib/api_spec.rb
352
+ - spec/lib/api/insert_snippet_spec.rb
339
353
  - spec/lib/command_line/sspm_config_spec.rb
340
354
  - spec/lib/command_line/sspm_init_spec.rb
341
355
  - spec/lib/command_line/sspm_install_spec.rb
@@ -359,8 +373,8 @@ test_files:
359
373
  - test/command_test.rb
360
374
  - test/config_test.rb
361
375
  - test/context_test.rb
362
- - test/core_test.rb
363
376
  - test/git_repository_test.rb
377
+ - test/insert_snippet_test.rb
364
378
  - test/install_command_test.rb
365
379
  - test/repository_manager_test.rb
366
380
  - test/snippet_test.rb